Source for file items.php

Documentation is available at items.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_menus
  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.  * The Menu Item Controller
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_menus
  17.  * @since       1.6
  18.  */
  19. {
  20.     public function __construct($config array())
  21.     {
  22.         parent::__construct($config);
  23.         $this->registerTask('unsetDefault',    'setDefault');
  24.     }
  25.  
  26.     /**
  27.      * Proxy for getModel
  28.      * @since   1.6
  29.      */
  30.     public function getModel($name 'Item'$prefix 'MenusModel'$config array())
  31.     {
  32.         return parent::getModel($name$prefixarray('ignore_request' => true));
  33.     }
  34.  
  35.     /**
  36.      * Rebuild the nested set tree.
  37.      *
  38.      * @return  bool    False on failure or error, true on success.
  39.      * @since   1.6
  40.      */
  41.     public function rebuild()
  42.     {
  43.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  44.  
  45.         $this->setRedirect('index.php?option=com_menus&view=items');
  46.  
  47.         $model $this->getModel();
  48.  
  49.         if ($model->rebuild())
  50.         {
  51.             // Reorder succeeded.
  52.             $this->setMessage(JText::_('COM_MENUS_ITEMS_REBUILD_SUCCESS'));
  53.             return true;
  54.         }
  55.         else
  56.         {
  57.             // Rebuild failed.
  58.             $this->setMessage(JText::sprintf('COM_MENUS_ITEMS_REBUILD_FAILED'));
  59.             return false;
  60.         }
  61.     }
  62.  
  63.     public function saveorder()
  64.     {
  65.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  66.  
  67.         // Get the arrays from the Request
  68.         $order $this->input->post->get('order'null'array');
  69.         $originalOrder explode(','$this->input->getString('original_order_values'));
  70.  
  71.         // Make sure something has changed
  72.         if (!($order === $originalOrder))
  73.         {
  74.             parent::saveorder();
  75.         }
  76.         else
  77.         {
  78.             // Nothing to reorder
  79.             $this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_listfalse));
  80.             return true;
  81.         }
  82.     }
  83.  
  84.     /**
  85.      * Method to set the home property for a list of items
  86.      *
  87.      * @since   1.6
  88.      */
  89.     public function setDefault()
  90.     {
  91.         // Check for request forgeries
  92.         JSession::checkToken('request'or die(JText::_('JINVALID_TOKEN'));
  93.  
  94.         // Get items to publish from the request.
  95.         $cid   $this->input->get('cid'array()'array');
  96.         $data  array('setDefault' => 1'unsetDefault' => 0);
  97.         $task  $this->getTask();
  98.         $value JArrayHelper::getValue($data$task0'int');
  99.  
  100.         if (empty($cid))
  101.         {
  102.             JError::raiseWarning(500JText::_($this->text_prefix.'_NO_ITEM_SELECTED'));
  103.         }
  104.         else
  105.         {
  106.             // Get the model.
  107.             $model $this->getModel();
  108.  
  109.             // Make sure the item ids are integers
  110.             JArrayHelper::toInteger($cid);
  111.  
  112.             // Publish the items.
  113.             if (!$model->setHome($cid$value))
  114.             {
  115.                 JError::raiseWarning(500$model->getError());
  116.             else {
  117.                 if ($value == 1)
  118.                 {
  119.                     $ntext 'COM_MENUS_ITEMS_SET_HOME';
  120.                 }
  121.                 else {
  122.                     $ntext 'COM_MENUS_ITEMS_UNSET_HOME';
  123.                 }
  124.                 $this->setMessage(JText::plural($ntextcount($cid)));
  125.             }
  126.         }
  127.  
  128.         $this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_listfalse));
  129.     }
  130. }

Documentation generated on Tue, 19 Nov 2013 15:06:02 +0100 by phpDocumentor 1.4.3