[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_menus 6 * 7 * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Menus\Administrator\Field; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Form\Field\ListField; 15 use Joomla\CMS\HTML\HTMLHelper; 16 use Joomla\CMS\Language\Text; 17 use Joomla\CMS\Router\Route; 18 use Joomla\Component\Menus\Administrator\Helper\MenusHelper; 19 use Joomla\Utilities\ArrayHelper; 20 21 // phpcs:disable PSR1.Files.SideEffects 22 \defined('_JEXEC') or die; 23 // phpcs:enable PSR1.Files.SideEffects 24 25 /** 26 * Menu Type field. 27 * 28 * @since 1.6 29 */ 30 class MenutypeField extends ListField 31 { 32 /** 33 * The form field type. 34 * 35 * @var string 36 * @since 1.6 37 */ 38 protected $type = 'menutype'; 39 40 /** 41 * Method to get the field input markup. 42 * 43 * @return string The field input markup. 44 * 45 * @since 1.6 46 */ 47 protected function getInput() 48 { 49 $html = array(); 50 $recordId = (int) $this->form->getValue('id'); 51 $size = (string) ($v = $this->element['size']) ? ' size="' . $v . '"' : ''; 52 $class = (string) ($v = $this->element['class']) ? ' class="form-control ' . $v . '"' : ' class="form-control"'; 53 $required = (string) $this->element['required'] ? ' required="required"' : ''; 54 $clientId = (int) $this->element['clientid'] ?: 0; 55 56 // Get a reverse lookup of the base link URL to Title 57 switch ($this->value) { 58 case 'url': 59 $value = Text::_('COM_MENUS_TYPE_EXTERNAL_URL'); 60 break; 61 62 case 'alias': 63 $value = Text::_('COM_MENUS_TYPE_ALIAS'); 64 break; 65 66 case 'separator': 67 $value = Text::_('COM_MENUS_TYPE_SEPARATOR'); 68 break; 69 70 case 'heading': 71 $value = Text::_('COM_MENUS_TYPE_HEADING'); 72 break; 73 74 case 'container': 75 $value = Text::_('COM_MENUS_TYPE_CONTAINER'); 76 break; 77 78 default: 79 $link = $this->form->getValue('link'); 80 $value = ''; 81 82 if ($link !== null) { 83 $model = Factory::getApplication()->bootComponent('com_menus') 84 ->getMVCFactory()->createModel('Menutypes', 'Administrator', array('ignore_request' => true)); 85 $model->setState('client_id', $clientId); 86 87 $rlu = $model->getReverseLookup(); 88 89 // Clean the link back to the option, view and layout 90 $value = Text::_(ArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link))); 91 } 92 break; 93 } 94 95 $link = Route::_('index.php?option=com_menus&view=menutypes&tmpl=component&client_id=' . $clientId . '&recordId=' . $recordId); 96 $html[] = '<span class="input-group"><input type="text" ' . $required . ' readonly="readonly" id="' . $this->id 97 . '" value="' . $value . '"' . $size . $class . '>'; 98 $html[] = '<button type="button" data-bs-target="#menuTypeModal" class="btn btn-primary" data-bs-toggle="modal">' 99 . '<span class="icon-list icon-white" aria-hidden="true"></span> ' 100 . Text::_('JSELECT') . '</button></span>'; 101 $html[] = HTMLHelper::_( 102 'bootstrap.renderModal', 103 'menuTypeModal', 104 array( 105 'url' => $link, 106 'title' => Text::_('COM_MENUS_ITEM_FIELD_TYPE_LABEL'), 107 'width' => '800px', 108 'height' => '300px', 109 'modalWidth' => 80, 110 'bodyHeight' => 70, 111 'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' 112 . Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>' 113 ) 114 ); 115 116 // This hidden field has an ID so it can be used for showon attributes 117 $html[] = '<input type="hidden" name="' . $this->name . '" value="' 118 . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" id="' . $this->id . '_val">'; 119 120 return implode("\n", $html); 121 } 122 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |