public static string
sort
(mixed $title, mixed $order, mixed $direction = 'asc', mixed $selected = 0, mixed $task = null, mixed $newDirection = 'asc', mixed $tip = '', mixed $icon = null, mixed $formName = 'adminForm')
/**
* Method to sort a column in a grid
*
* @param string $title The link title
* @param string $order The order field for the column
* @param string $direction The current direction
* @param mixed $selected The selected ordering
* @param string $task An optional task override
* @param string $newDirection An optional direction for the new column
* @param string $tip An optional text shown as tooltip title instead of $title
* @param string $icon Icon to show
* @param string $formName Name of the form to submit
*
* @return string
*/
public static function sort($title, $order, $direction = 'asc', $selected = 0, $task = null, $newDirection = 'asc', $tip = '', $icon = null, $formName = 'adminForm')
{
$direction = strtolower($direction);
$orderIcons = array('icon-caret-up', 'icon-caret-down');
$index = (int) ($direction === 'desc');
if ($order !== $selected) {
$direction = $newDirection;
} else {
$direction = $direction === 'desc' ? 'asc' : 'desc';
}
// Create an object to pass it to the layouts
$data = new \stdClass();
$data->order = $order;
$data->direction = $direction;
$data->selected = $selected;
$data->task = $task;
$data->tip = $tip;
$data->title = $title;
$data->orderIcon = $orderIcons[$index];
$data->icon = $icon;
$data->formName = $formName;
return LayoutHelper::render('joomla.searchtools.grid.sort', $data);
}