* @license GNU General Public License version 2 or later; see LICENSE.txt * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace */ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Object\CMSObject; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Session\Session; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Editor Fields button * * @since 3.7.0 */ class PlgButtonFields extends CMSPlugin { /** * Load the language file on instantiation. * * @var boolean * @since 3.7.0 */ protected $autoloadLanguage = true; /** * Display the button * * @param string $name The name of the button to add * * @return CMSObject|void The button options as CMSObject * * @since 3.7.0 */ public function onDisplay($name) { // Check if com_fields is enabled if (!ComponentHelper::isEnabled('com_fields')) { return; } // Guess the field context based on view. $jinput = Factory::getApplication()->input; $context = $jinput->get('option') . '.' . $jinput->get('view'); // Special context for com_categories if ($context === 'com_categories.category') { $context = $jinput->get('extension', 'com_content') . '.categories'; } $link = 'index.php?option=com_fields&view=fields&layout=modal&tmpl=component&context=' . $context . '&editor=' . $name . '&' . Session::getFormToken() . '=1'; $button = new CMSObject(); $button->modal = true; $button->link = $link; $button->text = Text::_('PLG_EDITORS-XTD_FIELDS_BUTTON_FIELD'); $button->name = $this->_type . '_' . $this->_name; $button->icon = 'puzzle'; $button->iconSVG = ''; $button->options = [ 'height' => '300px', 'width' => '800px', 'bodyHeight' => '70', 'modalWidth' => '80', ]; return $button; } }