[ 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_content 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\Content\Administrator\View\Featured; 12 13 use Joomla\CMS\Component\ComponentHelper; 14 use Joomla\CMS\Factory; 15 use Joomla\CMS\Language\Multilanguage; 16 use Joomla\CMS\Language\Text; 17 use Joomla\CMS\MVC\View\GenericDataException; 18 use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; 19 use Joomla\CMS\Plugin\PluginHelper; 20 use Joomla\CMS\Toolbar\Toolbar; 21 use Joomla\CMS\Toolbar\ToolbarHelper; 22 use Joomla\Component\Content\Administrator\Extension\ContentComponent; 23 use Joomla\Component\Content\Administrator\Helper\ContentHelper; 24 25 // phpcs:disable PSR1.Files.SideEffects 26 \defined('_JEXEC') or die; 27 // phpcs:enable PSR1.Files.SideEffects 28 29 /** 30 * View class for a list of featured articles. 31 * 32 * @since 1.6 33 */ 34 class HtmlView extends BaseHtmlView 35 { 36 /** 37 * An array of items 38 * 39 * @var array 40 */ 41 protected $items; 42 43 /** 44 * The pagination object 45 * 46 * @var \Joomla\CMS\Pagination\Pagination 47 */ 48 protected $pagination; 49 50 /** 51 * The model state 52 * 53 * @var \Joomla\CMS\Object\CMSObject 54 */ 55 protected $state; 56 57 /** 58 * Form object for search filters 59 * 60 * @var \Joomla\CMS\Form\Form 61 */ 62 public $filterForm; 63 64 /** 65 * The active search filters 66 * 67 * @var array 68 */ 69 public $activeFilters; 70 71 /** 72 * All transition, which can be executed of one if the items 73 * 74 * @var array 75 */ 76 protected $transitions = []; 77 78 /** 79 * Is this view an Empty State 80 * 81 * @var boolean 82 * @since 4.0.0 83 */ 84 private $isEmptyState = false; 85 86 /** 87 * Display the view 88 * 89 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 90 * 91 * @return void 92 */ 93 public function display($tpl = null) 94 { 95 $this->items = $this->get('Items'); 96 $this->pagination = $this->get('Pagination'); 97 $this->state = $this->get('State'); 98 $this->filterForm = $this->get('FilterForm'); 99 $this->activeFilters = $this->get('ActiveFilters'); 100 $this->vote = PluginHelper::isEnabled('content', 'vote'); 101 $this->hits = ComponentHelper::getParams('com_content')->get('record_hits', 1); 102 103 if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) { 104 $this->setLayout('emptystate'); 105 } 106 107 if (ComponentHelper::getParams('com_content')->get('workflow_enabled')) { 108 PluginHelper::importPlugin('workflow'); 109 110 $this->transitions = $this->get('Transitions'); 111 } 112 113 // Check for errors. 114 if (\count($errors = $this->get('Errors'))) { 115 throw new GenericDataException(implode("\n", $errors), 500); 116 } 117 118 $this->addToolbar(); 119 120 // We do not need to filter by language when multilingual is disabled 121 if (!Multilanguage::isEnabled()) { 122 unset($this->activeFilters['language']); 123 $this->filterForm->removeField('language', 'filter'); 124 } 125 126 parent::display($tpl); 127 } 128 129 /** 130 * Add the page title and toolbar. 131 * 132 * @return void 133 * 134 * @since 1.6 135 */ 136 protected function addToolbar() 137 { 138 $canDo = ContentHelper::getActions('com_content', 'category', $this->state->get('filter.category_id')); 139 $user = Factory::getApplication()->getIdentity(); 140 141 // Get the toolbar object instance 142 $toolbar = Toolbar::getInstance('toolbar'); 143 144 ToolbarHelper::title(Text::_('COM_CONTENT_FEATURED_TITLE'), 'star featured'); 145 146 if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_content', 'core.create')) > 0) { 147 $toolbar->addNew('article.add'); 148 } 149 150 if (!$this->isEmptyState && ($canDo->get('core.edit.state') || \count($this->transitions))) { 151 $dropdown = $toolbar->dropdownButton('status-group') 152 ->text('JTOOLBAR_CHANGE_STATUS') 153 ->toggleSplit(false) 154 ->icon('icon-ellipsis-h') 155 ->buttonClass('btn btn-action') 156 ->listCheck(true); 157 158 $childBar = $dropdown->getChildToolbar(); 159 160 if (\count($this->transitions)) { 161 $childBar->separatorButton('transition-headline') 162 ->text('COM_CONTENT_RUN_TRANSITIONS') 163 ->buttonClass('text-center py-2 h3'); 164 165 $cmd = "Joomla.submitbutton('articles.runTransition');"; 166 $messages = "{error: [Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')]}"; 167 $alert = 'Joomla.renderMessages(' . $messages . ')'; 168 $cmd = 'if (document.adminForm.boxchecked.value == 0) { ' . $alert . ' } else { ' . $cmd . ' }'; 169 170 foreach ($this->transitions as $transition) { 171 $childBar->standardButton('transition') 172 ->text($transition['text']) 173 ->buttonClass('transition-' . (int) $transition['value']) 174 ->icon('icon-project-diagram') 175 ->onclick('document.adminForm.transition_id.value=' . (int) $transition['value'] . ';' . $cmd); 176 } 177 178 $childBar->separatorButton('transition-separator'); 179 } 180 181 if ($canDo->get('core.edit.state')) { 182 $childBar->publish('articles.publish')->listCheck(true); 183 184 $childBar->unpublish('articles.unpublish')->listCheck(true); 185 186 $childBar->standardButton('unfeatured') 187 ->text('JUNFEATURE') 188 ->task('articles.unfeatured') 189 ->listCheck(true); 190 191 $childBar->archive('articles.archive')->listCheck(true); 192 193 $childBar->checkin('articles.checkin')->listCheck(true); 194 195 if (!$this->state->get('filter.published') == ContentComponent::CONDITION_TRASHED) { 196 $childBar->trash('articles.trash')->listCheck(true); 197 } 198 } 199 } 200 201 if (!$this->isEmptyState && $this->state->get('filter.published') == ContentComponent::CONDITION_TRASHED && $canDo->get('core.delete')) { 202 $toolbar->delete('articles.delete') 203 ->text('JTOOLBAR_EMPTY_TRASH') 204 ->message('JGLOBAL_CONFIRM_DELETE') 205 ->listCheck(true); 206 } 207 208 if ($user->authorise('core.admin', 'com_content') || $user->authorise('core.options', 'com_content')) { 209 $toolbar->preferences('com_content'); 210 } 211 212 ToolbarHelper::help('Articles:_Featured'); 213 } 214 }
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 |