example: Improve smarty_table_ordered_th function
This commit is contained in:
parent
7f2644b46a
commit
2bf05291fe
1 changed files with 10 additions and 7 deletions
|
@ -5,6 +5,8 @@ use EesyPHP\Date;
|
|||
use EesyPHP\Hook;
|
||||
use EesyPHP\Log;
|
||||
use EesyPHP\Tpl;
|
||||
use EesyPHP\Url;
|
||||
|
||||
|
||||
use function EesyPHP\format_size;
|
||||
|
||||
|
@ -70,14 +72,15 @@ Tpl :: register_function('format_size','smarty_format_size');
|
|||
|
||||
function smarty_table_ordered_th($params, $smarty) {
|
||||
if ($params['order'] && $params['url'] && $params['text'] && is_array($params['search'])) {
|
||||
$params['url'] .= (strpos($params['url'], '?') === false?'?':'&')."order=".$params['order'];
|
||||
echo "<a href='".$params['url']."'>".$params['text']."</a>";
|
||||
$params['url'] = Url::add_url_parameter($params['url'], 'order', $params['order']);
|
||||
printf("<a href='%s'>%s</a>", $params['url'], $params['text']);
|
||||
}
|
||||
if ($params['order']==$params['search']['order']) {
|
||||
echo (
|
||||
' <i class="fa fa-sort-'.
|
||||
(strtolower($params['search']['order_direction'])=='asc'?'up':'down').
|
||||
'" aria-hidden="true"></i>');
|
||||
if ($params['order'] == $params['search']['order']) {
|
||||
printf(
|
||||
' <i class="fa fa-sort-%s" aria-hidden="true"></i>',
|
||||
strtolower($params['search']['order_direction']) == 'asc'?
|
||||
'up':'down'
|
||||
);
|
||||
}
|
||||
}
|
||||
Tpl :: register_function('table_ordered_th','smarty_table_ordered_th');
|
||||
|
|
Loading…
Reference in a new issue