-
Notifications
You must be signed in to change notification settings - Fork 0
/
gm_javascript.js.php
203 lines (160 loc) · 7.54 KB
/
gm_javascript.js.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
/* --------------------------------------------------------------
gm_javascript.js.php 2016-06-23
Gambio GmbH
http://www.gambio.de
Copyright (c) 2016 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
require_once('includes/application_top.php');
if(isset($_SESSION['language_charset']))
{
header('Content-Type: text/javascript; charset=' . $_SESSION['language_charset']);
}
else
{
header('Content-Type: text/javascript; charset=utf-8');
}
if(gm_get_env_info('TEMPLATE_VERSION') >= 3 && (!isset($_GET['globals']) || $_GET['globals'] !== 'off'))
{
$httpCaching = MainFactory::create_object('HTTPCaching');
$httpCaching->start_output_buffer();
$isDebugMode = file_exists(DIR_FS_CATALOG . '.dev-environment');
$pageToken = $_SESSION['coo_page_token']->generate_token();
$cacheToken = MainFactory::create('CacheTokenHelper')->getCacheToken();
$jsEngineConfig = MainFactory::create('JSEngineConfiguration',
new NonEmptyStringType(GM_HTTP_SERVER . DIR_WS_CATALOG),
new NonEmptyStringType('templates/' . CURRENT_TEMPLATE . '/'),
new LanguageCode(new StringType($_SESSION['language_code'])),
MainFactory::create_object('LanguageTextManager', array(), true),
new EditableKeyValueCollection(array(
'buttons' => 'buttons',
'general' => 'general',
'labels' => 'labels',
'messages' => 'messages'
)), new BoolType($isDebugMode),
new StringType($pageToken), new StringType($cacheToken));
echo $jsEngineConfig->getJavaScript();
$suffix = '.min';
if($isDebugMode)
{
$suffix = '';
}
echo file_get_contents(DIR_FS_CATALOG . 'JSEngine/build/vendor' . $suffix . '.js') . "\n";
echo file_get_contents(DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/assets/javascript/vendor' . $suffix
. '.js') . "\n";
echo file_get_contents(DIR_FS_CATALOG . 'JSEngine/build/jse' . $suffix . '.js') . "\n";
echo file_get_contents(DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/assets/javascript/initialize_template'
. $suffix . '.js') . "\n";
echo file_get_contents(DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/assets/javascript/template_helpers'
. $suffix . '.js') . "\n";
$page = (isset($_GET['page'])) ? (string)$_GET['page'] : 'Global';
$usermodJsMaster = MainFactory::create('UsermodJSMaster', $page);
$files = $usermodJsMaster->get_files();
foreach($files as $file)
{
// print new line avoiding conflicts with comments
echo "\n";
if(file_exists($file))
{
include_once($file);
}
}
// print new line avoiding conflicts with comments
echo "\n";
// include RequireJS after usermods avoiding conflicts
echo file_get_contents(DIR_FS_CATALOG . 'JSEngine/build/require' . $suffix . '.js') . "\n";
$jsContent = $httpCaching->stop_output_buffer();
$httpCaching->send_header($jsContent, false, false, 'public', '', '');
$httpCaching->check_cache($jsContent);
echo $jsContent;
xtc_db_close();
exit;
}
if(MOBILE_ACTIVE == 'true' && (isset($_GET['section']) == false || trim($_GET['section']) != 'MobileCandy'))
{
xtc_db_close();
exit;
}
/////////////////// OLD SCRIPTS ///////////////////////
$_SESSION['lightbox']->set_actual('false');
$httpCaching = MainFactory::create_object('HTTPCaching');
$httpCaching->start_output_buffer();
if(!isset($_GET['globals']) || $_GET['globals'] != 'off')
{
// Session-ID as GET-param is deprecated and missing. Let set it manually.
if(!isset($_GET['XTCsid']))
{
$_GET['XTCsid'] = xtc_session_id();
}
$_GET['XTCsid_name'] = xtc_session_name();
$jsOptionsControl = MainFactory::create_object('JSOptionsControl');
$jsOptions = $jsOptionsControl->get_options_array($_GET);
?>
var js_options = <?php echo json_encode($jsOptions) ?>;
var t_php_helper = '';
<?php
if(is_object($GLOBALS['coo_debugger']) && $GLOBALS['coo_debugger']->is_enabled('js') == true
&& gm_get_env_info('TEMPLATE_VERSION') >= FIRST_GX2_TEMPLATE_VERSION
)
{
include_once(DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/javascript/StopWatch.js');
}
//JQuery
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/jquery/jquery.min.js'));
//JQuery Migrate
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/jquery/jquery-migrate.min.js'));
/* BOF StyleEdit */
if($_SESSION['style_edit_mode'] == 'edit' || $_SESSION['style_edit_mode'] == 'sos')
{
echo 'var style_edit_sectoken = "' . xtc_session_id() . '";';
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/jquery/ui/jquery-ui.js'));
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/jquery/plugins/fancybox/jquery.mousewheel-3.0.2.pack.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/jquery/plugins/fancybox/jquery.fancybox-1.3.0.pack.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/jquery/plugins/ajaxupload.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/config_StyleEdit.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/GMColorizer.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/GMStyleMonitor.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/GMStyleEditToolBox.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/GMStyleEditHandler.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/GMStyleEditSelector.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/GMStyleEditControl.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/GMBoxesPageMenu.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/GMBoxesMaster.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/GMUploader.js');
include_once(DIR_FS_CATALOG . 'StyleEdit/javascript/style_edit.js.php');
}
/* EOF StyleEdit */
$globalExtenderComponent = MainFactory::create_object('JSGlobalExtenderComponent');
$globalExtenderComponent->set_data('GET', $_GET);
$globalExtenderComponent->proceed();
}
$section = $_GET['section'];
if(preg_match('/[\W]+/', $section))
{
trigger_error('gm_javascript: $_GET["section"] contains unexpected characters', E_USER_ERROR);
}
$c_page = '';
if(isset($_GET['page']) && is_string($_GET['page']))
{
$c_page = trim((string)$_GET['page']);
}
if($c_page !== '')
{
$classNameSuffix = 'ExtenderComponent';
$requestRouter = MainFactory::create_object('RequestRouter', array($classNameSuffix));
$requestRouter->set_data('GET', $_GET);
$className = 'JS' . $c_page;
$proceedStatus = $requestRouter->proceed($className);
if($proceedStatus != true)
{
trigger_error('could not proceed module [' . htmlentities_wrapper($className) . ']', E_USER_ERROR);
}
}
((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
$jsContent = $httpCaching->stop_output_buffer();
$httpCaching->send_header($jsContent, false, false, 'public', '', '');
$httpCaching->check_cache($jsContent);
echo $jsContent;