[ 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\Newsfeed; 12 13 use Joomla\CMS\Component\ComponentHelper; 14 use Joomla\CMS\Factory; 15 use Joomla\CMS\Helper\ContentHelper; 16 use Joomla\CMS\Language\Associations; 17 use Joomla\CMS\Language\Text; 18 use Joomla\CMS\MVC\View\GenericDataException; 19 use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; 20 use Joomla\CMS\Toolbar\ToolbarHelper; 21 22 // phpcs:disable PSR1.Files.SideEffects 23 \defined('_JEXEC') or die; 24 // phpcs:enable PSR1.Files.SideEffects 25 26 /** 27 * View to edit a newsfeed. 28 * 29 * @since 1.6 30 */ 31 class HtmlView extends BaseHtmlView 32 { 33 /** 34 * The item object for the newsfeed 35 * 36 * @var \Joomla\CMS\Object\CMSObject 37 * 38 * @since 1.6 39 */ 40 protected $item; 41 42 /** 43 * The form object for the newsfeed 44 * 45 * @var \Joomla\CMS\Form\Form 46 * 47 * @since 1.6 48 */ 49 protected $form; 50 51 /** 52 * The model state of the newsfeed 53 * 54 * @var \Joomla\CMS\Object\CMSObject 55 * 56 * @since 1.6 57 */ 58 protected $state; 59 60 /** 61 * Execute and display a template script. 62 * 63 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 64 * 65 * @return void 66 * 67 * @since 1.6 68 */ 69 public function display($tpl = null) 70 { 71 $this->state = $this->get('State'); 72 $this->item = $this->get('Item'); 73 $this->form = $this->get('Form'); 74 75 // Check for errors. 76 if (count($errors = $this->get('Errors'))) { 77 throw new GenericDataException(implode("\n", $errors), 500); 78 } 79 80 // If we are forcing a language in modal (used for associations). 81 if ($this->getLayout() === 'modal' && $forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'cmd')) { 82 // Set the language field to the forcedLanguage and disable changing it. 83 $this->form->setValue('language', null, $forcedLanguage); 84 $this->form->setFieldAttribute('language', 'readonly', 'true'); 85 86 // Only allow to select categories with All language or with the forced language. 87 $this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage); 88 89 // Only allow to select tags with All language or with the forced language. 90 $this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage); 91 } 92 93 $this->addToolbar(); 94 parent::display($tpl); 95 } 96 97 /** 98 * Add the page title and toolbar. 99 * 100 * @return void 101 * 102 * @since 1.6 103 */ 104 protected function addToolbar() 105 { 106 Factory::getApplication()->input->set('hidemainmenu', true); 107 108 $user = $this->getCurrentUser(); 109 $isNew = ($this->item->id == 0); 110 $checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id')); 111 112 // Since we don't track these assets at the item level, use the category id. 113 $canDo = ContentHelper::getActions('com_newsfeeds', 'category', $this->item->catid); 114 115 $title = $isNew ? Text::_('COM_NEWSFEEDS_MANAGER_NEWSFEED_NEW') : Text::_('COM_NEWSFEEDS_MANAGER_NEWSFEED_EDIT'); 116 ToolbarHelper::title($title, 'rss newsfeeds'); 117 118 $toolbarButtons = []; 119 120 // If not checked out, can save the item. 121 if (!$checkedOut && ($canDo->get('core.edit') || count($user->getAuthorisedCategories('com_newsfeeds', 'core.create')) > 0)) { 122 ToolbarHelper::apply('newsfeed.apply'); 123 124 $toolbarButtons[] = ['save', 'newsfeed.save']; 125 } 126 127 if (!$checkedOut && count($user->getAuthorisedCategories('com_newsfeeds', 'core.create')) > 0) { 128 $toolbarButtons[] = ['save2new', 'newsfeed.save2new']; 129 } 130 131 // If an existing item, can save to a copy. 132 if (!$isNew && $canDo->get('core.create')) { 133 $toolbarButtons[] = ['save2copy', 'newsfeed.save2copy']; 134 } 135 136 ToolbarHelper::saveGroup( 137 $toolbarButtons, 138 'btn-success' 139 ); 140 141 if (empty($this->item->id)) { 142 ToolbarHelper::cancel('newsfeed.cancel'); 143 } else { 144 ToolbarHelper::cancel('newsfeed.cancel', 'JTOOLBAR_CLOSE'); 145 146 if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $canDo->get('core.edit')) { 147 ToolbarHelper::versions('com_newsfeeds.newsfeed', $this->item->id); 148 } 149 } 150 151 if (!$isNew && Associations::isEnabled() && ComponentHelper::isEnabled('com_associations')) { 152 ToolbarHelper::custom('newsfeed.editAssociations', 'contract', '', 'JTOOLBAR_ASSOCIATIONS', false, false); 153 } 154 155 ToolbarHelper::divider(); 156 ToolbarHelper::help('News_Feeds:_New_or_Edit'); 157 } 158 }
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 |