- md5
- d57d4896c2c0d1ff1698d3d61774176a
- sha1
- 778a2c33354ea282643c8fc6da201a8e387ef8f1
- sha256
- 5a4e08e2abc818d7e825c67b5ad43be0a925e7c27d0aab55ece39b190f02e7ce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors-xtd.menu
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\EditorsXtd\Menu\Extension;
use Joomla\CMS\Editor\Button\Button;
use Joomla\CMS\Event\Editor\EditorButtonsSetupEvent;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Session\Session;
use Joomla\Event\SubscriberInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Editor menu button
*
* @since 3.7.0
*/
final class Menu extends CMSPlugin implements SubscriberInterface
{
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 5.2.0
*/
public static function getSubscribedEvents(): array
{
return ['onEditorButtonsSetup' => 'onEditorButtonsSetup'];
}
/**
* @param EditorButtonsSetupEvent $event
* @return void
*
* @since 5.2.0
*/
public function onEditorButtonsSetup(EditorButtonsSetupEvent $event): void
{
$subject = $event->getButtonsRegistry();
$disabled = $event->getDisabledButtons();
if (\in_array($this->_name, $disabled)) {
return;
}
$button = $this->onDisplay($event->getEditorId());
if ($button) {
$subject->add($button);
}
}
/**
* Display the button
*
* @param string $name The name of the button to add
*
* @return Button|void The button options as Button object
*
* @since 3.7.0
*
* @deprecated 5.0 Use onEditorButtonsSetup event instead, will be removed in 7.0
*/
public function onDisplay($name)
{
$user = $this->getApplication()->getIdentity();
if (
$user->authorise('core.create', 'com_menus')
|| $user->authorise('core.edit', 'com_menus')
) {
$this->loadLanguage();
$link = 'index.php?option=com_menus&view=items&layout=modal&tmpl=component&'
. Session::getFormToken() . '=1&editor=' . $name;
$button = new Button(
$this->_name,
[
'action' => 'modal',
'link' => $link,
'text' => Text::_('PLG_EDITORS-XTD_MENU_BUTTON_MENU'),
'icon' => 'list',
'iconSVG' => '<svg viewBox="0 0 512 512" width="24" height="24"><path d="M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 1'
. '6 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 '
. '0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H1'
. '76a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16'
. 'v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16'
. 'h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"></path></svg>',
// This is whole Plugin name, it is needed for keeping backward compatibility
'name' => $this->_type . '_' . $this->_name,
]
);
return $button;
}
}
}
The same content is in 32 releases, Joomla 6.0.1-rc1 to 6.2.0-alpha3. See them all, or every version of this file.