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

📄 factory.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 2 页
字号:
					jimport('domit.xml_domit_include');					$doc = new DOMIT_Document();				}			}		}		return $doc;	}	/**	* Get an editor object	*	* @access public	* @param string $editor The editor to load, depends on the editor plugins that are installed	* @return object JEditor	*/	function &getEditor($editor = null)	{		jimport( 'joomla.html.editor' );		//get the editor configuration setting		if(is_null($editor))		{			$conf =& JFactory::getConfig();			$editor = $conf->getValue('config.editor');		}		$instance =& JEditor::getInstance($editor);		return $instance;	}	/**	 * Return a reference to the {@link JURI} object	 *	 * @access public	 * @return object JURI	 * @since 1.5	 */	function &getURI($uri = 'SERVER')	{		jimport('joomla.environment.uri');		$instance =& JURI::getInstance($uri);		return $instance;	}	/**	 * Return a reference to the {@link JDate} object	 *	 * @access public	 * @param mixed $time The initial time for the JDate object	 * @param int $tzOffset The timezone offset.	 * @return object JDate	 * @since 1.5	 */	function &getDate($time = 'now', $tzOffset = 0)	{		jimport('joomla.utilities.date');		static $instances;		static $classname;		static $mainLocale;		if(!isset($instances)) {			$instances = array();		}		$language =& JFactory::getLanguage();		$locale = $language->getTag();		if(!isset($classname) || $locale != $mainLocale) {			//Store the locale for future reference			$mainLocale = $locale;			$localePath = JPATH_ROOT . DS . 'language' . DS . $mainLocale . DS . $mainLocale . '.date.php';			if($mainLocale !== false && file_exists($localePath)) {				$classname = 'JDate'.str_replace('-', '_', $mainLocale);				JLoader::register( $classname,  $localePath);				if(!class_exists($classname)) {					//Something went wrong.  The file exists, but the class does not, default to JDate					$classname = 'JDate';				}			} else {				//No file, so default to JDate				$classname = 'JDate';			}		}		$key = $time . '-' . $tzOffset;		if(!isset($instances[$classname][$key])) {			$tmp = new $classname($time, $tzOffset);			//We need to serialize to break the reference			$instances[$classname][$key] = serialize($tmp);			unset($tmp);		}		$date = unserialize($instances[$classname][$key]);		return $date;	}	/**	 * Create a configuration object	 *	 * @access private	 * @param string	The path to the configuration file	 * @param string	The type of the configuration file	 * @return object JRegistry	 * @since 1.5	 */	function &_createConfig($file, $type = 'PHP')	{		jimport('joomla.registry.registry');		require_once $file;		// Create the registry with a default namespace of config		$registry = new JRegistry('config');		// Create the JConfig object		$config = new JFrameworkConfig();		// Load the configuration values into the registry		$registry->loadObject($config);		return $registry;	}	/**	 * Create a session object	 *	 * @access private	 * @param array $options An array containing session options	 * @return object JSession	 * @since 1.5	 */	function &_createSession( $options = array())	{		jimport('joomla.session.session');		//get the editor configuration setting		$conf =& JFactory::getConfig();		$handler =  $conf->getValue('config.session_handler', 'none');		// config time is in minutes		$options['expire'] = ($conf->getValue('config.lifetime')) ? $conf->getValue('config.lifetime') * 60 : 900;		$session = JSession::getInstance($handler, $options);		if ($session->getState() == 'expired') {			$session->restart();		}		return $session;	}	/**	 * Create an ACL object	 *	 * @access private	 * @return object JAuthorization	 * @since 1.5	 */	function &_createACL()	{		//TODO :: take the authorization class out of the application package		jimport( 'joomla.user.authorization' );		$db =&  JFactory::getDBO();		$options = array(			'db'				=> &$db,			'db_table_prefix'	=> $db->getPrefix() . 'core_acl_',			'debug'				=> 0		);		$acl = new JAuthorization( $options );		return $acl;	}	/**	 * Create an database object	 *	 * @access private	 * @return object JDatabase	 * @since 1.5	 */	function &_createDBO()	{		jimport('joomla.database.database');		jimport( 'joomla.database.table' );		$conf =& JFactory::getConfig();		$host 		= $conf->getValue('config.host');		$user 		= $conf->getValue('config.user');		$password 	= $conf->getValue('config.password');		$database	= $conf->getValue('config.db');		$prefix 	= $conf->getValue('config.dbprefix');		$driver 	= $conf->getValue('config.dbtype');		$debug 		= $conf->getValue('config.debug');		$options	= array ( 'driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix );		$db =& JDatabase::getInstance( $options );		if ( JError::isError($db) ) {			jexit('Database Error: ' . $db->toString() );		}		if ($db->getErrorNum() > 0) {			JError::raiseError(500 , 'JDatabase::getInstance: Could not connect to database <br />' . 'joomla.library:'.$db->getErrorNum().' - '.$db->getErrorMsg() );		}		$db->debug( $debug );		return $db;	}	/**	 * Create a mailer object	 *	 * @access private	 * @return object JMail	 * @since 1.5	 */	function &_createMailer()	{		jimport('joomla.mail.mail');		$conf	=& JFactory::getConfig();		$sendmail 	= $conf->getValue('config.sendmail');		$smtpauth 	= $conf->getValue('config.smtpauth');		$smtpuser 	= $conf->getValue('config.smtpuser');		$smtppass  	= $conf->getValue('config.smtppass');		$smtphost 	= $conf->getValue('config.smtphost');		$mailfrom 	= $conf->getValue('config.mailfrom');		$fromname 	= $conf->getValue('config.fromname');		$mailer 	= $conf->getValue('config.mailer');		// Create a JMail object		$mail 		=& JMail::getInstance();		// Set default sender		$mail->setSender(array ($mailfrom, $fromname));		// Default mailer is to use PHP's mail function		switch ($mailer)		{			case 'smtp' :				$mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass);				break;			case 'sendmail' :				$mail->useSendmail($sendmail);				break;			default :				$mail->IsMail();				break;		}		return $mail;	}	/**	 * Create a template object	 *	 * @access private	 * @param array An array of support template files to load	 * @return object JTemplate	 * @since 1.5	 */	function &_createTemplate($files = array())	{		jimport('joomla.template.template');		$conf =& JFactory::getConfig();		$tmpl = new JTemplate;		// patTemplate		if ($conf->getValue('config.caching')) {			 $tmpl->enableTemplateCache( 'File', JPATH_BASE.DS.'cache'.DS);		}		$tmpl->setNamespace( 'jtmpl' );		// load the wrapper and common templates		$tmpl->readTemplatesFromFile( 'page.html' );		$tmpl->applyInputFilter('ShortModifiers');		// load the stock templates		if (is_array( $files ))		{			foreach ($files as $file) {				$tmpl->readTemplatesFromInput( $file );			}		}		$tmpl->addGlobalVar( 'option', 				$GLOBALS['option'] );		$tmpl->addGlobalVar( 'self', 				$_SERVER['PHP_SELF'] );		$tmpl->addGlobalVar( 'uri_query', 			$_SERVER['QUERY_STRING'] );		$tmpl->addGlobalVar( 'REQUEST_URI',			JRequest::getURI() );		if (isset($GLOBALS['Itemid'])) {			$tmpl->addGlobalVar( 'itemid', $GLOBALS['Itemid'] );		}		return $tmpl;	}	/**	 * Create a language object	 *	 * @access private	 * @return object JLanguage	 * @since 1.5	 */	function &_createLanguage()	{		jimport('joomla.language.language');		$conf	=& JFactory::getConfig();		$locale	= $conf->getValue('config.language');		$lang	=& JLanguage::getInstance($locale);		$lang->setDebug($conf->getValue('config.debug_lang'));		return $lang;	}	/**	 * Create a document object	 *	 * @access private	 * @return object JDocument	 * @since 1.5	 */	function &_createDocument()	{		jimport('joomla.document.document');		$lang	=& JFactory::getLanguage();		//Keep backwards compatibility with Joomla! 1.0		$raw	= JRequest::getBool('no_html');		$type	= JRequest::getWord('format', $raw ? 'raw' : 'html');		$attributes = array (			'charset'	=> 'utf-8',			'lineend'	=> 'unix',			'tab'		=> '  ',			'language'	=> $lang->getTag(),			'direction'	=> $lang->isRTL() ? 'rtl' : 'ltr'		);		$doc =& JDocument::getInstance($type, $attributes);		return $doc;	}}

⌨️ 快捷键说明

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