| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - E4J srl |
| 6 |
* @copyright Copyright (C) 2024 E4J srl. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 12 |
|
| 13 |
$input = JFactory::getApplication()->input; |
| 14 |
|
| 15 |
// access the global operators object |
| 16 |
$oper_obj = VikBooking::getOperatorInstance(); |
| 17 |
|
| 18 |
// get tool data |
| 19 |
$tool_data = $oper_obj->getToolData($this->tool); |
| 20 |
|
| 21 |
if (!$tool_data) { |
| 22 |
// tool is unknown |
| 23 |
VBOHttpDocument::getInstance()->close(404, sprintf('Operator tool not found (%s)', $this->tool)); |
| 24 |
} |
| 25 |
|
| 26 |
if (!$oper_obj->checkPermissions($this->operator, $this->tool)) { |
| 27 |
// no permission to access this tool |
| 28 |
VBOHttpDocument::getInstance()->close(403, sprintf('Not enough permissions to access the tool (%s)', $this->tool)); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Wrap operator tool permissions into a registry. |
| 33 |
* NOTICE: checkPermissions() called above will modify |
| 34 |
* by reference the "perms" key on the operator array record. |
| 35 |
*/ |
| 36 |
$permissions = new JObject(($this->operator['perms'] ?: [])); |
| 37 |
|
| 38 |
// build URI to current tool |
| 39 |
$tool_uri = JRoute::rewrite( |
| 40 |
sprintf( |
| 41 |
'index.php?option=com_vikbooking&view=operators&tool=%s&Itemid=%d', |
| 42 |
$this->tool, |
| 43 |
JFactory::getApplication()->input->getInt('Itemid', 0) |
| 44 |
) |
| 45 |
); |
| 46 |
|
| 47 |
// tool icon |
| 48 |
$tool_icon = ($tool_data['icon'] ?? '') ?: '<i class="' . VikBookingIcons::i('cube') . '"></i>'; |
| 49 |
|
| 50 |
?> |
| 51 |
<div class="vbo-operator-tool-container"> |
| 52 |
<div class="vbo-operator-tool-breadcrumbs"> |
| 53 |
<span class="vbo-operator-tool-breadcrumb vbo-operator-tool-breadcrumb-home"> |
| 54 |
<a class="vbo-pref-color-text" href="<?php echo JRoute::rewrite('index.php?option=com_vikbooking&view=operators&Itemid=' . $input->getInt('Itemid', 0)); ?>"> |
| 55 |
<?php VikBookingIcons::e('th-list'); ?> |
| 56 |
<span class="vbo-operator-tool-breadcrumb-name"><?php echo JText::translate('VBMENUDASHBOARD'); ?></span> |
| 57 |
<span class="vbo-operator-tool-breadcrumb-separator"><?php VikBookingIcons::e('chevron-right'); ?></span> |
| 58 |
</a> |
| 59 |
</span> |
| 60 |
<!-- use .vbo-operator-tool-breadcrumb-step-current to define a previous breadcrump-step, not the home, not the current --> |
| 61 |
<span class="vbo-operator-tool-breadcrumb vbo-operator-tool-breadcrumb-step vbo-operator-tool-breadcrumb-step-current"> |
| 62 |
<?php echo $tool_icon; ?> |
| 63 |
<span class="vbo-operator-tool-breadcrumb-name"><?php echo $oper_obj->getToolName($this->tool); ?></span> |
| 64 |
</span> |
| 65 |
</div> |
| 66 |
<div class="vbo-operator-tool-wrap"> |
| 67 |
<?php |
| 68 |
// determine how to render the requested tool |
| 69 |
if (is_callable(($tool_data['rendering_callback'] ?? null))) { |
| 70 |
// render the tool through the callback ("layout", unless a custom tool defined a custom rendering callback) |
| 71 |
$tool_data['rendering_callback']($this->tool, $this->operator, $permissions, $tool_uri); |
| 72 |
} else { |
| 73 |
// render the tool by dispatching the dedicated event/hook |
| 74 |
VBOFactory::getPlatform()->getDispatcher()->trigger('onRenderOperatorTool' . ucfirst($this->tool), [$this->tool, $this->operator, $permissions, $tool_uri]); |
| 75 |
} |
| 76 |
?> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
|