Source for file setlanguage.php

Documentation is available at setlanguage.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Installation
  4.  * @subpackage  Controller
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Controller class to set the language for the Joomla Installer.
  14.  *
  15.  * @package     Joomla.Installation
  16.  * @subpackage  Controller
  17.  * @since       3.1
  18.  */
  19. {
  20.     /**
  21.      * Execute the controller.
  22.      *
  23.      * @return  void 
  24.      *
  25.      * @since   3.1
  26.      */
  27.     public function execute()
  28.     {
  29.         // Get the application
  30.         /* @var InstallationApplicationWeb $app */
  31.         $app $this->getApplication();
  32.  
  33.         // Check for request forgeries.
  34.         JSession::checkToken(or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN')403));
  35.  
  36.         // Very crude workaround to give an error message when JSON is disabled
  37.         if (!function_exists('json_encode'|| !function_exists('json_decode'))
  38.         {
  39.             $app->setHeader('status'500);
  40.             $app->setHeader('Content-Type''application/json; charset=utf-8');
  41.             $app->sendHeaders();
  42.             echo '{"token":"' JSession::getFormToken(true'","lang":"' JFactory::getLanguage()->getTag()
  43.                 . '","error":true,"header":"' JText::_('INSTL_HEADER_ERROR''","message":"' JText::_('INSTL_WARNJSON''"}';
  44.             $app->close();
  45.         }
  46.  
  47.         // Check for potentially unwritable session
  48.         $session JFactory::getSession();
  49.  
  50.         if ($session->isNew())
  51.         {
  52.             $this->sendResponse(new Exception(JText::_('INSTL_COOKIES_NOT_ENABLED')500));
  53.         }
  54.  
  55.         // Get the setup model.
  56.         $model new InstallationModelSetup;
  57.  
  58.         // Get the posted values from the request and validate them.
  59.         $data $this->input->post->get('jform'array()'array');
  60.         $return    $model->validate($data'preinstall');
  61.  
  62.         $r new stdClass;
  63.  
  64.         // Check for validation errors.
  65.         if ($return === false)
  66.         {
  67.             /*
  68.              * The validate method enqueued all messages for us, so we just need to
  69.              * redirect back to the site setup screen.
  70.              */
  71.             $r->view $this->input->getWord('view''site');
  72.             $app->sendJsonResponse($r);
  73.         }
  74.  
  75.         // Store the options in the session.
  76.         $model->storeOptions($return);
  77.  
  78.         // Setup language
  79.         $language JFactory::getLanguage();
  80.         $language->setLanguage($return['language']);
  81.  
  82.         // Redirect to the page.
  83.         $r->view $this->input->getWord('view''site');
  84.         $app->sendJsonResponse($r);
  85.     }
  86. }

Documentation generated on Tue, 19 Nov 2013 15:12:57 +0100 by phpDocumentor 1.4.3