[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_categories/ -> controller.php (source)

   1  <?php
   2  /**
   3   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   4   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   5   */
   6  
   7  // No direct access
   8  defined('_JEXEC') or die;
   9  
  10  jimport('joomla.application.component.controller');
  11  
  12  /**
  13   * Categories view class for the Category package.
  14   *
  15   * @package        Joomla.Administrator
  16   * @subpackage    com_categories
  17   * @since        1.6
  18   */
  19  class CategoriesController extends JController
  20  {
  21      /**
  22       * @var        string    The extension for which the categories apply.
  23       * @since    1.6
  24       */
  25      protected $extension;
  26  
  27      /**
  28       * Constructor.
  29       *
  30       * @param    array An optional associative array of configuration settings.
  31       * @see        JController
  32       * @since    1.6
  33       */
  34  	public function __construct($config = array())
  35      {
  36          parent::__construct($config);
  37  
  38          // Guess the JText message prefix. Defaults to the option.
  39          if (empty($this->extension)) {
  40              $this->extension = JRequest::getCmd('extension', 'com_content');
  41          }
  42      }
  43  
  44      /**
  45       * Method to display a view.
  46       *
  47       * @param    boolean            If true, the view output will be cached
  48       * @param    array            An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  49       *
  50       * @return    JController        This object to support chaining.
  51       * @since    1.5
  52       */
  53  	public function display($cachable = false, $urlparams = false)
  54      {
  55          // Get the document object.
  56          $document = JFactory::getDocument();
  57  
  58          // Set the default view name and format from the Request.
  59          $vName        = JRequest::getCmd('view', 'categories');
  60          $vFormat    = $document->getType();
  61          $lName        = JRequest::getCmd('layout', 'default');
  62          $id            = JRequest::getInt('id');
  63  
  64          // Check for edit form.
  65          if ($vName == 'category' && $lName == 'edit' && !$this->checkEditId('com_categories.edit.category', $id)) {
  66              // Somehow the person just went to the form - we don't allow that.
  67              $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
  68              $this->setMessage($this->getError(), 'error');
  69              $this->setRedirect(JRoute::_('index.php?option=com_categories&view=categories&extension='.$this->extension, false));
  70  
  71              return false;
  72          }
  73  
  74          // Get and render the view.
  75          if ($view = $this->getView($vName, $vFormat)) {
  76              // Get the model for the view.
  77              $model = $this->getModel($vName, 'CategoriesModel', array('name' => $vName . '.' . substr($this->extension, 4)));
  78  
  79              // Push the model into the view (as default).
  80              $view->setModel($model, true);
  81              $view->setLayout($lName);
  82  
  83              // Push document object into the view.
  84              $view->assignRef('document', $document);
  85              // Load the submenu.
  86              require_once  JPATH_COMPONENT.'/helpers/categories.php';
  87  
  88              CategoriesHelper::addSubmenu($model->getState('filter.extension'));
  89              $view->display();
  90          }
  91  
  92          return $this;
  93      }
  94  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1