[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Toolbar/Button/ -> InlinehelpButton.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Toolbar\Button;
  11  
  12  // phpcs:disable PSR1.Files.SideEffects
  13  \defined('JPATH_PLATFORM') or die;
  14  // phpcs:enable PSR1.Files.SideEffects
  15  
  16  /**
  17   * Renders a button to show / hide the inline help text
  18   *
  19   * @method self targetclass(string $value)
  20   * @method string getTargetclass()
  21   *
  22   * @since  4.1.0
  23   */
  24  class InlinehelpButton extends BasicButton
  25  {
  26      /**
  27       * Property layout.
  28       *
  29       * @var  string
  30       *
  31       * @since  4.1.3
  32       */
  33      protected $layout = 'joomla.toolbar.inlinehelp';
  34  
  35      /**
  36       * Prepare options for this button.
  37       *
  38       * @param   array  $options  The options for this button.
  39       *
  40       * @return  void
  41       *
  42       * @since  4.1.0
  43       */
  44      protected function prepareOptions(array &$options)
  45      {
  46          $options['text'] = $options['text'] ?: 'JINLINEHELP';
  47          $options['icon'] = $options['icon'] ?? 'fa-question-circle';
  48          $options['button_class'] = $options['button_class'] ?? 'btn btn-info';
  49          $options['attributes'] = array_merge(
  50              $options['attributes'] ?? [],
  51              [
  52                  'data-class' => $options['targetclass'] ?? 'hide-aware-inline-help'
  53              ]
  54          );
  55  
  56          parent::prepareOptions($options);
  57      }
  58  
  59      /**
  60       * Fetches the button HTML code.
  61       *
  62       * @param   string  $type         Unused string.
  63       * @param   string  $targetClass  The class of the DIVs holding the descriptions to toggle.
  64       * @param   string  $text         Button label
  65       * @param   string  $icon         Button icon
  66       * @param   string  $buttonClass  Button class
  67       *
  68       * @return  string
  69       *
  70       * @since       4.1.0
  71       *
  72       * @deprecated  5.0 Use render() instead.
  73       */
  74      public function fetchButton(
  75          $type = 'Inlinehelp',
  76          string $targetClass = 'hide-aware-inline-help',
  77          string $text = 'JINLINEHELP',
  78          string $icon = 'fa fa-question-circle',
  79          string $buttonClass = 'btn btn-info'
  80      ) {
  81          $this->name('inlinehelp')
  82              ->targetclass($targetClass)
  83              ->text($text)
  84              ->icon($icon)
  85              ->buttonClass($buttonClass);
  86  
  87          return $this->renderButton($this->options);
  88      }
  89  
  90      /**
  91       * Method to configure available option accessors.
  92       *
  93       * @return  array
  94       *
  95       * @since   4.1.0
  96       */
  97      protected static function getAccessors(): array
  98      {
  99          return array_merge(
 100              parent::getAccessors(),
 101              [
 102                  'targetclass',
 103              ]
 104          );
 105      }
 106  }


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