[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_templates 6 * 7 * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Templates\Administrator\Controller; 12 13 use Joomla\CMS\Language\Text; 14 use Joomla\CMS\MVC\Controller\AdminController; 15 use Joomla\CMS\MVC\Model\BaseDatabaseModel; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Template styles list controller class. 23 * 24 * @since 1.6 25 */ 26 class StylesController extends AdminController 27 { 28 /** 29 * Method to clone and existing template style. 30 * 31 * @return void 32 */ 33 public function duplicate() 34 { 35 // Check for request forgeries 36 $this->checkToken(); 37 38 $pks = (array) $this->input->post->get('cid', array(), 'int'); 39 40 // Remove zero values resulting from input filter 41 $pks = array_filter($pks); 42 43 try { 44 if (empty($pks)) { 45 throw new \Exception(Text::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED')); 46 } 47 48 $model = $this->getModel(); 49 $model->duplicate($pks); 50 $this->setMessage(Text::_('COM_TEMPLATES_SUCCESS_DUPLICATED')); 51 } catch (\Exception $e) { 52 $this->app->enqueueMessage($e->getMessage(), 'error'); 53 } 54 55 $this->setRedirect('index.php?option=com_templates&view=styles'); 56 } 57 58 /** 59 * Proxy for getModel. 60 * 61 * @param string $name The model name. Optional. 62 * @param string $prefix The class prefix. Optional. 63 * @param array $config Configuration array for model. Optional. 64 * 65 * @return BaseDatabaseModel 66 * 67 * @since 1.6 68 */ 69 public function getModel($name = 'Style', $prefix = 'Administrator', $config = array()) 70 { 71 return parent::getModel($name, $prefix, array('ignore_request' => true)); 72 } 73 74 /** 75 * Method to set the home template for a client. 76 * 77 * @return void 78 * 79 * @since 1.6 80 */ 81 public function setDefault() 82 { 83 // Check for request forgeries 84 $this->checkToken(); 85 86 $pks = (array) $this->input->post->get('cid', array(), 'int'); 87 88 // Remove zero values resulting from input filter 89 $pks = array_filter($pks); 90 91 try { 92 if (empty($pks)) { 93 throw new \Exception(Text::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED')); 94 } 95 96 // Pop off the first element. 97 $id = array_shift($pks); 98 99 /** @var \Joomla\Component\Templates\Administrator\Model\StyleModel $model */ 100 $model = $this->getModel(); 101 $model->setHome($id); 102 $this->setMessage(Text::_('COM_TEMPLATES_SUCCESS_HOME_SET')); 103 } catch (\Exception $e) { 104 $this->setMessage($e->getMessage(), 'warning'); 105 } 106 107 $this->setRedirect('index.php?option=com_templates&view=styles'); 108 } 109 110 /** 111 * Method to unset the default template for a client and for a language 112 * 113 * @return void 114 * 115 * @since 1.6 116 */ 117 public function unsetDefault() 118 { 119 // Check for request forgeries 120 $this->checkToken('request'); 121 122 $pks = (array) $this->input->get->get('cid', array(), 'int'); 123 124 // Remove zero values resulting from input filter 125 $pks = array_filter($pks); 126 127 try { 128 if (empty($pks)) { 129 throw new \Exception(Text::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED')); 130 } 131 132 // Pop off the first element. 133 $id = array_shift($pks); 134 135 /** @var \Joomla\Component\Templates\Administrator\Model\StyleModel $model */ 136 $model = $this->getModel(); 137 $model->unsetHome($id); 138 $this->setMessage(Text::_('COM_TEMPLATES_SUCCESS_HOME_UNSET')); 139 } catch (\Exception $e) { 140 $this->setMessage($e->getMessage(), 'warning'); 141 } 142 143 $this->setRedirect('index.php?option=com_templates&view=styles'); 144 } 145 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |