card.php
106 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 | * @param string id An optional ID to be set for the card. |
| 18 | * @param string class An additional class to be used (optional). |
| 19 | * @param string image Either the source image or the HTML itself. |
| 20 | * @param string badge The text to display within the badge icon in the summary. |
| 21 | * It is possible to specify plain text or HTML. |
| 22 | * @param string primary The primary text to be displayed in the summary. |
| 23 | * @param string secondary The secondary text to be displayed in the summary. |
| 24 | * @param string edit True to display the EDIT button. In case a string was |
| 25 | * passed, it will be used as callback when the button is clicked. |
| 26 | */ |
| 27 | $id = isset($displayData['id']) ? $displayData['id'] : null; |
| 28 | $class = isset($displayData['class']) ? $displayData['class'] : null; |
| 29 | $image = isset($displayData['image']) ? $displayData['image'] : null; |
| 30 | $badge = isset($displayData['badge']) ? $displayData['badge'] : null; |
| 31 | $primary = isset($displayData['primary']) ? $displayData['primary'] : ''; |
| 32 | $secondary = isset($displayData['secondary']) ? $displayData['secondary'] : ''; |
| 33 | $edit = isset($displayData['edit']) ? $displayData['edit'] : null; |
| 34 | $editText = isset($displayData['editText']) ? $displayData['editText'] : JText::translate('VAPEDIT'); |
| 35 | $editClass = isset($displayData['editClass']) ? $displayData['editClass'] : ''; |
| 36 | |
| 37 | ?> |
| 38 | |
| 39 | <div |
| 40 | class="vap-card<?php echo $class ? ' ' . $class : ''; ?>" |
| 41 | <?php echo $id ? 'id="' . $id . '"' : ''; ?> |
| 42 | > |
| 43 | |
| 44 | <div class="vap-card-image" style="<?php echo $image ? '' : 'display:none;'; ?>"> |
| 45 | <?php |
| 46 | if ($image) |
| 47 | { |
| 48 | if (preg_match("/^<img/", $image)) |
| 49 | { |
| 50 | echo $image; |
| 51 | } |
| 52 | else |
| 53 | { |
| 54 | ?><img src="<?php echo $image; ?>" /><?php |
| 55 | } |
| 56 | } |
| 57 | ?> |
| 58 | </div> |
| 59 | |
| 60 | <div class="vap-card-summary"> |
| 61 | |
| 62 | <?php |
| 63 | if ($badge) |
| 64 | { |
| 65 | ?> |
| 66 | <div class="card-badge-icon"> |
| 67 | <?php echo $badge; ?> |
| 68 | </div> |
| 69 | <?php |
| 70 | } |
| 71 | ?> |
| 72 | |
| 73 | <div class="card-text"> |
| 74 | <div class="card-text-primary"><?php echo $primary ?></div> |
| 75 | |
| 76 | <div class="card-text-secondary"><?php echo $secondary ?></div> |
| 77 | </div> |
| 78 | |
| 79 | <?php |
| 80 | if ($edit) |
| 81 | { |
| 82 | if (is_string($edit)) |
| 83 | { |
| 84 | $onclick = ' onclick="' . $this->escape($edit) . '"'; |
| 85 | } |
| 86 | else if (is_numeric($edit)) |
| 87 | { |
| 88 | $onclick = ' data-id="' . $edit . '"'; |
| 89 | } |
| 90 | else |
| 91 | { |
| 92 | $onclick = ''; |
| 93 | } |
| 94 | |
| 95 | ?> |
| 96 | <button type="button" class="btn card-edit<?php echo $editClass ? ' ' . $editClass : ''; ?>"<?php echo $onclick; ?>> |
| 97 | <?php echo $editText; ?> |
| 98 | </button> |
| 99 | <?php |
| 100 | } |
| 101 | ?> |
| 102 | |
| 103 | </div> |
| 104 | |
| 105 | </div> |
| 106 |