Source for file web.php
Documentation is available at web.php
* @package Joomla.Installation
* @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! Installation Application class
* @package Joomla.Installation
* @subpackage Application
// Run the parent constructor
// Load and set the dispatcher
// Enable sessions by default.
$this->config->set('session', true);
// Set the session default name.
$this->config->set('session_name', 'installation');
// Create the session if a session name is passed.
if ($this->config->get('session') !==
false)
// Register the session with JFactory
// Store the debug value to config based on the JDEBUG flag
$this->config->set('debug', JDEBUG);
// Register the config to JFactory
// Register the application to JFactory
JFactory::$application =
$this;
// Register the application name
$this->_name =
'installation';
// Register the client ID
// Set the root in the URI one level up.
$parts =
explode('/', JUri::base(true));
* Method to display errors in language parsing
* @return string Language debug output
$output =
'<h4>' .
JText::_('JDEBUG_LANGUAGE_FILES_IN_ERROR') .
'</h4>';
$errorfiles =
$lang->getErrorFiles();
foreach ($errorfiles as $error)
$output .=
"<li>$error</li>";
$output .=
'<pre>' .
JText::_('JNONE') .
'</pre>';
$output .=
'<h4>' .
JText::_('JDEBUG_LANGUAGE_UNTRANSLATED_STRING') .
'</h4>';
$orphans =
$lang->getOrphans();
ksort($orphans, SORT_STRING);
foreach ($orphans as $key =>
$occurance)
$guesses[] =
$key .
'="' .
$guess .
'"';
$output .=
implode("\n", $guesses);
$output .=
'<pre>' .
JText::_('JNONE') .
'</pre>';
* Dispatch the application
// Load the document to the API
// Register the document object with JFactory
if ($document->getType() ==
'html')
$document->setTitle(JText::_('INSTL_PAGE_TITLE'));
$contents =
$controller->execute();
catch
(RuntimeException $e)
$this->close($e->getCode());
// If debug language is set, append its output to the contents
if ($this->config->get('debug_lang'))
$document->setBuffer($contents, 'component');
$document->setTitle(JText::_('INSTL_PAGE_TITLE'));
// Mop up any uncaught exceptions.
$this->close($e->getCode());
* Method to run the Web application routines.
// Initialise the application
// Dispatch the application
* Method to load a PHP configuration class file based on convention and return the instantiated data object. You
* will extend this method in child classes to provide configuration data from whatever data source is relevant
* for your specific application.
* @param string $file The path and filename of the configuration file. If not provided, configuration.php
* in JPATH_BASE will be used.
* @param string $class The class name to instantiate.
* @return mixed Either an array or object to be loaded into the configuration object.
* @throws RuntimeException
* Method to get a controller object.
* @param string $task The task being executed
* @throws RuntimeException
// Set the controller class name based on the task
$class =
'InstallationController' .
ucfirst($task);
// If the requested controller exists let's use it.
throw
new RuntimeException('Class ' .
$class .
' not found');
* Returns the language code and help url set in the localise.xml file.
* Used for forcing a particular language in localised releases.
* @return mixed False on failure, array on success.
// Check that it's a localise file
if ($xml->getName() !=
'localise')
$ret['language'] = (string)
$xml->forceLang;
$ret['helpurl'] = (string)
$xml->helpurl;
$ret['debug'] = (string)
$xml->debug;
$ret['sampledata'] = (string)
$xml->sampledata;
* Returns the installed language files in the administrative and
* @param mixed $db JDatabaseDriver instance
* @return array Array with installed language packs in admin and site area
// Read the files in the admin area
// Read the files in the site area
$langfiles_disk =
$langfiles;
$langfiles['admin'] =
array();
$langfiles['site'] =
array();
$query =
$db->getQuery(true)
->select($db->quoteName(array('element','client_id')))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') .
' = ' .
$db->quote('language'));
$langs =
$db->loadObjectList();
foreach ($langs as $lang)
switch ($lang->client_id)
if (in_array($lang->element, $langfiles_disk['site']))
$langfiles['site'][] =
$lang->element;
if (in_array($lang->element, $langfiles_disk['admin']))
$langfiles['admin'][] =
$lang->element;
* Gets the name of the current template.
* @param boolean $params True to return the template parameters
* @return string The name of the template.
$template =
new stdClass;
$template->template =
'template';
* Initialise the application.
* @param array $options An optional associative array of configuration settings.
// Get the localisation information provided in the localise.xml file.
// Check the request data for the language.
if (empty($options['language']))
$requestLang =
$this->input->getCmd('lang', null);
$options['language'] =
$requestLang;
// Check the session for the language.
if (empty($options['language']))
$sessionOptions =
$this->getSession()->get('setup.options');
if (isset
($sessionOptions['language']))
$options['language'] =
$sessionOptions['language'];
// This could be a first-time visit - try to determine what the client accepts.
if (empty($options['language']))
if (!empty($forced['language']))
$options['language'] =
$forced['language'];
if (empty($options['language']))
$options['language'] =
'en-GB';
if (empty($options['language']))
$options['language'] =
'en-GB';
// Set the language in the class
$this->config->set('language', $options['language']);
$this->config->set('debug_lang', $forced['debug']);
$this->config->set('sampledata', $forced['sampledata']);
* Allows the application to load a custom or default document.
* The logic and options for creating this object are adequately generic for default cases
* but for many applications it will make sense to override this method and create a document,
* if required, based on more specific needs.
* @param JDocument $document An optional document object. If omitted, the factory document is created.
* @return InstallationApplicationWeb This method is chainable.
$type =
$this->input->get('format', 'html', 'word');
'language' =>
$lang->getTag(),
'direction' =>
$lang->isRTL() ?
'rtl' :
'ltr'
// Register the instance to JFactory
* Allows the application to load a custom or default session.
* The logic and options for creating this object are adequately generic for default cases
* but for many applications it will make sense to override this method and create a session,
* if required, based on more specific needs.
* @param JSession $session An optional session object. If omitted, the session is created.
* @return InstallationApplicationWeb This method is chainable.
// Generate a session name.
$name =
md5($this->get('secret') .
$this->get('session_name', get_class($this)));
// Calculate the session lifetime.
$lifetime =
(($this->get('lifetime')) ?
$this->get('lifetime') *
60 :
900);
// Get the session handler from the configuration.
$handler =
$this->get('session_handler', 'none');
// Initialize the options for JSession.
'force_ssl' =>
$this->get('force_ssl')
// Instantiate the session object.
if ($session->getState() ==
'expired')
if (!$session->get('registry') instanceof
JRegistry)
// Registry has been corrupted somehow
$session->set('registry', new JRegistry('session'));
// Set the session object.
* 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.
$file =
$this->input->getCmd('tmpl', 'index');
'template' =>
'template',
'file' =>
$file .
'.php',
$data =
$this->document->render($this->get('cache_enabled'), $options);
// Set the application output data.
* Method to send a JSON response. The data parameter
* can be a Exception object for when an error has occurred or
* a stdClass for a good response.
* @param mixed $response stdClass on success, Exception on failure.
// Check if we need to send an error code.
if ($response instanceof
Exception)
// Send the appropriate error code response.
$this->setHeader('status', $response->getCode());
$this->setHeader('Content-Type', 'application/json; charset=utf-8');
// Send the JSON response.
// Close the application.
* Set configuration values
* @param array $vars Array of configuration values
* @param string $namespace The namespace
public function setCfg(array $vars =
array(), $namespace =
'config')
$this->config->loadArray($vars, $namespace);
Documentation generated on Tue, 19 Nov 2013 15:18:23 +0100 by phpDocumentor 1.4.3