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

📄 controller.php

📁 没什么功能
💻 PHP
📖 第 1 页 / 共 2 页
字号:
			echo $db->stderr();			return false;		}		$orders2 	= array();		$l = 0;		$r = 0;		for ($i=0, $n=count( $orders ); $i < $n; $i++) {			$ord = 0;			if (array_key_exists( $orders[$i]->position, $orders2 )) {				$ord =count( array_keys( $orders2[$orders[$i]->position] ) ) + 1;			}			$orders2[$orders[$i]->position][] = JHTML::_('select.option',  $ord, $ord.'::'.addslashes( $orders[$i]->title ) );		}		// get selected pages for $lists['selections']		if ( $cid[0] ) {			$query = 'SELECT menuid AS value'			. ' FROM #__modules_menu'			. ' WHERE moduleid = '.(int) $row->id			;			$db->setQuery( $query );			$lookup = $db->loadObjectList();			if (empty( $lookup )) {				$lookup = array( JHTML::_('select.option',  '-1' ) );				$row->pages = 'none';			} elseif (count($lookup) == 1 && $lookup[0]->value == 0) {				$row->pages = 'all';			} else {				$row->pages = null;			}		} else {			$lookup = array( JHTML::_('select.option',  0, JText::_( 'All' ) ) );			$row->pages = 'all';		}		if ( $row->access == 99 || $row->client_id == 1 || $lists['client_id'] ) {			$lists['access'] 			= 'Administrator';			$lists['showtitle'] 		= 'N/A <input type="hidden" name="showtitle" value="1" />';			$lists['selections'] 		= 'N/A';		} else {			if ( $client->id == '1' ) {				$lists['access'] 		= 'N/A';				$lists['selections'] 	= 'N/A';			} else {				$lists['access'] 		= JHTML::_('list.accesslevel',  $row );				$selections				= JHTML::_('menu.linkoptions');				$lists['selections']	= JHTML::_('select.genericlist',   $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' );			}			$lists['showtitle'] = JHTML::_('select.booleanlist',  'showtitle', 'class="inputbox"', $row->showtitle );		}		// build the html select list for published		$lists['published'] = JHTML::_('select.booleanlist',  'published', 'class="inputbox"', $row->published );		$row->description = '';		$lang =& JFactory::getLanguage();		if ( $client->id != '1' ) {			$lang->load( trim($row->module), JPATH_SITE );		} else {			$lang->load( trim($row->module) );		}		// xml file for module		if ($row->module == 'custom') {			$xmlfile = JApplicationHelper::getPath( $path, 'mod_custom' );		} else {			$xmlfile = JApplicationHelper::getPath( $path, $row->module );		}		$data = JApplicationHelper::parseXMLInstallFile($xmlfile);		if ($data)		{			foreach($data as $key => $value) {				$row->$key = $value;			}		}		// get params definitions		$params = new JParameter( $row->params, $xmlfile, 'module' );		require_once( JApplicationHelper::getPath( 'admin_html' ) );		HTML_modules::edit( $model, $row, $orders2, $lists, $params, $client );	}	/**	* Displays a list to select the creation of a new module	*/	function add()	{		global $mainframe;		// Initialize some variables		$modules	= array();		$client		=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		// path to search for modules		if ($client->id == '1') {			$path		= JPATH_ADMINISTRATOR.DS.'modules';			$langbase	= JPATH_ADMINISTRATOR;		} else {			$path		= JPATH_ROOT.DS.'modules';			$langbase	= JPATH_ROOT;		}		jimport('joomla.filesystem.folder');		$dirs = JFolder::folders( $path );		$lang =& JFactory::getLanguage();		foreach ($dirs as $dir)		{			if (substr( $dir, 0, 4 ) == 'mod_')			{				$files 				= JFolder::files( $path.DS.$dir, '^([_A-Za-z0-9]*)\.xml$' );				$module				= new stdClass;				$module->file 		= $files[0];				$module->module 	= str_replace( '.xml', '', $files[0] );				$module->path 		= $path.DS.$dir;				$modules[]			= $module;				$lang->load( $module->module, $langbase );			}		}		require_once( JPATH_COMPONENT.DS.'helpers'.DS.'xml.php' );		ModulesHelperXML::parseXMLModuleFile( $modules, $client );		$n = count($modules);		for ($i = 0; $i < $n; $i++) {			$modules[$i]->name = JText::_(stripslashes($modules[$i]->name));		}		// sort array of objects alphabetically by name		JArrayHelper::sortObjects( $modules, 'name' );		require_once( JApplicationHelper::getPath( 'admin_html' ) );		HTML_modules::add( $modules, $client );	}	/**	* Deletes one or more modules	*	* Also deletes associated entries in the #__module_menu table.	* @param array An array of unique category id numbers	*/	function remove()	{		global $mainframe;		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$db		=& JFactory::getDBO();		$client	=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$this->setRedirect( 'index.php?option=com_modules&client='.$client->id );		$cid	= JRequest::getVar( 'cid', array(), 'post', 'array' );		JArrayHelper::toInteger( $cid );		if (empty( $cid )) {			return JError::raiseWarning( 500, 'No items selected' );		}		$cids = implode( ',', $cid );		// pasamio: Disabled this as it breaks the uninstall ability!		/*$query = 'SELECT id, module, title, iscore, params'		. ' FROM #__modules WHERE id IN ('.$cids.')'		;		$db->setQuery( $query );		if (!($rows = $db->loadObjectList())) {			return JError::raiseError( 500, $db->getErrorMsg() );		}*/		// remove mappings first (lest we leave orphans)		$query = 'DELETE FROM #__modules_menu'			. ' WHERE moduleid IN ( '.$cids.' )'			;		$db->setQuery( $query );		if (!$db->query()) {			return JError::raiseError( 500, $db->getErrorMsg() );		}		// remove module		$query = 'DELETE FROM #__modules'			. ' WHERE id IN ('.$cids.')'			;		$db->setQuery( $query );		if (!$db->query()) {			return JError::raiseError( 500, $db->getErrorMsg() );		}		$this->setMessage( JText::sprintf( 'Items removed', count( $cid ) ) );	}	/**	* Publishes or Unpublishes one or more modules	*/	function publish()	{		global $mainframe;		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$db 	=& JFactory::getDBO();		$user 	=& JFactory::getUser();		$client	=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$this->setRedirect( 'index.php?option=com_modules&client='.$client->id );		$cache = & JFactory::getCache();		$cache->clean( 'com_content' );		$cid 	= JRequest::getVar( 'cid', array(), 'post', 'array' );		JArrayHelper::toInteger($cid);		$task	= $this->getTask();		$publish	= ($task == 'publish');		if (empty( $cid )) {			return JError::raiseWarning( 500, 'No items selected' );		}		$cids = implode( ',', $cid );		$query = 'UPDATE #__modules'		. ' SET published = ' . intval( $publish )		. ' WHERE id IN ( '.$cids.' )'		. ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )'		;		$db->setQuery( $query );		if (!$db->query()) {			return JError::raiseWarning( 500, $db->getErrorMsg() );		}		if (count( $cid ) == 1) {			$row =& JTable::getInstance('module');			$row->checkin( $cid[0] );		}	}	/**	 * Cancels an edit operation	 */	function cancel()	{		global $mainframe;		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$db		=& JFactory::getDBO();		$client	=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$this->setRedirect( 'index.php?option=com_modules&client='.$client->id );		$row =& JTable::getInstance('module');		// ignore array elements		$row->bind(JRequest::get('post'), 'selections params' );		$row->checkin();	}	/**	 * Moves the order of a record	 */	function reorder()	{		global $mainframe;		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$db		=& JFactory::getDBO();		$client	=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$this->setRedirect( 'index.php?option=com_modules&client='.$client->id );		$cid 	= JRequest::getVar( 'cid', array(), 'post', 'array' );		JArrayHelper::toInteger($cid);		$task	= $this->getTask();		$inc	= ($task == 'orderup' ? -1 : 1);		if (empty( $cid )) {			return JError::raiseWarning( 500, 'No items selected' );		}		$row =& JTable::getInstance('module');		$row->load( (int) $cid[0] );		$row->move( $inc, 'position = '.$db->Quote( $row->position ).' AND client_id='.(int) $client->id  );	}	/**	 * Changes the access level of a record	 */	function access()	{		global $mainframe;		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$db		=& JFactory::getDBO();		$client	=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$this->setRedirect( 'index.php?option=com_modules&client='.$client->id );		$cid 	= JRequest::getVar( 'cid', array(), 'post', 'array' );		JArrayHelper::toInteger($cid);		$task	= JRequest::getCmd( 'task' );		if (empty( $cid )) {			return JError::raiseWarning( 500, 'No items selected' );		}		switch ( $task )		{			case 'accesspublic':				$access = 0;				break;			case 'accessregistered':				$access = 1;				break;			case 'accessspecial':				$access = 2;				break;		}		$row =& JTable::getInstance('module');		$row->load( (int) $cid[0] );		$row->access = $access;		if ( !$row->check() ) {			JError::raiseWarning( 500, $row->getError() );		}		if ( !$row->store() ) {			JError::raiseWarning( 500, $row->getError() );		}	}	/**	 * Saves the orders of the supplied list	 */	function saveOrder()	{		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$db		=& JFactory::getDBO();		$client	=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$this->setRedirect( 'index.php?option=com_modules&client='.$client->id );		$cid 	= JRequest::getVar( 'cid', array(), 'post', 'array' );		JArrayHelper::toInteger($cid);		if (empty( $cid )) {			return JError::raiseWarning( 500, 'No items selected' );		}		$total		= count( $cid );		$row 		=& JTable::getInstance('module');		$groupings = array();		$order 		= JRequest::getVar( 'order', array(0), 'post', 'array' );		JArrayHelper::toInteger($order);		// update ordering values		for ($i = 0; $i < $total; $i++)		{			$row->load( (int) $cid[$i] );			// track postions			$groupings[] = $row->position;			if ($row->ordering != $order[$i])			{				$row->ordering = $order[$i];				if (!$row->store()) {					return JError::raiseWarning( 500, $db->getErrorMsg() );				}			}		}		// execute updateOrder for each parent group		$groupings = array_unique( $groupings );		foreach ($groupings as $group){			$row->reorder('position = '.$db->Quote($group).' AND client_id = '.(int) $client->id);		}		$this->setMessage (JText::_( 'New ordering saved' ));	}	function preview()	{		$document =& JFactory::getDocument();		$document->setTitle(JText::_('Module Preview'));		require_once( JApplicationHelper::getPath( 'admin_html' ) );		HTML_modules::preview( );	}}

⌨️ 快捷键说明

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