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

📄 admin.categories.php

📁 mambo的cms源代码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/*** @version $Id: admin.categories.php,v 1.21 2005/02/16 03:32:44 kochp Exp $* @package Mambo* @subpackage Categories* @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' ) );// get parameters from the URL or submitted form$section 	= mosGetParam( $_REQUEST, 'section', 'content' );$cid 		= mosGetParam( $_REQUEST, 'cid', array(0) );if (!is_array( $cid )) {	$cid = array(0);}switch ($task) {	case 'new':		editCategory( 0, $section );		break;	case 'edit':		editCategory( intval( $cid[0] ) );		break;	case 'editA':		editCategory( intval( $id ) );		break;	case 'moveselect':		moveCategorySelect( $option, $cid, $section );		break;	case 'movesave':		moveCategorySave( $cid, $section );		break;	case 'copyselect':		copyCategorySelect( $option, $cid, $section );		break;	case 'copysave':		copyCategorySave( $cid, $section );		break;	case 'go2menu':	case 'go2menuitem':	case 'menulink':	case 'save':	case 'apply':		saveCategory( $task );		break;	case 'remove':		removeCategories( $section, $cid );		break;	case 'publish':		publishCategories( $section, $id, $cid, 1 );		break;	case 'unpublish':		publishCategories( $section, $id, $cid, 0 );		break;	case 'cancel':		cancelCategory();		break;	case 'orderup':		orderCategory( $cid[0], -1 );		break;	case 'orderdown':		orderCategory( $cid[0], 1 );		break;	case 'accesspublic':		accessMenu( $cid[0], 0, $section );		break;	case 'accessregistered':		accessMenu( $cid[0], 1, $section );		break;	case 'accessspecial':		accessMenu( $cid[0], 2, $section );		break;	case 'saveorder':		saveOrder( $cid, $section );		break;	default:		showCategories( $section, $option );		break;}/*** Compiles a list of categories for a section* @param string The name of the category section*/function showCategories( $section, $option ) {	global $database, $mainframe, $mosConfig_list_limit, $mosConfig_absolute_path;	$sectionid 		= $mainframe->getUserStateFromRequest( "sectionid{$option}{$section}", 'sectionid', 0 );	$limit 			= $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit );	$limitstart 	= $mainframe->getUserStateFromRequest( "view{$section}limitstart", 'limitstart', 0 );	$section_name 	= '';	$content_add 	= '';	$content_join 	= '';	$order 			= "\n ORDER BY c.ordering, c.name";	if (intval( $section ) > 0) {		$table = 'content';		$query = "SELECT name FROM #__sections WHERE id='$section'";		$database->setQuery( $query );		$section_name = $database->loadResult();		$section_name = 'Content: '. $section_name;		$where 	= "\n WHERE c.section='$section'";		$type 	= 'content';	} else if (strpos( $section, 'com_' ) === 0) {		$table = substr( $section, 4 );		$query = "SELECT name FROM #__components WHERE link='option=$section'";		$database->setQuery( $query );		$section_name = $database->loadResult();		$where 	= "\n WHERE c.section='$section'";		$type 	= 'other';		// special handling for contact component		if ( $section == 'com_contact_details' ) {			$section_name 	= 'Contact';		}		$section_name = 'Component: '. $section_name;	} else {		$table 	= $section;		$where 	= "\n WHERE c.section='$section'";		$type 	= 'other';	}	// get the total number of records	$query = "SELECT count(*) FROM #__categories WHERE section='$section'";	$database->setQuery( $query );	$total = $database->loadResult();	// allows for viweing of all content categories	if ( $section == 'content' ) {		$table 			= 'content';		$content_add 	= "\n , z.title AS section_name";		$content_join 	= "\n LEFT JOIN #__sections AS z ON z.id = c.section";		//$where = "\n WHERE s1.catid = c.id";		$where 			= "\n WHERE c.section NOT LIKE '%com_%'";		$order 			= "\n ORDER BY c.section, c.ordering, c.name";		$section_name 	= 'All Content';		// get the total number of records		$database->setQuery( "SELECT count(*) FROM #__categories INNER JOIN #__sections AS s ON s.id = section" );		$total = $database->loadResult();		$type 			= 'content';	}	// used by filter	if ( $sectionid > 0 ) {		$filter = "\n AND c.section = '$sectionid'";	} else {		$filter = '';	}	require_once( $mosConfig_absolute_path . '/administrator/includes/pageNavigation.php' );	$pageNav = new mosPageNav( $total, $limitstart, $limit );	$query = "SELECT  c.*, c.checked_out as checked_out_contact_category, g.name AS groupname, u.name AS editor,"	. "COUNT(DISTINCT s2.checked_out) AS checked_out"	. $content_add	. "\n FROM #__categories AS c"	. "\n LEFT JOIN #__users AS u ON u.id = c.checked_out"	. "\n LEFT JOIN #__groups AS g ON g.id = c.access"	//. "\n LEFT JOIN #__$table AS s1 ON s1.catid = c.id"	. "\n LEFT JOIN #__$table AS s2 ON s2.catid = c.id AND s2.checked_out > 0"	. $content_join	. $where	. $filter	. "\n AND c.published != -2"	. "\n GROUP BY c.id"	. $order	. "\n LIMIT $pageNav->limitstart, $pageNav->limit"	;	$database->setQuery( $query );	$rows = $database->loadObjectList();	if ($database->getErrorNum()) {		echo $database->stderr();		return;	}	$count = count( $rows );	// number of Active Items	for ( $i = 0; $i < $count; $i++ ) {		$query = "SELECT COUNT( a.id )"		. "\n FROM #__content AS a"		. "\n WHERE a.catid = ". $rows[$i]->id		. "\n AND a.state <> '-2'"		;		$database->setQuery( $query );		$active = $database->loadResult();		$rows[$i]->active = $active;	}	// number of Trashed Items	for ( $i = 0; $i < $count; $i++ ) {		$query = "SELECT COUNT( a.id )"		. "\n FROM #__content AS a"		. "\n WHERE a.catid = ". $rows[$i]->id		. "\n AND a.state = '-2'"		;		$database->setQuery( $query );		$trash = $database->loadResult();		$rows[$i]->trash = $trash;	}	// get list of sections for dropdown filter	$javascript = 'onchange="document.adminForm.submit();"';	$lists['sectionid']			= mosAdminMenus::SelectSection( 'sectionid', $sectionid, $javascript );	categories_html::show( $rows, $section, $section_name, $pageNav, $lists, $type );}/*** Compiles information to add or edit a category* @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 editCategory( $uid=0, $section='' ) {	global $database, $my, $adminLanguage;	$type 		= mosGetParam( $_REQUEST, 'type', '' );	$redirect 	= mosGetParam( $_REQUEST, 'section', 'content' );	$row = new mosCategory( $database );	// load the row from the db table	$row->load( $uid );	// fail if checked out not by 'me'	if ($row->checked_out && $row->checked_out <> $my->id) {		mosRedirect( 'index2.php?option=categories&section='. $row->section, $adminLanguage->A_COMP_CATEG_MESSAGE ." ". $row->title ." ". $adminLanguage->A_COMP_CATEG_MESSAGE2 );	}	if ($uid) {		// existing record		$row->checkout( $my->id );		// code for Link Menu		if ( $row->section > 0 ) {			$query = "SELECT *"			. "\n FROM #__menu"			. "\n WHERE componentid = ". $row->id			. "\n AND ( type = 'content_archive_category' OR type = 'content_blog_category' OR type = 'content_category' )"			;			$database->setQuery( $query );			$menus = $database->loadObjectList();			$count = count( $menus );			for( $i = 0; $i < $count; $i++ ) {				switch ( $menus[$i]->type ) {					case 'content_category':						$menus[$i]->type = $adminLanguage->A_COMP_CATEG_TABLE ;						break;					case 'content_blog_category':						$menus[$i]->type = $adminLanguage->A_COMP_CATEG_BLOG ;						break;					case 'content_archive_category':						$menus[$i]->type = $adminLanguage->A_COMP_CATEG_BLOG_ARCHIVE ;						break;				}			}		} else {			$menus = array();		}	} else {		// new record		$row->section = $section;		$row->published = 1;		$menus = NULL;	}	// make order list	$order = array();	$database->setQuery( "SELECT COUNT(*) FROM #__categories WHERE section='$row->section'" );	$max = intval( $database->loadResult() ) + 1;	for ($i=1; $i < $max; $i++) {		$order[] = mosHTML::makeOption( $i );	}	// build the html select list for sections	if ( $section == 'content' ) {		$query = "SELECT s.id AS value, s.title AS text"		. "\n FROM #__sections AS s"		. "\n ORDER BY s.ordering"		;		$database->setQuery( $query );		$sections = $database->loadObjectList();		$lists['section'] = mosHTML::selectList( $sections, 'section', 'class="inputbox" size="1"', 'value', 'text' );;	} else {		if ( $type == 'other' ) {			$section_name = 'N/A';		} else {			$temp = new mosSection( $database );			$temp->load( $row->section );			$section_name = $temp->name;		}		$lists['section'] = '<input type="hidden" name="section" value="'. $row->section .'" />'. $section_name;	}	// build the html select list for category types	$types[] = mosHTML::makeOption( '', $adminLanguage->A_COMP_CATEG_SELECT_TYPE );	if ($row->section == 'com_contact_details') {		$types[] = mosHTML::makeOption( 'contact_category_table', $adminLanguage->A_COMP_CATEG_CONTACT_CATEG_TABLE );	} else	if ($row->section == 'com_newsfeeds') {		$types[] = mosHTML::makeOption( 'newsfeed_category_table', $adminLanguage->A_COMP_CATEG_NEWSFEED_CATEG_TABLE );	} else	if ($row->section == 'com_weblinks') {		$types[] = mosHTML::makeOption( 'weblink_category_table', $adminLanguage->A_COMP_CATEG_WEBLINK_CATEG_TABLE );	} else {		$types[] = mosHTML::makeOption( 'content_category', $adminLanguage->A_COMP_CATEG_CONTENT_CATEG_TABLE );		$types[] = mosHTML::makeOption( 'content_blog_category', $adminLanguage->A_COMP_CATEG_CONTENT_CATEG_BLOG );		$types[] = mosHTML::makeOption( 'content_archive_category', $adminLanguage->A_COMP_CATEG_CONTENT_CATEG_ARCH_BLOG );	} // if	$lists['link_type'] 		= mosHTML::selectList( $types, 'link_type', 'class="inputbox" size="1"', 'value', 'text' );;	// build the html select list for ordering	$query = "SELECT ordering AS value, title AS text"	. "\n FROM #__categories"	. "\n WHERE section = '$row->section'"	. "\n ORDER BY ordering"	;	$lists['ordering'] 			= mosAdminMenus::SpecificOrdering( $row, $uid, $query );	// build the select list for the image positions	$active =  ( $row->image_position ? $row->image_position : 'left' );	$lists['image_position'] 	= mosAdminMenus::Positions( 'image_position', $active, NULL, 0, 0 );	// Imagelist	$lists['image'] 			= mosAdminMenus::Images( 'image', $row->image );	// build the html select list for the group access	$lists['access'] 			= mosAdminMenus::Access( $row );	// build the html radio buttons for published	$lists['published'] 		= mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published );	// build the html select list for menu selection	$lists['menuselect']		= mosAdminMenus::MenuSelect( ); 	categories_html::edit( $row, $lists, $redirect, $menus );}/*** Saves the catefory after an edit form submit* @param string The name of the category section*/function saveCategory( $task ) {	global $database;	$menu 		= mosGetParam( $_POST, 'menu', 'mainmenu' );	$menuid		= mosGetParam( $_POST, 'menuid', 0 );	$redirect 	= mosGetParam( $_POST, 'redirect', '' );	$oldtitle 	= mosGetParam( $_POST, 'oldtitle', null );	$row = new mosCategory( $database );	if (!$row->bind( $_POST )) {		echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";		exit();	}	if (!$row->check()) {		echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";		exit();	}	if (!$row->store()) {		echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";		exit();	}	$row->checkin();	$row->updateOrder( "section='$row->section'" );	if ( $oldtitle ) {		if ($oldtitle != $row->title) {			$database->setQuery( "UPDATE #__menu SET name='$row->title' WHERE name='$oldtitle' AND type='content_category'" );			$database->query();		}	}	// Update Section Count	if ($row->section != 'com_contact_details' &&		$row->section != 'com_newsfeeds' &&		$row->section != 'com_weblinks') {		$query = "UPDATE #__sections SET count=count+1"		. "\n WHERE id = '$row->section'"		;		$database->setQuery( $query );	}	if (!$database->query()) {		echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";		exit();	}	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( $row->id );			break;		case 'apply':			$msg = 'Changes to Category saved';			mosRedirect( 'index2.php?option=com_categories&section='. $redirect .'&task=editA&hidemainmenu=1&id='. $row->id, $msg );			break;			case 'save':		default:			$msg = 'Category saved';			mosRedirect( 'index2.php?option=com_categories&section='. $redirect, $msg );			break;	}}/*** Deletes one or more categories from the categories table

⌨️ 快捷键说明

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