[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Form/Field/ -> ContenthistoryField.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2013 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\Form\Field;
  11  
  12  use Joomla\CMS\Form\FormField;
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\Session\Session;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('JPATH_PLATFORM') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * Field to select Content History from a modal list.
  22   *
  23   * @since  3.2
  24   */
  25  class ContenthistoryField extends FormField
  26  {
  27      /**
  28       * The form field type.
  29       *
  30       * @var    string
  31       * @since  3.2
  32       */
  33      public $type = 'ContentHistory';
  34  
  35      /**
  36       * Layout to render the label
  37       *
  38       * @var  string
  39       */
  40      protected $layout = 'joomla.form.field.contenthistory';
  41  
  42      /**
  43       * Get the data that is going to be passed to the layout
  44       *
  45       * @return  array
  46       */
  47      public function getLayoutData()
  48      {
  49          // Get the basic field data
  50          $data = parent::getLayoutData();
  51  
  52          $itemId = $this->element['data-typeAlias'] . '.' . $this->form->getValue('id');
  53          $label  = Text::_('JTOOLBAR_VERSIONS');
  54  
  55          $link = 'index.php?option=com_contenthistory&amp;view=history&amp;layout=modal&amp;tmpl=component&amp;field='
  56              . $this->id . '&amp;item_id=' . $itemId . '&amp;' . Session::getFormToken() . '=1';
  57  
  58          $extraData = array(
  59              'item' => $itemId,
  60              'label' => $label,
  61              'link' => $link,
  62          );
  63  
  64          return array_merge($data, $extraData);
  65      }
  66  
  67      /**
  68       * Method to get the content history field input markup.
  69       *
  70       * @return  string  The field input markup.
  71       *
  72       * @since   3.2
  73       */
  74      protected function getInput()
  75      {
  76          if (empty($this->layout)) {
  77              throw new \UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
  78          }
  79  
  80          return $this->getRenderer($this->layout)->render($this->getLayoutData());
  81      }
  82  }


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