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

📄 controller.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** * @version		$Id: controller.php 10836 2008-08-28 10:56:44Z eddieajau $ * @package		Joomla * @subpackage	Templates * @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. *//** * @package		Joomla * @subpackage	Templates */class TemplatesController{	/**	* Compiles a list of installed, version 4.5+ templates	*	* Based on xml files found.  If no xml file found the template	* is ignored	*/	function viewTemplates()	{		global $mainframe, $option;		// Initialize some variables		$db		=& JFactory::getDBO();		$client	=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		// Initialize the pagination variables		$limit		= $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');		$limitstart = $mainframe->getUserStateFromRequest($option.'.'.$client->id.'.limitstart', 'limitstart', 0, 'int');		$select[] 			= JHTML::_('select.option', '0', JText::_('Site'));		$select[] 			= JHTML::_('select.option', '1', JText::_('Administrator'));		$lists['client'] 	= JHTML::_('select.genericlist',  $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $client->id);		$tBaseDir = $client->path.DS.'templates';		//get template xml file info		$rows = array();		$rows = TemplatesHelper::parseXMLTemplateFiles($tBaseDir);		// set dynamic template information		for($i = 0; $i < count($rows); $i++)  {			$rows[$i]->assigned		= TemplatesHelper::isTemplateAssigned($rows[$i]->directory);			$rows[$i]->published	= TemplatesHelper::isTemplateDefault($rows[$i]->directory, $client->id);		}		jimport('joomla.html.pagination');		$page = new JPagination(count($rows), $limitstart, $limit);		$rows = array_slice($rows, $page->limitstart, $page->limit);		require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');		TemplatesView::showTemplates($rows, $lists, $page, $option, $client);	}	/**	* Show the template with module position in an iframe	*/	function previewTemplate()	{		$template	= JRequest::getVar('id', '', 'method', 'cmd');		$option 	= JRequest::getCmd('option');		$client		=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		if (!$template)		{			return JError::raiseWarning( 500, JText::_('Template not specified') );		}		// Set FTP credentials, if given		jimport('joomla.client.helper');		JClientHelper::setCredentialsFromRequest('ftp');		require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');		TemplatesView::previewTemplate($template, true, $client, $option);	}	/**	* Publish, or make current, the selected template	*/	function publishTemplate()	{		global $mainframe;		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$db		= & JFactory::getDBO();		$cid	= JRequest::getVar('cid', array(), 'method', 'array');		$cid	= array(JFilterInput::clean(@$cid[0], 'cmd'));		$option	= JRequest::getCmd('option');		$client	=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		if ($cid[0])		{			$query = 'DELETE FROM #__templates_menu' .					' WHERE client_id = '.(int) $client->id .					' AND (menuid = 0 OR template = '.$db->Quote($cid[0]).')';			$db->setQuery($query);			$db->query();			$query = 'INSERT INTO #__templates_menu' .					' SET client_id = '.(int) $client->id .', template = '.$db->Quote($cid[0]).', menuid = 0';			$db->setQuery($query);			$db->query();		}		$mainframe->redirect('index.php?option='.$option.'&client='.$client->id);	}	function editTemplate()	{		jimport('joomla.filesystem.path');		// Initialize some variables		$db			= & JFactory::getDBO();		$cid		= JRequest::getVar('cid', array(), 'method', 'array');		$cid		= array(JFilterInput::clean(@$cid[0], 'cmd'));		$template	= $cid[0];		$option		= JRequest::getCmd('option');		$client		=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		if (!$cid[0]) {			return JError::raiseWarning( 500, JText::_('Template not specified') );		}		$tBaseDir	= JPath::clean($client->path.DS.'templates');		if (!is_dir( $tBaseDir . DS . $template )) {			return JError::raiseWarning( 500, JText::_('Template not found') );		}		$lang =& JFactory::getLanguage();		$lang->load( 'tpl_'.$template, JPATH_ADMINISTRATOR );		$ini	= $client->path.DS.'templates'.DS.$template.DS.'params.ini';		$xml	= $client->path.DS.'templates'.DS.$template.DS.'templateDetails.xml';		$row	= TemplatesHelper::parseXMLTemplateFile($tBaseDir, $template);		jimport('joomla.filesystem.file');		// Read the ini file		if (JFile::exists($ini)) {			$content = JFile::read($ini);		} else {			$content = null;		}		$params = new JParameter($content, $xml, 'template');		$assigned = TemplatesHelper::isTemplateAssigned($row->directory);		$default = TemplatesHelper::isTemplateDefault($row->directory, $client->id);		if($client->id == '1')  {			$lists['selections'] =  JText::_('Cannot assign an administrator template');		} else {			$lists['selections'] = TemplatesHelper::createMenuList($template);		}		if ($default) {			$row->pages = 'all';		} elseif (!$assigned) {			$row->pages = 'none';		} else {			$row->pages = null;		}		// Set FTP credentials, if given		jimport('joomla.client.helper');		$ftp =& JClientHelper::setCredentialsFromRequest('ftp');		require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');		TemplatesView::editTemplate($row, $lists, $params, $option, $client, $ftp, $template);	}	function saveTemplate()	{		global $mainframe;		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$db			 = & JFactory::getDBO();		$template	= JRequest::getVar('id', '', 'method', 'cmd');		$option		= JRequest::getVar('option', '', '', 'cmd');		$client		=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$menus		= JRequest::getVar('selections', array(), 'post', 'array');		$params		= JRequest::getVar('params', array(), 'post', 'array');		$default	= JRequest::getBool('default');		JArrayHelper::toInteger($menus);		if (!$template) {			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));		}		// Set FTP credentials, if given		jimport('joomla.client.helper');		JClientHelper::setCredentialsFromRequest('ftp');		$ftp = JClientHelper::getCredentials('ftp');		$file = $client->path.DS.'templates'.DS.$template.DS.'params.ini';		jimport('joomla.filesystem.file');		if (JFile::exists($file) && count($params))		{			$registry = new JRegistry();			$registry->loadArray($params);			$txt = $registry->toString();			// Try to make the params file writeable			if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {				JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file writable'));			}			$return = JFile::write($file, $txt);			// Try to make the params file unwriteable			if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {				JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file unwritable'));			}			if (!$return) {				$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));			}		}		// Reset all existing assignments		$query = 'DELETE FROM #__templates_menu' .				' WHERE client_id = 0' .				' AND template = '.$db->Quote( $template );		$db->setQuery($query);		$db->query();		if ($default) {			$menus = array( 0 );		}		foreach ($menus as $menuid)		{			// If 'None' is not in array			if ((int) $menuid >= 0)			{

⌨️ 快捷键说明

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