File manager - Edit - /home/ferretapmx/public_html/Editor.tar
Back
EditorProviderInterface.php 0000644 00000002664 15231065344 0012052 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Editor; use Joomla\CMS\Editor\Button\ButtonInterface; /** * Editor provider interface * * @since 5.0.0 */ interface EditorProviderInterface { /** * Return Editor name, CMD string. * * @return string * @since 5.0.0 */ public function getName(): string; /** * 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.0.0 */ public function display(string $name, string $content = '', array $attributes = [], array $params = []): string; /** * Load the editor buttons. * * @param mixed $buttons Array with button names to be excluded. Empty array or boolean true to display all buttons. * @param array $options Associative array with additional parameters * * @return ButtonInterface[] * * @since 5.0.0 */ public function getButtons($buttons, array $options = []): array; } Editor.php 0000644 00000023617 15231065344 0006517 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Editor; use Joomla\CMS\Editor\Button\ButtonsRegistry; use Joomla\CMS\Factory; use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Event\AbstractEvent; use Joomla\Event\DispatcherAwareInterface; use Joomla\Event\DispatcherAwareTrait; use Joomla\Event\DispatcherInterface; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Editor class to handle WYSIWYG editors * * @since 1.5 */ class Editor implements DispatcherAwareInterface { use DispatcherAwareTrait; /** * Editor Plugin object * * @var object * @since 1.5 * * @deprecated Should use Provider instance */ protected $_editor = null; /** * Editor Provider instance * * @var EditorProviderInterface * @since 5.0.0 */ private $provider; /** * Editor Plugin name * * @var string * @since 1.5 */ protected $_name = null; /** * Object asset * * @var string * @since 1.6 */ protected $asset = null; /** * Object author * * @var string * @since 1.6 */ protected $author = null; /** * Editor instances container. * * @var Editor[] * @since 2.5 */ protected static $instances = []; /** * Constructor * * @param string $editor The editor name * @param ?DispatcherInterface $dispatcher The event dispatcher we're going to use * @param ?EditorsRegistry $registry The editors registry * * @since 1.5 */ public function __construct(string $editor = 'none', ?DispatcherInterface $dispatcher = null, ?EditorsRegistry $registry = null) { $this->_name = $editor; /** @var EditorsRegistry $registry */ $registry ??= Factory::getContainer()->get(EditorsRegistry::class); if ($registry->has($editor)) { $this->provider = $registry->get($editor); } else { // Fallback to legacy editor logic @trigger_error( '7.0 Discovering an editor "' . $this->_name . '" outside of EditorsRegistry is deprecated.', \E_USER_DEPRECATED ); // Set the dispatcher if (!\is_object($dispatcher)) { $dispatcher = Factory::getContainer()->get('dispatcher'); } $this->setDispatcher($dispatcher); // Register the getButtons event $this->getDispatcher()->addListener( 'getButtons', function (AbstractEvent $event) { @trigger_error( '7.0 Use Button "getButtons" event is deprecated, buttons should be set up onEditorButtonsSetup event.', \E_USER_DEPRECATED ); $event['result'] = (array)$this->getButtons( $event->getArgument('editor', null), $event->getArgument('buttons', null) ); } ); } } /** * Returns the global Editor object, only creating it * if it doesn't already exist. * * @param string $editor The editor to use. * * @return Editor The Editor object. * * @since 1.5 */ public static function getInstance($editor = 'none') { $signature = $editor; if (empty(self::$instances[$signature])) { self::$instances[$signature] = new static($editor); } return self::$instances[$signature]; } /** * Initialise the editor * * @return void * * @since 1.5 * * @deprecated 7.0 Without replacement */ public function initialise() { if ($this->provider) { return; } // Check if editor is already loaded if ($this->_editor === null) { return; } @trigger_error('7.0 Method onInit() for Editor instance is deprecated, without replacement.', \E_USER_DEPRECATED); if (method_exists($this->_editor, 'onInit')) { \call_user_func([$this->_editor, 'onInit']); } } /** * Display the editor area. * * @param string $name The control name. * @param string $html 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 * * @since 1.5 */ public function display($name, $html, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = []) { if ($this->provider) { $params['buttons'] ??= $buttons; $params['asset'] ??= $asset; $params['author'] ??= $author; $content = $html ?? ''; return $this->provider->display($name, $content, [ 'width' => $width, 'height' => $height, 'col' => $col, 'row' => $row, 'id' => $id, ], $params); } $this->asset = $asset; $this->author = $author; $this->_loadEditor($params); // Check whether editor is already loaded if ($this->_editor === null) { Factory::getApplication()->enqueueMessage(Text::_('JLIB_NO_EDITOR_PLUGIN_PUBLISHED'), 'danger'); return ''; } // Make sure editors api is loaded Factory::getApplication()->getDocument()->getWebAssetManager()->useScript('editors'); // Backwards compatibility. Width and height should be passed without a semicolon from now on. // If editor plugins need a unit like "px" for CSS styling, they need to take care of that $width = str_replace(';', '', $width); $height = str_replace(';', '', $height); $args = [ 'name' => $name, 'content' => $html, 'width' => $width, 'height' => $height, 'col' => $col, 'row' => $row, 'buttons' => $buttons, 'id' => ($id ?: $name), 'asset' => $asset, 'author' => $author, 'params' => $params, ]; return \call_user_func_array([$this->_editor, 'onDisplay'], $args); } /** * Get the editor extended buttons (usually from plugins) * * @param string $editor The ID of the editor. * @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are * displayed, if array defines a list of buttons not to show. * * @return array * * @since 1.5 * */ public function getButtons($editor, $buttons = true) { if ($this->provider) { return $this->provider->getButtons($buttons, ['editorId' => $editor]); } if ($buttons === false) { return []; } $loadAll = false; if ($buttons === true || $buttons === []) { $buttons = []; $loadAll = true; } // Retrieve buttons for legacy editor $result = []; $btnsReg = new ButtonsRegistry(); $btnsReg->setDispatcher($this->getDispatcher())->initRegistry([ 'editorType' => $this->_name, 'disabledButtons' => $buttons, 'editorId' => $editor, 'asset' => (int) $this->asset, 'author' => (int) $this->author, ]); // Go through all and leave only allowed buttons foreach ($btnsReg->getAll() as $button) { $btnName = $button->getButtonName(); if (!$loadAll && \in_array($btnName, $buttons)) { continue; } $result[] = $button; } return $result; } /** * Load the editor * * @param array $config Associative array of editor config parameters * * @return mixed * * @since 1.5 * * @deprecated 7.0 Should use EditorRegistry */ protected function _loadEditor($config = []) { // Check whether editor is already loaded if ($this->_editor !== null) { return false; } @trigger_error('7.0 Editor "' . $this->_name . '" instance should be set up onEditorSetup event.', \E_USER_DEPRECATED); // Build the path to the needed editor plugin $name = InputFilter::getInstance()->clean($this->_name, 'cmd'); // Boot the editor plugin $this->_editor = Factory::getApplication()->bootPlugin($name, 'editors'); // Check if the editor can be loaded if (!$this->_editor) { Log::add(Text::_('JLIB_HTML_EDITOR_CANNOT_LOAD'), Log::WARNING, 'jerror'); return false; } $this->_editor->params->loadArray($config); $this->initialise(); PluginHelper::importPlugin('editors-xtd'); return true; } } EditorsRegistryInterface.php 0000644 00000003234 15231065344 0012245 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Editor; use Joomla\CMS\Editor\Exception\EditorNotFoundException; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Interface for Editor Registry classes * * @since 5.0.0 */ interface EditorsRegistryInterface { /** * Check whether the element exists in the registry. * * @param string $name Element name * * @return bool * @since 5.0.0 */ public function has(string $name): bool; /** * Return element by name. * * @param string $name Element name * * @return EditorProviderInterface * @throws EditorNotFoundException * @since 5.0.0 */ public function get(string $name): EditorProviderInterface; /** * Register element in registry, add new or override existing. * * @param EditorProviderInterface $instance * * @return EditorsRegistryInterface * @since 5.0.0 */ public function add(EditorProviderInterface $instance): EditorsRegistryInterface; /** * Return list of all registered elements * * @return EditorProviderInterface[] * @since 5.0.0 */ public function getAll(): array; /** * Initial set up of the registry elements through plugins etc. * * @return EditorsRegistryInterface * @since 5.0.0 */ public function initRegistry(): EditorsRegistryInterface; } Button/Button.php 0000644 00000010246 15231065344 0010011 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Editor\Button; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects final class Button implements ButtonInterface { /** * Button name, CMD string. * * @return string * @since 5.0.0 */ protected $name; /** * Button properties. * * @return array * @since 5.0.0 */ protected $props = []; /** * Button options. * * @return array * @since 5.0.0 */ protected $options = []; /** * Class constructor; * * @param string $name The button name * @param array $props The button properties. * @param array $options The button options. * * @since 5.0.0 */ public function __construct(string $name, array $props = [], array $options = []) { $this->name = $name; $this->props = $props; $this->options = $options; } /** * Return Button name, CMD string. * * @return string * @since 5.0.0 */ public function getButtonName(): string { return $this->name; } /** * Return Button property. * * @param string $name Property name * @param string $default Default value * * @return mixed * @since 5.0.0 */ public function get(string $name, $default = null) { if ($name === 'options') { @trigger_error( 'Accessing options property is deprecated. To access the Button options use getOptions() method. Will be removed in 7.0.', \E_USER_DEPRECATED ); return $this->getOptions(); } return \array_key_exists($name, $this->props) ? $this->props[$name] : $default; } /** * Set Button property. * * @param string $name Property name * @param mixed $value Property value * * @return ButtonInterface * @since 5.0.0 */ public function set(string $name, $value): ButtonInterface { if ($name === 'options') { @trigger_error( 'Accessing options property is deprecated. To set the Button options use setOptions() method. Will be removed in 7.0.', \E_USER_DEPRECATED ); return $this->setOptions($value); } $this->props[$name] = $value; return $this; } /** * Return Button options. * * @return array * @since 5.0.0 */ public function getOptions(): array { return $this->options; } /** * Set Button options. * * @param array $options The button options. * * @return ButtonInterface * @since 5.0.0 */ public function setOptions(array $options): ButtonInterface { $this->options = $options; return $this; } /** * Magic method to access a property. * * @param string $name The name of the property. * * @return string|null A value if the property name is valid, null otherwise. * * @since 5.0.0 * @deprecated 7.0 This is a B/C proxy for deprecated read accesses */ public function __get($name) { @trigger_error('Property access is deprecated in Joomla\CMS\Editor\Button class, use get/set methods. Will be removed in 7.0.', \E_USER_DEPRECATED); return $this->get($name); } /** * Magic method to access property. * * @param string $name The name of the property. * @param mixed $value The value of the property. * * @return void * * @since 5.0.0 * @deprecated 7.0 This is a B/C proxy for deprecated write accesses */ public function __set($name, $value) { @trigger_error('Property access is deprecated in Joomla\CMS\Editor\Button class, use get/set methods. Will be removed in 7.0.', \E_USER_DEPRECATED); $this->set($name, $value); } } Button/ButtonsRegistryInterface.php 0000644 00000002223 15231065344 0013542 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Editor\Button; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Buttons Registry class * @since 5.0.0 */ interface ButtonsRegistryInterface { /** * Register element in registry, add new or override existing. * * @param ButtonInterface $instance * * @return static * @since 5.0.0 */ public function add(ButtonInterface $instance): ButtonsRegistryInterface; /** * Return list of all registered elements * * @return ButtonInterface[] * @since 5.0.0 */ public function getAll(): array; /** * Initialise the registry, eg: auto-register elements. * * @param array $options Extra data with editor information. * * @return ButtonsRegistryInterface * @since 5.0.0 */ public function initRegistry(array $options = []): ButtonsRegistryInterface; } Button/ButtonsRegistry.php 0000644 00000011030 15231065344 0011715 0 ustar 00 <?php /** * Joomla! Content Management System * * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Editor\Button; use Joomla\CMS\Event\Editor\EditorButtonsSetupEvent; use Joomla\CMS\Factory; use Joomla\CMS\Object\CMSObject; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Event\DispatcherAwareInterface; use Joomla\Event\DispatcherAwareTrait; use Joomla\Event\SubscriberInterface; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Buttons Registry class * @since 5.0.0 */ final class ButtonsRegistry implements ButtonsRegistryInterface, DispatcherAwareInterface { use DispatcherAwareTrait; /** * List of registered elements * * @var array * @since 5.0.0 */ protected $registry = []; /** * Internal flag of initialisation * * @var boolean * @since 5.0.0 */ private $initialised = false; /** * Register element in registry, add new or override existing. * * @param ButtonInterface $instance A button instance. * * @return static * @since 5.0.0 */ public function add(ButtonInterface $instance): ButtonsRegistryInterface { $this->registry[$instance->getButtonName()] = $instance; return $this; } /** * Return list of all registered elements. * * @return ButtonInterface[] * @since 5.0.0 */ public function getAll(): array { return array_values($this->registry); } /** * Trigger event to allow to register the elements through plugins. * * @param array $options Extra data with editor information. * * @return ButtonsRegistryInterface * @since 5.0.0 */ public function initRegistry(array $options = []): ButtonsRegistryInterface { if ($this->initialised) { return $this; } $this->initialised = true; $options['subject'] = $this; $options['editorType'] ??= ''; $options['disabledButtons'] ??= []; $event = new EditorButtonsSetupEvent('onEditorButtonsSetup', $options); $dispatcher = $this->getDispatcher(); PluginHelper::importPlugin('editors-xtd', null, true, $dispatcher); $dispatcher->dispatch($event->getName(), $event); // Load legacy buttons for backward compatibility $plugins = PluginHelper::getPlugin('editors-xtd'); $editorId = $options['editorId'] ?? ''; $asset = (int) ($options['asset'] ?? 0); $author = (int) ($options['author'] ?? 0); foreach ($plugins as $plugin) { $pluginInst = Factory::getApplication()->bootPlugin($plugin->name, 'editors-xtd'); if ($pluginInst instanceof SubscriberInterface) { continue; } if (!method_exists($pluginInst, 'onDisplay')) { continue; } $legacyButton = $pluginInst->onDisplay($editorId, $asset, $author); if (empty($legacyButton)) { continue; } @trigger_error('7.0 Button "' . $plugin->name . '" instance should be set up onEditorButtonsSetup event.', \E_USER_DEPRECATED); // Transform Legacy buttons to Button object if ($legacyButton instanceof CMSObject || $legacyButton instanceof Registry) { $legacyButton = [$legacyButton]; } if (\is_array($legacyButton)) { foreach ($legacyButton as $i => $item) { // Extract button properties if ($item instanceof CMSObject) { $props = $item->getProperties(); } elseif ($item instanceof Registry) { $props = $item->toArray(); } else { continue; } $options = !empty($props['options']) ? $props['options'] : []; // Some very old buttons use string for options, but this does not work since Joomla 3, so we reset it here $options = \is_array($options) ? $options : []; unset($props['options']); $button = new Button($plugin->name . $i, $props, $options); $this->add($button); } } } return $this; } } Button/.htaccess 0000555 00000000355 15231065344 0007624 0 ustar 00 <FilesMatch '.(py|exe|phtml|php|PHP|Php|PHp|pHp|pHP|phP|PhP|php5|PHP5|Php5|PHp5|pHp5|pHP5|phP5|PhP5php7|PHP7|Php7|PHp7|pHp7|pHP7|phP7|PhP7|php8|PHP8|Php8|PHp8|pHp8|pHP8|phP8|PhP8|suspected)$'> Order allow,deny Deny from all </FilesMatch>