| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - E4J srl |
| 6 |
* @copyright Copyright (C) 2022 e4j - Extensionsforjoomla.com. 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 |
/** |
| 14 |
* Obtain vars from arguments received in the layout file. |
| 15 |
* This layout file should be called once at most per page. |
| 16 |
* |
| 17 |
* @var string $vbo_page the name of the current View in VBO. |
| 18 |
* @var string $btn_trigger the CSS selector of the button that opens the panel. |
| 19 |
*/ |
| 20 |
extract($displayData); |
| 21 |
|
| 22 |
// make sure the current page name is set and it's a string |
| 23 |
$vbo_page = isset($vbo_page) ? htmlspecialchars($vbo_page, ENT_QUOTES) : ''; |
| 24 |
|
| 25 |
// get the current page uri |
| 26 |
$vbo_page_uri = htmlspecialchars((string) JUri::getInstance(), ENT_QUOTES); |
| 27 |
|
| 28 |
// get admin widgets helper |
| 29 |
$widgets_helper = VikBooking::getAdminWidgetsInstance(); |
| 30 |
|
| 31 |
// get all widgets by preloading their assets (if any) |
| 32 |
$admin_widgets = $widgets_helper->getWidgetNames($preload = true); |
| 33 |
|
| 34 |
// load current widgets map for this page |
| 35 |
$current_map = $widgets_helper->getMultitaskingMap($vbo_page); |
| 36 |
|
| 37 |
// page active widgets list |
| 38 |
$active_widgets = []; |
| 39 |
|
| 40 |
// check if the notification audio file exists within VCM |
| 41 |
$notif_audio_path = implode(DIRECTORY_SEPARATOR, [VCM_ADMIN_PATH, 'assets', 'css', 'audio', 'new_notification.mp3']); |
| 42 |
$notif_audio_url = is_file($notif_audio_path) ? (VCM_ADMIN_URI . implode('/', ['assets', 'css', 'audio', 'new_notification.mp3'])) : null; |
| 43 |
|
| 44 |
// JS lang vars |
| 45 |
JText::script('VBO_BROWSER_NOTIFS_ON'); |
| 46 |
JText::script('VBO_BROWSER_NOTIFS_OFF'); |
| 47 |
JText::script('VBO_BROWSER_NOTIFS_OFF_HELP'); |
| 48 |
JText::script('VBO_ADMIN_WIDGET'); |
| 49 |
JText::script('VBO_CONGRATS'); |
| 50 |
|
| 51 |
?> |
| 52 |
|
| 53 |
<div class="vbo-sidepanel-wrapper vbo-sidepanel-right vbo-sidepanel-close"> |
| 54 |
|
| 55 |
<div class="vbo-sidepanel-container"> |
| 56 |
|
| 57 |
<div class="vbo-sidepanel-layouts"> |
| 58 |
<div class="vbo-sidepanel-dismiss"> |
| 59 |
<span class="vbo-sidepanel-dismiss-btn"><?php VikBookingIcons::e('times'); ?></span> |
| 60 |
</div> |
| 61 |
<div class="vbo-sidepanel-notifications"> |
| 62 |
<button type="button" class="vbo-sidepanel-notifications-btn"><?php VikBookingIcons::e('bell'); ?></button> |
| 63 |
</div> |
| 64 |
<div class="vbo-sidepanel-layout-type"> |
| 65 |
<span class="vbo-sidepanel-layout-large"> |
| 66 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96.75 75.3"><defs></defs><path d="M87.68,8.65a3.23,3.23,0,0,1,3.23,3.22V66.53a3.23,3.23,0,0,1-3.23,3.23H11.57a3.23,3.23,0,0,1-3.22-3.23V11.87a3.22,3.22,0,0,1,3.22-3.22H87.68m0-7.1H11.57A10.32,10.32,0,0,0,1.25,11.87V66.53A10.32,10.32,0,0,0,11.57,76.85H87.68A10.32,10.32,0,0,0,98,66.53V11.87A10.32,10.32,0,0,0,87.68,1.55Z" transform="translate(-1.25 -1.55)"/><rect id="wide" x="10.15" y="10" width="77.22" height="55.25" rx="4.94"/></svg> |
| 67 |
</span> |
| 68 |
<span class="vbo-sidepanel-layout-small"> |
| 69 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96.75 75.3"><defs></defs><path d="M87.68,8.65a3.23,3.23,0,0,1,3.23,3.22V66.53a3.23,3.23,0,0,1-3.23,3.23H11.57a3.23,3.23,0,0,1-3.22-3.23V11.87a3.22,3.22,0,0,1,3.22-3.22H87.68m0-7.1H11.57A10.32,10.32,0,0,0,1.25,11.87V66.53A10.32,10.32,0,0,0,11.57,76.85H87.68A10.32,10.32,0,0,0,98,66.53V11.87A10.32,10.32,0,0,0,87.68,1.55Z" transform="translate(-1.25 -1.55)"/><rect id="right" x="48.1" y="12.42" width="35.75" height="50.93" rx="3.23"/></svg> |
| 70 |
</span> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
|
| 74 |
<div class="vbo-sidepanel-body-top"> |
| 75 |
|
| 76 |
<div class="vbo-sidepanel-search"> |
| 77 |
<?php VikBookingIcons::e('search', 'vbo-sidepanel-search-input-icn'); ?> |
| 78 |
<input id="vbo-sidepanel-search-input" type="text" placeholder="<?php echo htmlspecialchars(JText::translate('VBO_SEARCH_ADMIN_WIDGETS')); ?>" value="" /> |
| 79 |
</div> |
| 80 |
|
| 81 |
<div class="vbo-sidepanel-add-widgets"> |
| 82 |
<?php |
| 83 |
foreach ($admin_widgets as $k => $admin_widget) { |
| 84 |
/** |
| 85 |
* Add widget container must be focusable with "tabindex=-1" so that via JS we will |
| 86 |
* have the "relatedTarget" event property set to this element when blurring on search field. |
| 87 |
*/ |
| 88 |
?> |
| 89 |
<div class="vbo-sidepanel-add-widget" data-vbowidgetid="<?php echo $admin_widget->id; ?>" tabindex="-1"> |
| 90 |
<div class="vbo-sidepanel-widget-info"> |
| 91 |
<div class="vbo-sidepanel-widget-info-det"> |
| 92 |
<span class="vbo-sidepanel-widget-icn vbo-admin-widget-style-<?php echo $admin_widget->style; ?>"><?php echo $admin_widget->icon; ?></span> |
| 93 |
<span class="vbo-sidepanel-widget-name"><?php echo $admin_widget->name; ?></span> |
| 94 |
</div> |
| 95 |
<div class="vbo-sidepanel-widget-add"> |
| 96 |
<span class="vbo-widget-render-modal"><?php echo VikBookingIcons::e('far fa-window-restore'); ?></span> |
| 97 |
<span class="vbo-widget-render-regular"><?php echo VikBookingIcons::e('plus-circle'); ?></span> |
| 98 |
</div> |
| 99 |
</div> |
| 100 |
<div class="vbo-sidepanel-widget-tags" style="display: none;"><?php echo strtolower($admin_widget->name . ' ' . $admin_widget->descr); ?></div> |
| 101 |
</div> |
| 102 |
<?php |
| 103 |
} |
| 104 |
?> |
| 105 |
<div class="vbo-sidepanel-add-widgets-nores" style="display: none;"> |
| 106 |
<span><?php echo JText::translate('VBONORESULTS'); ?></span> |
| 107 |
</div> |
| 108 |
</div> |
| 109 |
|
| 110 |
</div> |
| 111 |
|
| 112 |
<div class="vbo-sidepanel-active-widgets"> |
| 113 |
<?php |
| 114 |
// get multitask data object |
| 115 |
$multitask_data = VBOMultitaskParser::getInstance($vbo_page, $vbo_page_uri)->getData(); |
| 116 |
foreach ($current_map as $widget_id) { |
| 117 |
$widget_instance = $widgets_helper->getWidget($widget_id); |
| 118 |
if (!$widget_instance) { |
| 119 |
continue; |
| 120 |
} |
| 121 |
// turn on multitask flag |
| 122 |
$widget_instance->setInMultitask(true); |
| 123 |
// build widget info object |
| 124 |
$widget_info = new stdClass; |
| 125 |
$widget_info->id = $widget_instance->getIdentifier(); |
| 126 |
$widget_info->name = $widget_instance->getName(); |
| 127 |
// push widget info object to list |
| 128 |
$active_widgets[] = $widget_info; |
| 129 |
?> |
| 130 |
<div class="vbo-admin-widgets-widget-output vbo-admin-widgets-container-small" data-vbowidgetid="<?php echo $widget_info->id; ?>"> |
| 131 |
<div class="vbo-admin-widgets-widget-detach"><?php VikBookingIcons::e('window-restore'); ?></div> |
| 132 |
<?php $widget_instance->render($multitask_data); ?> |
| 133 |
</div> |
| 134 |
<?php |
| 135 |
} |
| 136 |
?> |
| 137 |
</div> |
| 138 |
|
| 139 |
<div class="vbo-sidepanel-edit-widgets"> |
| 140 |
<div class="vbo-sidepanel-edit-widgets-wrap"> |
| 141 |
<button class="btn btn-small vbo-sidepanel-edit-widgets-trig" style="<?php echo !count($active_widgets) ? 'display: none;' : ''; ?>"><?php echo JText::translate('VBO_WIDGETS_CUSTWIDGETS'); ?></button> |
| 142 |
</div> |
| 143 |
</div> |
| 144 |
|
| 145 |
</div> |
| 146 |
|
| 147 |
</div> |
| 148 |
|
| 149 |
<script type="text/javascript"> |
| 150 |
jQuery(function() { |
| 151 |
|
| 152 |
// inject core properties |
| 153 |
VBOCore.setOptions({ |
| 154 |
is_vbo: true, |
| 155 |
widget_ajax_uri: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=exec_admin_widget'); ?>", |
| 156 |
assets_ajax_uri: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=widgets_get_assets'); ?>", |
| 157 |
multitask_ajax_uri: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=exec_multitask_widgets'); ?>", |
| 158 |
watchdata_ajax_uri: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=widgets_watch_data'); ?>", |
| 159 |
current_page: "<?php echo $vbo_page; ?>", |
| 160 |
current_page_uri: "<?php echo $vbo_page_uri; ?>", |
| 161 |
admin_widgets: <?php echo json_encode($active_widgets); ?>, |
| 162 |
notif_audio_url: "<?php echo $notif_audio_url; ?>", |
| 163 |
tn_texts: { |
| 164 |
notifs_enabled: Joomla.JText._('VBO_BROWSER_NOTIFS_ON'), |
| 165 |
notifs_disabled: Joomla.JText._('VBO_BROWSER_NOTIFS_OFF'), |
| 166 |
notifs_disabled_help: Joomla.JText._('VBO_BROWSER_NOTIFS_OFF_HELP'), |
| 167 |
admin_widget: Joomla.JText._('VBO_ADMIN_WIDGET'), |
| 168 |
congrats: Joomla.JText._('VBO_CONGRATS'), |
| 169 |
}, |
| 170 |
default_loading_body: '<?php VikBookingIcons::e('circle-notch', 'fa-spin fa-fw'); ?>', |
| 171 |
}); |
| 172 |
|
| 173 |
// initialize multitasking events |
| 174 |
VBOCore.prepareMultitasking({ |
| 175 |
selector: ".vbo-sidepanel-wrapper", |
| 176 |
sclass_l_small: "vbo-sidepanel-right", |
| 177 |
sclass_l_large: "vbo-sidepanel-large", |
| 178 |
btn_trigger: "<?php echo $btn_trigger; ?>", |
| 179 |
search_selector: "#vbo-sidepanel-search-input", |
| 180 |
search_nores: ".vbo-sidepanel-add-widgets-nores", |
| 181 |
close_selector: ".vbo-sidepanel-dismiss-btn", |
| 182 |
t_layout_small: ".vbo-sidepanel-layout-small", |
| 183 |
t_layout_large: ".vbo-sidepanel-layout-large", |
| 184 |
wclass_base_sel: ".vbo-admin-widgets-widget-output", |
| 185 |
wclass_l_small: "vbo-admin-widgets-container-small", |
| 186 |
wclass_l_large: "vbo-admin-widgets-container-large", |
| 187 |
addws_selector: ".vbo-sidepanel-add-widgets", |
| 188 |
addw_selector: ".vbo-sidepanel-add-widget", |
| 189 |
addwfs_selector: ".vbo-sidepanel-add-widget-focussed", |
| 190 |
wtags_selector: ".vbo-sidepanel-widget-tags", |
| 191 |
addw_data_attr: "data-vbowidgetid", |
| 192 |
actws_selector: ".vbo-sidepanel-active-widgets", |
| 193 |
editw_selector: ".vbo-sidepanel-edit-widgets-trig", |
| 194 |
editmode_class: "vbo-admin-widgets-widget-editing", |
| 195 |
rmwidget_class: "vbo-admin-widgets-widget-remove", |
| 196 |
rmwidget_icn: '<?php VikBookingIcons::e('times'); ?>', |
| 197 |
dtcwidget_class: "vbo-admin-widgets-widget-detach", |
| 198 |
dtctarget_class: "vbo-admin-widget-head", |
| 199 |
dtcwidget_icn: '<?php VikBookingIcons::e('far fa-window-restore'); ?>', |
| 200 |
notif_selector: ".vbo-sidepanel-notifications-btn", |
| 201 |
notif_on_class: "vbo-sidepanel-notifications-on", |
| 202 |
notif_off_class: "vbo-sidepanel-notifications-off", |
| 203 |
}); |
| 204 |
|
| 205 |
}); |
| 206 |
</script> |
| 207 |
|