PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
trunk 1.2.17 1.2.18 1.2.19
vikappointments / libraries / adapter / html / classes / grid.php
vikappointments / libraries / adapter / html / classes Last commit date
access.php 2 years ago behavior.php 5 months ago bootstrap.php 5 months ago contentlanguage.php 2 years ago date.php 1 month ago form.php 2 years ago formbehavior.php 5 months ago grid.php 2 years ago jquery.php 2 years ago list.php 2 years ago number.php 2 years ago select.php 2 years ago user.php 2 years ago
grid.php
78 lines
1 <?php
2 /**
3 * @package VikWP - Libraries
4 * @subpackage adapter.html
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * Utility class for Grid behaviors.
16 *
17 * @since 10.0
18 */
19 abstract class JHtmlGrid
20 {
21 /**
22 * Method to sort a column in a grid.
23 *
24 * @param string $title The link title.
25 * @param string $order The order field for the column.
26 * @param string $direction The current direction.
27 * @param string $selected The selected ordering.
28 * @param string $task An optional task override.
29 * @param string $new_direction An optional direction for the new column.
30 * @param string $tip An optional text shown as tooltip title instead of $title.
31 * @param string $form An optional form selector.
32 *
33 * @return string The HTML grid column.
34 */
35 public static function sort($title, $order, $direction = 'asc', $selected = '', $task = null, $new_direction = 'asc', $tip = '', $form = null)
36 {
37 $direction = strtolower($direction);
38 $icon = array('sort-up', 'sort-down');
39 $index = (int) ($direction === 'desc');
40
41 if ($order != $selected)
42 {
43 $direction = $new_direction;
44 }
45 else
46 {
47 $direction = $direction === 'desc' ? 'asc' : 'desc';
48 }
49
50 if ($form)
51 {
52 $form = ', document.getElementById(\'' . $form . '\')';
53 }
54
55 $html = '<a href="#" onclick="Joomla.tableOrdering(\'' . $order . '\',\'' . $direction . '\',\'' . $task . '\'' . $form . ');return false;"'
56 . ' title="' . htmlspecialchars(JText::translate($tip ? $tip : '')) . '"'
57 . ($order == $selected ? 'class="activesort"' : '')
58 . '">';
59
60 $html .= JText::translate($title);
61
62 if ($order == $selected)
63 {
64 $html .= '<i class="fas fa-' . $icon[$index] . '"></i>';
65 }
66 else if (substr($title, 0, 1) !== '<')
67 {
68 // include sortable icon only in case the column title doesn't start with
69 // a tag opening, which could mean that the th displays another icon
70 $html .= '<i class="fas fa-sort"></i>';
71 }
72
73 $html .= '</a>';
74
75 return $html;
76 }
77 }
78