Skip to content

Commit eaa8b47

Browse files
committed
Simplify code in SortableTable when applying filter to cell
1 parent 8716a8d commit eaa8b47

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

public/main/inc/lib/sortable_table.class.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,26 +1053,23 @@ public function filter_data($row)
10531053
{
10541054
$url_params = $this->get_sortable_table_param_string().'&'.$this->get_additional_url_paramstring();
10551055
foreach ($this->column_filters as $column => &$function) {
1056-
$firstParam = isset($row[$column]) ? $row[$column] : 0;
1056+
$firstParam = $row[$column] ?? 0;
10571057
$row[$column] = call_user_func($function, $firstParam, $url_params, $row);
10581058
}
1059-
if (count($this->form_actions) > 0) {
1060-
if (strlen($row[0]) > 0) {
1061-
$checkboxParams = [];
1062-
1063-
if (isset($_GET[$this->param_prefix.'selectall'])) {
1064-
$checkboxParams['checked'] = 'checked';
1065-
}
1059+
if (count($this->form_actions) > 0 && strlen($row[0]) > 0) {
1060+
$checkboxParams = [];
10661061

1067-
$row[0] = Display::input('checkbox', $this->checkbox_name.'[]', $row[0], $checkboxParams);
1062+
if (isset($_GET[$this->param_prefix.'selectall'])) {
1063+
$checkboxParams['checked'] = 'checked';
10681064
}
1065+
1066+
$row[0] = Display::input('checkbox', $this->checkbox_name.'[]', $row[0], $checkboxParams);
10691067
}
10701068
if (is_array($row)) {
1071-
foreach ($row as &$value) {
1072-
if (empty($value)) {
1073-
$value = '-';
1074-
}
1075-
}
1069+
$row = array_map(
1070+
fn($value) => empty($value) ? '-' : $value,
1071+
$row
1072+
);
10761073
}
10771074

10781075
return $row;

0 commit comments

Comments
 (0)