aboutsummaryrefslogtreecommitdiff
path: root/app/views/shared/sort_link.php
blob: 514646805203ee8e5c627d08251422876736a22b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$attributes = array_intersect_key($attributes, array_flip(['style', 'colspan']));
if ($controller->sortby === $field) {
    $attributes['class'] = 'sort' . mb_strtolower($controller->order);
}

$parameters = [
    "sortby{$controller->page_params_suffix}" => $field,
];
if ($controller->sortby !== $field || $controller->order === 'DESC') {
    $parameters["order{$controller->page_params_suffix}"] = 'ASC';
} else {
    $parameters["order{$controller->page_params_suffix}"] = 'DESC';
}
?>
<th <?= arrayToHtmlAttributes($attributes) ?>>
    <a href="<?= $controller->link_for($action, $parameters) ?>"><?= htmlReady($text) ?></a>
</th>