[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_banners/controllers/ -> banners.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.controlleradmin');
  11  
  12  /**
  13   * Banners list controller class.
  14   *
  15   * @package        Joomla.Administrator
  16   * @subpackage    com_banners
  17   * @since        1.6
  18   */
  19  class BannersControllerBanners extends JControllerAdmin
  20  {
  21      /**
  22       * @var        string    The prefix to use with controller messages.
  23       * @since    1.6
  24       */
  25      protected $text_prefix = 'COM_BANNERS_BANNERS';
  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          $this->registerTask('sticky_unpublish',    'sticky_publish');
  39      }
  40  
  41      /**
  42       * Proxy for getModel.
  43       * @since    1.6
  44       */
  45  	public function getModel($name = 'Banner', $prefix = 'BannersModel', $config = array('ignore_request' => true))
  46      {
  47          $model = parent::getModel($name, $prefix, $config);
  48          return $model;
  49      }
  50  
  51      /**
  52       * @since    1.6
  53       */
  54  	public function sticky_publish()
  55      {
  56          // Check for request forgeries.
  57          JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
  58  
  59          // Initialise variables.
  60          $user    = JFactory::getUser();
  61          $ids    = JRequest::getVar('cid', array(), '', 'array');
  62          $values    = array('sticky_publish' => 1, 'sticky_unpublish' => 0);
  63          $task    = $this->getTask();
  64          $value    = JArrayHelper::getValue($values, $task, 0, 'int');
  65  
  66          if (empty($ids)) {
  67              JError::raiseWarning(500, JText::_('COM_BANNERS_NO_BANNERS_SELECTED'));
  68          } else {
  69              // Get the model.
  70              $model    = $this->getModel();
  71  
  72              // Change the state of the records.
  73              if (!$model->stick($ids, $value)) {
  74                  JError::raiseWarning(500, $model->getError());
  75              } else {
  76                  if ($value == 1) {
  77                      $ntext = 'COM_BANNERS_N_BANNERS_STUCK';
  78                  } else {
  79                      $ntext = 'COM_BANNERS_N_BANNERS_UNSTUCK';
  80                  }
  81                  $this->setMessage(JText::plural($ntext, count($ids)));
  82              }
  83          }
  84  
  85          $this->setRedirect('index.php?option=com_banners&view=banners');
  86      }
  87  }


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