[ 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) 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\Banners\Administrator\Controller; 12 13 use Joomla\CMS\Application\CMSApplication; 14 use Joomla\CMS\Language\Text; 15 use Joomla\CMS\MVC\Controller\AdminController; 16 use Joomla\CMS\MVC\Factory\MVCFactoryInterface; 17 use Joomla\Input\Input; 18 use Joomla\Utilities\ArrayHelper; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('_JEXEC') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * Banners list controller class. 26 * 27 * @since 1.6 28 */ 29 class BannersController extends AdminController 30 { 31 /** 32 * The prefix to use with controller messages. 33 * 34 * @var string 35 * @since 1.6 36 */ 37 protected $text_prefix = 'COM_BANNERS_BANNERS'; 38 39 /** 40 * Constructor. 41 * 42 * @param array $config An optional associative array of configuration settings. 43 * @param MVCFactoryInterface $factory The factory. 44 * @param CMSApplication $app The Application for the dispatcher 45 * @param Input $input Input 46 * 47 * @since 3.0 48 */ 49 public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null) 50 { 51 parent::__construct($config, $factory, $app, $input); 52 53 $this->registerTask('sticky_unpublish', 'sticky_publish'); 54 } 55 56 /** 57 * Method to get a model object, loading it if required. 58 * 59 * @param string $name The model name. Optional. 60 * @param string $prefix The class prefix. Optional. 61 * @param array $config Configuration array for model. Optional. 62 * 63 * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel The model. 64 * 65 * @since 1.6 66 */ 67 public function getModel($name = 'Banner', $prefix = 'Administrator', $config = array('ignore_request' => true)) 68 { 69 return parent::getModel($name, $prefix, $config); 70 } 71 72 /** 73 * Stick items 74 * 75 * @return void 76 * 77 * @since 1.6 78 */ 79 public function sticky_publish() 80 { 81 // Check for request forgeries. 82 $this->checkToken(); 83 84 $ids = (array) $this->input->get('cid', array(), 'int'); 85 $values = array('sticky_publish' => 1, 'sticky_unpublish' => 0); 86 $task = $this->getTask(); 87 $value = ArrayHelper::getValue($values, $task, 0, 'int'); 88 89 // Remove zero values resulting from input filter 90 $ids = array_filter($ids); 91 92 if (empty($ids)) { 93 $this->app->enqueueMessage(Text::_('COM_BANNERS_NO_BANNERS_SELECTED'), 'warning'); 94 } else { 95 // Get the model. 96 /** @var \Joomla\Component\Banners\Administrator\Model\BannerModel $model */ 97 $model = $this->getModel(); 98 99 // Change the state of the records. 100 if (!$model->stick($ids, $value)) { 101 $this->app->enqueueMessage($model->getError(), 'warning'); 102 } else { 103 if ($value == 1) { 104 $ntext = 'COM_BANNERS_N_BANNERS_STUCK'; 105 } else { 106 $ntext = 'COM_BANNERS_N_BANNERS_UNSTUCK'; 107 } 108 109 $this->setMessage(Text::plural($ntext, \count($ids))); 110 } 111 } 112 113 $this->setRedirect('index.php?option=com_banners&view=banners'); 114 } 115 }
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 |