[ 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_banners 6 * 7 * @copyright (C) 2017 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\Banners\Administrator\Controller; 12 13 use Joomla\CMS\Application\ApplicationHelper; 14 use Joomla\CMS\Language\Text; 15 use Joomla\CMS\MVC\Controller\BaseController; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Tracks list controller class. 23 * 24 * @since 1.6 25 */ 26 class TracksController extends BaseController 27 { 28 /** 29 * The prefix to use with controller messages. 30 * 31 * @var string 32 * @since 1.6 33 */ 34 protected $context = 'com_banners.tracks'; 35 36 /** 37 * Method to get a model object, loading it if required. 38 * 39 * @param string $name The model name. Optional. 40 * @param string $prefix The class prefix. Optional. 41 * @param array $config Configuration array for model. Optional. 42 * 43 * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel The model. 44 * 45 * @since 1.6 46 */ 47 public function getModel($name = 'Tracks', $prefix = 'Administrator', $config = array('ignore_request' => true)) 48 { 49 return parent::getModel($name, $prefix, $config); 50 } 51 52 /** 53 * Method to remove a record. 54 * 55 * @return void 56 * 57 * @since 1.6 58 */ 59 public function delete() 60 { 61 // Check for request forgeries. 62 $this->checkToken(); 63 64 // Get the model. 65 /** @var \Joomla\Component\Banners\Administrator\Model\TracksModel $model */ 66 $model = $this->getModel(); 67 68 // Load the filter state. 69 $model->setState('filter.type', $this->app->getUserState($this->context . '.filter.type')); 70 $model->setState('filter.begin', $this->app->getUserState($this->context . '.filter.begin')); 71 $model->setState('filter.end', $this->app->getUserState($this->context . '.filter.end')); 72 $model->setState('filter.category_id', $this->app->getUserState($this->context . '.filter.category_id')); 73 $model->setState('filter.client_id', $this->app->getUserState($this->context . '.filter.client_id')); 74 $model->setState('list.limit', 0); 75 $model->setState('list.start', 0); 76 77 $count = $model->getTotal(); 78 79 // Remove the items. 80 if (!$model->delete()) { 81 $this->app->enqueueMessage($model->getError(), 'warning'); 82 } elseif ($count > 0) { 83 $this->setMessage(Text::plural('COM_BANNERS_TRACKS_N_ITEMS_DELETED', $count)); 84 } else { 85 $this->setMessage(Text::_('COM_BANNERS_TRACKS_NO_ITEMS_DELETED')); 86 } 87 88 $this->setRedirect('index.php?option=com_banners&view=tracks'); 89 } 90 91 /** 92 * Display method for the raw track data. 93 * 94 * @param boolean $cachable If true, the view output will be cached 95 * @param array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}. 96 * 97 * @return static This object to support chaining. 98 * 99 * @since 1.5 100 * @todo This should be done as a view, not here! 101 */ 102 public function display($cachable = false, $urlparams = array()) 103 { 104 // Get the document object. 105 $vName = 'tracks'; 106 107 // Get and render the view. 108 if ($view = $this->getView($vName, 'raw')) { 109 // Check for request forgeries. 110 $this->checkToken('GET'); 111 112 // Get the model for the view. 113 /** @var \Joomla\Component\Banners\Administrator\Model\TracksModel $model */ 114 $model = $this->getModel($vName); 115 116 // Load the filter state. 117 $app = $this->app; 118 119 $model->setState('filter.type', $app->getUserState($this->context . '.filter.type')); 120 $model->setState('filter.begin', $app->getUserState($this->context . '.filter.begin')); 121 $model->setState('filter.end', $app->getUserState($this->context . '.filter.end')); 122 $model->setState('filter.category_id', $app->getUserState($this->context . '.filter.category_id')); 123 $model->setState('filter.client_id', $app->getUserState($this->context . '.filter.client_id')); 124 $model->setState('list.limit', 0); 125 $model->setState('list.start', 0); 126 127 $form = $this->input->get('jform', array(), 'array'); 128 129 $model->setState('basename', $form['basename']); 130 $model->setState('compressed', $form['compressed']); 131 132 // Create one year cookies. 133 $cookieLifeTime = time() + 365 * 86400; 134 $cookieDomain = $app->get('cookie_domain', ''); 135 $cookiePath = $app->get('cookie_path', '/'); 136 $isHttpsForced = $app->isHttpsForced(); 137 138 $this->input->cookie->set( 139 ApplicationHelper::getHash($this->context . '.basename'), 140 $form['basename'], 141 $cookieLifeTime, 142 $cookiePath, 143 $cookieDomain, 144 $isHttpsForced, 145 true 146 ); 147 148 $this->input->cookie->set( 149 ApplicationHelper::getHash($this->context . '.compressed'), 150 $form['compressed'], 151 $cookieLifeTime, 152 $cookiePath, 153 $cookieDomain, 154 $isHttpsForced, 155 true 156 ); 157 158 // Push the model into the view (as default). 159 $view->setModel($model, true); 160 161 // Push document object into the view. 162 $view->document = $this->app->getDocument(); 163 164 $view->display(); 165 } 166 167 return $this; 168 } 169 }
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 |