[ 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_associations 6 * 7 * @copyright (C) 2017 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\Associations\Administrator\Field\Modal; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Form\FormField; 15 use Joomla\CMS\HTML\HTMLHelper; 16 use Joomla\CMS\Language\Text; 17 use Joomla\CMS\Session\Session; 18 19 // phpcs:disable PSR1.Files.SideEffects 20 \defined('_JEXEC') or die; 21 // phpcs:enable PSR1.Files.SideEffects 22 23 /** 24 * Supports a modal item picker. 25 * 26 * @since 3.7.0 27 */ 28 class AssociationField extends FormField 29 { 30 /** 31 * The form field type. 32 * 33 * @var string 34 * @since 3.7.0 35 */ 36 protected $type = 'Modal_Association'; 37 38 /** 39 * Method to get the field input markup. 40 * 41 * @return string The field input markup. 42 * 43 * @since 3.7.0 44 */ 45 protected function getInput() 46 { 47 // @todo USE Layouts here!!! 48 // The active item id field. 49 $value = (int) $this->value ?: ''; 50 51 $doc = Factory::getApplication()->getDocument(); 52 $wa = $doc->getWebAssetManager(); 53 54 $doc->addScriptOptions('admin_associations_modal', ['itemId' => $value]); 55 $wa->useScript('com_associations.admin-associations-modal'); 56 57 // Setup variables for display. 58 $html = array(); 59 60 $linkAssociations = 'index.php?option=com_associations&view=associations&layout=modal&tmpl=component' 61 . '&forcedItemType=' . Factory::getApplication()->input->get('itemtype', '', 'string') . '&function=jSelectAssociation_' . $this->id; 62 63 $linkAssociations .= "&forcedLanguage=' + document.getElementById('target-association').getAttribute('data-language') + '"; 64 65 $urlSelect = $linkAssociations . '&' . Session::getFormToken() . '=1'; 66 67 // Select custom association button 68 $html[] = '<button' 69 . ' type="button"' 70 . ' id="select-change"' 71 . ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"' 72 . ' data-bs-toggle="modal"' 73 . ' data-select="' . Text::_('COM_ASSOCIATIONS_SELECT_TARGET') . '"' 74 . ' data-change="' . Text::_('COM_ASSOCIATIONS_CHANGE_TARGET') . '"' 75 . ' data-bs-target="#associationSelect' . $this->id . 'Modal">' 76 . '<span class="icon-file" aria-hidden="true"></span> ' 77 . '<span id="select-change-text"></span>' 78 . '</button>'; 79 80 // Clear association button 81 $html[] = '<button' 82 . ' type="button"' 83 . ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"' 84 . ' onclick="return Joomla.submitbutton(\'undo-association\');"' 85 . ' id="remove-assoc">' 86 . '<span class="icon-times" aria-hidden="true"></span> ' . Text::_('JCLEAR') 87 . '</button>'; 88 89 $html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . $value . '">'; 90 91 // Select custom association modal 92 $html[] = HTMLHelper::_( 93 'bootstrap.renderModal', 94 'associationSelect' . $this->id . 'Modal', 95 array( 96 'title' => Text::_('COM_ASSOCIATIONS_SELECT_TARGET'), 97 'backdrop' => 'static', 98 'url' => $urlSelect, 99 'height' => '400px', 100 'width' => '800px', 101 'bodyHeight' => 70, 102 'modalWidth' => 80, 103 'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' 104 . Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>', 105 ) 106 ); 107 108 return implode("\n", $html); 109 } 110 }
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 |