Source for file administrator.php
Documentation is available at administrator.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! Administrator Application class
* @package Joomla.Libraries
* @subpackage Application
* @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
$this->_name =
'administrator';
// Register the client ID
// Execute the parent constructor
// Set the root in the URI based on the application name
* Dispatch the application
* @param string $component The component which is being rendered.
public function dispatch($component =
null)
// Load the document to the API
// Register the document object with JFactory
switch ($document->getType())
$document->setMetaData('keywords', $this->get('MetaKeys'));
// Store the template and its params to the config
$this->set('theme', $template->template);
$this->set('themeParams', $template->params);
$document->setTitle($this->get('sitename') .
' - ' .
JText::_('JADMINISTRATION'));
$document->setDescription($this->get('MetaDesc'));
$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
if ($lang->hasKey('JERROR_MAGIC_QUOTES'))
$this->enqueueMessage('Your host needs to disable magic_quotes_gpc to run this version of Joomla!', 'error');
// Mark afterInitialise in the profiler.
// Mark afterRoute in the profiler.
// Dispatch the application
// Mark afterDispatch in the profiler.
* 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 =
'administrator', array $options =
array())
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
// Load the template name from the database
$query =
$db->getQuery(true)
->select('template, s.params')
->from('#__template_styles as s')
->join('LEFT', '#__extensions as e ON e.type=' .
$db->quote('template') .
' AND e.element=s.template AND e.client_id=s.client_id');
$query->where('s.client_id = 1 AND id = ' . (int)
$admin_style .
' AND e.enabled = 1', 'OR');
$query->where('s.client_id = 1 AND home = ' .
$db->quote('1'), 'OR')
$template =
$db->loadObject();
$template->params =
new JRegistry($template->params);
$template->template =
'isis';
throw
new InvalidArgumentException(JText::sprintf('JERROR_COULD_NOT_FIND_TEMPLATE', $template->template));
return $template->template;
* 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.
$guestUsergroup =
JComponentHelper::getParams('com_users')->get('guest_usergroup', 1);
$user->groups =
array($guestUsergroup);
// If a language was specified it has priority, otherwise use user or default language settings
if (empty($options['language']))
$lang =
$user->getParam('admin_language');
// Make sure that the user's language exists
$options['language'] =
$lang;
$options['language'] =
$params->get('administrator', $this->get('language', 'en-GB'));
// One last check to make sure we have something
$lang =
$this->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
// Load the language from the API
// Register the language object with JFactory
$lang->load('lib_joomla', JPATH_ADMINISTRATOR);
* 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())
$options['group'] =
'Public Backend';
// Make sure users are not auto-registered
$options['autoregister'] =
false;
// Set the application login entry point
$options['entry_url'] =
JUri::base() .
'index.php?option=com_users&task=login';
// Set the access control action to check.
$options['action'] =
'core.login.admin';
$result =
parent::login($credentials, $options);
if (!($result instanceof
Exception))
$lang =
$this->input->getCmd('lang', 'en-GB');
* Purge the jos_messages table of old messages
$userid =
$user->get('id');
$query =
$db->getQuery(true)
->from($db->quoteName('#__messages_cfg'))
->where($db->quoteName('user_id') .
' = ' . (int)
$userid, 'AND')
->where($db->quoteName('cfg_name') .
' = ' .
$db->quote('auto_purge'), 'AND');
$config =
$db->loadObject();
// Check if auto_purge value set
if (is_object($config) and $config->cfg_name ==
'auto_purge')
$purge =
$config->cfg_value;
// If no value set, default is 7 days
// If purge value is not 0, then allow purging of old messages
// Purge old messages at day set in message configuration
$pastStamp =
$past->toSql();
->delete($db->quoteName('#__messages'))
->where($db->quoteName('date_time') .
' < ' .
$db->Quote($pastStamp), 'AND')
->where($db->quoteName('user_id_to') .
' = ' . (int)
$userid, 'AND');
* 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.
$component =
$input->getCmd('option', 'com_login');
$file =
$input->getCmd('tmpl', 'index');
if ($component ==
'com_login')
$this->set('themeFile', $file .
'.php');
// Safety check for when configuration.php root_user is in use.
$rootUser =
$config->get('root_user');
'JWARNING_REMOVE_ROOT_USER',
* 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()
if ($this->get('force_ssl') >=
1 &&
strtolower($uri->getScheme()) !=
'https')
$uri->setScheme('https');
// Trigger the onAfterRoute event.
Documentation generated on Tue, 19 Nov 2013 14:53:35 +0100 by phpDocumentor 1.4.3