first commit
This commit is contained in:
21
plugins/editors-xtd/article/article.xml
Normal file
21
plugins/editors-xtd/article/article.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="editors-xtd" method="upgrade">
|
||||
<name>plg_editors-xtd_article</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2009-10</creationDate>
|
||||
<copyright>(C) 2009 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>PLG_ARTICLE_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\EditorsXtd\Article</namespace>
|
||||
<files>
|
||||
<folder plugin="article">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_article.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_article.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/editors-xtd/article/services/provider.php
Normal file
46
plugins/editors-xtd/article/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.article
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\EditorsXtd\Article\Extension\Article;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new Article(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('editors-xtd', 'article')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
115
plugins/editors-xtd/article/src/Extension/Article.php
Normal file
115
plugins/editors-xtd/article/src/Extension/Article.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.article
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\EditorsXtd\Article\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 Article button
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
final class Article extends CMSPlugin implements SubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Returns an array of events this subscriber will listen to.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return ['onEditorButtonsSetup' => 'onEditorButtonsSetup'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EditorButtonsSetupEvent $event
|
||||
* @return void
|
||||
*
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function onEditorButtonsSetup(EditorButtonsSetupEvent $event)
|
||||
{
|
||||
$subject = $event->getButtonsRegistry();
|
||||
$disabled = $event->getDisabledButtons();
|
||||
|
||||
if (\in_array($this->_name, $disabled)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->loadLanguage();
|
||||
|
||||
$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, void if ACL check fails.
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @deprecated 6.0 Use onEditorButtonsSetup event
|
||||
*/
|
||||
public function onDisplay($name)
|
||||
{
|
||||
$user = $this->getApplication()->getIdentity();
|
||||
|
||||
// Can create in any category (component permission) or at least in one category
|
||||
$canCreateRecords = $user->authorise('core.create', 'com_content')
|
||||
|| \count($user->getAuthorisedCategories('com_content', 'core.create')) > 0;
|
||||
|
||||
// Instead of checking edit on all records, we can use **same** check as the form editing view
|
||||
$values = (array) $this->getApplication()->getUserState('com_content.edit.article.id');
|
||||
$isEditingRecords = \count($values);
|
||||
|
||||
// This ACL check is probably a double-check (form view already performed checks)
|
||||
$hasAccess = $canCreateRecords || $isEditingRecords;
|
||||
if (!$hasAccess) {
|
||||
return;
|
||||
}
|
||||
|
||||
$link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&'
|
||||
. Session::getFormToken() . '=1&editor=' . $name;
|
||||
|
||||
$button = new Button(
|
||||
$this->_name,
|
||||
[
|
||||
'action' => 'modal',
|
||||
'link' => $link,
|
||||
'text' => Text::_('PLG_ARTICLE_BUTTON_ARTICLE'),
|
||||
'icon' => 'file-add',
|
||||
'iconSVG' => '<svg viewBox="0 0 32 32" width="24" height="24"><path d="M28 24v-4h-4v4h-4v4h4v4h4v-4h4v-4zM2 2h18v6h6v10h2v-10l-8-'
|
||||
. '8h-20v32h18v-2h-16z"></path></svg>',
|
||||
// This is whole Plugin name, it is needed for keeping backward compatibility
|
||||
'name' => $this->_type . '_' . $this->_name,
|
||||
]
|
||||
);
|
||||
|
||||
return $button;
|
||||
}
|
||||
}
|
||||
21
plugins/editors-xtd/contact/contact.xml
Normal file
21
plugins/editors-xtd/contact/contact.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="editors-xtd" method="upgrade">
|
||||
<name>plg_editors-xtd_contact</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2016-10</creationDate>
|
||||
<copyright>(C) 2016 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.7.0</version>
|
||||
<description>PLG_EDITORS-XTD_CONTACT_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\EditorsXtd\Contact</namespace>
|
||||
<files>
|
||||
<folder plugin="contact">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_contact.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_contact.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/editors-xtd/contact/services/provider.php
Normal file
46
plugins/editors-xtd/contact/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.contact
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\EditorsXtd\Contact\Extension\Contact;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new Contact(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('editors-xtd', 'contact')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
75
plugins/editors-xtd/contact/src/Extension/Contact.php
Normal file
75
plugins/editors-xtd/contact/src/Extension/Contact.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.contact
|
||||
*
|
||||
* @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\Contact\Extension;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Editor Contact button
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Contact extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Display the button
|
||||
*
|
||||
* @param string $name The name of the button to add
|
||||
*
|
||||
* @return CMSObject|void The button options as CMSObject
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function onDisplay($name)
|
||||
{
|
||||
$user = $this->getApplication()->getIdentity();
|
||||
|
||||
if (
|
||||
$user->authorise('core.create', 'com_contact')
|
||||
|| $user->authorise('core.edit', 'com_contact')
|
||||
|| $user->authorise('core.edit.own', 'com_contact')
|
||||
) {
|
||||
// The URL for the contacts list
|
||||
$link = 'index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&'
|
||||
. Session::getFormToken() . '=1&editor=' . $name;
|
||||
|
||||
$button = new CMSObject();
|
||||
$button->action = 'modal';
|
||||
$button->link = $link;
|
||||
$button->text = Text::_('PLG_EDITORS-XTD_CONTACT_BUTTON_CONTACT');
|
||||
$button->name = $this->_type . '_' . $this->_name;
|
||||
$button->icon = 'address';
|
||||
$button->iconSVG = '<svg viewBox="0 0 448 512" width="24" height="24"><path d="M436 160c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-20V48c'
|
||||
. '0-26.5-21.5-48-48-48H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h320c26.5 0 48-21.5 48-48v-48h20c6.6 0 12-5.4 1'
|
||||
. '2-12v-40c0-6.6-5.4-12-12-12h-20v-64h20c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-20v-64h20zm-228-32c35.3 0 64 28.7'
|
||||
. ' 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zm112 236.8c0 10.6-10 19.2-22.4 19.2H118.4C106 384 96 375.4 96 364.'
|
||||
. '8v-19.2c0-31.8 30.1-57.6 67.2-57.6h5c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h5c37.1 0 67.2 25.8 67.2 57.6v19.2z">'
|
||||
. '</path></svg>';
|
||||
|
||||
return $button;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
plugins/editors-xtd/fields/fields.xml
Normal file
21
plugins/editors-xtd/fields/fields.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="editors-xtd" method="upgrade">
|
||||
<name>plg_editors-xtd_fields</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2017-02</creationDate>
|
||||
<copyright>(C) 2017 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.7.0</version>
|
||||
<description>PLG_EDITORS-XTD_FIELDS_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\EditorsXtd\Fields</namespace>
|
||||
<files>
|
||||
<folder plugin="fields">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_fields.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_fields.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/editors-xtd/fields/services/provider.php
Normal file
46
plugins/editors-xtd/fields/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.fields
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\EditorsXtd\Fields\Extension\Fields;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new Fields(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('editors-xtd', 'fields')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
82
plugins/editors-xtd/fields/src/Extension/Fields.php
Normal file
82
plugins/editors-xtd/fields/src/Extension/Fields.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.fields
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\EditorsXtd\Fields\Extension;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Editor Fields button
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Fields extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Display the button
|
||||
*
|
||||
* @param string $name The name of the button to add
|
||||
*
|
||||
* @return CMSObject|void The button options as CMSObject
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function onDisplay($name)
|
||||
{
|
||||
// Check if com_fields is enabled
|
||||
if (!ComponentHelper::isEnabled('com_fields')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Guess the field context based on view.
|
||||
$jinput = $this->getApplication()->getInput();
|
||||
$context = $jinput->get('option') . '.' . $jinput->get('view');
|
||||
|
||||
// Special context for com_categories
|
||||
if ($context === 'com_categories.category') {
|
||||
$context = $jinput->get('extension', 'com_content') . '.categories';
|
||||
}
|
||||
|
||||
$link = 'index.php?option=com_fields&view=fields&layout=modal&tmpl=component&context='
|
||||
. $context . '&editor=' . $name . '&' . Session::getFormToken() . '=1';
|
||||
|
||||
$button = new CMSObject();
|
||||
$button->action = 'modal';
|
||||
$button->link = $link;
|
||||
$button->text = Text::_('PLG_EDITORS-XTD_FIELDS_BUTTON_FIELD');
|
||||
$button->name = $this->_type . '_' . $this->_name;
|
||||
$button->icon = 'puzzle';
|
||||
$button->iconSVG = '<svg viewBox="0 0 576 512" width="24" height="24"><path d="M519.442 288.651c-41.519 0-59.5 31.593-82.058 31.593C377.'
|
||||
. '409 320.244 432 144 432 144s-196.288 80-196.288-3.297c0-35.827 36.288-46.25 36.288-85.985C272 19.216 243.885 0 210.'
|
||||
. '539 0c-34.654 0-66.366 18.891-66.366 56.346 0 41.364 31.711 59.277 31.711 81.75C175.885 207.719 0 166.758 0 166.758'
|
||||
. 'v333.237s178.635 41.047 178.635-28.662c0-22.473-40-40.107-40-81.471 0-37.456 29.25-56.346 63.577-56.346 33.673 0 61'
|
||||
. '.788 19.216 61.788 54.717 0 39.735-36.288 50.158-36.288 85.985 0 60.803 129.675 25.73 181.23 25.73 0 0-34.725-120.1'
|
||||
. '01 25.827-120.101 35.962 0 46.423 36.152 86.308 36.152C556.712 416 576 387.99 576 354.443c0-34.199-18.962-65.792-56'
|
||||
. '.558-65.792z"></path></svg>';
|
||||
|
||||
return $button;
|
||||
}
|
||||
}
|
||||
21
plugins/editors-xtd/image/image.xml
Normal file
21
plugins/editors-xtd/image/image.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="editors-xtd" method="upgrade">
|
||||
<name>plg_editors-xtd_image</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2004-08</creationDate>
|
||||
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>PLG_IMAGE_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\EditorsXtd\Image</namespace>
|
||||
<files>
|
||||
<folder plugin="image">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_image.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_image.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/editors-xtd/image/services/provider.php
Normal file
46
plugins/editors-xtd/image/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.image
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\EditorsXtd\Image\Extension\Image;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new Image(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('editors-xtd', 'image')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
176
plugins/editors-xtd/image/src/Extension/Image.php
Normal file
176
plugins/editors-xtd/image/src/Extension/Image.php
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.image
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\EditorsXtd\Image\Extension;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Editor Image button
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
final class Image extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.1
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Display the button.
|
||||
*
|
||||
* @param string $name The name of the button to display.
|
||||
* @param string $asset The name of the asset being edited.
|
||||
* @param integer $author The id of the author owning the asset being edited.
|
||||
*
|
||||
* @return CMSObject|false
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function onDisplay($name, $asset, $author)
|
||||
{
|
||||
$doc = $this->getApplication()->getDocument();
|
||||
$user = $this->getApplication()->getIdentity();
|
||||
$extension = $this->getApplication()->getInput()->get('option');
|
||||
|
||||
// For categories we check the extension (ex: component.section)
|
||||
if ($extension === 'com_categories') {
|
||||
$parts = explode('.', $this->getApplication()->getInput()->get('extension', 'com_content'));
|
||||
$extension = $parts[0];
|
||||
}
|
||||
|
||||
$asset = $asset !== '' ? $asset : $extension;
|
||||
|
||||
if (
|
||||
$user->authorise('core.edit', $asset)
|
||||
|| $user->authorise('core.create', $asset)
|
||||
|| (\count($user->getAuthorisedCategories($asset, 'core.create')) > 0)
|
||||
|| ($user->authorise('core.edit.own', $asset) && $author === $user->id)
|
||||
|| (\count($user->getAuthorisedCategories($extension, 'core.edit')) > 0)
|
||||
|| (\count($user->getAuthorisedCategories($extension, 'core.edit.own')) > 0 && $author === $user->id)
|
||||
) {
|
||||
$doc->getWebAssetManager()
|
||||
->useScript('webcomponent.media-select')
|
||||
->useScript('webcomponent.field-media')
|
||||
->useStyle('webcomponent.media-select');
|
||||
|
||||
$doc->addScriptOptions('xtdImageModal', [$name . '_ImageModal']);
|
||||
$doc->addScriptOptions('media-picker-api', ['apiBaseUrl' => Uri::base() . 'index.php?option=com_media&format=json']);
|
||||
|
||||
if (\count($doc->getScriptOptions('media-picker')) === 0) {
|
||||
$imagesExt = array_map(
|
||||
'trim',
|
||||
explode(
|
||||
',',
|
||||
ComponentHelper::getParams('com_media')->get(
|
||||
'image_extensions',
|
||||
'bmp,gif,jpg,jpeg,png,webp'
|
||||
)
|
||||
)
|
||||
);
|
||||
$audiosExt = array_map(
|
||||
'trim',
|
||||
explode(
|
||||
',',
|
||||
ComponentHelper::getParams('com_media')->get(
|
||||
'audio_extensions',
|
||||
'mp3,m4a,mp4a,ogg'
|
||||
)
|
||||
)
|
||||
);
|
||||
$videosExt = array_map(
|
||||
'trim',
|
||||
explode(
|
||||
',',
|
||||
ComponentHelper::getParams('com_media')->get(
|
||||
'video_extensions',
|
||||
'mp4,mp4v,mpeg,mov,webm'
|
||||
)
|
||||
)
|
||||
);
|
||||
$documentsExt = array_map(
|
||||
'trim',
|
||||
explode(
|
||||
',',
|
||||
ComponentHelper::getParams('com_media')->get(
|
||||
'doc_extensions',
|
||||
'doc,odg,odp,ods,odt,pdf,ppt,txt,xcf,xls,csv'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$doc->addScriptOptions('media-picker', [
|
||||
'images' => $imagesExt,
|
||||
'audios' => $audiosExt,
|
||||
'videos' => $videosExt,
|
||||
'documents' => $documentsExt,
|
||||
]);
|
||||
}
|
||||
|
||||
Text::script('JFIELD_MEDIA_LAZY_LABEL');
|
||||
Text::script('JFIELD_MEDIA_ALT_LABEL');
|
||||
Text::script('JFIELD_MEDIA_ALT_CHECK_LABEL');
|
||||
Text::script('JFIELD_MEDIA_ALT_CHECK_DESC_LABEL');
|
||||
Text::script('JFIELD_MEDIA_CLASS_LABEL');
|
||||
Text::script('JFIELD_MEDIA_FIGURE_CLASS_LABEL');
|
||||
Text::script('JFIELD_MEDIA_FIGURE_CAPTION_LABEL');
|
||||
Text::script('JFIELD_MEDIA_LAZY_LABEL');
|
||||
Text::script('JFIELD_MEDIA_SUMMARY_LABEL');
|
||||
Text::script('JFIELD_MEDIA_EMBED_CHECK_DESC_LABEL');
|
||||
Text::script('JFIELD_MEDIA_DOWNLOAD_CHECK_DESC_LABEL');
|
||||
Text::script('JFIELD_MEDIA_DOWNLOAD_CHECK_LABEL');
|
||||
Text::script('JFIELD_MEDIA_EMBED_CHECK_LABEL');
|
||||
Text::script('JFIELD_MEDIA_WIDTH_LABEL');
|
||||
Text::script('JFIELD_MEDIA_TITLE_LABEL');
|
||||
Text::script('JFIELD_MEDIA_HEIGHT_LABEL');
|
||||
Text::script('JFIELD_MEDIA_UNSUPPORTED');
|
||||
Text::script('JFIELD_MEDIA_DOWNLOAD_FILE');
|
||||
|
||||
$link = 'index.php?option=com_media&view=media&tmpl=component&e_name=' . $name . '&asset=' . $asset . '&mediatypes=0,1,2,3' . '&author=' . $author;
|
||||
|
||||
$button = new CMSObject();
|
||||
$button->modal = true;
|
||||
$button->link = $link;
|
||||
$button->text = Text::_('PLG_IMAGE_BUTTON_IMAGE');
|
||||
$button->name = $this->_type . '_' . $this->_name;
|
||||
$button->icon = 'pictures';
|
||||
$button->iconSVG = '<svg width="24" height="24" viewBox="0 0 512 512"><path d="M464 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48'
|
||||
. ' 48 48h416c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm-6 336H54a6 6 0 0 1-6-6V118a6 6 0 0 1 6-6h404a6 6'
|
||||
. ' 0 0 1 6 6v276a6 6 0 0 1-6 6zM128 152c-22.091 0-40 17.909-40 40s17.909 40 40 40 40-17.909 40-40-17.909-40-40-40'
|
||||
. 'zM96 352h320v-80l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L192 304l-39.515-39.515c-4.686-4.686-12.284-4'
|
||||
. '.686-16.971 0L96 304v48z"></path></svg>';
|
||||
$button->options = [
|
||||
'height' => '400px',
|
||||
'width' => '800px',
|
||||
'bodyHeight' => '70',
|
||||
'modalWidth' => '80',
|
||||
'tinyPath' => $link,
|
||||
'confirmCallback' => 'Joomla.getImage(Joomla.selectedMediaFile, \'' . $name . '\', this)',
|
||||
'confirmText' => Text::_('PLG_IMAGE_BUTTON_INSERT'),
|
||||
];
|
||||
|
||||
return $button;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
21
plugins/editors-xtd/menu/menu.xml
Normal file
21
plugins/editors-xtd/menu/menu.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="editors-xtd" method="upgrade">
|
||||
<name>plg_editors-xtd_menu</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2016-08</creationDate>
|
||||
<copyright>(C) 2016 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.7.0</version>
|
||||
<description>PLG_EDITORS-XTD_MENU_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\EditorsXtd\Menu</namespace>
|
||||
<files>
|
||||
<folder plugin="menu">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_menu.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_menu.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/editors-xtd/menu/services/provider.php
Normal file
46
plugins/editors-xtd/menu/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.article
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\EditorsXtd\Menu\Extension\Menu;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new Menu(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('editors-xtd', 'menu')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
76
plugins/editors-xtd/menu/src/Extension/Menu.php
Normal file
76
plugins/editors-xtd/menu/src/Extension/Menu.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?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\Language\Text;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
// 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
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Display the button
|
||||
*
|
||||
* @param string $name The name of the button to add
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return CMSObject
|
||||
*/
|
||||
public function onDisplay($name)
|
||||
{
|
||||
/*
|
||||
* Use the built-in element view to select the menu item.
|
||||
* Currently uses blank class.
|
||||
*/
|
||||
$user = $this->getApplication()->getIdentity();
|
||||
|
||||
if (
|
||||
$user->authorise('core.create', 'com_menus')
|
||||
|| $user->authorise('core.edit', 'com_menus')
|
||||
) {
|
||||
$link = 'index.php?option=com_menus&view=items&layout=modal&tmpl=component&'
|
||||
. Session::getFormToken() . '=1&editor=' . $name;
|
||||
|
||||
$button = new CMSObject();
|
||||
$button->action = 'modal';
|
||||
$button->link = $link;
|
||||
$button->text = Text::_('PLG_EDITORS-XTD_MENU_BUTTON_MENU');
|
||||
$button->name = $this->_type . '_' . $this->_name;
|
||||
$button->icon = 'list';
|
||||
$button->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>';
|
||||
|
||||
return $button;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
plugins/editors-xtd/module/module.xml
Normal file
21
plugins/editors-xtd/module/module.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="editors-xtd" method="upgrade">
|
||||
<name>plg_editors-xtd_module</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2015-10</creationDate>
|
||||
<copyright>(C) 2015 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.5.0</version>
|
||||
<description>PLG_MODULE_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\EditorsXtd\Module</namespace>
|
||||
<files>
|
||||
<folder plugin="module">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_module.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_module.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/editors-xtd/module/services/provider.php
Normal file
46
plugins/editors-xtd/module/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.article
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\EditorsXtd\Module\Extension\Module;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new Module(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('editors-xtd', 'module')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
76
plugins/editors-xtd/module/src/Extension/Module.php
Normal file
76
plugins/editors-xtd/module/src/Extension/Module.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.module
|
||||
*
|
||||
* @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\EditorsXtd\Module\Extension;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Editor Module button
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
final class Module extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.5
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Display the button
|
||||
*
|
||||
* @param string $name The name of the button to add
|
||||
*
|
||||
* @return CMSObject|void The button options as CMSObject
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
public function onDisplay($name)
|
||||
{
|
||||
/*
|
||||
* Use the built-in element view to select the module.
|
||||
* Currently uses blank class.
|
||||
*/
|
||||
$user = $this->getApplication()->getIdentity();
|
||||
|
||||
if (
|
||||
$user->authorise('core.create', 'com_modules')
|
||||
|| $user->authorise('core.edit', 'com_modules')
|
||||
|| $user->authorise('core.edit.own', 'com_modules')
|
||||
) {
|
||||
$link = 'index.php?option=com_modules&view=modules&layout=modal&tmpl=component&'
|
||||
. Session::getFormToken() . '=1&editor=' . $name;
|
||||
|
||||
$button = new CMSObject();
|
||||
$button->action = 'modal';
|
||||
$button->link = $link;
|
||||
$button->text = Text::_('PLG_MODULE_BUTTON_MODULE');
|
||||
$button->name = $this->_type . '_' . $this->_name;
|
||||
$button->icon = 'cube';
|
||||
$button->iconSVG = '<svg viewBox="0 0 512 512" width="24" height="24"><path d="M239.1 6.3l-208 78c-18.7 7-31.1 '
|
||||
. '25-31.1 45v225.1c0 18.2 10.3 34.8 26.5 42.9l208 104c13.5 6.8 29.4 6.8 42.9 0l208-104c16.3-8.1 26.5-24.8 '
|
||||
. '26.5-42.9V129.3c0-20-12.4-37.9-31.1-44.9l-208-78C262 2.2 250 2.2 239.1 6.3zM256 68.4l192 72v1.1l-192 '
|
||||
. '78-192-78v-1.1l192-72zm32 356V275.5l160-65v133.9l-160 80z"></path></svg>';
|
||||
|
||||
return $button;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
plugins/editors-xtd/pagebreak/pagebreak.xml
Normal file
21
plugins/editors-xtd/pagebreak/pagebreak.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="editors-xtd" method="upgrade">
|
||||
<name>plg_editors-xtd_pagebreak</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2004-08</creationDate>
|
||||
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>PLG_EDITORSXTD_PAGEBREAK_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\EditorsXtd\PageBreak</namespace>
|
||||
<files>
|
||||
<folder plugin="pagebreak">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_pagebreak.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_pagebreak.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/editors-xtd/pagebreak/services/provider.php
Normal file
46
plugins/editors-xtd/pagebreak/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.pagebreak
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\EditorsXtd\PageBreak\Extension\PageBreak;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new PageBreak(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('editors-xtd', 'pagebreak')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
84
plugins/editors-xtd/pagebreak/src/Extension/PageBreak.php
Normal file
84
plugins/editors-xtd/pagebreak/src/Extension/PageBreak.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.pagebreak
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\EditorsXtd\PageBreak\Extension;
|
||||
|
||||
use Joomla\CMS\Application\CMSWebApplicationInterface;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Editor Pagebreak button
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
final class PageBreak extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 3.1
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Display the button
|
||||
*
|
||||
* @param string $name The name of the button to add
|
||||
*
|
||||
* @return CMSObject|void The button options as CMSObject
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function onDisplay($name)
|
||||
{
|
||||
$app = $this->getApplication();
|
||||
|
||||
if (!$app instanceof CMSWebApplicationInterface) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $app->getIdentity();
|
||||
|
||||
// Can create in any category (component permission) or at least in one category
|
||||
$canCreateRecords = $user->authorise('core.create', 'com_content')
|
||||
|| \count($user->getAuthorisedCategories('com_content', 'core.create')) > 0;
|
||||
|
||||
// Instead of checking edit on all records, we can use **same** check as the form editing view
|
||||
$values = (array) $app->getUserState('com_content.edit.article.id');
|
||||
$isEditingRecords = \count($values);
|
||||
|
||||
// This ACL check is probably a double-check (form view already performed checks)
|
||||
$hasAccess = $canCreateRecords || $isEditingRecords;
|
||||
if (!$hasAccess) {
|
||||
return;
|
||||
}
|
||||
|
||||
$app->getDocument()->addScriptOptions('xtd-pagebreak', ['editor' => $name]);
|
||||
$link = 'index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=' . $name;
|
||||
|
||||
$button = new CMSObject();
|
||||
$button->action = 'modal';
|
||||
$button->link = $link;
|
||||
$button->text = $app->getLanguage()->_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK');
|
||||
$button->name = $this->_type . '_' . $this->_name;
|
||||
$button->icon = 'copy';
|
||||
$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'
|
||||
. '.172h-3.172v-3.172zM14 2.828l3.172 3.172h-3.172v-3.172zM2 2h10v6h6v14h-16v-20zM30 30h-16v-6h6v-14h4v6h6v14z"></pa'
|
||||
. 'th></svg>';
|
||||
|
||||
return $button;
|
||||
}
|
||||
}
|
||||
21
plugins/editors-xtd/readmore/readmore.xml
Normal file
21
plugins/editors-xtd/readmore/readmore.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="editors-xtd" method="upgrade">
|
||||
<name>plg_editors-xtd_readmore</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2006-03</creationDate>
|
||||
<copyright>(C) 2006 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>PLG_READMORE_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\EditorsXtd\ReadMore</namespace>
|
||||
<files>
|
||||
<folder plugin="readmore">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_readmore.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_editors-xtd_readmore.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/editors-xtd/readmore/services/provider.php
Normal file
46
plugins/editors-xtd/readmore/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.article
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\EditorsXtd\ReadMore\Extension\ReadMore;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$plugin = new ReadMore(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('editors-xtd', 'readmore')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
101
plugins/editors-xtd/readmore/src/Extension/ReadMore.php
Normal file
101
plugins/editors-xtd/readmore/src/Extension/ReadMore.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors-xtd.readmore
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\EditorsXtd\ReadMore\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\Event\SubscriberInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Editor Readmore button
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
final class ReadMore extends CMSPlugin implements SubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Returns an array of events this subscriber will listen to.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return ['onEditorButtonsSetup' => 'onEditorButtonsSetup'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EditorButtonsSetupEvent $event
|
||||
* @return void
|
||||
*
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function onEditorButtonsSetup(EditorButtonsSetupEvent $event)
|
||||
{
|
||||
$subject = $event->getButtonsRegistry();
|
||||
$disabled = $event->getDisabledButtons();
|
||||
|
||||
if (\in_array($this->_name, $disabled)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->loadLanguage();
|
||||
|
||||
$button = $this->onDisplay($event->getEditorId());
|
||||
$subject->add($button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Readmore button
|
||||
*
|
||||
* @param string $name The name of the button to add
|
||||
*
|
||||
* @return Button $button A two element array of (imageName, textToInsert)
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @deprecated 6.0 Use onEditorButtonsSetup event
|
||||
*/
|
||||
public function onDisplay($name)
|
||||
{
|
||||
// Register the asset "editor-button.<button name>", will be loaded by the button layout
|
||||
$this->getApplication()->getDocument()->getWebAssetManager()
|
||||
->registerScript(
|
||||
'editor-button.' . $this->_name,
|
||||
'com_content/admin-article-readmore.min.js',
|
||||
[],
|
||||
['type' => 'module'],
|
||||
['editors', 'joomla.dialog']
|
||||
);
|
||||
|
||||
Text::script('PLG_READMORE_ALREADY_EXISTS');
|
||||
|
||||
$button = new Button(
|
||||
$this->_name,
|
||||
[
|
||||
'action' => 'insert-readmore',
|
||||
'text' => Text::_('PLG_READMORE_BUTTON_READMORE'),
|
||||
'icon' => 'arrow-down',
|
||||
'iconSVG' => '<svg viewBox="0 0 32 32" width="24" height="24"><path d="M32 12l-6-6-10 10-10-10-6 6 16 16z"></path></svg>',
|
||||
// This is whole Plugin name, it is needed for keeping backward compatibility
|
||||
'name' => $this->_type . '_' . $this->_name,
|
||||
]
|
||||
);
|
||||
return $button;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user