📄 admin.content.php
字号:
<?php/*** @version $Id: admin.content.php,v 1.24 2005/02/15 14:09:21 kochp Exp $* @package Mambo* @subpackage Content* @copyright (C) 2000 - 2005 Miro International Pty Ltd* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL* Mambo is Free Software*//** ensure this file is being included by a parent file */defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );require_once( $mainframe->getPath( 'admin_html' ) );$sectionid = mosGetParam( $_REQUEST, 'sectionid', 0 );$id = mosGetParam( $_REQUEST, 'id', '' );$cid = mosGetParam( $_POST, 'cid', array(0) );if (!is_array( $cid )) { $cid = array(0);}switch ($task) { case 'clean_cache': mosCache::cleanCache( 'com_content' ); mosRedirect( 'index2.php', $adminLanguage->A_COMP_CONTENT_CACHE ); break; case 'new': editContent( 0, $sectionid, $option ); break; case 'edit': editContent( $id, $sectionid, $option ); break; case 'editA': editContent( $cid[0], '', $option ); break; case 'go2menu': case 'go2menuitem': case 'resethits': case 'menulink': case 'apply': case 'save': mosCache::cleanCache( 'com_content' ); saveContent( $sectionid, $task ); break; case 'remove': removeContent( $cid, $sectionid, $option ); break; case 'publish': changeContent( $cid, 1, $option ); break; case 'unpublish': changeContent( $cid, 0, $option ); break; case 'toggle_frontpage': toggleFrontPage( $cid, $sectionid, $option ); break; case 'archive': changeContent( $cid, -1, $option ); break; case 'unarchive': changeContent( $cid, 0, $option ); break; case 'cancel': cancelContent(); break; case 'orderup': orderContent( $cid[0], -1, $option ); break; case 'orderdown': orderContent( $cid[0], 1, $option ); break; case 'showarchive': viewArchive( $sectionid, $option ); break; case 'movesect': moveSection( $cid, $sectionid, $option ); break; case 'movesectsave': moveSectionSave( $cid, $sectionid, $option ); break; case 'copy': copyItem( $cid, $sectionid, $option ); break; case 'copysave': copyItemSave( $cid, $sectionid, $option ); break; case 'accesspublic': accessMenu( $cid[0], 0, $option ); break; case 'accessregistered': accessMenu( $cid[0], 1, $option ); break; case 'accessspecial': accessMenu( $cid[0], 2, $option ); break; case 'saveorder': saveOrder( $cid ); break; default: viewContent( $sectionid, $option ); break;}/*** Compiles a list of installed or defined modules* @param database A database connector object*/function viewContent( $sectionid, $option ) { global $database, $mainframe, $mosConfig_list_limit, $adminLanguage; $catid = $mainframe->getUserStateFromRequest( "catid{$option}{$sectionid}", 'catid', 0 ); $filter_authorid = $mainframe->getUserStateFromRequest( "filter_authorid{$option}{$sectionid}", 'filter_authorid', 0 ); $filter_sectionid = $mainframe->getUserStateFromRequest( "filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0 ); $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ); $limitstart = $mainframe->getUserStateFromRequest( "view{$option}{$sectionid}limitstart", 'limitstart', 0 ); $search = $mainframe->getUserStateFromRequest( "search{$option}{$sectionid}", 'search', '' ); $search = $database->getEscaped( trim( strtolower( $search ) ) ); $redirect = $sectionid; $filter = ''; //getting a undefined variable error if ( $sectionid == 0 ) { // used to show All content items $where = array( "c.state >= 0", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'", ); $order = "\n ORDER BY s.title, c.catid, cc.ordering, cc.title, c.ordering"; $all = 1; //$filter = "\n , #__sections AS s WHERE s.id = c.section"; if ($filter_sectionid > 0) { $filter = "\nWHERE cc.section=$filter_sectionid"; } $section->title = $adminLanguage->A_COMP_CONTENT_ALL_ITEMS; $section->id = 0; } else { $where = array( "c.state >= 0", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'", "c.sectionid='$sectionid'" ); $order = "\n ORDER BY cc.ordering, cc.title, c.ordering"; $all = NULL; $filter = "\n WHERE cc.section = '$sectionid'"; $section = new mosSection( $database ); $section->load( $sectionid ); } // used by filter if ( $filter_sectionid > 0 ) { $where[] = "c.sectionid = '$filter_sectionid'"; } if ( $catid > 0 ) { $where[] = "c.catid = '$catid'"; } if ( $filter_authorid > 0 ) { $where[] = "c.created_by = '$filter_authorid'"; } if ( $search ) { $where[] = "LOWER( c.title ) LIKE '%$search%'"; } // get the total number of records $database->setQuery( "SELECT count(*) FROM #__content AS c, #__categories AS cc, #__sections AS s" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") ); $total = $database->loadResult(); require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); $pageNav = new mosPageNav( $total, $limitstart, $limit ); $query = "SELECT c.*, g.name AS groupname, cc.name, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author" . "\n FROM #__content AS c, #__categories AS cc, #__sections AS s" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" . "\n LEFT JOIN #__users AS v ON v.id = c.created_by" . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id" . ( count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : '' ) . $order . "\n LIMIT $pageNav->limitstart,$pageNav->limit" ; $database->setQuery( $query ); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } // get list of categories for dropdown filter $query = "SELECT cc.id AS value, cc.title AS text, section" . "\n FROM #__categories AS cc" . "\n INNER JOIN #__sections AS s ON s.id=cc.section " . $filter . "\n ORDER BY s.ordering, cc.ordering" ; $lists['catid'] = filterCategory( $query, $catid ); // get list of sections for dropdown filter $javascript = 'onchange="document.adminForm.submit();"'; $lists['sectionid'] = mosAdminMenus::SelectSection( 'filter_sectionid', $filter_sectionid, $javascript ); // get list of Authors for dropdown filter $query = "SELECT c.created_by AS value, u.name AS text" . "\n FROM #__content AS c" . "\n INNER JOIN #__sections AS s ON s.id = c.sectionid" . "\n LEFT JOIN #__users AS u ON u.id = c.created_by" . "\n WHERE c.state <> '-1'" . "\n AND c.state <> '-2'" . "\n GROUP BY u.name" . "\n ORDER BY u.name" ; $authors[] = mosHTML::makeOption( '0', _SEL_AUTHOR ); $database->setQuery( $query ); $authors = array_merge( $authors, $database->loadObjectList() ); $lists['authorid'] = mosHTML::selectList( $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_authorid ); HTML_content::showContent( $rows, $section, $lists, $search, $pageNav, $all, $redirect );}/*** Shows a list of archived content items* @param int The section id*/function viewArchive( $sectionid, $option ) { global $database, $mainframe, $mosConfig_list_limit; $catid = $mainframe->getUserStateFromRequest( "catidarc{$option}{$sectionid}", 'catid', 0 ); $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ); $limitstart = $mainframe->getUserStateFromRequest( "viewarc{$option}{$sectionid}limitstart", 'limitstart', 0 ); $search = $mainframe->getUserStateFromRequest( "searcharc{$option}{$sectionid}", 'search', '' ); $filter_authorid = $mainframe->getUserStateFromRequest( "filter_authorid{$option}{$sectionid}", 'filter_authorid', 0 ); $filter_sectionid = $mainframe->getUserStateFromRequest( "filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0 ); $search = $database->getEscaped( trim( strtolower( $search ) ) ); $redirect = $sectionid; if ( $sectionid == 0 ) { $where = array( "c.state = -1", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'" ); $filter = "\n , #__sections AS s WHERE s.id = c.section"; $all = 1; } else { $where = array( "c.state = -1", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'", "c.sectionid='$sectionid'" ); $filter = "\n WHERE section = '$sectionid'"; $all = NULL; } // used by filter if ( $filter_sectionid > 0 ) { $where[] = "c.sectionid = '$filter_sectionid'"; } if ( $filter_authorid > 0 ) { $where[] = "c.created_by = '$filter_authorid'"; } if ($catid > 0) { $where[] = "c.catid='$catid'"; } if ($search) { $where[] = "LOWER(c.title) LIKE '%$search%'"; } // get the total number of records $query = "SELECT count(*)" . "FROM #__content AS c, #__categories AS cc, #__sections AS s" . ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : '' ) ; $database->setQuery( $query ); $total = $database->loadResult(); require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); $pageNav = new mosPageNav( $total, $limitstart, $limit ); $query = "SELECT c.*, g.name AS groupname, cc.name, v.name AS author" . "\n FROM #__content AS c, #__categories AS cc, #__sections AS s" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . "\n LEFT JOIN #__users AS v ON v.id = c.created_by" . ( count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : '' ) . "\n ORDER BY c.catid, c.ordering" . "\n LIMIT $pageNav->limitstart,$pageNav->limit" ; $database->setQuery( $query ); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return; } // get list of categories for dropdown filter $query = "SELECT c.id AS value, c.title AS text" . "\n FROM #__categories AS c" . $filter . "\n ORDER BY c.ordering" ; $lists['catid'] = filterCategory( $query, $catid ); // get list of sections for dropdown filter $javascript = 'onchange="document.adminForm.submit();"'; $lists['sectionid'] = mosAdminMenus::SelectSection( 'filter_sectionid', $filter_sectionid, $javascript ); $section = new mosSection( $database ); $section->load( $sectionid ); // get list of Authors for dropdown filter $query = "SELECT c.created_by AS value, u.name AS text" . "\n FROM #__content AS c" . "\n INNER JOIN #__sections AS s ON s.id = c.sectionid" . "\n LEFT JOIN #__users AS u ON u.id = c.created_by" . "\n WHERE c.state = '-1'" . "\n GROUP BY u.name" . "\n ORDER BY u.name" ; $authors[] = mosHTML::makeOption( '0', _SEL_AUTHOR ); $database->setQuery( $query ); $authors = array_merge( $authors, $database->loadObjectList() ); $lists['authorid'] = mosHTML::selectList( $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_authorid ); HTML_content::showArchive( $rows, $section, $lists, $search, $pageNav, $option, $all, $redirect );}/*** Compiles information to add or edit the record* @param database A database connector object* @param integer The unique id of the record to edit (0 if new)* @param integer The id of the content section*/function editContent( $uid=0, $sectionid=0, $option ) { global $database, $my, $mainframe, $adminLanguage; global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset; $redirect = mosGetParam( $_POST, 'redirect', '' ); if ( !$redirect ) { $redirect = $sectionid; } // load the row from the db table $row = new mosContent( $database ); $row->load( $uid ); if ($uid) { $sectionid = $row->sectionid; if ($row->state < 0) { mosRedirect( 'index2.php?option=com_content§ionid='. $row->sectionid, $adminLanguage->A_COMP_CONTENT_CANNOT ); } } if ( $sectionid == 0 ) { $where = "\n WHERE section NOT LIKE '%com_%'"; } else { $where = "\n WHERE section='$sectionid'"; } // get the type name - which is a special category if ($row->sectionid){ $query = "SELECT name FROM #__sections WHERE id=$row->sectionid"; $database->setQuery( $query ); $section = $database->loadResult(); $contentSection = $section; } else { $query = "SELECT name FROM #__sections WHERE id=$sectionid"; $database->setQuery( $query ); $section = $database->loadResult(); $contentSection = $section; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -