Source for file styles.php

Documentation is available at styles.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_templates
  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.  * Template styles list controller class.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_templates
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * Method to clone and existing template style.
  22.      *
  23.      * @return  void 
  24.      */
  25.     public function duplicate()
  26.     {
  27.         // Check for request forgeries
  28.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  29.  
  30.         $pks $this->input->post->get('cid'array()'array');
  31.  
  32.         try
  33.         {
  34.             if (empty($pks))
  35.             {
  36.                 throw new Exception(JText::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED'));
  37.             }
  38.  
  39.             JArrayHelper::toInteger($pks);
  40.  
  41.             $model $this->getModel();
  42.             $model->duplicate($pks);
  43.             $this->setMessage(JText::_('COM_TEMPLATES_SUCCESS_DUPLICATED'));
  44.         }
  45.         catch (Exception $e)
  46.         {
  47.             JError::raiseWarning(500$e->getMessage());
  48.         }
  49.  
  50.         $this->setRedirect('index.php?option=com_templates&view=styles');
  51.     }
  52.  
  53.     /**
  54.      * Proxy for getModel.
  55.      *
  56.      * @param   string  $name    The model name. Optional.
  57.      * @param   string  $prefix  The class prefix. Optional.
  58.      * @param   array   $config  Configuration array for model. Optional.
  59.      *
  60.      * @return  JModelLegacy 
  61.      *
  62.      * @since   1.6
  63.      */
  64.     public function getModel($name 'Style'$prefix 'TemplatesModel'$config array())
  65.     {
  66.         $model parent::getModel($name$prefixarray('ignore_request' => true));
  67.  
  68.         return $model;
  69.     }
  70.  
  71.     /**
  72.      * Method to set the home template for a client.
  73.      *
  74.      * @return  void 
  75.      *
  76.      * @since   1.6
  77.      */
  78.     public function setDefault()
  79.     {
  80.         // Check for request forgeries
  81.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  82.  
  83.         $pks $this->input->post->get('cid'array()'array');
  84.  
  85.         try
  86.         {
  87.             if (empty($pks))
  88.             {
  89.                 throw new Exception(JText::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED'));
  90.             }
  91.  
  92.             JArrayHelper::toInteger($pks);
  93.  
  94.             // Pop off the first element.
  95.             $id array_shift($pks);
  96.             $model $this->getModel();
  97.             $model->setHome($id);
  98.             $this->setMessage(JText::_('COM_TEMPLATES_SUCCESS_HOME_SET'));
  99.         }
  100.         catch (Exception $e)
  101.         {
  102.             JError::raiseWarning(500$e->getMessage());
  103.         }
  104.  
  105.         $this->setRedirect('index.php?option=com_templates&view=styles');
  106.     }
  107.  
  108.     /**
  109.      * Method to unset the default template for a client and for a language
  110.      *
  111.      * @return  void 
  112.      *
  113.      * @since   1.6
  114.      */
  115.     public function unsetDefault()
  116.     {
  117.         // Check for request forgeries
  118.         JSession::checkToken('request'or jexit(JText::_('JINVALID_TOKEN'));
  119.  
  120.         $pks $this->input->get->get('cid'array()'array');
  121.         JArrayHelper::toInteger($pks);
  122.  
  123.         try
  124.         {
  125.             if (empty($pks))
  126.             {
  127.                 throw new Exception(JText::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED'));
  128.             }
  129.  
  130.             // Pop off the first element.
  131.             $id array_shift($pks);
  132.             $model $this->getModel();
  133.             $model->unsetHome($id);
  134.             $this->setMessage(JText::_('COM_TEMPLATES_SUCCESS_HOME_UNSET'));
  135.         }
  136.         catch (Exception $e)
  137.         {
  138.             JError::raiseWarning(500$e->getMessage());
  139.         }
  140.  
  141.         $this->setRedirect('index.php?option=com_templates&view=styles');
  142.     }
  143. }

Documentation generated on Tue, 19 Nov 2013 15:14:41 +0100 by phpDocumentor 1.4.3