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\Hook;
|
||||||
use EesyPHP\Log;
|
use EesyPHP\Log;
|
||||||
use EesyPHP\Tpl;
|
use EesyPHP\Tpl;
|
||||||
|
use EesyPHP\Url;
|
||||||
|
|
||||||
|
|
||||||
use function EesyPHP\format_size;
|
use function EesyPHP\format_size;
|
||||||
|
|
||||||
|
@ -70,14 +72,15 @@ Tpl :: register_function('format_size','smarty_format_size');
|
||||||
|
|
||||||
function smarty_table_ordered_th($params, $smarty) {
|
function smarty_table_ordered_th($params, $smarty) {
|
||||||
if ($params['order'] && $params['url'] && $params['text'] && is_array($params['search'])) {
|
if ($params['order'] && $params['url'] && $params['text'] && is_array($params['search'])) {
|
||||||
$params['url'] .= (strpos($params['url'], '?') === false?'?':'&')."order=".$params['order'];
|
$params['url'] = Url::add_url_parameter($params['url'], 'order', $params['order']);
|
||||||
echo "<a href='".$params['url']."'>".$params['text']."</a>";
|
printf("<a href='%s'>%s</a>", $params['url'], $params['text']);
|
||||||
}
|
}
|
||||||
if ($params['order'] == $params['search']['order']) {
|
if ($params['order'] == $params['search']['order']) {
|
||||||
echo (
|
printf(
|
||||||
' <i class="fa fa-sort-'.
|
' <i class="fa fa-sort-%s" aria-hidden="true"></i>',
|
||||||
(strtolower($params['search']['order_direction'])=='asc'?'up':'down').
|
strtolower($params['search']['order_direction']) == 'asc'?
|
||||||
'" aria-hidden="true"></i>');
|
'up':'down'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Tpl :: register_function('table_ordered_th','smarty_table_ordered_th');
|
Tpl :: register_function('table_ordered_th','smarty_table_ordered_th');
|
||||||
|
|
Loading…
Reference in a new issue