| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Administrator 4 * @subpackage com_config 5 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 9 defined('JPATH_BASE') or die; 10 11 /** 12 * Text Filters form field. 13 * 14 * @package Joomla.Administrator 15 * @subpackage com_config 16 * @since 1.6 17 */ 18 class JFormFieldFilters extends JFormField 19 { 20 /** 21 * The form field type. 22 * 23 * @var string 24 * @since 1.6 25 */ 26 public $type = 'Filters'; 27 28 /** 29 * Method to get the field input markup. 30 * 31 * TODO: Add access check. 32 * 33 * @return string The field input markup. 34 * @since 1.6 35 */ 36 protected function getInput() 37 { 38 // Get the available user groups. 39 $groups = $this->getUserGroups(); 40 // Build the form control. 41 $html = array(); 42 43 // Open the table. 44 $html[] = '<table id="filter-config">'; 45 46 // The table heading. 47 $html[] = ' <thead>'; 48 $html[] = ' <tr>'; 49 $html[] = ' <th>'; 50 $html[] = ' <span class="acl-action">'.JText::_('JGLOBAL_FILTER_GROUPS_LABEL').'</span>'; 51 $html[] = ' </th>'; 52 $html[] = ' <th>'; 53 $html[] = ' <span class="acl-action" title="'.JText::_('JGLOBAL_FILTER_TYPE_LABEL').'">'.JText::_('JGLOBAL_FILTER_TYPE_LABEL').'</span>'; 54 $html[] = ' </th>'; 55 $html[] = ' <th>'; 56 $html[] = ' <span class="acl-action" title="'.JText::_('JGLOBAL_FILTER_TAGS_LABEL').'">'.JText::_('JGLOBAL_FILTER_TAGS_LABEL').'</span>'; 57 $html[] = ' </th>'; 58 $html[] = ' <th>'; 59 $html[] = ' <span class="acl-action" title="'.JText::_('JGLOBAL_FILTER_ATTRIBUTES_LABEL').'">'.JText::_('JGLOBAL_FILTER_ATTRIBUTES_LABEL').'</span>'; 60 $html[] = ' </th>'; 61 $html[] = ' </tr>'; 62 $html[] = ' </thead>'; 63 64 // The table body. 65 $html[] = ' <tbody>'; 66 67 foreach ($groups as $group) { 68 if (!isset($this->value[$group->value])) { 69 $this->value[$group->value] = array('filter_type' => 'BL', 'filter_tags' => '', 'filter_attributes' => ''); 70 } 71 $group_filter = $this->value[$group->value]; 72 73 $html[] = ' <tr>'; 74 $html[] = ' <th class="acl-groups left">'; 75 $html[] = ' '.str_repeat('<span class="gi">|—</span>', $group->level).$group->text; 76 $html[] = ' </th>'; 77 $html[] = ' <td>'; 78 $html[] = ' <select name="'.$this->name.'['.$group->value.'][filter_type]" id="'.$this->id.$group->value.'_filter_type" class="hasTip" title="'.JText::_('JGLOBAL_FILTER_TYPE_LABEL').'::'.JText::_('JGLOBAL_FILTER_TYPE_DESC').'">'; 79 $html[] = ' <option value="BL"'.($group_filter['filter_type'] == 'BL' ? ' selected="selected"' : '').'>'.JText::_('COM_CONFIG_FIELD_FILTERS_DEFAULT_BLACK_LIST').'</option>'; 80 $html[] = ' <option value="CBL"'.($group_filter['filter_type'] == 'CBL' ? ' selected="selected"' : '').'>'.JText::_('COM_CONFIG_FIELD_FILTERS_CUSTOM_BLACK_LIST').'</option>'; 81 $html[] = ' <option value="WL"'.($group_filter['filter_type'] == 'WL' ? ' selected="selected"' : '').'>'.JText::_('COM_CONFIG_FIELD_FILTERS_WHITE_LIST').'</option>'; 82 $html[] = ' <option value="NH"'.($group_filter['filter_type'] == 'NH' ? ' selected="selected"' : '').'>'.JText::_('COM_CONFIG_FIELD_FILTERS_NO_HTML').'</option>'; 83 $html[] = ' <option value="NONE"'.($group_filter['filter_type'] == 'NONE' ? ' selected="selected"' : '').'>'.JText::_('COM_CONFIG_FIELD_FILTERS_NO_FILTER').'</option>'; 84 $html[] = ' </select>'; 85 $html[] = ' </td>'; 86 $html[] = ' <td>'; 87 $html[] = ' <input name="'.$this->name.'['.$group->value.'][filter_tags]" id="'.$this->id.$group->value.'_filter_tags" title="'.JText::_('JGLOBAL_FILTER_TAGS_LABEL').'" value="'.$group_filter['filter_tags'].'"/>'; 88 $html[] = ' </td>'; 89 $html[] = ' <td>'; 90 $html[] = ' <input name="'.$this->name.'['.$group->value.'][filter_attributes]" id="'.$this->id.$group->value.'_filter_attributes" title="'.JText::_('JGLOBAL_FILTER_ATTRIBUTES_LABEL').'" value="'.$group_filter['filter_attributes'].'"/>'; 91 $html[] = ' </td>'; 92 $html[] = ' </tr>'; 93 } 94 $html[] = ' </tbody>'; 95 96 // Close the table. 97 $html[] = '</table>'; 98 return implode("\n", $html); 99 } 100 101 /** 102 * A helper to get the list of user groups. 103 * 104 * @return array 105 * @since 1.6 106 */ 107 protected function getUserGroups() 108 { 109 // Get a database object. 110 $db = JFactory::getDBO(); 111 // Get the user groups from the database. 112 $query = $db->getQuery(true); 113 $query->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level'); 114 $query->from('#__usergroups AS a'); 115 $query->join('LEFT', '#__usergroups AS b on a.lft > b.lft AND a.rgt < b.rgt'); 116 $query->group('a.id, a.title, a.lft'); 117 $query->order('a.lft ASC'); 118 $db->setQuery($query); 119 $options = $db->loadObjectList(); 120 121 return $options; 122 } 123 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |