[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/editors/none/ -> none.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Editors.none
   6   *
   7   * @copyright   (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9  
  10   * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
  11   */
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Layout\LayoutHelper;
  15  use Joomla\CMS\Plugin\CMSPlugin;
  16  use Joomla\Event\Event;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Plain Textarea Editor Plugin
  24   *
  25   * @since  1.5
  26   */
  27  class PlgEditorNone extends CMSPlugin
  28  {
  29      /**
  30       * Display the editor area.
  31       *
  32       * @param   string   $name     The control name.
  33       * @param   string   $content  The contents of the text area.
  34       * @param   string   $width    The width of the text area (px or %).
  35       * @param   string   $height   The height of the text area (px or %).
  36       * @param   integer  $col      The number of columns for the textarea.
  37       * @param   integer  $row      The number of rows for the textarea.
  38       * @param   boolean  $buttons  True and the editor buttons will be displayed.
  39       * @param   string   $id       An optional ID for the textarea (note: since 1.6). If not supplied the name is used.
  40       * @param   string   $asset    The object asset
  41       * @param   object   $author   The author.
  42       * @param   array    $params   Associative array of editor parameters.
  43       *
  44       * @return  string
  45       */
  46      public function onDisplay(
  47          $name,
  48          $content,
  49          $width,
  50          $height,
  51          $col,
  52          $row,
  53          $buttons = true,
  54          $id = null,
  55          $asset = null,
  56          $author = null,
  57          $params = array()
  58      ) {
  59          if (empty($id)) {
  60              $id = $name;
  61          }
  62  
  63          // Only add "px" to width and height if they are not given as a percentage
  64          if (is_numeric($width)) {
  65              $width .= 'px';
  66          }
  67  
  68          if (is_numeric($height)) {
  69              $height .= 'px';
  70          }
  71  
  72          $readonly = !empty($params['readonly']) ? ' readonly disabled' : '';
  73  
  74          Factory::getDocument()->getWebAssetManager()
  75              ->registerAndUseScript(
  76                  'webcomponent.editor-none',
  77                  'plg_editors_none/joomla-editor-none.min.js',
  78                  [],
  79                  ['type' => 'module']
  80              );
  81  
  82          return '<joomla-editor-none>'
  83              . '<textarea name="' . $name . '" id="' . $id . '" cols="' . $col . '" rows="' . $row
  84              . '" style="width: ' . $width . '; height: ' . $height . ';"' . $readonly . '>' . $content . '</textarea>'
  85              . '</joomla-editor-none>'
  86              . $this->_displayButtons($id, $buttons, $asset, $author);
  87      }
  88  
  89      /**
  90       * Displays the editor buttons.
  91       *
  92       * @param   string  $name     The control name.
  93       * @param   mixed   $buttons  [array with button objects | boolean true to display buttons]
  94       * @param   string  $asset    The object asset
  95       * @param   object  $author   The author.
  96       *
  97       * @return  void|string HTML
  98       */
  99      public function _displayButtons($name, $buttons, $asset, $author)
 100      {
 101          if (is_array($buttons) || (is_bool($buttons) && $buttons)) {
 102              $buttonsEvent = new Event(
 103                  'getButtons',
 104                  [
 105                      'editor'    => $name,
 106                      'buttons' => $buttons,
 107                  ]
 108              );
 109  
 110              $buttonsResult = $this->getDispatcher()->dispatch('getButtons', $buttonsEvent);
 111              $buttons       = $buttonsResult['result'];
 112  
 113              return LayoutHelper::render('joomla.editors.buttons', $buttons);
 114          }
 115      }
 116  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer