Source for file site.php
Documentation is available at site.php
* @package Joomla.Libraries
* @subpackage Application
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Joomla! Site Application class
* @package Joomla.Libraries
* @subpackage Application
* Option to filter by language
* @deprecated 4.0 Will be renamed $language_filter
* Option to detect language by the browser
* @deprecated 4.0 Will be renamed $detect_browser
* @param mixed $input An optional argument to provide dependency injection for the application's
* input object. If the argument is a JInput object that object will become
* the application's input object, otherwise a default input object is created.
* @param mixed $config An optional argument to provide dependency injection for the application's
* config object. If the argument is a JRegistry object that object will become
* the application's config object, otherwise a default config object is created.
* @param mixed $client An optional argument to provide dependency injection for the application's
* client object. If the argument is a JApplicationWebClient object that object will become
* the application's client object, otherwise a default client object is created.
public function __construct(JInput $input =
null, JRegistry $config =
null, JApplicationWebClient $client =
null)
// Register the application name
// Register the client ID
// Execute the parent constructor
* Check if the user can access the application
* @param integer $itemid The item ID to check authorisation for
if (!$menus->authorise($itemid))
if ($user->get('id') ==
0)
$url =
JRoute::_('index.php?option=com_users&view=login', false);
* Dispatch the application
* @param string $component The component which is being rendered.
public function dispatch($component =
null)
// Get the component if not set.
$component =
$this->input->getCmd('option', null);
// Load the document to the API
$router =
static::getRouter();
// Register the document object with JFactory
switch ($document->getType())
$languages =
JLanguageHelper::getLanguages('lang_code');
if (isset
($languages[$lang_code]) &&
$languages[$lang_code]->metakey)
$document->setMetaData('keywords', $languages[$lang_code]->metakey);
$document->setMetaData('keywords', $this->get('MetaKeys'));
$document->setMetaData('rights', $this->get('MetaRights'));
if ($router->getMode() ==
JROUTER_MODE_SEF)
// Store the template and its params to the config
$this->set('theme', $template->template);
$this->set('themeParams', $template->params);
$document->setTitle($params->get('page_title'));
$document->setDescription($params->get('page_description'));
// Add version number or not based on global configuration
if ($this->get('MetaVersion', 0))
$document->setGenerator('Joomla! - Open Source Content Management - Version ' .
JVERSION);
$document->setGenerator('Joomla! - Open Source Content Management');
$document->setBuffer($contents, 'component');
// Trigger the onAfterDispatch event.
* Method to run the Web application routines.
// Initialise the application
// Mark afterInitialise in the profiler.
// Mark afterRoute in the profiler.
// Dispatch the application
// Mark afterDispatch in the profiler.
* Return the current state of the detect browser option.
* Return the current state of the language filter.
* Return a reference to the JMenu object.
* @param string $name The name of the application/client.
* @param array $options An optional associative array of configuration settings.
* @return JMenu JMenu object.
public function getMenu($name =
'site', $options =
array())
$menu =
parent::getMenu($name, $options);
* Get the application parameters
* @param string $option The component option
* @return object The parameters object
* @deprecated 4.0 Use getParams() instead
* Get the application parameters
* @param string $option The component option
* @return object The parameters object
static $params =
array();
if (!isset
($params[$hash]))
// Get component parameters
$option =
$this->input->getCmd('option', null);
// Get new instance of component global parameters
$menu =
$menus->getActive();
$title =
$this->get('sitename');
if (isset
($languages[$lang_code]) &&
$languages[$lang_code]->metadesc)
$description =
$languages[$lang_code]->metadesc;
$description =
$this->get('MetaDesc');
$rights =
$this->get('MetaRights');
$robots =
$this->get('robots');
// Lets cascade the parameters if we have menu item parameters
$temp->loadString($menu->params);
$params[$hash]->merge($temp);
// Get com_menu global settings
$params[$hash]->merge($temp);
// If supplied, use page title
$title =
$temp->get('page_title', $title);
$params[$hash]->def('page_title', $title);
$params[$hash]->def('page_description', $description);
$params[$hash]->def('page_rights', $rights);
$params[$hash]->def('robots', $robots);
* Return a reference to the JPathway object.
* @param string $name The name of the application.
* @param array $options An optional associative array of configuration settings.
* @return JPathway A JPathway object
public function getPathway($name =
'site', $options =
array())
return parent::getPathway($name, $options);
* Return a reference to the JRouter object.
* @param string $name The name of the application.
* @param array $options An optional associative array of configuration settings.
public static function getRouter($name =
'site', array $options =
array())
$options['mode'] =
$config->get('sef');
return parent::getRouter($name, $options);
* Gets the name of the current template.
* @param boolean $params True to return the template parameters
* @return string The name of the template.
* @throws InvalidArgumentException
// Get the id of the active menu item
$item =
$menu->getActive();
$item =
$menu->getItem($this->input->getInt('Itemid', null));
$id =
$item->template_style_id;
$tid =
$this->input->getUint('templateStyle', 0);
if (!$templates =
$cache->get('templates0' .
$tag))
$query =
$db->getQuery(true)
->select('id, home, template, s.params')
->from('#__template_styles as s')
->where('s.client_id = 0')
->join('LEFT', '#__extensions as e ON e.element=s.template AND e.type=' .
$db->quote('template') .
' AND e.client_id=s.client_id');
$templates =
$db->loadObjectList('id');
foreach ($templates as &$template)
$registry->loadString($template->params);
$template->params =
$registry;
if ($template->home ==
1 &&
!isset
($templates[0]) ||
$this->_language_filter &&
$template->home ==
$tag)
$templates[0] =
clone $template;
$cache->store($templates, 'templates0' .
$tag);
if (isset
($templates[$id]))
$template =
$templates[$id];
$template =
$templates[0];
// Allows for overriding the active template from the request
// Need to filter the default value as well
// Try to find data for 'beez3' template
foreach ($templates as $tmpl)
// Check, the data were found and if template really exists
throw
new InvalidArgumentException(JText::sprintf('JERROR_COULD_NOT_FIND_TEMPLATE', $original_tmpl));
* Initialise the application.
* @param array $options An optional associative array of configuration settings.
// If the user is a guest we populate it with the guest user group.
$user->groups =
array($guestUsergroup);
// If a language was specified it has priority, otherwise use user or default language settings
if (empty($options['language']))
// Detect the specified language
$lang =
$this->input->getString('language', null);
// Make sure that the user's language exists
$options['language'] =
$lang;
// Detect cookie language
$lang =
$this->input->cookie->get(md5($this->get('secret') .
'language'), null, 'string');
// Make sure that the user's language exists
$options['language'] =
$lang;
if (empty($options['language']))
$lang =
$user->getParam('language');
// Make sure that the user's language exists
$options['language'] =
$lang;
// Detect browser language
// Make sure that the user's language exists
$options['language'] =
$lang;
if (empty($options['language']))
// Detect default language
$options['language'] =
$params->get('site', $this->get('language', 'en-GB'));
// One last check to make sure we have something
$lang =
$this->config->get('language', 'en-GB');
$options['language'] =
$lang;
// As a last ditch fail to english
$options['language'] =
'en-GB';
// Execute the parent initialiseApp method.
parent::initialiseApp($options);
// Load the language to the API
// Register the language object with JFactory
* Try the lib_joomla file in the current language (without allowing the loading of the file in the default language)
* Fallback to the default language if necessary
$lang->load('lib_joomla', JPATH_SITE, null, false, true)
* Login authentication function
* @param array $credentials Array('username' => string, 'password' => string)
* @param array $options Array('remember' => boolean)
* @return boolean True on success.
public function login($credentials, $options =
array())
// Set the application login entry point
$options['entry_url'] =
JUri::base() .
'index.php?option=com_users&task=user.login';
// Set the access control action to check.
$options['action'] =
'core.login.site';
return parent::login($credentials, $options);
* Rendering is the process of pushing the document buffers into the template
* placeholders, retrieving data from the document and pushing it into
* the application response buffer.
// No special processing for feeds
$file =
$this->input->get('tmpl', 'index');
if (!$this->get('offline') &&
($file ==
'offline'))
$this->set('themeFile', 'index.php');
$this->set('themeFile', 'offline.php');
$this->setHeader('Status', '503 Service Temporarily Unavailable', 'true');
$this->set('themeFile', 'component.php');
// Ensure themeFile is set by now
if ($this->get('themeFile') ==
'')
$this->set('themeFile', $file .
'.php');
* Routing is the process of examining the request environment to determine which
* component should receive the request. The component optional parameters
* are then set in the request object to be processed when the application is being
protected function route()
// Execute the parent method
$Itemid =
$this->input->getInt('Itemid', null);
* Set the current state of the detect browser option.
* @param boolean $state The new state of the detect browser option
* @return boolean The previous state
* Set the current state of the language filter.
* @param boolean $state The new state of the language filter
* @return boolean The previous state
* Overrides the default template that would be used
* @param string $template The template name
* @param mixed $styleParams The template style parameters
public function setTemplate($template, $styleParams =
null)
Documentation generated on Tue, 19 Nov 2013 15:13:55 +0100 by phpDocumentor 1.4.3