-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexponent.js.php
More file actions
342 lines (297 loc) · 8.83 KB
/
exponent.js.php
File metadata and controls
342 lines (297 loc) · 8.83 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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<?php
##################################################
#
# Copyright (c) 2004-2006 OIC Group, Inc.
# Copyright 2006 Maxim Mueller
# Written and Designed by James Hunt
#
# This file is part of Exponent
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
//Initialize exponent Framework
include_once("exponent.php");
?>
// exponent Javascript Support Systems
//DEPRECATED: functional wrapper around OO API
function exponentJSinitialize() {
eXp.initialize();
}
//DEPRECATED: functional wrapper around OO API
function exponentJSregister(func) {
eXp.register(func);
}
//DEPRECATED: functional wrapper around OO API
function exponentGetCookie(name) {
eXp.getCookie(name);
}
//DEPRECATED: functional wrapper around OO API
function makeLink() {
return eXp.makeLink(makeLink.arguments);
}
//DEPRECATED: functional wrapper around OO API
function openWindow(url, name, options) {
eXp.openWindow(url, name, options);
}
//DEPRECATED: functional wrapper around OO API
function openSelector(mod, dest, vmod, vview) {
eXp.openSelector(mod, dest, vmod, vview);
}
//DEPRECATED: functional wrapper around OO API
function openContentSelector(mod, dest, view) {
eXp.openContentSelector(mod, dest, view);
}
//DEPRECATED: functional wrapper around OO API
function sourceSelected(hidden, showPreview, src, desc) {
eXp.sourceSelected(hidden, showPreview, src, desc);
}
//DEPRECATED: functional wrapper around OO API
function selectAll(prefix,checked) {
eXp.selectAll(prefix, checked);
}
//DEPRECATED: functional wrapper around OO API
function isOneSelected(prefix, enabledOnly) {
eXp.isOneSelected(prefix, enabledOnly);
}
// Patch the String object, to make string parsing a little easier in exponent
String.prototype.isValid = function (alpha,numeric,others) {
for (var i = 0; i < this.length; i++) {
if (alpha && this.isAlpha(i)) continue;
if (numeric && this.isNumeric(i)) continue;
var isGood = false;
for (var j = 0; j < others.length; j++) {
if (others[j] == this.charAt(i)) {
isGood = true;
continue;
}
}
if (!isGood) return false;
}
return true;
}
String.prototype.isNumeric = function(index) {
var charcode = this.charCodeAt(index);
return (
(charcode >= 48 && charcode < 48+10)
);
}
String.prototype.isAlpha = function(index) {
var charcode = this.charCodeAt(index);
return (
(charcode >= 65 && charcode < 65+26) ||
(charcode >= 97 && charcode < 97+26)
);
}
String.prototype.trim = function() {
str = this;
while (1) {
if (str.substring(str.length - 1, str.length) != " ") break;
str = str.substr(0,str.length - 1);
}
while (1 && str.length > 0) {
if (str.substring(0,1) != " ") break;
str = str.substr(1,str.length - 1);
}
return str;
}
//introduction of a common namespace object
//TODO: migrate all of E`s JS API to this new object
eXp = new Object();
eXp.LANG = "<?php echo LANG; ?>";
eXp.PATH_RELATIVE = "<?php echo PATH_RELATIVE; ?>";
eXp.URL_FULL = "<?php echo URL_FULL; ?>";
eXp.THEME_RELATIVE = "<?php echo THEME_RELATIVE; ?>";
eXp.ICON_RELATIVE = "<?php echo ICON_RELATIVE; ?>";
eXp.onLoadInits = new Array(); // array of functions
eXp.openWindows = new Array(); // array of window references.
eXp.includeOnce = function(id, file) {
// do we even have to do something ?
if (!document.getElementById(id)){
//TODO: check for html spelling, right now we assume XHTML
// get the head element
myHeadElem = document.getElementsByTagName("head").item(0);
myNewElem = document.createElement("script");
myNewElem.setAttribute("id",id);
myNewElem.setAttribute("type","text/javascript");
myNewElem.setAttribute("defer","false");
myNewElem.setAttribute("src",file);
myHeadElem.appendChild(myNewElem);
} else {
//TODO: write handling for overiding of scripts, e.g. by themes.
};
};
eXp.initialize = function() {
for (i = 0; i < eXp.onLoadInits.length; i++) {
if(typeof(eXp.onLoadInits[i]) == "String") {
//new style allows for function parameters
eval(eXp.onLoadInits[i]);
} else {
eXp.onLoadInits[i]();
}
}
}
eXp.register = function(func) {
eXp.onLoadInits.push(func);
}
eXp.getCookie = function(name) {
cookiestr = document.cookie;
var nameIndex = cookiestr.indexOf(name);
if (nameIndex != -1) { // found the named cookie
var startOffset = nameIndex+name.length+1;
var endOffset = cookiestr.indexOf(";",startOffset);
if (endOffset == -1) endOffset = cookiestr.length;
return cookiestr.substring(startOffset,endOffset);
}
return "";
}
eXp.makeLink = function() {
var args = eXp.makeLink.arguments;
var link = eXp.PATH_RELATIVE + "index.php?";
for (var i = 0; i < args.length; i+=2) {
if(typeof(args[i]) == "object") {
for (var j = 0; j < args[i].length; j+=2) {
var w = args[i][j+1];
if (w != null && w != "") {
link += escape(args[i][j]) + "=" + escape(args[i][j+1]) + "&";
//alert(link);
}
}
} else {
var v = args[i+1];
if (v != null && v != "") {
link += escape(args[i]) + "=" + escape(args[i+1]) + "&";
}
}
}
return link.substr(0,link.length - 1);
}
eXp.openWindow = function(url, name, options) {
for (key in eXp.openWindows) {
if (key == name) {
if (eXp.openWindows[key].focus()) {
return;
} else {
break;
}
}
}
eXp.openWindows[name] = window.open(url,name,options);
}
eXp.openSelector = function(mod, dest, vmod, vview) {
var url = eXp.PATH_RELATIVE+"source_selector.php?showmodules="+mod+"&dest="+escape(dest)+"&vmod="+vmod+"&vview="+vview;
openWindow(url,'sourcePicker','title=no,resizable=yes,toolbar=no,width=900,height=750,scrollbars=yes');
}
eXp.openContentSelector = function(mod, dest, view) {
var url = eXp.PATH_RELATIVE+"content_selector.php?showmodules="+mod+"&dest="+escape(dest)+"&vmod=containermodule&vview="+view;
eXp.openWindow(url,'contentPicker','title=no,toolbar=no,width=640,height=480,scrollbars=yes');
}
eXp.sourceSelected = function(hidden, showPreview, src, desc) {
var hidden = document.getElementById(hidden);
hidden.value = src;
if (showPreview){
showPreviewCall();
}
}
eXp.selectAll = function(prefix, checked) {
elems = document.getElementsByTagName("input");
for (var key in elems) {
if (elems[key].type == "checkbox" && elems[key].name.substr(0,prefix.length) == prefix) {
elems[key].checked = checked;
}
}
}
eXp.isOneSelected = function(prefix, enabledOnly) {
if (typeof enabledOnly == "undefined") {
enabledOnly = true;
}
elems = document.getElementsByTagName("input");
for (var key in elems) {
if (elems[key].type == "checkbox" && elems[key].name.substr(0,prefix.length) == prefix) {
if (enabledOnly && elems[key].checked && !elems[key].disabled) return true;
if (!enabledOnly && elems[key].checked) return true;
}
}
return false;
}
eXp.i18n = function(i18n_string) {
if(eXp._TR[i18n_string]) {
i18n_string = eXp._TR[i18n_string];
}
return i18n_string;
}
//FJD - added for easier javascript debugging
function print_r(input, _indent)
{
if(typeof(_indent) == 'string') {
var indent = _indent + ' ';
var paren_indent = _indent + ' ';
} else {
var indent = ' ';
var paren_indent = '';
}
switch(typeof(input)) {
case 'boolean':
var output = (input ? 'true' : 'false') + "\n";
break;
case 'object':
if ( input===null ) {
var output = "null\n";
break;
}
var output = ((input.reverse) ? 'Array' : 'Object') + " (\n";
for(var i in input) {
output += indent + "[" + i + "] => " + print_r(input[i], indent);
}
output += paren_indent + ")\n";
break;
case 'number':
case 'string':
default:
var output = "" + input + "\n";
}
return output;
}
// This converts a javascript array to a string in PHP serialized format.
// This is useful for passing arrays to PHP. On the PHP side you can
// unserialize this string from a cookie or request variable.
function js_array_to_php_array (a)
{
var a_php = "";
var total = 0;
for (var key in a)
{
++ total;
a_php = a_php + "s:" +
String(key).length + ":\"" + String(key) + "\";s:" +
String(a[key]).length + ":\"" + String(a[key]) + "\";";
}
a_php = "a:" + total + ":{" + a_php + "}";
return a_php;
}
function page(page) {
var uri = 'index.php?module=travelmodule&_common=1&action=page&ajax_action=1' + '&page=' + page;
YAHOO.util.Connect.asyncRequest('POST', uri, {
success : function(o) {
document.getElementById('page-objects').innerHTML= o.responseText;
},
failure : function(o) {
alert('An error was encountered while processing your request. ' + o.statusText);
},
timeout : 5000
});
}
function divtoggle(id) {
el = document.getElementById(id);
if (el.style.display == 'none') {
el.style.display = 'block';
} else {
el.style.display = 'none';
}
}