configure('requestURI',$config['admin_url'].'/editcontent.php?'.CMS_SECURE_PARAM_NAME.'='.$_SESSION[CMS_USER_KEY].'&content_id='.$content_id); $xajax->register(XAJAX_FUNCTION,'ajaxpreview'); $headtext = $xajax->getJavascript('../lib/xajax')."\n"; if (isset($_POST["cancel"])) { redirect("listcontent.php".$urlext); } if ($apply) { $CMS_EXCLUDE_FROM_RECENT=1; } #Get a list of content types and pick a default if necessary $gCms = cmsms(); $contentops = $gCms->GetContentOperations(); $existingtypes = $contentops->ListContentTypes(false,true); #Get current userid and make sure they have permission to add something $userid = get_userid(); $access = check_ownership($userid, $content_id) || check_permission($userid, 'Modify Any Page') || check_permission($userid, 'Manage All Content'); $adminaccess = $access; if (!$access) { $access = check_authorship($userid, $content_id); } if ($access) { // get the content object. $contentobj = ""; $content_type = 'content'; // default content type. if( !is_object($contentobj) && $content_id != -1 ) { // load the content object from the database. $contentobj = $contentops->LoadContentFromId($content_id); $content_type = $contentobj->Type(); } if( isset($_POST['content_type']) ) { $content_type = $_POST['content_type']; } $xajax->processRequest(); // validate the content type we want... if( isset($existingtypes) && count($existingtypes) > 0 && in_array($content_type,array_keys($existingtypes)) ) { // woot, it's a valid content type } else { redirect("listcontent.php".$urlext."&page=".$pagelist_id.'&error=error_contenttype'); } try { if( $content_id != -1 && strtolower(get_class($contentobj)) != strtolower($content_type) ) { // content type change... // this also updates the content object with the POST params. copycontentobj($contentobj, $content_type); } else if( strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ) { // we posted... so update the content object. updatecontentobj($contentobj); } cms_utils::set_app_data('editing_content',$contentobj); } catch( CmsEditContentException $e ) { $error = $e->getMessage(); } if ($submit || $apply) { try { // Fill contentobj with parameters // $contentobj->SetProperties(); // calguy should not be necessary $contentobj->FillParams($_POST,true); $error = $contentobj->ValidateData(); if ($error === FALSE) { $contentobj->SetLastModifiedBy(get_userid()); $contentobj->Save(); $contentops =& $gCms->GetContentOperations(); $contentops->SetAllHierarchyPositions(); // put mention into the admin log audit($contentobj->Id(), 'Content Item: '.$contentobj->Name(), 'Edited'); if ($submit) { redirect("listcontent.php".$urlext."&page=".$pagelist_id.'&message=contentupdated'); } } } catch( CmsEditContentException $e ) { $error = $e->getMessage(); } if ($ajax) { header('Content-Type: text/xml'); print ''; print ''; if ($error !== false) { print 'Error'; print '' . join('', $error) . ''; print ']]>'; } else { print 'Success'; print ''; } print ''; exit; } } } if (strlen($contentobj->Name()) > 0) { $CMS_ADMIN_SUBTITLE = $contentobj->Name(); } // Detect if a WYSIWYG is in use, and grab its form submit action $addlScriptSubmit = ''; $modobj = cms_utils::get_wysiwyg_module(); if( $modobj ) { $addlScriptSubmit .= $modobj->WYSIWYGPageFormSubmit(); } $closestr = cms_html_entity_decode(lang('close')); $cancelstr = cms_html_entity_decode(lang('confirmcancel')); $headtext .= << // ' + e.details + '<\/p><\/div>'; jQuery('[name=cancel]').fadeOut(); jQuery('[name=cancel]').attr('value','{$closestr}'); jQuery('[name=cancel]').fadeIn(); } else { htmlShow = ''; htmlShow += e.details; htmlShow += '<\/ul><\/div>'; } jQuery('#Edit_Content_Result').html(htmlShow); }); }); // ]]> EOSCRIPT; include_once("header.php"); // AJAX result container print ''; $tmpfname = ''; if (!$access) { echo "".lang('noaccessto',array(lang('editpage'))).""; } else { #Get a list of content_types and build the dropdown to select one $typesdropdown = ''; $cur_content_type = ''; foreach ($existingtypes as $onetype => $onetypename ) { if( $onetype == 'errorpage' && !check_permission($userid,'Manage All Content') ) { continue; } $typesdropdown .= '"; } $typesdropdown .= ""; $tabnames = $contentobj->TabNames(); if( !$error ) { $error = $contentobj->GetError(); } if (FALSE == empty($error)) { echo $themeObject->ShowErrors($error); } $numberoftabs = count($tabnames); $tab_contents_array = array(); for ($currenttab = 0; $currenttab < $numberoftabs; $currenttab++) { $contentarray = $contentobj->EditAsArray(false, $currenttab, $adminaccess); $tab_contents_array[$currenttab] = $contentarray; } ?> ShowHeader('editcontent'); ?> HasPreview()) { echo ''.lang('preview').''; } ?> " enctype="multipart/form-data" ##FORMSUBMITSTUFFGOESHERE##> '; $submit_buttons .= ' '; $submit_buttons .= ' '; if( $contentobj->IsViewable() && $contentobj->Active() ) { $submit_buttons .= ' '.$themeObject->DisplayImage('icons/system/view.gif',lang('view_page'),'','','systemicon').''; } $submit_buttons .= ''; //echo $submit_buttons; $showtabs = 1; if ($numberoftabs == 0) { $numberoftabs = 1; $showtabs = 1; } for ($currenttab = 0; $currenttab < $numberoftabs; $currenttab++) { if ($showtabs == 1) { ?> : '.$contentarray[$i][2]; } ?> HasPreview()) { echo ''; ?> src="> '; echo ''; } echo $submit_buttons; ?> « '.lang('back').''; include_once("footer.php"); # vim:ts=4 sw=4 noet ?>
' + e.details + '<\/p><\/div>'; jQuery('[name=cancel]').fadeOut(); jQuery('[name=cancel]').attr('value','{$closestr}'); jQuery('[name=cancel]').fadeIn(); } else { htmlShow = '
".lang('noaccessto',array(lang('editpage')))."
'; $submit_buttons .= ' '; $submit_buttons .= ' '; if( $contentobj->IsViewable() && $contentobj->Active() ) { $submit_buttons .= ' '.$themeObject->DisplayImage('icons/system/view.gif',lang('view_page'),'','','systemicon').''; } $submit_buttons .= '