primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View 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>

View 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;
}
);
}
};

View File

@ -0,0 +1,57 @@
<?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\Event\Editor\EditorSetupEvent;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\SubscriberInterface;
use Joomla\Plugin\Editors\None\Provider\EditorNoneProvider;
// 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 implements SubscriberInterface
{
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 5.2.0
*/
public static function getSubscribedEvents(): array
{
return [
'onEditorSetup' => 'onEditorSetup',
];
}
/**
* Register Editor instance
*
* @param EditorSetupEvent $event
*
* @return void
*
* @since 5.2.0
*/
public function onEditorSetup(EditorSetupEvent $event): void
{
$event->getEditorsRegistry()
->add(new EditorNoneProvider($this->params, $this->getApplication(), $this->getDispatcher()));
}
}

View File

@ -0,0 +1,131 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2024 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\Provider;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Editor\AbstractEditorProvider;
use Joomla\Event\DispatcherInterface;
use Joomla\Registry\Registry;
/**
* Editor provider class
*
* @since 5.2.0
*/
final class EditorNoneProvider extends AbstractEditorProvider
{
/**
* A Registry object holding the parameters for the plugin
*
* @var Registry
* @since 5.2.0
*/
protected $params;
/**
* The application object
*
* @var CMSApplicationInterface
*
* @since 5.2.0
*/
protected $application;
/**
* Class constructor
*
* @param Registry $params
* @param CMSApplicationInterface $application
* @param DispatcherInterface $dispatcher
*
* @since 5.2.0
*/
public function __construct(Registry $params, CMSApplicationInterface $application, DispatcherInterface $dispatcher)
{
$this->params = $params;
$this->application = $application;
$this->setDispatcher($dispatcher);
}
/**
* Return Editor name, CMD string.
*
* @return string
* @since 5.2.0
*/
public function getName(): string
{
return 'none';
}
/**
* Gets the editor HTML markup
*
* @param string $name Input name.
* @param string $content The content of the field.
* @param array $attributes Associative array of editor attributes.
* @param array $params Associative array of editor parameters.
*
* @return string The HTML markup of the editor
*
* @since 5.2.0
*/
public function display(string $name, string $content = '', array $attributes = [], array $params = []): string
{
$col = $attributes['col'] ?? '';
$row = $attributes['row'] ?? '';
$width = $attributes['width'] ?? '';
$height = $attributes['height'] ?? '';
$id = $attributes['id'] ?? '';
$buttons = $params['buttons'] ?? true;
$asset = $params['asset'] ?? 0;
$author = $params['author'] ?? 0;
$readonly = !empty($params['readonly']) ? ' readonly disabled' : '';
if (!$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';
}
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->application->getDocument()->getWebAssetManager();
// Add assets
if (!$wa->assetExists('script', 'webcomponent.editor-none')) {
$wa->registerScript(
'webcomponent.editor-none',
'plg_editors_none/joomla-editor-none.min.js',
[],
['type' => 'module'],
['editors']
);
}
$wa->useScript('webcomponent.editor-none');
// Render buttons
$buttonsStr = $this->displayButtons($buttons, ['asset' => $asset, 'author' => $author, 'editorId' => $id]);
return '<joomla-editor-none>'
. '<textarea name="' . $name . '" id="' . $id . '" cols="' . $col . '" rows="' . $row
. '" style="width: ' . $width . '; height: ' . $height . ';"' . $readonly . '>' . $content . '</textarea>'
. $buttonsStr
. '</joomla-editor-none>';
}
}