Back to Grid class

Method published

public static string
published
(mixed $value, mixed $i, mixed $img1 = 'tick.png', mixed $img0 = 'publish_x.png', mixed $prefix = '')
Method to create a clickable icon to change the state of an item
Parameters
  • mixed $value Either the scalar value or an object (for backward compatibility, deprecated)
  • int $i The index
  • string $img1 Image for a positive or on value
  • string $img0 Image for the empty or off value
  • string $prefix An optional prefix for the task
Returns
  • string
Since
  • 1.5
Class: Grid
Project: Joomla

Method published - Source code

/**
 * Method to create a clickable icon to change the state of an item
 *
 * @param   mixed    $value   Either the scalar value or an object (for backward compatibility, deprecated)
 * @param   integer  $i       The index
 * @param   string   $img1    Image for a positive or on value
 * @param   string   $img0    Image for the empty or off value
 * @param   string   $prefix  An optional prefix for the task
 *
 * @return  string
 *
 * @since   1.5
 */
public static function published($value, $i, $img1 = 'tick.png', $img0 = 'publish_x.png', $prefix = '')
{
    if (is_object($value)) {
        $value = $value->published;
    }
    $img = $value ? $img1 : $img0;
    $task = $value ? 'unpublish' : 'publish';
    $alt = $value ? Text::_('JPUBLISHED') : Text::_('JUNPUBLISHED');
    $action = $value ? Text::_('JLIB_HTML_UNPUBLISH_ITEM') : Text::_('JLIB_HTML_PUBLISH_ITEM');
    return '<a href="#" onclick="return Joomla.listItemTask(\'cb' . $i . '\',\'' . $prefix . $task . '\')" title="' . $action . '">' . HTMLHelper::_('image', 'admin/' . $img, $alt, null, true) . '</a>';
}