admin.php
1 month ago
index.html
4 years ago
inspector.php
4 years ago
mediamanager.php
4 years ago
scripts.php
5 months ago
inspector.php
92 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 | * VikAppointments inspector HTML helper. |
| 16 | * |
| 17 | * @since 1.7 |
| 18 | */ |
| 19 | abstract class VAPHtmlInspector |
| 20 | { |
| 21 | /** |
| 22 | * Renders a HTML inspector. |
| 23 | * |
| 24 | * @param string $id The inspector ID. |
| 25 | * @param array $attributes An array of attributes for the inspector. |
| 26 | * - title An optional inspector title; |
| 27 | * - closeButton True to display the close button; |
| 28 | * - keyboard True to dismiss the inspector by pressing ESC; |
| 29 | * - width The width of the sidebar (in pixel or percentage). |
| 30 | * - placement Where the inspector should be placed (left or right); |
| 31 | * - class Either a string or a list of additional classes. |
| 32 | * - url An optional URL to render the body within a <iframe>; |
| 33 | * - footer An optional footer to be placed at bottom. |
| 34 | * @param string $body An optional HTML string to be placed in the body. |
| 35 | * |
| 36 | * @return string The inspector HTML. |
| 37 | * |
| 38 | * @uses script() |
| 39 | */ |
| 40 | public static function render($id, array $attributes = array(), $body = null) |
| 41 | { |
| 42 | // raise error in case ID is empty |
| 43 | if (!$id) |
| 44 | { |
| 45 | throw new RuntimeException('Missing Inspector ID', 404); |
| 46 | } |
| 47 | |
| 48 | $vik = VAPApplication::getInstance(); |
| 49 | |
| 50 | // load inspector scripts |
| 51 | $vik->addScript(VAPASSETS_ADMIN_URI . 'js/inspector.js'); |
| 52 | $vik->addStyleSheet(VAPASSETS_ADMIN_URI . 'css/inspector.css'); |
| 53 | JText::script('VAPCONNECTIONLOSTERROR'); |
| 54 | |
| 55 | $data = array(); |
| 56 | |
| 57 | // fetch layout data |
| 58 | $data['id'] = $id; |
| 59 | $data['title'] = !empty($attributes['title']) ? $attributes['title'] : false; |
| 60 | $data['closeButton'] = !empty($attributes['closeButton']) ? true : false; |
| 61 | $data['keyboard'] = !empty($attributes['keyboard']) ? true : false; |
| 62 | $data['url'] = !empty($attributes['url']) ? $attributes['url'] : false; |
| 63 | $data['width'] = !empty($attributes['width']) ? $attributes['width'] : ''; |
| 64 | $data['placement'] = !empty($attributes['placement']) ? $attributes['placement'] : 'right'; |
| 65 | $data['class'] = !empty($attributes['class']) ? (array) $attributes['class'] : array(); |
| 66 | $data['footer'] = !empty($attributes['footer']) ? $attributes['footer'] : false; |
| 67 | $data['body'] = (string) $body; |
| 68 | |
| 69 | // santitize width |
| 70 | if (preg_match("/^[\d.]+$/", (string) $data['width'])) |
| 71 | { |
| 72 | // append "px" because we received an amount |
| 73 | $data['width'] .= 'px'; |
| 74 | } |
| 75 | |
| 76 | // append custom class in case of blank template |
| 77 | if (JFactory::getApplication()->input->get('tmpl') === 'component') |
| 78 | { |
| 79 | $data['class'][] = 'blank-template'; |
| 80 | } |
| 81 | |
| 82 | // join the classes |
| 83 | $data['class'] = implode(' ', $data['class']); |
| 84 | |
| 85 | // create layout |
| 86 | $layout = new JLayoutFile('inspector.sidebar'); |
| 87 | |
| 88 | // return HTML of the field |
| 89 | return $layout->render($data); |
| 90 | } |
| 91 | } |
| 92 |