badge.php
67 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 | /** |
| 15 | * Layout variables |
| 16 | * ----------------- |
| 17 | * @var object $tag The object holding the tag details. |
| 18 | * @var array $attrs A list of field attributes. |
| 19 | */ |
| 20 | extract($displayData); |
| 21 | |
| 22 | if (!isset($attrs['style'])) |
| 23 | { |
| 24 | $attrs['style'] = ''; |
| 25 | } |
| 26 | |
| 27 | // check if the tag owns a color |
| 28 | if ($tag->color) |
| 29 | { |
| 30 | // overwrite default color of the tag |
| 31 | $attrs['style'] .= 'background-color: #' . $tag->color . ';'; |
| 32 | |
| 33 | // check if the tag color is bright or dark |
| 34 | if (JHtml::fetch('vaphtml.color.light', $tag->color)) |
| 35 | { |
| 36 | // we have a light background, so we need to use a darker foreground |
| 37 | $attrs['style'] .= 'color: #333;'; |
| 38 | } |
| 39 | else |
| 40 | { |
| 41 | // we have a dark background, so we need to use a lighter foreground |
| 42 | $attrs['style'] .= 'color: #fff;'; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // fetch attributes string |
| 47 | $attrs_str = ''; |
| 48 | |
| 49 | foreach ($attrs as $k => $v) |
| 50 | { |
| 51 | if ($k != 'class') |
| 52 | { |
| 53 | $attrs_str .= ' ' . $k; |
| 54 | |
| 55 | if (!is_bool($v)) |
| 56 | { |
| 57 | $attrs_str .= ' = "' . $this->escape($v) . '"'; |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | ?> |
| 63 | |
| 64 | <span class="badge<?php echo (!empty($attrs['class']) ? ' ' . $attrs['class'] : ''); ?>"<?php echo $attrs_str; ?>> |
| 65 | <?php echo $tag->name; ?> |
| 66 | </span> |
| 67 |