[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/editors/codemirror/src/Field/ -> FontsField.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Editors.codemirror
   6   *
   7   * @copyright   (C) 2014 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\CodeMirror\Field;
  12  
  13  use Joomla\CMS\Form\Field\ListField;
  14  use Joomla\CMS\HTML\HTMLHelper;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * Supports an HTML select list of fonts
  22   *
  23   * @package     Joomla.Plugin
  24   * @subpackage  Editors.codemirror
  25   * @since       3.4
  26   */
  27  class FontsField extends ListField
  28  {
  29      /**
  30       * The form field type.
  31       *
  32       * @var    string
  33       * @since  3.4
  34       */
  35      protected $type = 'Fonts';
  36  
  37      /**
  38       * Method to get the list of fonts field options.
  39       *
  40       * @return  array  The field option objects.
  41       *
  42       * @since   3.4
  43       */
  44      protected function getOptions()
  45      {
  46          $fonts = json_decode(file_get_contents(JPATH_PLUGINS . '/editors/codemirror/fonts.json'));
  47          $options = array();
  48  
  49          foreach ($fonts as $key => $info) {
  50              $options[] = HTMLHelper::_('select.option', $key, $info->name);
  51          }
  52  
  53          // Merge any additional options in the XML definition.
  54          return array_merge(parent::getOptions(), $options);
  55      }
  56  }


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