public static string
action
(mixed $i, mixed $task, mixed $prefix = '', mixed $activeTitle = '', mixed $inactiveTitle = '', mixed $tip = false, mixed $activeClass = '', mixed $inactiveClass = '', mixed $enabled = true, mixed $translate = true, mixed $checkbox = 'cb', mixed $formId = null)
/**
* 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 $activeTitle An optional active tooltip to display if $enable is true
* @param string $inactiveTitle An optional inactive tooltip to display if $enable is true
* @param boolean $tip An optional setting for tooltip
* @param string $activeClass An optional active HTML class
* @param string $inactiveClass 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.
* @param string $formId An optional form selector.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function action($i, $task, $prefix = '', $activeTitle = '', $inactiveTitle = '', $tip = false, $activeClass = '', $inactiveClass = '', $enabled = true, $translate = true, $checkbox = 'cb', $formId = null)
{
if (is_array($prefix)) {
$options = $prefix;
$activeTitle = array_key_exists('active_title', $options) ? $options['active_title'] : $activeTitle;
$inactiveTitle = array_key_exists('inactive_title', $options) ? $options['inactive_title'] : $inactiveTitle;
$tip = array_key_exists('tip', $options) ? $options['tip'] : $tip;
$activeClass = array_key_exists('active_class', $options) ? $options['active_class'] : $activeClass;
$inactiveClass = array_key_exists('inactive_class', $options) ? $options['inactive_class'] : $inactiveClass;
$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;
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
}
if ($tip) {
$title = $enabled ? $activeTitle : $inactiveTitle;
$title = $translate ? Text::_($title) : $title;
$ariaid = $checkbox . $task . $i . '-desc';
// Don't show empty tooltip.
if ($title === '') {
$tip = false;
}
}
if ($enabled) {
$html[] = '<a class="tbody-icon' . ($activeClass === 'publish' ? ' active' : '') . '"';
if ($formId !== null) {
$html[] = ' href="javascript:void(0);" onclick="return Joomla.listItemTask(\'' . $checkbox . $i . '\',\'' . $prefix . $task . '\',\'' . $formId . '\')"';
} else {
$html[] = ' href="javascript:void(0);" onclick="return Joomla.listItemTask(\'' . $checkbox . $i . '\',\'' . $prefix . $task . '\')"';
}
$html[] = $tip ? ' aria-labelledby="' . $ariaid . '"' : '';
$html[] = '>';
$html[] = LayoutHelper::render('joomla.icon.iconclass', ['icon' => $activeClass]);
$html[] = '</a>';
$html[] = $tip ? '<div role="tooltip" id="' . $ariaid . '">' . $title . '</div>' : '';
} else {
$html[] = '<span class="tbody-icon jgrid"';
$html[] = $tip ? ' aria-labelledby="' . $ariaid . '"' : '';
$html[] = '>';
$html[] = LayoutHelper::render('joomla.icon.iconclass', ['icon' => $inactiveClass]);
$html[] = '</span>';
$html[] = $tip ? '<div role="tooltip" id="' . $ariaid . '">' . $title . '</div>' : '';
}
return implode($html);
}