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

📄 admin.menus.php

📁 mambo的cms源代码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/*** @version $Id: admin.menus.php,v 1.30 2005/02/16 18:27:26 troozers Exp $* @package Mambo* @subpackage Menus* @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' ) );$id 		= intval( mosGetParam( $_GET, 'id', 0 ) );$type 		= mosGetParam( $_REQUEST, 'type', false );$menutype 	= mosGetParam( $_REQUEST, 'menutype', 'mainmenu' );$task 		= mosGetParam( $_REQUEST, 'task', '' );$access 	= mosGetParam( $_POST, 'access', '' );$utaccess	= mosGetParam( $_POST, 'utaccess', '' );$ItemName	= mosGetParam( $_POST, 'ItemName', '' );$menu 		= mosGetParam( $_POST, 'menu', '' );$cid 		= mosGetParam( $_POST, 'cid', array(0) );$path 		= $mosConfig_absolute_path .'/administrator/components/com_menus/';if (!is_array( $cid )) {	$cid = array(0);}switch ($task) {	case 'new':		addMenuItem( $cid, $menutype, $option, $task );		break;	case 'edit':		$cid[0]	= ( $id ? $id : $cid[0] );		$menu = new mosMenu( $database );		if ( $cid[0] ) {			$menu->load( $cid[0]  );		} else {			$menu->type = $type;		}		if ( $menu->type ) {			$type = $menu->type;			require( $path . $menu->type .'/'. $menu->type .'.menu.php' );		}		break;	case 'save':	case 'apply':		require( $path . $type .'/'. $type .'.menu.php' );		break;	case 'publish':	case 'unpublish':		if ($msg = publishMenuSection( $cid, ($task == 'publish') )) {			// proceed no further if the menu item can't be published			mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype .'&mosmsg= '.$msg );		} else {			mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype );		}		break;	case 'remove':		if ($msg = TrashMenusection( $cid )) {			mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype .'&mosmsg= '.$msg );		} else {			mosRedirect( 'index2.php?option=com_menus&menutype='. $menutype );		}		break;	case 'cancel':		cancelMenu( $option );		break;	case 'orderup':		orderMenu( $cid[0], -1, $option );		break;	case 'orderdown':		orderMenu( $cid[0], 1, $option );		break;	case 'accesspublic':		accessMenu( $cid[0], 0, $option, $menutype );		break;	case 'accessregistered':		accessMenu( $cid[0], 1, $option, $menutype );		break;	case 'accessspecial':		accessMenu( $cid[0], 2, $option, $menutype );		break;	case 'movemenu':		moveMenu( $option, $cid, $menutype );		break;	case 'movemenusave':		moveMenuSave( $option, $cid, $menu, $menutype );		break;	case 'copymenu':		copyMenu( $option, $cid, $menutype );		break;	case 'copymenusave':		copyMenuSave( $option, $cid, $menu, $menutype );		break;	case 'cancelcopymenu':	case 'cancelmovemenu':		viewMenuItems( $menutype, $option );		break;	case 'saveorder':		saveOrder( $cid, $menutype );		break;	default:		$type = trim( mosGetParam( $_REQUEST, 'type', null ) );		if ($type) {			// adding a new item - type selection form			require( $path . $type .'/'. $type .'.menu.php' );		} else {			viewMenuItems( $menutype, $option );		}	break;}/*** Shows a list of items for a menu*/function viewMenuItems( $menutype, $option ) {	global $database, $mainframe, $mosConfig_list_limit, $adminLanguage;	$limit 		= $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit );	$limitstart 	= $mainframe->getUserStateFromRequest( "view{$option}limitstart$menutype", 'limitstart', 0 );	$levellimit 	= $mainframe->getUserStateFromRequest( "view{$option}limit$menutype", 'levellimit', 10 );	$search 	= $mainframe->getUserStateFromRequest( "search{$option}$menutype", 'search', '' );	$search 	= $database->getEscaped( trim( strtolower( $search ) ) );	// select the records	// note, since this is a tree we have to do the limits code-side	if ($search) {		$query = "SELECT m.id"		. "\n FROM #__menu AS m"		//. "\n LEFT JOIN #__content AS c ON c.id = m.componentid AND type='content_typed'"		. "\n WHERE menutype='$menutype'"		. "\n AND LOWER(m.name) LIKE '%" . strtolower( $search ) . "%'"		;		$database->setQuery( $query );		$search_rows = $database->loadResultArray();	}	$query = "SELECT m.*, u.name AS editor, g.name AS groupname, c.publish_up, c.publish_down, com.name AS com_name"	. "\n FROM #__menu AS m"	. "\n LEFT JOIN #__users AS u ON u.id = m.checked_out"	. "\n LEFT JOIN #__groups AS g ON g.id = m.access"	. "\n LEFT JOIN #__content AS c ON c.id = m.componentid AND m.type='content_typed'"	. "\n LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type='components'"	. "\n WHERE m.menutype='$menutype'"	. "\n AND m.published != -2"	. "\n ORDER BY parent,ordering"	;	$database->setQuery( $query );	$rows = $database->loadObjectList();	// establish the hierarchy of the menu	$children = array();	// first pass - collect children	foreach ($rows as $v ) {		$pt = $v->parent;		$list = @$children[$pt] ? $children[$pt] : array();		array_push( $list, $v );		$children[$pt] = $list;	}	// second pass - get an indent list of the items	$list = mosTreeRecurse( 0, '', array(), $children, max( 0, $levellimit-1 ) );	// eventually only pick out the searched items.	if ($search) {		$list1 = array();		foreach ($search_rows as $sid ) {			foreach ($list as $item) {				if ($item->id == $sid) {					$list1[] = $item;				}			}		}		// replace full list with found items		$list = $list1;	}	$total = count( $list );	require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' );	$pageNav = new mosPageNav( $total, $limitstart, $limit  );	$levellist = mosHTML::integerSelectList( 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit );	// slice out elements based on limits	$list = array_slice( $list, $pageNav->limitstart, $pageNav->limit );	$i = 0;	foreach ( $list as $mitem ) {		$edit = '';		switch ( $mitem->type ) {			case 'separator':			case 'component_item_link':				break;			case 'url':				if ( eregi( 'index.php\?', $mitem->link ) ) {					if ( !eregi( 'Itemid=', $mitem->link ) ) {						$mitem->link .= '&Itemid='. $mitem->id;					}				}				break;			case 'newsfeed_link':				$edit = 'index2.php?option=com_newsfeeds&task=edit&hidemainmenu=1A&id=' . $mitem->componentid;				$list[$i]->descrip 	= $adminLanguage->A_COMP_MENUS_EDIT_NEWSFEED_TIP;				$mitem->link .= '&Itemid='. $mitem->id;				break;			case 'contact_item_link':				$edit = 'index2.php?option=com_contact&task=editA&hidemainmenu=1&id=' . $mitem->componentid;				$list[$i]->descrip 	= $adminLanguage->A_COMP_MENUS_EDIT_CONTACT_TIP;				$mitem->link .= '&Itemid='. $mitem->id;				break;			case 'content_item_link':				$edit = 'index2.php?option=com_content&task=edit&hidemainmenu=1&id=' . $mitem->componentid;				$list[$i]->descrip 	= $adminLanguage->A_COMP_MENUS_EDIT_CONTENT_TIP;				break;			case 'content_typed':				$edit = 'index2.php?option=com_typedcontent&task=edit&hidemainmenu=1&id='. $mitem->componentid;				$list[$i]->descrip 	= $adminLanguage->A_COMP_MENUS_EDIT_STATIC_TIP;				break;			default:				$mitem->link .= '&Itemid='. $mitem->id;				break;		}		$list[$i]->link = $mitem->link;		$list[$i]->edit = $edit;		$i++;	}	$i = 0;	foreach ( $list as $row ) {		// pulls name and description from menu type xml		$row = ReadMenuXML( $row->type, $row->com_name );		$list[$i]->type 	= $row[0];		if (!isset($list[$i]->descrip)) $list[$i]->descrip = $row[1];		$i++;	}	HTML_menusections::showMenusections( $list, $pageNav, $search, $levellist, $menutype, $option );}/*** Displays a selection list for menu item types*/function addMenuItem( &$cid, $menutype, $option, $task ) {	global $mosConfig_absolute_path;	$types 	= array();	// list of directories	$dirs 	= mosReadDirectory( $mosConfig_absolute_path .'/administrator/components/com_menus' );	// load files for menu types	foreach ( $dirs as $dir ) {		// needed within menu type .php files		$type 	= $dir;		$dir 	= $mosConfig_absolute_path .'/administrator/components/com_menus/'. $dir;		if ( is_dir( $dir ) ) {			$files = mosReadDirectory( $dir, ".\.menu\.php$" );			foreach ($files as $file) {				require_once( "$dir/$file" );				// type of menu type				$types[]->type = $type;			}		}	}	$i = 0;	foreach ( $types as $type ) {		// pulls name and description from menu type xml		$row = ReadMenuXML( $type->type );		$types[$i]->name 	= $row[0];		$types[$i]->descrip = $row[1];		$types[$i]->group 	= $row[2];		$i++;	}	// sort array of objects alphabetically by name of menu type	SortArrayObjects( $types, 'name', 1 );	// split into Content	$i = 0;	foreach ( $types as $type ) {		if ( strstr( $type->group, 'Content' ) ) {			$types_content[] = $types[$i];		}		$i++;	}	// split into Links	$i = 0;	foreach ( $types as $type ) {		if ( strstr( $type->group, 'Link' ) ) {			$types_link[] = $types[$i];		}		$i++;	}	// split into Component	$i = 0;	foreach ( $types as $type ) {		if ( strstr( $type->group, 'Component' ) ) {			$types_component[] = $types[$i];		}		$i++;	}	// split into Other	$i = 0;	foreach ( $types as $type ) {		if ( strstr( $type->group, 'Other' ) || !$type->group ) {			$types_other[] = $types[$i];		}		$i++;	}	HTML_menusections::addMenuItem( $cid, $menutype, $option, $types_content, $types_component, $types_link, $types_other );}/*** Generic function to save the menu*/function saveMenu( $option, $task='save' ) {	global $database, $adminLanguage;	$params = mosGetParam( $_POST, 'params', '' );	if (is_array( $params )) {	    $txt = array();	    foreach ($params as $k=>$v) {	        $txt[] = "$k=$v";		}		$_POST['params'] = mosParameters::textareaHandling( $txt );	}	$row = new mosMenu( $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( "menutype='$row->menutype' AND parent='$row->parent'" );	$msg = $adminLanguage->A_COMP_MENUS_ITEM_SAVED;

⌨️ 快捷键说明

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