[ 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_newsfeeds 6 * 7 * @copyright (C) 2008 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\Newsfeeds\Administrator\View\Newsfeeds; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Helper\ContentHelper; 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\Object\CMSObject; 20 use Joomla\CMS\Toolbar\Toolbar; 21 use Joomla\CMS\Toolbar\ToolbarHelper; 22 23 // phpcs:disable PSR1.Files.SideEffects 24 \defined('_JEXEC') or die; 25 // phpcs:enable PSR1.Files.SideEffects 26 27 /** 28 * View class for a list of newsfeeds. 29 * 30 * @since 1.6 31 */ 32 class HtmlView extends BaseHtmlView 33 { 34 /** 35 * The list of newsfeeds 36 * 37 * @var CMSObject 38 * 39 * @since 1.6 40 */ 41 protected $items; 42 43 /** 44 * The pagination object 45 * 46 * @var \Joomla\CMS\Pagination\Pagination 47 * 48 * @since 1.6 49 */ 50 protected $pagination; 51 52 /** 53 * The model state 54 * 55 * @var CMSObject 56 * 57 * @since 1.6 58 */ 59 protected $state; 60 61 /** 62 * Is this view an Empty State 63 * 64 * @var boolean 65 * 66 * @since 4.0.0 67 */ 68 private $isEmptyState = false; 69 70 /** 71 * Execute and display a template script. 72 * 73 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 74 * 75 * @return void 76 * 77 * @since 1.6 78 */ 79 public function display($tpl = null) 80 { 81 $this->items = $this->get('Items'); 82 $this->pagination = $this->get('Pagination'); 83 $this->state = $this->get('State'); 84 $this->filterForm = $this->get('FilterForm'); 85 $this->activeFilters = $this->get('ActiveFilters'); 86 87 if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) { 88 $this->setLayout('emptystate'); 89 } 90 91 // Check for errors. 92 if (\count($errors = $this->get('Errors'))) { 93 throw new GenericDataException(implode("\n", $errors), 500); 94 } 95 96 // We don't need toolbar in the modal layout. 97 if ($this->getLayout() !== 'modal') { 98 $this->addToolbar(); 99 100 // We do not need to filter by language when multilingual is disabled 101 if (!Multilanguage::isEnabled()) { 102 unset($this->activeFilters['language']); 103 $this->filterForm->removeField('language', 'filter'); 104 } 105 } else { 106 // In article associations modal we need to remove language filter if forcing a language. 107 // We also need to change the category filter to show show categories with All or the forced language. 108 if ($forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'CMD')) { 109 // If the language is forced we can't allow to select the language, so transform the language selector filter into a hidden field. 110 $languageXml = new \SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />'); 111 $this->filterForm->setField($languageXml, 'filter', true); 112 113 // Also, unset the active language filter so the search tools is not open by default with this filter. 114 unset($this->activeFilters['language']); 115 116 // One last changes needed is to change the category filter to just show categories with All language or with the forced language. 117 $this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter'); 118 } 119 } 120 121 parent::display($tpl); 122 } 123 124 /** 125 * Add the page title and toolbar. 126 * 127 * @return void 128 * 129 * @since 1.6 130 */ 131 protected function addToolbar() 132 { 133 $state = $this->get('State'); 134 $canDo = ContentHelper::getActions('com_newsfeeds', 'category', $state->get('filter.category_id')); 135 $user = Factory::getApplication()->getIdentity(); 136 137 // Get the toolbar object instance 138 $toolbar = Toolbar::getInstance('toolbar'); 139 140 ToolbarHelper::title(Text::_('COM_NEWSFEEDS_MANAGER_NEWSFEEDS'), 'rss newsfeeds'); 141 142 if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_newsfeeds', 'core.create')) > 0) { 143 $toolbar->addNew('newsfeed.add'); 144 } 145 146 if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $user->authorise('core.admin'))) { 147 $dropdown = $toolbar->dropdownButton('status-group') 148 ->text('JTOOLBAR_CHANGE_STATUS') 149 ->toggleSplit(false) 150 ->icon('icon-ellipsis-h') 151 ->buttonClass('btn btn-action') 152 ->listCheck(true); 153 154 $childBar = $dropdown->getChildToolbar(); 155 156 $childBar->publish('newsfeeds.publish')->listCheck(true); 157 $childBar->unpublish('newsfeeds.unpublish')->listCheck(true); 158 $childBar->archive('newsfeeds.archive')->listCheck(true); 159 160 if ($user->authorise('core.admin')) { 161 $childBar->checkin('newsfeeds.checkin')->listCheck(true); 162 } 163 164 if ($this->state->get('filter.published') != -2) { 165 $childBar->trash('newsfeeds.trash')->listCheck(true); 166 } 167 168 // Add a batch button 169 if ( 170 $user->authorise('core.create', 'com_newsfeeds') 171 && $user->authorise('core.edit', 'com_newsfeeds') 172 && $user->authorise('core.edit.state', 'com_newsfeeds') 173 ) { 174 $childBar->popupButton('batch') 175 ->text('JTOOLBAR_BATCH') 176 ->selector('collapseModal') 177 ->listCheck(true); 178 } 179 } 180 181 if (!$this->isEmptyState && $state->get('filter.published') == -2 && $canDo->get('core.delete')) { 182 $toolbar->delete('newsfeeds.delete') 183 ->text('JTOOLBAR_EMPTY_TRASH') 184 ->message('JGLOBAL_CONFIRM_DELETE') 185 ->listCheck(true); 186 } 187 188 if ($user->authorise('core.admin', 'com_newsfeeds') || $user->authorise('core.options', 'com_newsfeeds')) { 189 $toolbar->preferences('com_newsfeeds'); 190 } 191 192 $toolbar->help('News_Feeds'); 193 } 194 }
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 |