Skip to content

Commit

Permalink
Improvement: Better sorting test if it's an associative array
Browse files Browse the repository at this point in the history
  • Loading branch information
georgmaisser authored and ibernhardf committed Jan 16, 2025
1 parent 2034e38 commit 87dd176
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions classes/output/table.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,16 +760,18 @@ public function return_sort_columns(array $sortcolumns) {

global $SESSION;

if (empty($this->wbtable->sortablecolumns )) {
if (empty($this->wbtable->sortablecolumns)) {
return null;
}

$isassociative = array_keys($this->wbtable->sortablecolumns) !== range(0, count($this->wbtable->sortablecolumns) - 1);

$sortarray['options'] = [];
foreach ($this->wbtable->sortablecolumns as $key => $value) {

// If we have an assoziative array, we have localized values.
// Else, we need to use the same value twice.
if (!isset($this->wbtable->columns[$key])) {
if (!$isassociative) {
$key = $value;
}

Expand Down

0 comments on commit 87dd176

Please sign in to comment.