[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/installation/includes/ -> application.php (source)

   1  <?php
   2  /**
   3  * @version        $Id: application.php 14401 2010-01-26 14:10:00Z louis $
   4  * @package        Joomla
   5  * @subpackage    Installation
   6  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7  * @license        GNU/GPL, see LICENSE.php
   8  * Joomla! is free software. This version may have been modified pursuant
   9  * to the GNU General Public License, and as distributed it includes or
  10  * is derivative of works licensed under the GNU General Public License or
  11  * other free or open source software licenses.
  12  * See COPYRIGHT.php for copyright notices and details.
  13  */
  14  
  15  // no direct access
  16  defined( '_JEXEC' ) or die( 'Restricted access' );
  17  
  18  /**
  19  * Joomla! Application class
  20  *
  21  * Provide many supporting API functions
  22  *
  23  * @package        Joomla
  24  * @final
  25  */
  26  class JInstallation extends JApplication
  27  {
  28      /**
  29       * The url of the site
  30       *
  31       * @var string
  32       * @access protected
  33       */
  34      var $_siteURL = null;
  35  
  36      /**
  37      * Class constructor
  38      *
  39      * @access protected
  40      * @param    array An optional associative array of configuration settings.
  41      * Recognized key values include 'clientId' (this list is not meant to be comprehensive).
  42      */
  43  	function __construct($config = array())
  44      {
  45          $config['clientId'] = 2;
  46          parent::__construct($config);
  47  
  48          JError::setErrorHandling(E_ALL, 'Ignore');
  49          $this->_createConfiguration();
  50  
  51          //Set the root in the URI based on the application name
  52          JURI::root(null, str_replace('/'.$this->getName(), '', JURI::base(true)));
  53      }
  54  
  55      /**
  56       * Render the application
  57       *
  58       * @access public
  59       */
  60  	function render()
  61      {
  62          $document    =& JFactory::getDocument();
  63          $config        =& JFactory::getConfig();
  64          $user        =& JFactory::getUser();
  65  
  66          switch($document->getType())
  67          {
  68              case 'html':
  69                  //set metadata
  70                  $document->setTitle(JText::_('PAGE_TITLE'));
  71                  break;
  72  
  73              default: break;
  74          }
  75  
  76          // Define component path
  77          define( 'JPATH_COMPONENT',                    JPATH_BASE.DS.'installer');
  78          define( 'JPATH_COMPONENT_SITE',                JPATH_SITE.DS.'installer');
  79          define( 'JPATH_COMPONENT_ADMINISTRATOR',    JPATH_ADMINISTRATOR.DS.'installer');
  80  
  81          // Execute the component
  82          ob_start();
  83          require_once(JPATH_COMPONENT.DS.'installer.php');
  84          $contents = ob_get_contents();
  85          ob_end_clean();
  86  
  87          $params = array(
  88              'template'     => 'template',
  89              'file'        => 'index.php',
  90              'directory' => JPATH_THEMES
  91          );
  92  
  93          $document->setBuffer( $contents, 'installation');
  94          $document->setTitle(JText::_('PAGE_TITLE'));
  95          $data = $document->render(false, $params);
  96          JResponse::setBody($data);
  97      }
  98  
  99      /**
 100      * Initialise the application.
 101      *
 102      * @access public
 103      */
 104  	function initialise( $options = array())
 105      {
 106          //Get the localisation information provided in the localise xml file
 107          $forced = $this->getLocalise();
 108  
 109          // Check URL arguement - useful when user has just set the language preferences
 110          if(empty($options['language']))
 111          {
 112              $vars        = JRequest::getVar('vars');
 113              if ( is_array($vars) && ! empty($vars['lang'])  )
 114              {
 115                  $varLang    = $vars['lang'];
 116                  $options['language']    = $varLang;
 117              }
 118          }
 119  
 120          // Check the application state - useful when the user has previously set the language preference
 121          if(empty($options['language']))
 122          {
 123              $configLang = $this->getUserState('application.lang');
 124              if ( $configLang ) {
 125                  $options['language']    = $configLang;
 126              }
 127          }
 128  
 129          // This could be a first-time visit - try to determine what the client accepts
 130          if(empty($options['language']))
 131          {
 132              if ( empty($forced['lang'])) {
 133                  jimport('joomla.language.helper');
 134                  $options['language'] = JLanguageHelper::detectLanguage();
 135              } else {
 136                  $options['language'] = $forced['lang'];
 137              }
 138          }
 139  
 140          // Give the user English
 141          if (empty($options['language'])) {
 142              $options['language'] = 'en-GB';
 143          }
 144  
 145          //Set the language in the class
 146          $conf =& JFactory::getConfig();
 147          $conf->setValue('config.language', $options['language']);
 148          $conf->setValue('config.debug_lang', $forced['debug']);
 149      }
 150  
 151      /**
 152       * Set configuration values
 153       *
 154       * @access private
 155       * @param array     Array of configuration values
 156       * @param string     The namespace
 157       */
 158  	function setCfg( $vars, $namespace = 'config' ) {
 159          $this->_registry->loadArray( $vars, $namespace );
 160      }
 161  
 162      /**
 163       * Create the configuration registry
 164       *
 165       * @access private
 166       */
 167  	function _createConfiguration()
 168      {
 169          jimport( 'joomla.registry.registry' );
 170  
 171          // Create the registry with a default namespace of config which is read only
 172          $this->_registry = new JRegistry( 'config' );
 173      }
 174  
 175      /**
 176      * Get the template
 177      *
 178      * @return string The template name
 179      */
 180  	function getTemplate()
 181      {
 182          return 'template';
 183      }
 184  
 185      /**
 186       * Create the user session
 187       *
 188       * @access private
 189       * @param string        The sessions name
 190       * @return    object         JSession
 191       */
 192      function &_createSession( $name )
 193      {
 194          $options = array();
 195          $options['name'] = $name;
 196  
 197          $session = &JFactory::getSession($options);
 198          if (!is_a($session->get('registry'), 'JRegistry')) {
 199              // Registry has been corrupted somehow
 200              $session->set('registry', new JRegistry('session'));
 201          }
 202  
 203          return $session;
 204      }
 205  
 206      /**
 207       * returns the langauge code and help url set in the localise.xml file.
 208       * Used for forcing a particular language in localised releases
 209       */
 210  	function getLocalise()
 211      {
 212          $xml = & JFactory::getXMLParser('Simple');
 213  
 214          if (!$xml->loadFile(JPATH_SITE.DS.'installation'.DS.'localise.xml')) {
 215              return 'no file'; //null;
 216          }
 217  
 218          // Check that it's a localise file
 219          if ($xml->document->name() != 'localise') {
 220              return 'not a localise'; //null;
 221          }
 222  
 223          $tags =  $xml->document->children();
 224          $ret = array();
 225          $ret['lang']     = $tags[0]->data();
 226          $ret['helpurl'] = $tags[1]->data();
 227          $ret['debug']    = $tags[2]->data();
 228          return  $ret;
 229  
 230      }
 231  
 232      /**
 233       * Returns the installed admin language files in the administrative and
 234       * front-end area.
 235       *
 236       * @access private
 237       * @return    array         Array with installed language packs in admin area
 238       */
 239  	function getLocaliseAdmin()
 240      {
 241          jimport('joomla.filesystem.folder');
 242  
 243          // Read the files in the admin area
 244          $path = JLanguage::getLanguagePath(JPATH_SITE.DS.'administrator');
 245          $langfiles['admin'] = JFolder::folders( $path );
 246  
 247          $path = JLanguage::getLanguagePath(JPATH_SITE);
 248          $langfiles['site'] = JFolder::folders( $path );
 249  
 250          return $langfiles;
 251      }
 252  }
 253  
 254  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1