. */ use Alledia\OSMap\Factory; use Joomla\CMS\Form\FormField; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; defined('_JEXEC') or die(); require_once 'TraitOsmapField.php'; class OsmapFormFieldSitemaps extends FormField { use TraitOsmapField; /** * @inheritdoc */ protected $type = 'Sitemaps'; /** * @var string */ protected static $scripts = []; /** * @inheritDoc */ protected function getInput() { if ($value = $this->value ?: '') { $db = Factory::getDbo(); $db->setQuery( $db->getQuery(true) ->select('name') ->from('#__osmap_sitemaps') ->where('id = ' . (int)$value) ); $selectedName = $db->loadResult(); } if (empty($selectedName)) { $selectedName = Text::_('COM_OSMAP_OPTION_SELECT_SITEMAP'); } $function = 'osmapSelectSitemap_' . $this->id; $linkQuery = [ 'option' => 'com_osmap', 'view' => 'sitemaps', 'layout' => 'modal', 'tmpl' => 'component', 'function' => $function ]; $link = 'index.php?' . htmlspecialchars(http_build_query($linkQuery)); return HTMLHelper::_( 'alledia.renderModal', [ 'id' => $this->id, 'name' => $this->name, 'link' => $link, 'function' => $function, 'itemType' => 'Sitemap', 'title' => Text::_('COM_OSMAP_OPTION_SELECT_SITEMAP'), 'hint' => $selectedName, 'value' => $value, 'required' => $this->required, ] ); } /** * @inheritDoc */ protected function getLabel() { return str_replace($this->id, $this->id . '_id', parent::getLabel()); } }