📄 admin.content.php
字号:
// fail if checked out not by 'me' if ($row->checked_out && $row->checked_out <> $my->id) { mosRedirect( "index2.php?option=com_content", $adminLanguage->A_COMP_CONTENT_MODULE ." ". $row->title ." ". $adminLanguage->A_COMP_CONTENT_ANOTHER ); } if ($uid) { $row->checkout( $my->id ); if (trim( $row->images )) { $row->images = explode( "\n", $row->images ); } else { $row->images = array(); } $row->created = mosFormatDate( $row->created, '%Y-%m-%d %H:%M:%S' ); $row->modified = mosFormatDate( $row->modified, '%Y-%m-%d %H:%M:%S' ); $row->publish_up = mosFormatDate( $row->publish_up, '%Y-%m-%d %H:%M:%S' ); if (trim( $row->publish_down ) == '0000-00-00 00:00:00') { $row->publish_down = 'Never'; } $query = "SELECT name from #__users" . "\n WHERE id=$row->created_by" ; $database->setQuery( $query ); $row->creator = $database->loadResult(); $query = "SELECT name from #__users" . "\n WHERE id=$row->modified_by" ; $database->setQuery( $query ); $row->modifier = $database->loadResult(); $query = "SELECT content_id from #__content_frontpage" . "\n WHERE content_id=$row->id" ; $database->setQuery( $query ); $row->frontpage = $database->loadResult(); // get list of links to this item $and = "\n AND componentid = ". $row->id; $menus = mosAdminMenus::Links2Menu( 'content_item_link', $and ); } else { $row->sectionid = $sectionid; $row->version = 0; $row->state = 1; $row->ordering = 0; $row->images = array(); //$row->publish_up = date( 'Y-m-d', time() ); $row->publish_up = date( 'Y-m-d', time() + $mosConfig_offset * 60 * 60 ); $row->publish_down = 'Never'; $row->catid = NULL; $row->creator = ''; $row->modifier = ''; $row->frontpage = 0; $menus = array(); } $javascript = "onchange=\"changeDynaList( 'catid', sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\""; $query = "SELECT s.id AS value, s.title AS text" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering"; $database->setQuery( $query ); if ( $sectionid == 0 ) { $sections[] = mosHTML::makeOption( '-1', $adminLanguage->A_COMP_CONTENT_SELECT_SEC ); $sections = array_merge( $sections, $database->loadObjectList() ); $lists['sectionid'] = mosHTML::selectList( $sections, 'sectionid', 'class="inputbox" size="1" '. $javascript, 'value', 'text' ); } else { $lists['sectionid'] = mosHTML::selectList( $database->loadObjectList(), 'sectionid', 'class="inputbox" size="1" '. $javascript, 'value', 'text', intval( $row->sectionid) ); } $sections = $database->loadObjectList(); $sectioncategories = array(); $sectioncategories[-1] = array(); $sectioncategories[-1][] = mosHTML::makeOption( '-1', $adminLanguage->A_COMP_CONTENT_SELECT_CAT ); foreach($sections as $section) { $sectioncategories[$section->value] = array(); $query = "SELECT id AS value, name AS text" . "\n FROM #__categories" . "\n WHERE section='$section->value'" . "\n ORDER BY ordering"; $database->setQuery( $query ); $rows2 = $database->loadObjectList(); foreach($rows2 as $row2) { $sectioncategories[$section->value][] = mosHTML::makeOption( $row2->value, $row2->text ); } } // get list of categories if ( !$row->catid && !$row->sectionid ) { $categories[] = mosHTML::makeOption( '-1', 'Select Category' ); $lists['catid'] = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1"', 'value', 'text' ); } else { $query = "SELECT id AS value, name AS text" . "\n FROM #__categories" . $where . "\n ORDER BY ordering"; $database->setQuery( $query ); $categories[] = mosHTML::makeOption( '-1', $adminLanguage->A_COMP_CONTENT_SELECT_CAT ); $categories = array_merge( $categories, $database->loadObjectList() ); $lists['catid'] = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1"', 'value', 'text', intval( $row->catid ) ); } // build the html select list for ordering $query = "SELECT ordering AS value, title AS text" . "\n FROM #__content" . "\n WHERE catid='$row->catid'" . "\n AND state >= 0" . "\n ORDER BY ordering" ; $lists['ordering'] = mosAdminMenus::SpecificOrdering( $row, $uid, $query, 1 ); // calls function to read image from directory $pathA = $mosConfig_absolute_path .'/images/stories'; $pathL = $mosConfig_live_site .'/images/stories'; $images = array(); $folders = array(); $folders[] = mosHTML::makeOption( '/' ); mosAdminMenus::ReadImages( $pathA, '/', $folders, $images ); // list of folders in images/stories/ $lists['folders'] = mosAdminMenus::GetImageFolders( $folders, $pathL ); // list of images in specfic folder in images/stories/ $lists['imagefiles'] = mosAdminMenus::GetImages( $images, $pathL ); // list of saved images $lists['imagelist'] = mosAdminMenus::GetSavedImages( $row, $pathL ); // build list of users $active = ( intval( $row->created_by ) ? intval( $row->created_by ) : $my->id ); $lists['created_by'] = mosAdminMenus::UserSelect( 'created_by', $active ); // build the select list for the image position alignment $lists['_align'] = mosAdminMenus::Positions( '_align' ); // build the select list for the image caption alignment $lists['_caption_align'] = mosAdminMenus::Positions( '_caption_align' ); // build the html select list for the group access $lists['access'] = mosAdminMenus::Access( $row ); // build the html select list for menu selection $lists['menuselect'] = mosAdminMenus::MenuSelect( ); // build the select list for the image caption position $pos[] = mosHTML::makeOption( 'bottom', _CMN_BOTTOM ); $pos[] = mosHTML::makeOption( 'top', _CMN_TOP ); $lists['_caption_position'] = mosHTML::selectList( $pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text' ); // get params definitions $params =& new mosParameters( $row->attribs, $mainframe->getPath( 'com_xml', 'com_content' ), 'component' ); HTML_content::editContent( $row, $contentSection, $lists, $sectioncategories, $images, $params, $option, $redirect, $menus );}/*** Saves the content item an edit form submit* @param database A database connector object*/function saveContent( $sectionid, $task ) { global $database, $my, $mainframe, $mosConfig_offset; $menu = mosGetParam( $_POST, 'menu', 'mainmenu' ); $menuid = mosGetParam( $_POST, 'menuid', 0 ); $row = new mosContent( $database ); if (!$row->bind( $_POST )) { echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; exit(); } $isNew = ( $row->id < 1 ); if ($isNew) { //$row->created = $row->created ? $row->created : date( "Y-m-d H:i:s" ); $row->created = $row->created ? mosFormatDate( $row->created, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset * 60 * 60 ) : date( "Y-m-d H:i:s" ); $row->created_by = $row->created_by ? $row->created_by : $my->id; } else { $row->modified = date( "Y-m-d H:i:s" ); $row->modified_by = $my->id; //$row->created = $row->created ? $row->created : date( "Y-m-d H:i:s" ); $row->created = $row->created ? mosFormatDate( $row->created, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset ) : date( "Y-m-d H:i:s" ); $row->created_by = $row->created_by ? $row->created_by : $my->id; } if (strlen(trim( $row->publish_up )) <= 10) { $row->publish_up .= " 00:00:00"; } $row->publish_up = mosFormatDate($row->publish_up, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset ); if (trim( $row->publish_down ) == "Never") { $row->publish_down = "0000-00-00 00:00:00"; } $row->state = mosGetParam( $_REQUEST, 'published', 0 ); $params = mosGetParam( $_POST, 'params', '' ); if (is_array( $params )) { $txt = array(); foreach ( $params as $k=>$v) { $txt[] = "$k=$v"; } $row->attribs = implode( "\n", $txt ); } // code cleaner for xhtml transitional compliance $row->introtext = str_replace( '<br>', '<br />', $row->introtext ); $row->fulltext = str_replace( '<br>', '<br />', $row->fulltext ); // remove <br /> take being automatically added to empty fulltext $length = strlen( $row->fulltext ) < 9; $search = strstr( $row->fulltext, '<br />'); if ( $length && $search ) { $row->fulltext = NULL; } if (!$row->check()) { echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; exit(); } $row->version++; if (!$row->store()) { echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; exit(); } // manage frontpage items require_once( $mainframe->getPath( 'class', 'com_frontpage' ) ); $fp = new mosFrontPage( $database ); if (mosGetParam( $_REQUEST, 'frontpage', 0 )) { // toggles go to first place if (!$fp->load( $row->id )) { // new entry $database->setQuery( "INSERT INTO #__content_frontpage VALUES ('$row->id','1')" ); if (!$database->query()) { echo "<script> alert('".$database->stderr()."');</script>\n"; exit(); } $fp->ordering = 1; } } else { // no frontpage mask if (!$fp->delete( $row->id )) { $msg .= $fp->stderr(); } $fp->ordering = 0; } $fp->updateOrder(); $row->checkin(); $row->updateOrder( "catid='$row->catid' AND state >= 0" ); $redirect = mosGetParam( $_POST, 'redirect', $sectionid ); switch ( $task ) { case 'go2menu': mosRedirect( 'index2.php?option=com_menus&menutype='. $menu ); break; case 'go2menuitem': mosRedirect( 'index2.php?option=com_menus&menutype='. $menu .'&task=edit&hidemainmenu=1&id='. $menuid ); break; case 'menulink': menuLink( $redirect, $row->id ); break; case 'resethits': resethits( $redirect, $row->id ); break; case 'apply': $msg = 'Successfully Saved changes to Item: '. $row->title; mosRedirect( 'index2.php?option=com_content§ionid='. $redirect .'&task=edit&hidemainmenu=1&id='. $row->id, $msg ); case 'save': default: $msg = 'Successfully Saved Item: '. $row->title; mosRedirect( 'index2.php?option=com_content§ionid='. $redirect, $msg ); break; }}/*** Changes the state of one or more content pages* @param string The name of the category section* @param integer A unique category id (passed from an edit form)* @param array An array of unique category id numbers* @param integer 0 if unpublishing, 1 if publishing* @param string The name of the current user*/function changeContent( $cid=null, $state=0, $option ) { global $database, $my, $adminLanguage; if (count( $cid ) < 1) { $action = $state == 1 ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); echo "<script> alert('". $adminLanguage->A_COMP_SEL_ITEM ." ". $action ."'); window.history.go(-1);</script>\n"; exit; } $total = count ( $cid ); $cids = implode( ',', $cid ); $database->setQuery( "UPDATE #__content SET state='$state'" . "\nWHERE id IN ($cids) AND (checked_out=0 OR (checked_out='".$my->id."'))" ); if (!$database->query()) { echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); } if (count( $cid ) == 1) { $row = new mosContent( $database ); $row->checkin( $cid[0] ); } if ( $state == "-1" ) { $msg = $total ." ". $adminLanguage->A_COMP_CONTENT_ARCHIVED; } else if ( $state == "1" ) { $msg = $total ." ". $adminLanguage->A_COMP_CONTENT_PUBLISHED; } else if ( $state == "0" ) { $msg = $total ." ". $adminLanguage->A_COMP_CONTENT_UNPUBLISHED; } $redirect = mosGetParam( $_POST, 'redirect', $row->sectionid ); $task = mosGetParam( $_POST, 'returntask', '' ); if ( $task ) { $task = '&task='. $task; } else { $task = ''; } mosRedirect( 'index2.php?option='. $option . $task .'§ionid='. $redirect .'&mosmsg='. $msg );}/*** Changes the state of one or more content pages* @param string The name of the category section* @param integer A unique category id (passed from an edit form)* @param array An array of unique category id numbers* @param integer 0 if unpublishing, 1 if publishing* @param string The name of the current user*/function toggleFrontPage( $cid, $section, $option ) { global $database, $my, $mainframe, $adminLanguage; if (count( $cid ) < 1) { echo "<script> alert(\"". $adminLanguage->A_COMP_CONTENT_SEL_TOG ."\"); window.history.go(-1);</script>\n"; exit; } $msg = ''; require_once( $mainframe->getPath( 'class', 'com_frontpage' ) ); $fp = new mosFrontPage( $database ); foreach ($cid as $id) { // toggles go to first place if ($fp->load( $id )) { if (!$fp->delete( $id )) { $msg .= $fp->stderr(); } $fp->ordering = 0; } else { // new entry $database->setQuery( "INSERT INTO #__content_frontpage VALUES ('$id','0')" ); if (!$database->query()) { echo "<script> alert('".$database->stderr()."');</script>\n"; exit(); } $fp->ordering = 0; } $fp->updateOrder(); } mosRedirect( 'index2.php?option='. $option .'§ionid='. $section, $msg );}function removeContent( &$cid, $sectionid, $option ) { global $database, $mainframe, $adminLanguage; $total = count( $cid ); if ( $total < 1) { echo "<script> alert(\"". $adminLanguage->A_COMP_CONTENT_SEL_DEL ."\"); window.history.go(-1);</script>\n"; exit; } $state = '-2'; $ordering = '0'; //seperate contentids $cids = implode( ',', $cid ); $query = "UPDATE #__content SET state = '". $state ."', ordering = '". $ordering ."'" . "\n WHERE id IN ( ". $cids ." )" ; $database->setQuery( $query ); if ( !$database->query() ) { echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); } $msg = $total ." Item(s) sent to the Trash"; $return = mosGetParam( $_POST, 'returntask', '' ); mosRedirect( 'index2.php?option='. $option .'&task='. $return .'§ionid='. $sectionid, $msg );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -