Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions libraries/src/HTML/Helpers/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ abstract class Grid
*/
public static function sort($title, $order, $direction = 'asc', $selected = '', $task = null, $newDirection = 'asc', $tip = '', $form = null)
{
Factory::getDocument()->getWebAssetManager()->useScript('list-view');
HTMLHelper::_('bootstrap.tooltip', '.hasTooltip');

$direction = strtolower($direction);
Expand All @@ -56,12 +55,12 @@ public static function sort($title, $order, $direction = 'asc', $selected = '',
$direction = $direction === 'desc' ? 'asc' : 'desc';
}

$html = '<a href="#" class="hasTooltip" title="' . htmlspecialchars(Text::_('JGLOBAL_CLICK_TO_SORT_THIS_COLUMN')) . '"'
. ' data-ordering-order="' . $order . '"'
. ' data-ordering-direction="' . $direction . '"'
. ' data-ordering-task="' . $task . '"'
. ' data-ordering-form="' . (isset($form) ? $form : '') . '"'
. ' data-bs-placement="top">';
if ($form) {
$form = ', document.getElementById(\'' . $form . '\')';
}

$html = '<a href="#" onclick="Joomla.tableOrdering(\'' . $order . '\',\'' . $direction . '\',\'' . $task . '\'' . $form . ');return false;"'
. ' class="hasTooltip" title="' . htmlspecialchars(Text::_('JGLOBAL_CLICK_TO_SORT_THIS_COLUMN')) . '" data-bs-placement="top">';

if (isset($title['0']) && $title['0'] === '<') {
$html .= $title;
Expand Down Expand Up @@ -90,15 +89,9 @@ public static function sort($title, $order, $direction = 'asc', $selected = '',
*/
public static function checkall($name = 'checkall-toggle', $action = 'Joomla.checkAll(this)')
{
Factory::getDocument()->getWebAssetManager()->useScript('list-view');
HTMLHelper::_('behavior.core');

if ($action !== 'Joomla.checkAll(this)') {
$action = ' onclick="' . $action . '"';
} else {
$action = '';
}

return '<input class="js-grid-item-check-all form-check-input" autocomplete="off" type="checkbox" name="' . $name . '" value="" title="' . Text::_('JGLOBAL_CHECK_ALL') . '"' . $action . '>';
return '<input class="form-check-input" autocomplete="off" type="checkbox" name="' . $name . '" value="" title="' . Text::_('JGLOBAL_CHECK_ALL') . '" onclick="' . $action . '">';
}

/**
Expand All @@ -118,12 +111,17 @@ public static function checkall($name = 'checkall-toggle', $action = 'Joomla.che
*/
public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid', $stub = 'cb', $title = '', $formId = null)
{
Factory::getDocument()->getWebAssetManager()->useScript('list-view');
if ($formId !== null) {
return $checkedOut ? '' : '<label for="' . $stub . $rowNum . '"><span class="visually-hidden">' . Text::_('JSELECT')
. ' ' . htmlspecialchars($title, ENT_COMPAT, 'UTF-8') . '</span></label>'
. '<input class="form-check-input" type="checkbox" id="' . $stub . $rowNum . '" name="' . $name . '[]" value="' . $recId
. '" onclick="Joomla.isChecked(this.checked, \'' . $formId . '\');">';
}

return $checkedOut ? '' : '<label for="' . $stub . $rowNum . '"><span class="visually-hidden">' . Text::_('JSELECT')
. ' ' . htmlspecialchars($title, ENT_COMPAT, 'UTF-8') . '</span></label>'
. '<input class="js-grid-item-is-checked form-check-input" autocomplete="off" type="checkbox" id="' . $stub . $rowNum . '" name="' . $name . '[]" value="' . $recId
. '"' . ($formId !== null ? ' data-form-id="' . $formId . '"' : '') . '>';
. '<input class="form-check-input" autocomplete="off" type="checkbox" id="' . $stub . $rowNum . '" name="' . $name . '[]" value="' . $recId
. '" onclick="Joomla.isChecked(this.checked);">';
}

/**
Expand Down Expand Up @@ -174,8 +172,6 @@ public static function checkedOut(&$row, $i, $identifier = 'id')
*/
public static function published($value, $i, $img1 = 'tick.png', $img0 = 'publish_x.png', $prefix = '')
{
Factory::getDocument()->getWebAssetManager()->useScript('list-view');

if (is_object($value)) {
$value = $value->published;
}
Expand All @@ -185,7 +181,7 @@ public static function published($value, $i, $img1 = 'tick.png', $img0 = 'publis
$alt = $value ? Text::_('JPUBLISHED') : Text::_('JUNPUBLISHED');
$action = $value ? Text::_('JLIB_HTML_UNPUBLISH_ITEM') : Text::_('JLIB_HTML_PUBLISH_ITEM');

return '<a href="#" class="js-grid-item-action" data-item-id="cb' . $i . '" data-item-task="' . $prefix . $task . '" title="' . $action . '">'
return '<a href="#" onclick="return Joomla.listItemTask(\'cb' . $i . '\',\'' . $prefix . $task . '\')" title="' . $action . '">'
. HTMLHelper::_('image', 'admin/' . $img, $alt, null, true) . '</a>';
}

Expand Down