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

📄 controller.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 2 页
字号:
				// check if there is already a template assigned to this menu item				$query = 'DELETE FROM #__templates_menu' .						' WHERE client_id = 0' .						' AND menuid = '.(int) $menuid;				$db->setQuery($query);				$db->query();				$query = 'INSERT INTO #__templates_menu' .						' SET client_id = 0, template = '. $db->Quote( $template ) .', menuid = '.(int) $menuid;				$db->setQuery($query);				$db->query();			}		}		$task = JRequest::getCmd('task');		if($task == 'apply') {			$mainframe->redirect('index.php?option='.$option.'&task=edit&cid[]='.$template.'&client='.$client->id);		} else {			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id);		}	}	function cancelTemplate()	{		global $mainframe;		// Initialize some variables		$option	= JRequest::getCmd('option');		$client	=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		// Set FTP credentials, if given		jimport('joomla.client.helper');		JClientHelper::setCredentialsFromRequest('ftp');		$mainframe->redirect('index.php?option='.$option.'&client='.$client->id);	}	function editTemplateSource()	{		global $mainframe;		// Initialize some variables		$option		= JRequest::getCmd('option');		$client		=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$template	= JRequest::getVar('id', '', 'method', 'cmd');		$file		= $client->path.DS.'templates'.DS.$template.DS.'index.php';		// Read the source file		jimport('joomla.filesystem.file');		$content = JFile::read($file);		if ($content !== false)		{			// Set FTP credentials, if given			jimport('joomla.client.helper');			$ftp =& JClientHelper::setCredentialsFromRequest('ftp');			$content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');			require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');			TemplatesView::editTemplateSource($template, $content, $option, $client, $ftp);		} else {			$msg = JText::sprintf('Operation Failed Could not open', $file);			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg);		}	}	function saveTemplateSource()	{		global $mainframe;		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$option			= JRequest::getCmd('option');		$client			=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$template		= JRequest::getVar('id', '', 'method', 'cmd');		$filecontent	= JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW);		if (!$template) {			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));		}		if (!$filecontent) {			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.'));		}		// Set FTP credentials, if given		jimport('joomla.client.helper');		JClientHelper::setCredentialsFromRequest('ftp');		$ftp = JClientHelper::getCredentials('ftp');		$file = $client->path.DS.'templates'.DS.$template.DS.'index.php';		// Try to make the template file writeable		if (!$ftp['enabled'] && !JPath::setPermissions($file, '0755')) {			JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file writable'));		}		jimport('joomla.filesystem.file');		$return = JFile::write($file, $filecontent);		// Try to make the template file unwriteable		if (!$ftp['enabled'] && !JPath::setPermissions($file, '0555')) {			JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file unwritable'));		}		if ($return)		{			$task = JRequest::getCmd('task');			switch($task)			{				case 'apply_source':					$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_source&id='.$template, JText::_('Template source saved'));					break;				case 'save_source':				default:					$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('Template source saved'));					break;			}		}		else {			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));		}	}	function chooseTemplateCSS()	{		global $mainframe;		// Initialize some variables		$option 	= JRequest::getCmd('option');		$template	= JRequest::getVar('id', '', 'method', 'cmd');		$client		=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		// Determine template CSS directory		$dir = $client->path.DS.'templates'.DS.$template.DS.'css';		// List template .css files		jimport('joomla.filesystem.folder');		$files = JFolder::files($dir, '\.css$', false, false);		// Set FTP credentials, if given		jimport('joomla.client.helper');		JClientHelper::setCredentialsFromRequest('ftp');		require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');		TemplatesView::chooseCSSFiles($template, $dir, $files, $option, $client);	}	function editTemplateCSS()	{		global $mainframe;		// Initialize some variables		$option		= JRequest::getCmd('option');		$client		=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$template	= JRequest::getVar('id', '', 'method', 'cmd');		$filename	= JRequest::getVar('filename', '', 'method', 'cmd');		jimport('joomla.filesystem.file');		if (JFile::getExt($filename) !== 'css') {			$msg = JText::_('Wrong file type given, only CSS files can be edited.');			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=choose_css&id='.$template, $msg, 'error');		}		$content = JFile::read($client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename);		if ($content !== false)		{			// Set FTP credentials, if given			jimport('joomla.client.helper');			$ftp =& JClientHelper::setCredentialsFromRequest('ftp');			$content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');			require_once (JPATH_COMPONENT.DS.'admin.templates.html.php');			TemplatesView::editCSSSource($template, $filename, $content, $option, $client, $ftp);		}		else		{			$msg = JText::sprintf('Operation Failed Could not open', $client->path.$filename);			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg);		}	}	function saveTemplateCSS()	{		global $mainframe;		// Check for request forgeries		JRequest::checkToken() or jexit( 'Invalid Token' );		// Initialize some variables		$option			= JRequest::getCmd('option');		$client			=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));		$template		= JRequest::getVar('id', '', 'post', 'cmd');		$filename		= JRequest::getVar('filename', '', 'post', 'cmd');		$filecontent	= JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW);		if (!$template) {			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));		}		if (!$filecontent) {			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.'));		}		// Set FTP credentials, if given		jimport('joomla.client.helper');		JClientHelper::setCredentialsFromRequest('ftp');		$ftp = JClientHelper::getCredentials('ftp');		$file = $client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename;		// Try to make the css file writeable		if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {			JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file writable'));		}		jimport('joomla.filesystem.file');		$return = JFile::write($file, $filecontent);		// Try to make the css file unwriteable		if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {			JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file unwritable'));		}		if ($return)		{			$task = JRequest::getCmd('task');			switch($task)			{				case 'apply_css':					$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_css&id='.$template.'&filename='.$filename,  JText::_('File Saved'));					break;				case 'save_css':				default:					$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('File Saved'));					break;			}		}		else {			$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&id='.$template.'&task=choose_css', JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));		}	}}

⌨️ 快捷键说明

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