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

📄 list.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 2 页
字号:
            }            $default++;		}        if (!empty($items)) {            // Sent menu items to the trash            JArrayHelper::toInteger($items, array(0));            $where = ' WHERE (id = ' . implode( ' OR id = ', $items ) . ') AND home = 0';            $query = 'UPDATE #__menu' .                    ' SET published = '.(int) $state.', parent = 0, ordering = 0, checked_out = 0, checked_out_time = '.$db->Quote($nd) .                    $where;            $db->setQuery( $query );            if (!$db->query()) {                $this->setError( $db->getErrorMsg() );                return false;            }        }		// clean cache		MenusHelper::cleanCache();        		return count($items);	}	function fromTrash($items)	{		$db		=& $this->getDBO();		$nd		= $db->getNullDate();		$state	= 0;		// Add all children to the list		foreach ($items as $id)		{			$this->_addChildren($id, $items);		}		// Sent menu items to the trash		JArrayHelper::toInteger($items, array(0));		$where = ' WHERE id = ' . implode( ' OR id = ', $items );		$query = 'UPDATE #__menu' .				' SET published = '.(int) $state.', parent = 0, ordering = 99999, checked_out = 0, checked_out_time = '.$db->Quote($nd) .				$where;		$db->setQuery( $query );		if (!$db->query()) {			$this->setError( $db->getErrorMsg() );			return false;		}		// clean cache (require helper because method can be called from com_trash)		require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' );		MenusHelper::cleanCache();				return count($items);	}	/**	* Set the state of selected menu items	*/	function setHome( $item )	{		$db =& $this->getDBO();		// Clear home field for all other items		$query = 'UPDATE #__menu' .				' SET home = 0' .				' WHERE 1';		$db->setQuery( $query );		if ( !$db->query() ) {			$this->setError($db->getErrorMsg());			return false;		}		// Set the given item to home		$query = 'UPDATE #__menu' .				' SET home = 1' .				' WHERE id = '.(int) $item;		$db->setQuery( $query );		if ( !$db->query() ) {			$this->setError($db->getErrorMsg());			return false;		}				// clean cache		MenusHelper::cleanCache();				return true;	}	/**	* Set the state of selected menu items	*/	function setItemState( $items, $state )	{		if(is_array($items))		{			$row =& $this->getTable();			foreach ($items as $id)			{				$row->load( $id );				if ($row->home != 1) {					$row->published = $state;					if ($state != 1) {						// Set any alias menu types to not point to unpublished menu items						$db = &$this->getDBO();						$query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND link = '.(int)$id;						$db->setQuery( $query );						if (!$db->query()) {							$this->setError( $db->getErrorMsg() );							return false;						}					}					if (!$row->check()) {						$this->setError($row->getError());						return false;					}					if (!$row->store()) {						$this->setError($row->getError());						return false;					}				} else {					JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot unpublish the default menu item'));					return false;				}			}		}		// clean cache		MenusHelper::cleanCache();		return true;	}	/**	* Set the access of selected menu items	*/	function setAccess( $items, $access )	{		$row =& $this->getTable();		foreach ($items as $id)		{			$row->load( $id );			$row->access = $access;			// Set any alias menu types to not point to unpublished menu items			$db = &$this->getDBO();			$query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND access < '.(int)$access.' AND link = '.(int)$id;			$db->setQuery( $query );			if (!$db->query()) {				$this->setError( $db->getErrorMsg() );				return false;			}			if (!$row->check()) {				$this->setError($row->getError());				return false;			}			if (!$row->store()) {				$this->setError($row->getError());				return false;			}		}		// clean cache		MenusHelper::cleanCache();				return true;	}	function orderItem($item, $movement)	{		$row =& $this->getTable();		$row->load( $item );		if (!$row->move( $movement, 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent )) {			$this->setError($row->getError());			return false;		}				// clean cache		MenusHelper::cleanCache();				return true;	}	function setOrder($items, $menutype)	{		$total		= count( $items );		$row		=& $this->getTable();		$groupings	= array();		$order		= JRequest::getVar( 'order', array(), 'post', 'array' );		JArrayHelper::toInteger($order);		// update ordering values		for( $i=0; $i < $total; $i++ ) {			$row->load( $items[$i] );			// track parents			$groupings[] = $row->parent;			if ($row->ordering != $order[$i]) {				$row->ordering = $order[$i];				if (!$row->store()) {					$this->setError($row->getError());					return false;				}			} // if		} // for		// execute updateOrder for each parent group		$groupings = array_unique( $groupings );		foreach ($groupings as $group){			$row->reorder('menutype = '.$this->_db->Quote($menutype).' AND parent = '.(int) $group.' AND published >=0');		}		// clean cache		MenusHelper::cleanCache();				return true;	}	/**	 * Delete one or more menu items	 * @param mixed int or array of id values	 */	function delete( $ids )	{		JArrayHelper::toInteger($ids);		if (!empty( $ids )) {			// Add all children to the list			foreach ($ids as $id)			{				$this->_addChildren($id, $ids);			}			$db = &$this->getDBO();			// Delete associated module and template mappings			$where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids );			$query = 'DELETE FROM #__modules_menu '				. $where;			$db->setQuery( $query );			if (!$db->query()) {				$this->setError( $menuTable->getErrorMsg() );				return false;			}			$query = 'DELETE FROM #__templates_menu '				. $where;			$db->setQuery( $query );			if (!$db->query()) {				$this->setError( $menuTable->getErrorMsg() );				return false;			}			// Set any alias menu types to not point to missing menu items			$query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')';			$db->setQuery( $query );			if (!$db->query()) {				$this->setError( $db->getErrorMsg() );				return false;			}			// Delete the menu items			$where = 'WHERE id = ' . implode( ' OR id = ', $ids );			$query = 'DELETE FROM #__menu ' . $where;			$db->setQuery( $query );			if (!$db->query()) {				$this->setError( $db->getErrorMsg() );				return false;			}		}		// clean cache		MenusHelper::cleanCache();				return true;	}	/**	 * Delete menu items by type	 */	function deleteByType( $type = '' )	{		$db = &$this->getDBO();		$query = 'SELECT id' .				' FROM #__menu' .				' WHERE menutype = ' . $db->Quote( $type );		$db->setQuery( $query );		$ids = $db->loadResultArray();		if ($db->getErrorNum()) {			$this->setError( $db->getErrorMsg() );			return false;		}		return $this->delete( $ids );	}	function _addChildren($id, &$list)	{		// Initialize variables		$return = true;		// Get all rows with parent of $id		$db =& $this->getDBO();		$query = 'SELECT id' .				' FROM #__menu' .				' WHERE parent = '.(int) $id;		$db->setQuery( $query );		$rows = $db->loadObjectList();		// Make sure there aren't any errors		if ($db->getErrorNum()) {			$this->setError($db->getErrorMsg());			return false;		}		// Recursively iterate through all children... kinda messy		// TODO: Cleanup this method		foreach ($rows as $row)		{			$found = false;			foreach ($list as $idx)			{				if ($idx == $row->id) {					$found = true;					break;				}			}			if (!$found) {				$list[] = $row->id;			}			$return = $this->_addChildren($row->id, $list);		}		return $return;	}	/*	 * Rebuild the sublevel field for items in the menu (if called with 2nd param = 0 or no params, it will rebuild entire menu tree's sublevel	 * @param array of menu item ids to change level to	 * @param int level to set the menu items to (based on parent	 */	function _rebuildSubLevel($cid = array(0), $level = 0)	{		JArrayHelper::toInteger($cid, array(0));		$db =& $this->getDBO();		$ids = implode( ',', $cid );		$cids = array();		if($level == 0) {			$query 	= 'UPDATE #__menu SET sublevel = 0 WHERE parent = 0';			$db->setQuery($query);			$db->query();			$query 	= 'SELECT id FROM #__menu WHERE parent = 0';			$db->setQuery($query);			$cids 	= $db->loadResultArray(0);		} else {			$query	= 'UPDATE #__menu SET sublevel = '.(int) $level					.' WHERE parent IN ('.$ids.')';			$db->setQuery( $query );			$db->query();			$query	= 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')';			$db->setQuery( $query );			$cids 	= $db->loadResultArray( 0 );		}		if (!empty( $cids )) {			$this->_rebuildSubLevel( $cids, $level + 1 );		}	}}

⌨️ 快捷键说明

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