PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/adapter/html/classes/list.php +66 -0 1.6.1 → 1.8.16 View file →
@@ -1,0 +1,66 @@
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 list behaviors.
16 + *
17 + * @since 10.0
18 + */
19 +abstract class JHtmlList
20 +{
21 + /**
22 + * Select list of active users.
23 + *
24 + * @param string $name The name of the field.
25 + * @param string $active The active user.
26 + * @param integer $nouser If set include an option to select no user.
27 + * @param string $javascript Custom javascript.
28 + * @param string $order Specify a field to order by.
29 + *
30 + * @return string The HTML for a list of users list of users.
31 + */
32 + public static function users($name, $active, $nouser = 0, $javascript = null, $order = 'display_name')
33 + {
34 + if (empty($order))
35 + {
36 + $order = 'name';
37 + }
38 +
39 + $select = '';
40 +
41 + if ($nouser)
42 + {
43 + $select = $nouser ? "<option value=\"0\">--</option>" : '';
44 + }
45 +
46 + $dbo = JFactory::getDbo();
47 +
48 + $q = "SELECT `id`, `display_name`
49 + FROM `#__users`
50 + ORDER BY `{$order}` ASC";
51 +
52 + $dbo->setQuery($q);
53 + $dbo->execute();
54 +
55 + if ($dbo->getNumRows())
56 + {
57 + foreach ($dbo->loadObjectlist() as $u)
58 + {
59 + $status = $active == $u->id ? ' selected="selected"' : '';
60 + $select .= "<option value=\"{$u->id}\"{$status}>{$u->display_name}</option>";
61 + }
62 + }
63 +
64 + return "<select name=\"{$name}\" {$javascript}>{$select}</select>";
65 + }
66 +}