first commit
This commit is contained in:
21
plugins/editors/none/none.xml
Normal file
21
plugins/editors/none/none.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="editors" method="upgrade">
|
||||
<name>plg_editors_none</name>
|
||||
<version>3.0.0</version>
|
||||
<creationDate>2005-09</creationDate>
|
||||
<author>Joomla! Project</author>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<description>PLG_NONE_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Editors\None</namespace>
|
||||
<files>
|
||||
<folder plugin="none">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_editors_none.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_editors_none.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
46
plugins/editors/none/services/provider.php
Normal file
46
plugins/editors/none/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors.none
|
||||
*
|
||||
* @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\Editors\None\Extension\None;
|
||||
|
||||
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 None(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('editors', 'none')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
116
plugins/editors/none/src/Extension/None.php
Normal file
116
plugins/editors/none/src/Extension/None.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Editors.none
|
||||
*
|
||||
* @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\Editors\None\Extension;
|
||||
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Event\Event;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Plain Textarea Editor Plugin
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
final class None extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Display the editor area.
|
||||
*
|
||||
* @param string $name The control name.
|
||||
* @param string $content The contents of the text area.
|
||||
* @param string $width The width of the text area (px or %).
|
||||
* @param string $height The height of the text area (px or %).
|
||||
* @param integer $col The number of columns for the textarea.
|
||||
* @param integer $row The number of rows for the textarea.
|
||||
* @param boolean $buttons True and the editor buttons will be displayed.
|
||||
* @param string $id An optional ID for the textarea (note: since 1.6). If not supplied the name is used.
|
||||
* @param string $asset The object asset
|
||||
* @param object $author The author.
|
||||
* @param array $params Associative array of editor parameters.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function onDisplay(
|
||||
$name,
|
||||
$content,
|
||||
$width,
|
||||
$height,
|
||||
$col,
|
||||
$row,
|
||||
$buttons = true,
|
||||
$id = null,
|
||||
$asset = null,
|
||||
$author = null,
|
||||
$params = []
|
||||
) {
|
||||
if (empty($id)) {
|
||||
$id = $name;
|
||||
}
|
||||
|
||||
// Only add "px" to width and height if they are not given as a percentage
|
||||
if (is_numeric($width)) {
|
||||
$width .= 'px';
|
||||
}
|
||||
|
||||
if (is_numeric($height)) {
|
||||
$height .= 'px';
|
||||
}
|
||||
|
||||
$readonly = !empty($params['readonly']) ? ' readonly disabled' : '';
|
||||
|
||||
$this->getApplication()->getDocument()->getWebAssetManager()
|
||||
->registerAndUseScript(
|
||||
'webcomponent.editor-none',
|
||||
'plg_editors_none/joomla-editor-none.min.js',
|
||||
[],
|
||||
['type' => 'module'],
|
||||
['editors']
|
||||
);
|
||||
|
||||
return '<joomla-editor-none>'
|
||||
. '<textarea name="' . $name . '" id="' . $id . '" cols="' . $col . '" rows="' . $row
|
||||
. '" style="width: ' . $width . '; height: ' . $height . ';"' . $readonly . '>' . $content . '</textarea>'
|
||||
. $this->displayButtons($id, $buttons, $asset, $author)
|
||||
. '</joomla-editor-none>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the editor buttons.
|
||||
*
|
||||
* @param string $name The control name.
|
||||
* @param mixed $buttons [array with button objects | boolean true to display buttons]
|
||||
* @param string $asset The object asset
|
||||
* @param object $author The author.
|
||||
*
|
||||
* @return void|string HTML
|
||||
*/
|
||||
private function displayButtons($name, $buttons, $asset, $author)
|
||||
{
|
||||
if (\is_array($buttons) || (\is_bool($buttons) && $buttons)) {
|
||||
$buttonsEvent = new Event(
|
||||
'getButtons',
|
||||
[
|
||||
'editor' => $name,
|
||||
'buttons' => $buttons,
|
||||
]
|
||||
);
|
||||
|
||||
$buttonsResult = $this->getDispatcher()->dispatch('getButtons', $buttonsEvent);
|
||||
$buttons = $buttonsResult['result'];
|
||||
|
||||
return LayoutHelper::render('joomla.editors.buttons', $buttons);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user