[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/editors/tinymce/src/Field/ -> UploaddirsField.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Editors.tinymce
   6   *
   7   * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Plugin\Editors\TinyMCE\Field;
  12  
  13  use Joomla\CMS\Component\ComponentHelper;
  14  use Joomla\CMS\Form\Field\FolderlistField;
  15  use Joomla\CMS\HTML\HTMLHelper;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Generates the list of directories  available for drag and drop upload.
  23   *
  24   * @package     Joomla.Plugin
  25   * @subpackage  Editors.tinymce
  26   * @since       3.7.0
  27   */
  28  class UploaddirsField extends FolderlistField
  29  {
  30      protected $type = 'uploaddirs';
  31  
  32      /**
  33       * Method to attach a JForm object to the field.
  34       *
  35       * @param   \SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
  36       * @param   mixed              $value    The form field value to validate.
  37       * @param   string             $group    The field name group control value. This acts as an array container for the field.
  38       *                                       For example if the field has name="foo" and the group value is set to "bar" then the
  39       *                                       full field name would end up being "bar[foo]".
  40       *
  41       * @return  boolean  True on success.
  42       *
  43       * @see     \Joomla\CMS\Form\FormField::setup()
  44       * @since   3.7.0
  45       */
  46      public function setup(\SimpleXMLElement $element, $value, $group = null)
  47      {
  48          $return = parent::setup($element, $value, $group);
  49  
  50          // Get the path in which to search for file options.
  51          $this->directory   = ComponentHelper::getParams('com_media')->get('image_path');
  52          $this->recursive   = true;
  53          $this->hideDefault = true;
  54  
  55          return $return;
  56      }
  57  
  58      /**
  59       * Method to get the directories options.
  60       *
  61       * @return  array  The dirs option objects.
  62       *
  63       * @since   3.7.0
  64       */
  65      public function getOptions()
  66      {
  67          return parent::getOptions();
  68      }
  69  
  70      /**
  71       * Method to get the field input markup for the list of directories.
  72       *
  73       * @return  string  The field input markup.
  74       *
  75       * @since   3.7.0
  76       */
  77      protected function getInput()
  78      {
  79          $html = array();
  80  
  81          // Get the field options.
  82          $options = (array) $this->getOptions();
  83  
  84          // Reset the non selected value to null
  85          if ($options[0]->value === '-1') {
  86              $options[0]->value = '';
  87          }
  88  
  89          // Create a regular list.
  90          $html[] = HTMLHelper::_('select.genericlist', $options, $this->name, 'class="form-select"', 'value', 'text', $this->value, $this->id);
  91  
  92          return implode($html);
  93      }
  94  }


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