* @link http://www.tassos.gr * @copyright Copyright © 2020 Tassos Marinos All Rights Reserved * @license GNU GPLv3 or later */ defined('_JEXEC') or die('Restricted access'); use Joomla\CMS\Form\FormField; use Joomla\CMS\HTML\HTMLHelper; class JFormFieldTFImageDimensionsControl extends FormField { /** * Renders the input field with the video previewer. * * @return string The field input markup. */ protected function getInput() { $this->assets(); $isNew = $this->form->getData()->get('id') == 0; $by = isset($this->element['by']) ? (string) $this->element['by'] : ''; $width = isset($this->element['width']) ? (string) $this->element['width'] : ''; $height = isset($this->element['height']) ? (string) $this->element['height'] : ''; $hide_disabled_option = isset($this->element['hide_disabled_option']) ? (string) $this->element['hide_disabled_option'] === 'true' : false; $disabled_label = isset($this->element['disabled_label']) ? (string) $this->element['disabled_label'] : 'JDISABLED'; $hide_dropdown = isset($this->element['hide_dropdown']) ? (string) $this->element['hide_dropdown'] === 'true' : false; if (is_string($this->value)) { $this->value = json_decode($this->value, true); } $elName = (string) $this->element['name']; $by_field = ''; if (!$hide_dropdown) { $by_field = ' ' . (!$hide_disabled_option ? '' : '') . ' '; } else { $by_field = ''; } $xml = new SimpleXMLElement(' ' . ($this->group ? '' : '') . ' ' . $by_field . ' ' . ($this->group ? '' : '') . ' '); $this->form->setField($xml); $html = []; $fields = isset($xml->fields) ? $xml->fields->field : $xml->field; foreach ($fields as $key => $field) { $name = $field->attributes()->name; $html[] = $this->form->renderField($name, ($this->group ? $this->group . '.' : '') . $elName); } return '
' . implode('', $html) . '
'; } private function assets() { HTMLHelper::stylesheet('plg_system_nrframework/controls/imagedimensions.css', ['relative' => true, 'version' => 'auto']); HTMLHelper::script('plg_system_nrframework/controls/imagedimensions.js', ['relative' => true, 'version' => 'auto']); } }