Source for file jgrid.php
Documentation is available at jgrid.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Utility class for creating HTML Grids
* @package Joomla.Libraries
* Returns an action on a grid
* @param integer $i The row index
* @param string $task The task to fire
* @param string|array $prefix An optional task prefix or an array of options
* @param string $text An optional text to display [unused - @deprecated 4.0]
* @param string $active_title An optional active tooltip to display if $enable is true
* @param string $inactive_title An optional inactive tooltip to display if $enable is true
* @param boolean $tip An optional setting for tooltip
* @param string $active_class An optional active HTML class
* @param string $inactive_class An optional inactive HTML class
* @param boolean $enabled An optional setting for access control on the action.
* @param boolean $translate An optional setting for translation.
* @param string $checkbox An optional prefix for checkboxes.
* @return string The HTML markup
public static function action($i, $task, $prefix =
'', $text =
'', $active_title =
'', $inactive_title =
'', $tip =
false, $active_class =
'',
$inactive_class =
'', $enabled =
true, $translate =
true, $checkbox =
'cb')
$active_title =
array_key_exists('active_title', $options) ?
$options['active_title'] :
$active_title;
$inactive_title =
array_key_exists('inactive_title', $options) ?
$options['inactive_title'] :
$inactive_title;
$active_class =
array_key_exists('active_class', $options) ?
$options['active_class'] :
$active_class;
$inactive_class =
array_key_exists('inactive_class', $options) ?
$options['inactive_class'] :
$inactive_class;
$enabled =
array_key_exists('enabled', $options) ?
$options['enabled'] :
$enabled;
$translate =
array_key_exists('translate', $options) ?
$options['translate'] :
$translate;
$checkbox =
array_key_exists('checkbox', $options) ?
$options['checkbox'] :
$checkbox;
JHtml::_('bootstrap.tooltip');
$title =
$enabled ?
$active_title :
$inactive_title;
$title =
$translate ?
JText::_($title) :
$title;
$title =
JHtml::tooltipText($title, '', 0);
$html[] =
'<a class="btn btn-micro ' .
($active_class ==
"publish" ?
'active' :
'') .
' ' .
($tip ?
'hasTooltip"' :
'') .
'"';
$html[] =
' href="javascript:void(0);" onclick="return listItemTask(\'' .
$checkbox .
$i .
'\',\'' .
$prefix .
$task .
'\')"';
$html[] =
$tip ?
' title="' .
$title .
'"' :
'';
$html[] =
'<i class="icon-' .
$active_class .
'">';
$html[] =
'<a class="btn btn-micro disabled jgrid ' .
($tip ?
'hasTooltip' :
'') .
'"';
$html[] =
$tip ?
' title="' .
$title .
'"' :
'';
if ($active_class ==
"protected")
$html[] =
'<i class="icon-lock"></i>';
$html[] =
'<i class="icon-' .
$inactive_class .
'"></i>';
* Returns a state on a grid
* @param array $states array of value/state. Each state is an array of the form
* (task, text, title,html active class, HTML inactive class)
* or ('task'=>task, 'text'=>text, 'active_title'=>active title,
* 'inactive_title'=>inactive title, 'tip'=>boolean, 'active_class'=>html active class,
* 'inactive_class'=>html inactive class)
* @param integer $value The state value.
* @param integer $i The row index
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled An optional setting for access control on the action.
* @param boolean $translate An optional setting for translation.
* @param string $checkbox An optional prefix for checkboxes.
* @return string The HTML markup
public static function state($states, $value, $i, $prefix =
'', $enabled =
true, $translate =
true, $checkbox =
'cb')
$enabled =
array_key_exists('enabled', $options) ?
$options['enabled'] :
$enabled;
$translate =
array_key_exists('translate', $options) ?
$options['translate'] :
$translate;
$checkbox =
array_key_exists('checkbox', $options) ?
$options['checkbox'] :
$checkbox;
$i, $task, $prefix, $text, $active_title, $inactive_title, $tip,
$active_class, $inactive_class, $enabled, $translate, $checkbox
* Returns a published state on a grid
* @param integer $value The state value.
* @param integer $i The row index
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
* @param string $publish_up An optional start publishing date.
* @param string $publish_down An optional finish publishing date.
* @return string The HTML markup
* @see JHtmlJGrid::state()
public static function published($value, $i, $prefix =
'', $enabled =
true, $checkbox =
'cb', $publish_up =
null, $publish_down =
null)
$enabled =
array_key_exists('enabled', $options) ?
$options['enabled'] :
$enabled;
$checkbox =
array_key_exists('checkbox', $options) ?
$options['checkbox'] :
$checkbox;
$states =
array(1 =>
array('unpublish', 'JPUBLISHED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JPUBLISHED', true, 'publish', 'publish'),
0 =>
array('publish', 'JUNPUBLISHED', 'JLIB_HTML_PUBLISH_ITEM', 'JUNPUBLISHED', true, 'unpublish', 'unpublish'),
2 =>
array('unpublish', 'JARCHIVED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JARCHIVED', true, 'archive', 'archive'),
-
2 =>
array('publish', 'JTRASHED', 'JLIB_HTML_PUBLISH_ITEM', 'JTRASHED', true, 'trash', 'trash'));
// Special state for dates
if ($publish_up ||
$publish_down)
$publish_up =
($publish_up !=
$nullDate) ?
JFactory::getDate($publish_up, 'UTC')->setTimeZone($tz) :
false;
$publish_down =
($publish_down !=
$nullDate) ?
JFactory::getDate($publish_down, 'UTC')->setTimeZone($tz) :
false;
// Create tip text, only we have publish up or down settings
$tips[] =
JText::sprintf('JLIB_HTML_PUBLISHED_START', $publish_up->format(JDate::$format, true));
$tips[] =
JText::sprintf('JLIB_HTML_PUBLISHED_FINISHED', $publish_down->format(JDate::$format, true));
$tip =
empty($tips) ?
false :
implode('<br/>', $tips);
// Add tips and special titles
foreach ($states as $key =>
$state)
// Create special titles for published items
$states[$key][2] =
$states[$key][3] =
'JLIB_HTML_PUBLISHED_ITEM';
if ($publish_up >
$nullDate &&
$nowDate <
$publish_up->toUnix())
$states[$key][2] =
$states[$key][3] =
'JLIB_HTML_PUBLISHED_PENDING_ITEM';
$states[$key][5] =
$states[$key][6] =
'pending';
if ($publish_down >
$nullDate &&
$nowDate >
$publish_down->toUnix())
$states[$key][2] =
$states[$key][3] =
'JLIB_HTML_PUBLISHED_EXPIRED_ITEM';
$states[$key][5] =
$states[$key][6] =
'expired';
$states[$key][1] =
JText::_($states[$key][1]);
$states[$key][2] =
JText::_($states[$key][2]) .
'<br />' .
$tip;
$states[$key][3] =
JText::_($states[$key][3]) .
'<br />' .
$tip;
return static::state($states, $value, $i, array('prefix' =>
$prefix, 'translate' =>
!$tip), $enabled, true, $checkbox);
return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox);
* Returns a isDefault state on a grid
* @param integer $value The state value.
* @param integer $i The row index
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
* @return string The HTML markup
* @see JHtmlJGrid::state()
public static function isdefault($value, $i, $prefix =
'', $enabled =
true, $checkbox =
'cb')
$enabled =
array_key_exists('enabled', $options) ?
$options['enabled'] :
$enabled;
$checkbox =
array_key_exists('checkbox', $options) ?
$options['checkbox'] :
$checkbox;
0 =>
array('setDefault', '', 'JLIB_HTML_SETDEFAULT_ITEM', '', 1, 'unfeatured', 'unfeatured'),
1 =>
array('unsetDefault', 'JDEFAULT', 'JLIB_HTML_UNSETDEFAULT_ITEM', 'JDEFAULT', 1, 'featured', 'featured'),
return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox);
* Returns an array of standard published state filter options.
* @param array $config An array of configuration options.
* This array can contain a list of key/value pairs where values are boolean
* and keys can be taken from 'published', 'unpublished', 'archived', 'trash', 'all'.
* These pairs determine which values are displayed.
* @return string The HTML markup
// Build the active state filter options.
$options[] =
JHtml::_('select.option', '1', 'JPUBLISHED');
$options[] =
JHtml::_('select.option', '0', 'JUNPUBLISHED');
$options[] =
JHtml::_('select.option', '2', 'JARCHIVED');
$options[] =
JHtml::_('select.option', '-2', 'JTRASHED');
$options[] =
JHtml::_('select.option', '*', 'JALL');
* Returns a checked-out icon
* @param integer $i The row index.
* @param string $editorName The name of the editor.
* @param string $time The time that the object was checked out.
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled True to enable the action.
* @param string $checkbox An optional prefix for checkboxes.
* @return string The HTML markup
public static function checkedout($i, $editorName, $time, $prefix =
'', $enabled =
false, $checkbox =
'cb')
JHtml::_('bootstrap.tooltip');
$enabled =
array_key_exists('enabled', $options) ?
$options['enabled'] :
$enabled;
$checkbox =
array_key_exists('checkbox', $options) ?
$options['checkbox'] :
$checkbox;
$text =
$editorName .
'<br />' .
JHtml::_('date', $time, JText::_('DATE_FORMAT_LC')) .
'<br />' .
JHtml::_('date', $time, 'H:i');
$active_title =
JHtml::tooltipText(JText::_('JLIB_HTML_CHECKIN'), $text, 0);
$inactive_title =
JHtml::tooltipText(JText::_('JLIB_HTML_CHECKED_OUT'), $text, 0);
$i, 'checkin', $prefix, JText::_('JLIB_HTML_CHECKED_OUT'), $active_title, $inactive_title, true, 'checkedout',
'checkedout', $enabled, false, $checkbox
* Creates a order-up action icon.
* @param integer $i The row index.
* @param string $task An optional task to fire.
* @param string|array $prefix An optional task prefix or an array of options
* @param string $text An optional text to display
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
* @return string The HTML markup
public static function orderUp($i, $task =
'orderup', $prefix =
'', $text =
'JLIB_HTML_MOVE_UP', $enabled =
true, $checkbox =
'cb')
$enabled =
array_key_exists('enabled', $options) ?
$options['enabled'] :
$enabled;
$checkbox =
array_key_exists('checkbox', $options) ?
$options['checkbox'] :
$checkbox;
return static::action($i, $task, $prefix, $text, $text, $text, false, 'uparrow', 'uparrow_disabled', $enabled, true, $checkbox);
* Creates a order-down action icon.
* @param integer $i The row index.
* @param string $task An optional task to fire.
* @param string|array $prefix An optional task prefix or an array of options
* @param string $text An optional text to display
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
* @return string The HTML markup
public static function orderDown($i, $task =
'orderdown', $prefix =
'', $text =
'JLIB_HTML_MOVE_DOWN', $enabled =
true, $checkbox =
'cb')
$enabled =
array_key_exists('enabled', $options) ?
$options['enabled'] :
$enabled;
$checkbox =
array_key_exists('checkbox', $options) ?
$options['checkbox'] :
$checkbox;
return static::action($i, $task, $prefix, $text, $text, $text, false, 'downarrow', 'downarrow_disabled', $enabled, true, $checkbox);
Documentation generated on Tue, 19 Nov 2013 15:06:04 +0100 by phpDocumentor 1.4.3