⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin.sections.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/*** @version		$Id: admin.sections.php 10381 2008-06-01 03:35:53Z pasamio $* @package		Joomla* @subpackage	Sections* @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.* @license		GNU/GPL, see LICENSE.php* Joomla! is free software. This version may have been modified pursuant* to the GNU General Public License, and as distributed it includes or* is derivative of works licensed under the GNU General Public License or* other free or open source software licenses.* See COPYRIGHT.php for copyright notices and details.*/// no direct accessdefined( '_JEXEC' ) or die( 'Restricted access' );require_once( JApplicationHelper::getPath( 'admin_html' ) );// get parameters from the URL or submitted form$scope 		= JRequest::getCmd( 'scope' );$cid 		= JRequest::getVar( 'cid', array(0), '', 'array' );JArrayHelper::toInteger($cid, array(0));$task = JRequest::getCmd('task');switch ($task){	case 'add' :		editSection(false );		break;	case 'edit':		editSection(true );		break;	case 'go2menu':	case 'go2menuitem':	case 'save':	case 'apply':		saveSection( $option, $scope, $task );		break;	case 'remove':		removeSections( $cid, $scope, $option );		break;	case 'copyselect':		copySectionSelect( $option, $cid, $scope );		break;	case 'copysave':		copySectionSave( $cid, $scope );		break;	case 'publish':		publishSections( $scope, $cid, 1, $option );		break;	case 'unpublish':		publishSections( $scope, $cid, 0, $option );		break;	case 'cancel':		cancelSection( $option, $scope );		break;	case 'orderup':		orderSection( $cid[0], -1, $option, $scope );		break;	case 'orderdown':		orderSection( $cid[0], 1, $option, $scope );		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:		showSections( $scope, $option );		break;}/*** Compiles a list of categories for a section* @param database A database connector object* @param string The name of the category section* @param string The name of the current user*/function showSections( $scope, $option ){	global $mainframe;	$db					=& JFactory::getDBO();	$user				=& JFactory::getUser();	$filter_order		= $mainframe->getUserStateFromRequest( $option.'.filter_order',		'filter_order',		's.ordering',	'cmd' );	$filter_order_Dir	= $mainframe->getUserStateFromRequest( $option.'.filter_order_Dir',	'filter_order_Dir',	'',				'word' );	$filter_state		= $mainframe->getUserStateFromRequest( $option.'.filter_state',		'filter_state',		'',				'word' );	$search				= $mainframe->getUserStateFromRequest( $option.'.search',			'search',			'',				'string' );	$search				= JString::strtolower( $search );	$limit		= $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );	$limitstart	= $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );	$where[] = 's.scope = '.$db->Quote($scope);	if ( $filter_state ) {		if ( $filter_state == 'P' ) {			$where[] = 's.published = 1';		} else if ($filter_state == 'U' ) {			$where[] = 's.published = 0';		}	}	if ($search) {		$where[] = 'LOWER(s.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );	}	$where 		= ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );	$orderby 	= ' ORDER BY '.$filter_order.' '. $filter_order_Dir .', s.ordering';	// get the total number of records	$query = 'SELECT COUNT(*)'	. ' FROM #__sections AS s'	. $where	;	$db->setQuery( $query );	$total = $db->loadResult();	jimport('joomla.html.pagination');	$pageNav = new JPagination( $total, $limitstart, $limit );	$query = 'SELECT s.*, g.name AS groupname, u.name AS editor'	. ' FROM #__sections AS s'	. ' LEFT JOIN #__content AS cc ON s.id = cc.sectionid'	. ' LEFT JOIN #__users AS u ON u.id = s.checked_out'	. ' LEFT JOIN #__groups AS g ON g.id = s.access'	. $where	. ' GROUP BY s.id'	. $orderby	;	$db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );	$rows = $db->loadObjectList();	if ($db->getErrorNum()) {		echo $db->stderr();		return false;	}	$count = count( $rows );	// number of Active Categories	for ( $i = 0; $i < $count; $i++ ) {		$query = 'SELECT COUNT( a.id )'		. ' FROM #__categories AS a'		. ' WHERE a.section = '.$db->Quote($rows[$i]->id)		. ' AND a.published <> -2'		;		$db->setQuery( $query );		$active = $db->loadResult();		$rows[$i]->categories = $active;	}	// number of Active Items	for ( $i = 0; $i < $count; $i++ ) {		$query = 'SELECT COUNT( a.id )'		. ' FROM #__content AS a'		. ' WHERE a.sectionid = '.(int) $rows[$i]->id		. ' AND a.state <> -2'		;		$db->setQuery( $query );		$active = $db->loadResult();		$rows[$i]->active = $active;	}	// number of Trashed Items	for ( $i = 0; $i < $count; $i++ ) {		$query = 'SELECT COUNT( a.id )'		. ' FROM #__content AS a'		. ' WHERE a.sectionid = '.(int) $rows[$i]->id		. ' AND a.state = -2'		;		$db->setQuery( $query );		$trash = $db->loadResult();		$rows[$i]->trash = $trash;	}	// state filter	$lists['state']	= JHTML::_('grid.state',  $filter_state );	// table ordering	$lists['order_Dir']	= $filter_order_Dir;	$lists['order']		= $filter_order;	// search filter	$lists['search']= $search;	sections_html::show( $rows, $scope, $user->get('id'), $pageNav, $option, $lists );}/*** Compiles information to add or edit a section* @param database A database connector object* @param string The name of the category section* @param integer The unique id of the category to edit (0 if new)* @param string The name of the current user*/function editSection( $edit){	global $mainframe;	$db			=& JFactory::getDBO();	$user 		=& JFactory::getUser();	$option		= JRequest::getCmd( 'option');	$scope		= JRequest::getCmd( 'scope' );	$cid		= JRequest::getVar( 'cid', array(0), '', 'array' );	JArrayHelper::toInteger($cid, array(0));	$row =& JTable::getInstance('section');	// load the row from the db table	if ($edit)		$row->load( $cid[0] );	// fail if checked out not by 'me'	if ($row->isCheckedOut( $user->get('id') )) {		$msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The section' ), $row->title );		$mainframe->redirect( 'index.php?option='. $option .'&scope='. $row->scope, $msg );	}	if ( $edit ) {		$row->checkout( $user->get('id') );	} else {		$row->scope 		= $scope;		$row->published 	= 1;	}	// build the html select list for ordering	$query = 'SELECT ordering AS value, title AS text'	. ' FROM #__sections'	. ' WHERE scope='.$db->Quote($row->scope).' ORDER BY ordering'	;	if($edit)		$lists['ordering'] 			= JHTML::_('list.specificordering',  $row, $cid[0], $query );	else		$lists['ordering'] 			= JHTML::_('list.specificordering',  $row, '', $query );	// build the select list for the image positions	$active =  ( $row->image_position ? $row->image_position : 'left' );	$lists['image_position'] 	= JHTML::_('list.positions',  'image_position', $active, NULL, 0 );	// build the html select list for images	$lists['image'] 			= JHTML::_('list.images',  'image', $row->image );	// build the html select list for the group access	$lists['access'] 			= JHTML::_('list.accesslevel',  $row );	// build the html radio buttons for published	$lists['published'] 		= JHTML::_('select.booleanlist',  'published', 'class="inputbox"', $row->published );	sections_html::edit( $row, $option, $lists );}/*** Saves the catefory after an edit form submit* @param database A database connector object* @param string The name of the category section*/function saveSection( $option, $scope, $task ){	global $mainframe;	// Check for request forgeries	JRequest::checkToken() or jexit( 'Invalid Token' );	$db			=& JFactory::getDBO();	$menu		= JRequest::getVar( 'menu', 'mainmenu', 'post', 'string' );	$menuid		= JRequest::getVar( 'menuid', 0, 'post', 'int' );	$oldtitle	= JRequest::getVar( 'oldtitle', '', '', 'post', 'string' );	$post = JRequest::get('post');	// fix up special html fields	$post['description'] = JRequest::getVar( 'description', '', 'post', 'string', JREQUEST_ALLOWRAW );	$row =& JTable::getInstance('section');	if (!$row->bind($post)) {		JError::raiseError(500, $row->getError() );	}	if (!$row->check()) {		JError::raiseError(500, $row->getError() );	}	if ( $oldtitle ) {		if ( $oldtitle <> $row->title ) {			$query = 'UPDATE #__menu'			. ' SET name = '.$db->Quote($row->title)			. ' WHERE name = '.$db->Quote($oldtitle)			. ' AND type = "content_section"'			;			$db->setQuery( $query );			$db->query();		}	}	// if new item order last in appropriate group	if (!$row->id) {		$row->ordering = $row->getNextOrder();	}	if (!$row->store()) {		JError::raiseError(500, $row->getError() );	}	$row->checkin();	switch ( $task )	{		case 'go2menu':			$mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu );			break;		case 'go2menuitem':			$mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu .'&task=edit&id='. $menuid );			break;		case 'apply':			$msg = JText::_( 'Changes to Section saved' );			$mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope .'&task=edit&cid[]='. $row->id, $msg );			break;		case 'save':		default:			$msg = JText::_( 'Section saved' );			$mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope, $msg );			break;	}}/*** Deletes one or more categories from the categories table* @param database A database connector object* @param string The name of the category section* @param array An array of unique category id numbers*/function removeSections( $cid, $scope, $option ){	global $mainframe;	// Check for request forgeries	JRequest::checkToken() or jexit( 'Invalid Token' );	$db =& JFactory::getDBO();	if (count( $cid ) < 1) {		JError::raiseError(500, JText::_( 'Select a section to delete', true ) );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -