Source for file access.php
Documentation is available at access.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Extended Utility class for all HTML drawing classes.
* @package Joomla.Platform
* A cached array of the asset groups
protected static $asset_groups =
null;
* Displays a list of the available access view levels
* @param string $name The form field name.
* @param string $selected The name of the selected section.
* @param string $attribs Additional attributes to add to the select field.
* @param mixed $params True to add "All Sections" option or and array of options
* @param string $id The form field id
* @return string The required HTML for the SELECT tag.
* @see JFormFieldAccessLevel
public static function level($name, $selected, $attribs =
'', $params =
true, $id =
false)
$query =
$db->getQuery(true)
->select('a.id AS value, a.title AS text')
->from('#__viewlevels AS a')
->group('a.id, a.title, a.ordering')
->order('a.ordering ASC')
->order($db->quoteName('title') .
' ASC');
$options =
$db->loadObjectList();
// If params is an array, push these options to the array
// If all levels is allowed, push it into the array.
'list.select' =>
$selected,
* Displays a list of the available user groups.
* @param string $name The form field name.
* @param string $selected The name of the selected section.
* @param string $attribs Additional attributes to add to the select field.
* @param boolean $allowAll True to add "All Groups" option.
* @return string The required HTML for the SELECT tag.
* @see JFormFieldUsergroup
public static function usergroup($name, $selected, $attribs =
'', $allowAll =
true)
$query =
$db->getQuery(true)
->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level')
->from($db->quoteName('#__usergroups') .
' AS a')
->join('LEFT', $db->quoteName('#__usergroups') .
' AS b ON a.lft > b.lft AND a.rgt < b.rgt')
->group('a.id, a.title, a.lft, a.rgt')
$options =
$db->loadObjectList();
for ($i =
0, $n =
count($options); $i <
$n; $i++
)
$options[$i]->text =
str_repeat('- ', $options[$i]->level) .
$options[$i]->text;
// If all usergroups is allowed, push it into the array.
return JHtml::_('select.genericlist', $options, $name, array('list.attr' =>
$attribs, 'list.select' =>
$selected));
* Returns a UL list of user groups with check boxes
* @param string $name The name of the checkbox controls array
* @param array $selected An array of the checked boxes
* @param boolean $checkSuperAdmin If false only super admins can add to super admin groups
public static function usergroups($name, $selected, $checkSuperAdmin =
false)
$query =
$db->getQuery(true)
->select('a.*, COUNT(DISTINCT b.id) AS level')
->from($db->quoteName('#__usergroups') .
' AS a')
->join('LEFT', $db->quoteName('#__usergroups') .
' AS b ON a.lft > b.lft AND a.rgt < b.rgt')
->group('a.id, a.title, a.lft, a.rgt, a.parent_id')
$groups =
$db->loadObjectList();
for ($i =
0, $n =
count($groups); $i <
$n; $i++
)
// If checkSuperAdmin is true, only add item if the user is superadmin or the group is not super admin
if ((!$checkSuperAdmin) ||
$isSuperAdmin ||
(!JAccess::checkGroup($item->id, 'core.admin')))
// Setup the variable attributes.
$eid =
$count .
'group_' .
$item->id;
// Don't call in_array unless something is selected
$checked =
in_array($item->id, $selected) ?
' checked="checked"' :
'';
$rel =
($item->parent_id >
0) ?
' rel="' .
$count .
'group_' .
$item->parent_id .
'"' :
'';
// Build the HTML for the item.
$html[] =
' <div class="control-group">';
$html[] =
' <div class="controls">';
$html[] =
' <label class="checkbox" for="' .
$eid .
'">';
$html[] =
' <input type="checkbox" name="' .
$name .
'[]" value="' .
$item->id .
'" id="' .
$eid .
'"';
$html[] =
' ' .
$checked .
$rel .
' />';
$html[] =
' ' .
str_repeat('<span class="gi">|—</span>', $item->level) .
$item->title;
* Returns a UL list of actions with check boxes
* @param string $name The name of the checkbox controls array
* @param array $selected An array of the checked boxes
* @param string $component The component the permissions apply to
* @param string $section The section (within a component) the permissions apply to
public static function actions($name, $selected, $component, $section =
'global')
"/access/section[@name='" .
$section .
"']/"
$html[] =
'<ul class="checklist access-actions">';
for ($i =
0, $n =
count($actions); $i <
$n; $i++
)
// Setup the variable attributes.
$eid =
$count .
'action_' .
$item->id;
$checked =
in_array($item->id, $selected) ?
' checked="checked"' :
'';
// Build the HTML for the item.
$html[] =
' <input type="checkbox" name="' .
$name .
'[]" value="' .
$item->id .
'" id="' .
$eid .
'"';
$html[] =
' ' .
$checked .
' />';
$html[] =
' <label for="' .
$eid .
'">';
$html[] =
' ' .
JText::_($item->title);
* Gets a list of the asset groups as an array of JHtml compatible options.
* @return mixed An array or false if an error occurs
if (empty(static::$asset_groups))
$db =
JFactory::getDbo();
$query =
$db->getQuery(true)
->select('a.id AS value, a.title AS text')
->from($db->quoteName('#__viewlevels') .
' AS a')
->group('a.id, a.title, a.ordering')
->order('a.ordering ASC');
static::$asset_groups =
$db->loadObjectList();
return static::$asset_groups;
* Displays a Select list of the available asset groups
* @param string $name The name of the select element
* @param mixed $selected The selected asset group id
* @param string $attribs Optional attributes for the select field
* @param array $config An array of options for the control
* @return mixed An HTML string or null if an error occurs
public static function assetgrouplist($name, $selected, $attribs =
null, $config =
array())
$options =
static::assetgroups();
if (isset
($config['title']))
'id' => isset
($config['id']) ?
$config['id'] :
'assetgroups_' .
(++
$count),
'list.attr' =>
(is_null($attribs) ?
'class="inputbox" size="3"' :
$attribs),
'list.select' => (int)
$selected
Documentation generated on Tue, 19 Nov 2013 14:53:16 +0100 by phpDocumentor 1.4.3