| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage mod_vikbooking_chat |
| 5 |
* @author E4J s.r.l |
| 6 |
* @copyright Copyright (C) 2026 E4J s.r.l. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// no direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
$app = JFactory::getApplication(); |
| 15 |
$document = JFactory::getDocument(); |
| 16 |
|
| 17 |
if ($app->input->get('option') === 'com_vikbooking' && $app->input->get('view') === 'chat') { |
| 18 |
// do not display the module if we are inside a chat view |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
require_once VBO_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikbooking.php'; |
| 23 |
|
| 24 |
$document->addStyleSheet(VBO_SITE_URI . 'vikbooking_styles.css', ['version' => VIKBOOKING_SOFTWARE_VERSION]); |
| 25 |
VikBooking::loadPreferredColorStyles(); |
| 26 |
VikBooking::loadFontAwesome(); |
| 27 |
|
| 28 |
$options = [ |
| 29 |
'version' => '1.0', |
| 30 |
]; |
| 31 |
|
| 32 |
JHtml::fetch('script', VBO_MODULES_URI . 'modules/mod_vikbooking_chat/assets/script.js', $options); |
| 33 |
JHtml::fetch('stylesheet', VBO_MODULES_URI . 'modules/mod_vikbooking_chat/assets/style.css', $options); |
| 34 |
|
| 35 |
// security measure: register a new CSRF token to avoid spammers |
| 36 |
JHtml::fetch('vbohtml.scripts.ajaxcsrf'); |
| 37 |
|
| 38 |
$document->addStyleDeclaration( |
| 39 |
<<<CSS |
| 40 |
.vbo-chat-session-widget { |
| 41 |
--vbo-chat-widget-btn-background: {$params->get('background')}; |
| 42 |
--vbo-chat-widget-btn-color: {$params->get('color')}; |
| 43 |
} |
| 44 |
CSS |
| 45 |
); |
| 46 |
|
| 47 |
// get widget id |
| 48 |
$moduleId = $module->id ?? rand(1, 999); |
| 49 |
|
| 50 |
// get session from cookie |
| 51 |
$session = (new VBOChatSessionModel)->getFromCookie(); |
| 52 |
|
| 53 |
$faqs = []; |
| 54 |
|
| 55 |
// prepare FAQs |
| 56 |
for ($i = 1; $i <= 3; $i++) { |
| 57 |
$short = $params->get('faq_' . $i . '_short'); |
| 58 |
$long = $params->get('faq_' . $i . '_long'); |
| 59 |
|
| 60 |
if ($short && $long) { |
| 61 |
$faqs[] = (object) [ |
| 62 |
'summary' => $short, |
| 63 |
'question' => $long, |
| 64 |
]; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
// load preferred layout |
| 69 |
require JModuleHelper::getLayoutPath('mod_vikbooking_chat', $params->get('layout', 'default')); |
| 70 |
|