Back to JGrid class

Method state

public static string
state
(mixed $states, mixed $value, mixed $i, mixed $prefix = '', mixed $enabled = true, mixed $translate = true, mixed $checkbox = 'cb', mixed $formId = null)
Returns a state on a grid
Parameters
  • array $states array of value/state. Each state is an array of the form (task, text, active title, inactive title, tip (boolean), 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)
  • int $value The state value.
  • int $i The row index
  • string|array $prefix An optional task prefix or an array of options
  • bool $enabled An optional setting for access control on the action.
  • bool $translate An optional setting for translation.
  • string $checkbox An optional prefix for checkboxes.
  • string $formId An optional form selector.
Returns
  • string The HTML markup
Since
  • 1.6
Class: JGrid
Project: Joomla

Method state - Source code

/**
 * Returns a state on a grid
 *
 * @param   array         $states     array of value/state. Each state is an array of the form
 *                                    (task, text, active title, inactive title, tip (boolean), 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.
 * @param   string        $formId     An optional form selector.
 *
 * @return  string  The HTML markup
 *
 * @since   1.6
 */
public static function state($states, $value, $i, $prefix = '', $enabled = true, $translate = true, $checkbox = 'cb', $formId = null)
{
    if (is_array($prefix)) {
        $options = $prefix;
        $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'] : '';
    }
    $state = ArrayHelper::getValue($states, (int) $value, $states[0]);
    $task = array_key_exists('task', $state) ? $state['task'] : $state[0];
    $text = array_key_exists('text', $state) ? $state['text'] : (array_key_exists(1, $state) ? $state[1] : '');
    $activeTitle = array_key_exists('active_title', $state) ? $state['active_title'] : (array_key_exists(2, $state) ? $state[2] : '');
    $inactiveTitle = array_key_exists('inactive_title', $state) ? $state['inactive_title'] : (array_key_exists(3, $state) ? $state[3] : '');
    $tip = array_key_exists('tip', $state) ? $state['tip'] : (array_key_exists(4, $state) ? $state[4] : false);
    $activeClass = array_key_exists('active_class', $state) ? $state['active_class'] : (array_key_exists(5, $state) ? $state[5] : '');
    $inactiveClass = array_key_exists('inactive_class', $state) ? $state['inactive_class'] : (array_key_exists(6, $state) ? $state[6] : '');
    return static::action($i, $task, $prefix, $activeTitle, $inactiveTitle, $tip, $activeClass, $inactiveClass, $enabled, $translate, $checkbox, $formId);
}