[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Plugin 5 * @subpackage Editors-xtd.pagebreak 6 * 7 * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 10 * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace 11 */ 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Language\Text; 15 use Joomla\CMS\Object\CMSObject; 16 use Joomla\CMS\Plugin\CMSPlugin; 17 18 // phpcs:disable PSR1.Files.SideEffects 19 \defined('_JEXEC') or die; 20 // phpcs:enable PSR1.Files.SideEffects 21 22 /** 23 * Editor Pagebreak button 24 * 25 * @since 1.5 26 */ 27 class PlgButtonPagebreak extends CMSPlugin 28 { 29 /** 30 * Load the language file on instantiation. 31 * 32 * @var boolean 33 * @since 3.1 34 */ 35 protected $autoloadLanguage = true; 36 37 /** 38 * Display the button 39 * 40 * @param string $name The name of the button to add 41 * 42 * @return CMSObject|void The button options as CMSObject 43 * 44 * @since 1.5 45 */ 46 public function onDisplay($name) 47 { 48 $user = Factory::getUser(); 49 50 // Can create in any category (component permission) or at least in one category 51 $canCreateRecords = $user->authorise('core.create', 'com_content') 52 || count($user->getAuthorisedCategories('com_content', 'core.create')) > 0; 53 54 // Instead of checking edit on all records, we can use **same** check as the form editing view 55 $values = (array) Factory::getApplication()->getUserState('com_content.edit.article.id'); 56 $isEditingRecords = count($values); 57 58 // This ACL check is probably a double-check (form view already performed checks) 59 $hasAccess = $canCreateRecords || $isEditingRecords; 60 if (!$hasAccess) { 61 return; 62 } 63 64 Factory::getDocument()->addScriptOptions('xtd-pagebreak', array('editor' => $name)); 65 $link = 'index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=' . $name; 66 67 $button = new CMSObject(); 68 $button->modal = true; 69 $button->link = $link; 70 $button->text = Text::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK'); 71 $button->name = $this->_type . '_' . $this->_name; 72 $button->icon = 'copy'; 73 $button->iconSVG = '<svg viewBox="0 0 32 32" width="24" height="24"><path d="M26 8h-6v-2l-6-6h-14v24h12v8h20v-18l-6-6zM26 10.828l3.172 3' 74 . '.172h-3.172v-3.172zM14 2.828l3.172 3.172h-3.172v-3.172zM2 2h10v6h6v14h-16v-20zM30 30h-16v-6h6v-14h4v6h6v14z"></pa' 75 . 'th></svg>'; 76 $button->options = [ 77 'height' => '200px', 78 'width' => '400px', 79 'bodyHeight' => '70', 80 'modalWidth' => '80', 81 ]; 82 83 return $button; 84 } 85 }
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 |