[ 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_config 6 * 7 * @copyright (C) 2013 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\Config\Administrator\Field; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Form\FormField; 15 use Joomla\CMS\Language\Text; 16 use Joomla\CMS\Layout\LayoutHelper; 17 18 // phpcs:disable PSR1.Files.SideEffects 19 \defined('_JEXEC') or die; 20 // phpcs:enable PSR1.Files.SideEffects 21 22 /** 23 * Text Filters form field. 24 * 25 * @since 1.6 26 */ 27 class FiltersField extends FormField 28 { 29 /** 30 * The form field type. 31 * 32 * @var string 33 * @since 1.6 34 */ 35 public $type = 'Filters'; 36 37 /** 38 * Method to get the field input markup. 39 * 40 * @todo: Add access check. 41 * 42 * @return string The field input markup. 43 * 44 * @since 1.6 45 */ 46 protected function getInput() 47 { 48 // Add translation string for notification 49 Text::script('COM_CONFIG_TEXT_FILTERS_NOTE'); 50 51 // Add Javascript 52 Factory::getDocument()->getWebAssetManager()->useScript('com_config.filters'); 53 54 // Get the available user groups. 55 $groups = $this->getUserGroups(); 56 57 // Build the form control. 58 $html = array(); 59 60 // Open the table. 61 $html[] = '<table id="filter-config" class="table">'; 62 63 // The table heading. 64 $html[] = ' <thead>'; 65 $html[] = ' <tr>'; 66 $html[] = ' <th>'; 67 $html[] = ' <span class="acl-action">' . Text::_('JGLOBAL_FILTER_GROUPS_LABEL') . '</span>'; 68 $html[] = ' </th>'; 69 $html[] = ' <th>'; 70 $html[] = ' <span class="acl-action">' . Text::_('JGLOBAL_FILTER_TYPE_LABEL') . '</span>'; 71 $html[] = ' </th>'; 72 $html[] = ' <th>'; 73 $html[] = ' <span class="acl-action">' . Text::_('JGLOBAL_FILTER_TAGS_LABEL') . '</span>'; 74 $html[] = ' </th>'; 75 $html[] = ' <th>'; 76 $html[] = ' <span class="acl-action">' . Text::_('JGLOBAL_FILTER_ATTRIBUTES_LABEL') . '</span>'; 77 $html[] = ' </th>'; 78 $html[] = ' </tr>'; 79 $html[] = ' </thead>'; 80 81 // The table body. 82 $html[] = ' <tbody>'; 83 84 foreach ($groups as $group) { 85 if (!isset($this->value[$group->value])) { 86 $this->value[$group->value] = array('filter_type' => 'BL', 'filter_tags' => '', 'filter_attributes' => ''); 87 } 88 89 $group_filter = $this->value[$group->value]; 90 91 $group_filter['filter_tags'] = !empty($group_filter['filter_tags']) ? $group_filter['filter_tags'] : ''; 92 $group_filter['filter_attributes'] = !empty($group_filter['filter_attributes']) ? $group_filter['filter_attributes'] : ''; 93 94 $html[] = ' <tr>'; 95 $html[] = ' <td class="acl-groups left">'; 96 $html[] = ' ' . LayoutHelper::render('joomla.html.treeprefix', array('level' => $group->level + 1)) . $group->text; 97 $html[] = ' </td>'; 98 $html[] = ' <td>'; 99 $html[] = ' <label for="' . $this->id . $group->value . '_filter_type" class="visually-hidden">' 100 . Text::_('JGLOBAL_FILTER_TYPE_LABEL') . '</label>'; 101 $html[] = ' <select' 102 . ' name="' . $this->name . '[' . $group->value . '][filter_type]"' 103 . ' id="' . $this->id . $group->value . '_filter_type"' 104 . ' data-parent="' . ($group->parent) . '" ' 105 . ' data-id="' . ($group->value) . '" ' 106 . ' class="novalidate form-select"' 107 . '>'; 108 $html[] = ' <option value="BL"' . ($group_filter['filter_type'] == 'BL' ? ' selected="selected"' : '') . '>' 109 . Text::_('COM_CONFIG_FIELD_FILTERS_DEFAULT_FORBIDDEN_LIST') . '</option>'; 110 $html[] = ' <option value="CBL"' . ($group_filter['filter_type'] == 'CBL' ? ' selected="selected"' : '') . '>' 111 . Text::_('COM_CONFIG_FIELD_FILTERS_CUSTOM_FORBIDDEN_LIST') . '</option>'; 112 $html[] = ' <option value="WL"' . ($group_filter['filter_type'] == 'WL' ? ' selected="selected"' : '') . '>' 113 . Text::_('COM_CONFIG_FIELD_FILTERS_ALLOWED_LIST') . '</option>'; 114 $html[] = ' <option value="NH"' . ($group_filter['filter_type'] == 'NH' ? ' selected="selected"' : '') . '>' 115 . Text::_('COM_CONFIG_FIELD_FILTERS_NO_HTML') . '</option>'; 116 $html[] = ' <option value="NONE"' . ($group_filter['filter_type'] == 'NONE' ? ' selected="selected"' : '') . '>' 117 . Text::_('COM_CONFIG_FIELD_FILTERS_NO_FILTER') . '</option>'; 118 $html[] = ' </select>'; 119 $html[] = ' </td>'; 120 $html[] = ' <td>'; 121 $html[] = ' <label for="' . $this->id . $group->value . '_filter_tags" class="visually-hidden">' 122 . Text::_('JGLOBAL_FILTER_TAGS_LABEL') . '</label>'; 123 $html[] = ' <input' 124 . ' name="' . $this->name . '[' . $group->value . '][filter_tags]"' 125 . ' type="text"' 126 . ' id="' . $this->id . $group->value . '_filter_tags" class="novalidate form-control"' 127 . ' value="' . htmlspecialchars($group_filter['filter_tags'], ENT_QUOTES) . '"' 128 . '>'; 129 $html[] = ' </td>'; 130 $html[] = ' <td>'; 131 $html[] = ' <label for="' . $this->id . $group->value . '_filter_attributes"' 132 . ' class="visually-hidden">' . Text::_('JGLOBAL_FILTER_ATTRIBUTES_LABEL') . '</label>'; 133 $html[] = ' <input' 134 . ' name="' . $this->name . '[' . $group->value . '][filter_attributes]"' 135 . ' type="text"' 136 . ' id="' . $this->id . $group->value . '_filter_attributes" class="novalidate form-control"' 137 . ' value="' . htmlspecialchars($group_filter['filter_attributes'], ENT_QUOTES) . '"' 138 . '>'; 139 $html[] = ' </td>'; 140 $html[] = ' </tr>'; 141 } 142 143 $html[] = ' </tbody>'; 144 145 // Close the table. 146 $html[] = '</table>'; 147 148 return implode("\n", $html); 149 } 150 151 /** 152 * A helper to get the list of user groups. 153 * 154 * @return array 155 * 156 * @since 1.6 157 */ 158 protected function getUserGroups() 159 { 160 // Get a database object. 161 $db = $this->getDatabase(); 162 163 // Get the user groups from the database. 164 $query = $db->getQuery(true); 165 $query->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level, a.parent_id as parent'); 166 $query->from('#__usergroups AS a'); 167 $query->join('LEFT', '#__usergroups AS b on a.lft > b.lft AND a.rgt < b.rgt'); 168 $query->group('a.id, a.title, a.lft'); 169 $query->order('a.lft ASC'); 170 $db->setQuery($query); 171 $options = $db->loadObjectList(); 172 173 return $options; 174 } 175 }
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 |