Source for file helper.php

Documentation is available at helper.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  Joomla.Libraries
  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('Restricted access');
  11.  
  12. /**
  13.  * Helper class for controllers
  14.  *
  15.  * @package     Joomla.Site
  16.  * @subpackage  com_config
  17.  * @since       3.2
  18. */
  19. {
  20.     /**
  21.      * Method to parse a controller from a url
  22.      * Defaults to the base controllers and passes an array of options.
  23.      * $options[0] is the location of the controller which defaults to the core libraries (referenced as 'j'
  24.      * and then the named folder within the component entry point file.
  25.      * $options[1] is the name of the controller file,
  26.      * $options[2] is the name of the folder found in the component controller folder for controllers
  27.      * not prefixed with Config.
  28.      * Additional options maybe added to parameterise the controller.
  29.      *
  30.      * @param   JApplicationBase  $app  An application object
  31.      *
  32.      * @return  JController  A JController object
  33.      *
  34.      * @since   3.2
  35.      */
  36.     public function parseController($app)
  37.     {
  38.         $tasks array();
  39.  
  40.         if ($task $app->input->get('task'))
  41.         {
  42.             // Toolbar expects old style but we are using new style
  43.             // Remove when toolbar can handle either directly
  44.             if (strpos($task'/'!== false)
  45.             {
  46.                 $tasks explode('/'$task);
  47.             }
  48.             else
  49.             {
  50.                 $tasks explode('.'$task);
  51.             }
  52.         }
  53.         elseif ($controllerTask $app->input->get('controller'))
  54.         {
  55.             // Temporary solution
  56.             if (strpos($controllerTask'/'!== false)
  57.             {
  58.                 $tasks explode('/'$controllerTask);
  59.             }
  60.             else
  61.             {
  62.                 $tasks explode('.'$controllerTask);
  63.             }
  64.         }
  65.  
  66.         if (empty($tasks[0]|| $tasks[0== 'Config')
  67.         {
  68.             $location 'Config';
  69.         }
  70.         else
  71.         {
  72.             $location ucfirst(strtolower($tasks[0]));
  73.         }
  74.  
  75.         if (empty($tasks[1]))
  76.         {
  77.             $activity 'Display';
  78.         }
  79.         else
  80.         {
  81.             $activity ucfirst(strtolower($tasks[1]));
  82.         }
  83.  
  84.         $view '';
  85.  
  86.         if (!empty($tasks[2]))
  87.         {
  88.             $view ucfirst(strtolower($tasks[2]));
  89.         }
  90.  
  91.         // Some special handling for com_config administrator
  92.         $option $app->input->get('option');
  93.  
  94.         if ($app->isAdmin(&& $option == 'com_config')
  95.         {
  96.             $component $app->input->get('component');
  97.  
  98.             if (!empty($component))
  99.             {
  100.                 $view 'Component';
  101.             }
  102.             elseif ($option == 'com_config')
  103.             {
  104.                 $view 'Application';
  105.             }
  106.         }
  107.  
  108.         $controllerName $location 'Controller' $view $activity;
  109.  
  110.         if (!class_exists($controllerName))
  111.         {
  112.             return false;
  113.         }
  114.  
  115.         $controller new $controllerName;
  116.         $controller->options array();
  117.         $controller->options $tasks;
  118.  
  119.         return $controller;
  120.     }
  121. }

Documentation generated on Tue, 19 Nov 2013 15:04:26 +0100 by phpDocumentor 1.4.3