-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod_recranet.php
More file actions
54 lines (43 loc) · 1.94 KB
/
mod_recranet.php
File metadata and controls
54 lines (43 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @package Joomla.Site
* @subpackage mod_recranet
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$recranetConfig = array(
'organization' => (int) $params->get('organization'),
'locale' => (string) $params->get('locale'),
'country' => $params->get('country', null),
'currency' => (string) $params->get('currency'),
'googleApiKey' => (string) $params->get('googleApiKey'),
);
if ($params->get('accommodationCategory') !== null) {
$recranetConfig['accommodationParams']['accommodationCategory'] = (int) $params->get('accommodationCategory');
}
if ($params->get('localityCategory') !== null) {
$recranetConfig['accommodationParams']['localityCategory'] = (int) $params->get('localityCategory');
}
$document = JFactory::getDocument();
$document->addStylesheet(JUri::base() . 'modules/mod_recranet/css/mod_recranet.css');
// Set base URL for Angular HTML5 Mode routing
$language = JFactory::getLanguage()->getTag();
$activeMenuItem = JFactory::getApplication()->getMenu()->getActive($language);
$document->setBase(JRoute::_($activeMenuItem->link));
// Add SDK loader to head
if ($params->get('sdk')) {
// Create random string
$date = new DateTime();
$randomString = $date->format('U') . "=" . $date->format('U');
// Set script tag
$scriptHtml = "" .
"<script type='text/javascript'>" . PHP_EOL .
" window.recranetConfig = %s;" . PHP_EOL .
"</script>" . PHP_EOL .
"<script src='https://static.recranet.com/elements/%s/sdk.js?%s' type='text/javascript' async></script>";
// Add javascript tag to dom
$document->addCustomTag(vsprintf($scriptHtml, [json_encode($recranetConfig), (string) $params->get('locale'), $randomString]));
}
require JModuleHelper::getLayoutPath('mod_recranet', $params->get('layout', 'default'));