芝麻web文件管理V1.00
编辑当前文件:/home/p/r/i/prismawe/clients/canaldegap.fr_old/admin/addcontent.php
register(XAJAX_FUNCTION,'ajaxpreview'); $xajax->processRequest(); $headtext = $xajax->getJavascript('../lib/xajax')."\n"; if (isset($_POST["cancel"])) { redirect("listcontent.php".$urlext); } require_once("header.php"); $tmpfname = ''; $error = FALSE; $firsttime = "1"; #Flag to make sure we're not trying to fill params on the first display if (isset($_POST["firsttime"])) $firsttime = $_POST["firsttime"]; $submit = false; if (isset($_POST["submitbutton"])) $submit = true; $apply = false; if (isset($_POST["applybutton"])) $apply = true; $contentobj = ''; #Get current userid and make sure they have permission to add something $access = (check_permission($userid, 'Add Pages') || check_permission($userid, 'Manage All Content')); #Get a list of content types and pick a default if necessary global $gCms; $contentops =& $gCms->GetContentOperations(); $existingtypes = $contentops->ListContentTypes(); $content_type = ""; if (isset($_POST["content_type"])) { $content_type = $_POST["content_type"]; } else { if (isset($existingtypes) && count($existingtypes) > 0) { $content_type = 'content'; } else { $error = "No content types loaded!"; } } $contentobj = ""; if (isset($_POST["serialized_content"])) { $contentops =& $gCms->GetContentOperations(); $contentops->LoadContentType($_POST['orig_content_type']); $contentobj = unserialize(base64_decode($_POST["serialized_content"])); $contentobj->SetAddMode(); if (strtolower(get_class($contentobj)) != $content_type) { #Fill up the existing object with values in form #Create new object #Copy important fields to new object #Put new object on top of old on copycontentobj($contentobj, $content_type); } } else { $page_cachable = ((get_site_preference('page_cachable',"1")=="1")?true:false); $active = ((get_site_preference('page_active',"1")=="1")?true:false); $showinmenu = ((get_site_preference('page_showinmenu',"1")=="1")?true:false); $metadata = get_site_preference('page_metadata'); $parent_id = get_preference($userid, 'default_parent', -2); if (isset($_GET["parent_id"])) $parent_id = $_GET["parent_id"]; $contentops =& $gCms->GetContentOperations(); $contentobj = $contentops->CreateNewContent($content_type); $contentobj->SetAddMode(); $contentobj->SetOwner($userid); $contentobj->SetCachable($page_cachable); $contentobj->SetActive($active); $contentobj->SetShowInMenu($showinmenu); $contentobj->SetLastModifiedBy($userid); { $templateops =& $gCms->GetTemplateOperations(); $dflt = $templateops->LoadDefaultTemplate(); if( isset($dflt) ) { $contentobj->SetTemplateId($dflt->id); } } // this stuff should be changed somehow. $contentobj->SetMetadata($metadata); $contentobj->SetPropertyValue('content_en', get_site_preference('defaultpagecontent')); // why? if ($parent_id!=-1) $contentobj->SetParentId($parent_id); $contentobj->SetPropertyValue('searchable', get_site_preference('page_searchable',1)); $contentobj->SetPropertyValue('extra1', get_site_preference('page_extra1','')); $contentobj->SetPropertyValue('extra2', get_site_preference('page_extra2','')); $contentobj->SetPropertyValue('extra3', get_site_preference('page_extra3','')); $tmp = get_site_preference('additional_editors'); $tmp2 = array(); if( !empty($tmp) ) { $tmp2 = explode(',',$tmp); } $contentobj->SetAdditionalEditors($tmp2); } if ($access) { if ($submit || $apply) { #Fill contentobj with parameters $contentobj->SetAddMode(); $contentobj->FillParams($_POST); $contentobj->SetOwner($userid); $error = $contentobj->ValidateData(); if ($error === FALSE) { $contentobj->Save(); global $gCms; $contentops =& $gCms->GetContentOperations(); $contentops->SetAllHierarchyPositions(); if ($submit) { audit($contentobj->Id(), $contentobj->Name(), 'Added Content'); redirect('listcontent.php'.$urlext.'&message=contentadded'); } } } else if ($firsttime == "0") #Either we're a preview or a template postback { $contentobj->FillParams($_POST); // if (isset($_POST["additional_editors"])) // { // $addtarray = array(); // foreach ($_POST["additional_editors"] as $addt_user_id) // { // $addtarray[] = $addt_user_id; // } // $contentobj->SetAdditionalEditors($addtarray); // } } else { $firsttime = "0"; } } if (!$access) { echo "
".lang('noaccessto',array(lang('addcontent')))."
"; } else { #Get a list of content_types and build the dropdown to select one $typesdropdown = '
'; $cur_content_type = ''; foreach ($gCms->contenttypes as $onetype) { if( $onetype->type == 'errorpage' && !check_permission($userid,'Manage All Content') ) { continue; } $contentops->LoadContentType($onetype->type); $type_obj = new $onetype->type; $typesdropdown .= '
type == $content_type) { $typesdropdown .= ' selected="selected" '; $cur_content_type = $onetype->type; } $typesdropdown .= ">".($type_obj->FriendlyName())."
"; } $typesdropdown .= "
"; if (FALSE == empty($error)) { echo $themeObject->ShowErrors($error); } ?> EditAsArray(true, 0); #$contentarray2 = $contentobj->EditAsArray(true, 1); $tabnames = $contentobj->TabNames(); ?>
ShowHeader('addcontent').'
'; ?>
mPreview) { echo '
'.lang('preview').'
'; } ?>
'; $submit_buttons .= '
'; $submit_buttons .= '
'; $numberoftabs = count($tabnames); $showtabs = 1; if ($numberoftabs == 0) { $numberoftabs = 1; $showtabs = 1; } for ($currenttab = 0; $currenttab < $numberoftabs; $currenttab++) { if ($showtabs == 1) { ?>
:
EditAsArray(true, $currenttab, $access); for($i=0;$i
'; ?>
mPreview) { echo '
'; ?>
/index.php?=__CMS_PREVIEW_PAGE__">
'; } ?>
« '.lang('back').'
'; include_once("footer.php"); # vim:ts=4 sw=4 noet ?>