checkbox.php
2 days ago
color.php
2 days ago
date.php
2 days ago
editor.php
2 days ago
file.php
2 days ago
hidden.php
2 days ago
html.php
2 days ago
index.html
2 days ago
number.php
2 days ago
password.php
2 days ago
select.php
2 days ago
separator.php
2 days ago
tel.php
2 days ago
text.php
2 days ago
textarea.php
2 days ago
select.php
58 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 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 | $name = !empty($displayData['name']) ? $displayData['name'] : 'name'; |
| 15 | $id = !empty($displayData['id']) ? $displayData['id'] : $name; |
| 16 | $value = isset($displayData['value']) ? $displayData['value'] : ''; |
| 17 | $class = isset($displayData['class']) ? $displayData['class'] : ''; |
| 18 | $multiple = isset($displayData['multiple']) ? $displayData['multiple'] : false; |
| 19 | $options = isset($displayData['options']) ? $displayData['options'] : array(); |
| 20 | |
| 21 | if ($multiple) |
| 22 | { |
| 23 | $value = (array) $value; |
| 24 | } |
| 25 | |
| 26 | // check if we have an associative array |
| 27 | $is_assoc = (array_keys($options) !== range(0, count($options) - 1)); |
| 28 | |
| 29 | // check whether we should build an array of options |
| 30 | if ($is_assoc || ($options && is_scalar($options[0]))) |
| 31 | { |
| 32 | $tmp = array(); |
| 33 | |
| 34 | foreach ($options as $optValue => $optText) |
| 35 | { |
| 36 | if (!$is_assoc) |
| 37 | { |
| 38 | // in case of linear array, use the option text as value |
| 39 | $optValue = $optText; |
| 40 | } |
| 41 | |
| 42 | $tmp[] = JHtml::fetch('select.option', $optValue, $optText); |
| 43 | } |
| 44 | |
| 45 | $options = $tmp; |
| 46 | } |
| 47 | |
| 48 | ?> |
| 49 | |
| 50 | <select |
| 51 | name="<?php echo $this->escape($name); ?>" |
| 52 | id="<?php echo $this->escape($id); ?>" |
| 53 | class="<?php echo $this->escape($class); ?>" |
| 54 | <?php echo $multiple ? 'multiple' : ''; ?> |
| 55 | > |
| 56 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $value); ?> |
| 57 | </select> |
| 58 |