1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) XEHub <https://www.xehub.io> */ |
3
|
|
|
/** |
4
|
|
|
* @class moduleModel |
5
|
|
|
* @author XEHub ([email protected]) |
6
|
|
|
* @brief Model class of module module |
7
|
|
|
*/ |
8
|
|
|
class moduleModel extends module |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @brief Initialization |
12
|
|
|
*/ |
13
|
|
|
function init() |
14
|
|
|
{ |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @brief Check if mid, vid are available |
19
|
|
|
*/ |
20
|
|
|
function isIDExists($id, $site_srl = 0) |
21
|
|
|
{ |
22
|
|
|
if(!preg_match('/^[a-z]{1}([a-z0-9_]+)$/i',$id)) return true; |
23
|
|
|
// directory and rss/atom/api reserved checking, etc. |
24
|
|
|
$dirs = FileHandler::readDir(_XE_PATH_); |
25
|
|
|
$dirs[] = 'rss'; |
26
|
|
|
$dirs[] = 'atom'; |
27
|
|
|
$dirs[] = 'api'; |
28
|
|
|
if(in_array($id, $dirs)) return true; |
29
|
|
|
// mid test |
30
|
|
|
$args = new stdClass(); |
31
|
|
|
$args->mid = $id; |
32
|
|
|
$args->site_srl = $site_srl; |
33
|
|
|
$output = executeQuery('module.isExistsModuleName', $args); |
34
|
|
|
if($output->data->count) return true; |
35
|
|
|
// vid test (check mid != vid if site_srl=0, which means it is not a virtual site) |
36
|
|
|
if(!$site_srl) |
37
|
|
|
{ |
38
|
|
|
$site_args = new stdClass(); |
39
|
|
|
$site_args->domain = $id; |
40
|
|
|
$output = executeQuery('module.isExistsSiteDomain', $site_args); |
41
|
|
|
if($output->data->count) return true; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return false; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @brief Get site information |
49
|
|
|
*/ |
50
|
|
|
function getSiteInfo($site_srl, $columnList = array()) |
51
|
|
|
{ |
52
|
|
|
$args = new stdClass(); |
53
|
|
|
$args->site_srl = $site_srl; |
54
|
|
|
$output = executeQuery('module.getSiteInfo', $args, $columnList); |
55
|
|
|
return $output->data; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
function getSiteInfoByDomain($domain, $columnList = array()) |
59
|
|
|
{ |
60
|
|
|
$args = new stdClass(); |
61
|
|
|
$args->domain = $domain; |
62
|
|
|
$output = executeQuery('module.getSiteInfoByDomain', $args, $columnList); |
63
|
|
|
return $output->data; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @brief Get module information with document_srl |
68
|
|
|
* In this case, it is unable to use the cache file |
69
|
|
|
*/ |
70
|
|
|
function getModuleInfoByDocumentSrl($document_srl) |
71
|
|
|
{ |
72
|
|
|
$args = new stdClass(); |
73
|
|
|
$args->document_srl = $document_srl; |
74
|
|
|
$output = executeQuery('module.getModuleInfoByDocument', $args); |
75
|
|
|
$this->applyDefaultSkin($output->data); |
76
|
|
|
return $this->addModuleExtraVars($output->data); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @brief Get the default mid according to the domain |
81
|
|
|
*/ |
82
|
|
|
function getDefaultMid() |
83
|
|
|
{ |
84
|
|
|
$default_url = Context::getDefaultUrl(); |
85
|
|
View Code Duplication |
if($default_url && substr_compare($default_url, '/', -1) === 0) $default_url = substr($default_url, 0, -1); |
86
|
|
|
|
87
|
|
|
$request_url = Context::getRequestUri(); |
88
|
|
|
if($request_url && substr_compare($request_url, '/', -1) === 0) $request_url = substr($request_url, 0, -1); |
89
|
|
|
|
90
|
|
|
$default_url_parse = parse_url($default_url); |
91
|
|
|
$request_url_parse = parse_url($request_url); |
92
|
|
|
$vid = Context::get('vid'); |
93
|
|
|
$mid = Context::get('mid'); |
94
|
|
|
|
95
|
|
|
// Set up |
96
|
|
|
$domain = ''; |
97
|
|
|
$site_info = NULL; |
98
|
|
|
if($default_url && $default_url_parse['host'] != $request_url_parse['host']) |
99
|
|
|
{ |
100
|
|
|
$hostname = $request_url_parse['host']; |
101
|
|
|
$path = $request_url_parse['path']; |
102
|
|
|
$port = $request_url_parse['port']; |
103
|
|
View Code Duplication |
if(strlen($path) >= 1 && substr_compare($path, '/', -1) === 0) $path = substr($path, 0, -1); |
104
|
|
|
|
105
|
|
|
$domain = sprintf('%s%s%s', $hostname, $port && ($port != 80 )? ':'.$port : '', $path); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
if($domain === '') |
109
|
|
|
{ |
110
|
|
|
if(!$vid) $vid = $mid; |
111
|
|
|
if($vid) |
112
|
|
|
{ |
113
|
|
|
$domain = $vid; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
118
|
|
|
// If domain is set, look for subsite |
119
|
|
|
if($domain !== '') |
120
|
|
|
{ |
121
|
|
|
$site_info = false; |
122
|
|
|
if($oCacheHandler->isSupport()) |
123
|
|
|
{ |
124
|
|
|
$object_key = 'site_info:' . md5($domain); |
125
|
|
|
$domain_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
126
|
|
|
$site_info = $oCacheHandler->get($domain_cache_key); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
if($site_info === false) |
130
|
|
|
{ |
131
|
|
|
$args = new stdClass(); |
132
|
|
|
$args->domain = $domain; |
133
|
|
|
$output = executeQuery('module.getSiteInfoByDomain', $args); |
134
|
|
|
$site_info = $output->data; |
135
|
|
|
|
136
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($domain_cache_key, $site_info); |
|
|
|
|
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
if($site_info && $vid) |
140
|
|
|
{ |
141
|
|
|
Context::set('vid', $site_info->domain, true); |
|
|
|
|
142
|
|
|
if(strtolower($mid)==strtolower($site_info->domain)) Context::set('mid', $site_info->mid,true); |
|
|
|
|
143
|
|
|
} |
144
|
|
|
if(!$site_info || !$site_info->domain) { $domain = ''; unset($site_info); } |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
// If no virtual website was found, get default website |
148
|
|
|
if($domain === '') |
149
|
|
|
{ |
150
|
|
|
$site_info = false; |
151
|
|
|
if($oCacheHandler->isSupport()) |
152
|
|
|
{ |
153
|
|
|
$object_key = 'default_site'; |
154
|
|
|
$default_site_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
155
|
|
|
$site_info = $oCacheHandler->get($default_site_cache_key); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
if($site_info === false) |
159
|
|
|
{ |
160
|
|
|
$args = new stdClass(); |
161
|
|
|
$args->site_srl = 0; |
162
|
|
|
$output = executeQuery('module.getSiteInfo', $args); |
163
|
|
|
// Update the related informaion if there is no default site info |
164
|
|
|
if(!$output->data) |
165
|
|
|
{ |
166
|
|
|
// Create a table if sites table doesn't exist |
167
|
|
|
$oDB = &DB::getInstance(); |
168
|
|
|
if(!$oDB->isTableExists('sites')) $oDB->createTableByXmlFile(_XE_PATH_.'modules/module/schemas/sites.xml'); |
|
|
|
|
169
|
|
|
if(!$oDB->isTableExists('sites')) return; |
170
|
|
|
|
171
|
|
|
// Get mid, language |
172
|
|
|
$mid_output = $oDB->executeQuery('module.getDefaultMidInfo', $args); |
173
|
|
|
$db_info = Context::getDBInfo(); |
174
|
|
|
$domain = Context::getDefaultUrl(); |
175
|
|
|
$url_info = parse_url($domain); |
176
|
|
|
$domain = $url_info['host'].( (!empty($url_info['port'])&&$url_info['port']!=80)?':'.$url_info['port']:'').$url_info['path']; |
177
|
|
|
|
178
|
|
|
$site_args = new stdClass; |
179
|
|
|
$site_args->site_srl = 0; |
180
|
|
|
$site_args->index_module_srl = $mid_output->data->module_srl; |
181
|
|
|
$site_args->domain = $domain; |
182
|
|
|
$site_args->default_language = $db_info->lang_type; |
183
|
|
|
|
184
|
|
|
if($output->data && !$output->data->index_module_srl) |
185
|
|
|
{ |
186
|
|
|
$output = executeQuery('module.updateSite', $site_args); |
|
|
|
|
187
|
|
|
} |
188
|
|
|
else |
189
|
|
|
{ |
190
|
|
|
$output = executeQuery('module.insertSite', $site_args); |
191
|
|
|
if(!$output->toBool()) return $output; |
192
|
|
|
} |
193
|
|
|
$output = executeQuery('module.getSiteInfo', $args); |
194
|
|
|
} |
195
|
|
|
$site_info = $output->data; |
196
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($default_site_cache_key, $site_info); |
|
|
|
|
197
|
|
|
} |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
if(!$site_info->module_srl) return $site_info; |
201
|
|
|
if(is_array($site_info) && $site_info->data[0]) $site_info = $site_info[0]; |
202
|
|
|
return $this->addModuleExtraVars($site_info); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* @brief Get module information by mid |
207
|
|
|
*/ |
208
|
|
|
function getModuleInfoByMid($mid, $site_srl = 0, $columnList = array()) |
|
|
|
|
209
|
|
|
{ |
210
|
|
|
if(!$mid || ($mid && !preg_match("/^[a-z][a-z0-9_]+$/i", $mid))) |
211
|
|
|
{ |
212
|
|
|
return; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
$args = new stdClass(); |
216
|
|
|
$args->mid = $mid; |
217
|
|
|
$args->site_srl = (int)$site_srl; |
218
|
|
|
|
219
|
|
|
$module_srl = false; |
|
|
|
|
220
|
|
|
$module_info = false; |
221
|
|
|
|
222
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
223
|
|
|
if($oCacheHandler->isSupport()) |
224
|
|
|
{ |
225
|
|
|
$object_key = 'module_srl:'.$mid.'_'.$site_srl; |
226
|
|
|
$module_srl_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
227
|
|
|
$module_srl = $oCacheHandler->get($module_srl_cache_key); |
228
|
|
View Code Duplication |
if($module_srl) |
229
|
|
|
{ |
230
|
|
|
$object_key = 'mid_info:' . $module_srl; |
231
|
|
|
$module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
232
|
|
|
$module_info = $oCacheHandler->get($module_info_cache_key); |
233
|
|
|
} |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
if($module_info === false) |
237
|
|
|
{ |
238
|
|
|
$output = executeQuery('module.getMidInfo', $args); |
239
|
|
|
$module_info = $output->data; |
240
|
|
|
if($oCacheHandler->isSupport()) |
241
|
|
|
{ |
242
|
|
|
$oCacheHandler->put($module_srl_cache_key, $module_info->module_srl); |
|
|
|
|
243
|
|
|
|
244
|
|
|
$object_key = 'mid_info:' . $module_info->module_srl; |
245
|
|
|
$module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
246
|
|
|
$oCacheHandler->put($module_info_cache_key, $module_info); |
247
|
|
|
} |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
$this->applyDefaultSkin($module_info); |
251
|
|
|
if(!$module_info->module_srl && $module_info->data[0]) $module_info = $module_info->data[0]; |
252
|
|
|
return $this->addModuleExtraVars($module_info); |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Get module info by menu_item_srl. |
257
|
|
|
* |
258
|
|
|
* @params int $menu_item_srl |
259
|
|
|
* |
260
|
|
|
* @return BaseObject $moduleInfo |
261
|
|
|
*/ |
262
|
|
|
public function getModuleInfoByMenuItemSrl($menu_item_srl = 0) |
263
|
|
|
{ |
264
|
|
|
$menuItemSrl = Context::get('menu_item_srl'); |
265
|
|
|
$menuItemSrl = (!$menuItemSrl) ? $menu_item_srl : $menuItemSrl; |
266
|
|
|
|
267
|
|
|
if(!$menuItemSrl) |
268
|
|
|
{ |
269
|
|
|
$this->stop(-1, 'msg_invalid_request'); |
|
|
|
|
270
|
|
|
return; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
$args = new stdClass(); |
274
|
|
|
$args->menu_item_srl = $menuItemSrl; |
275
|
|
|
$output = executeQuery('module.getModuleInfoByMenuItemSrl', $args); |
276
|
|
|
if(!$output->toBool()) |
277
|
|
|
{ |
278
|
|
|
return $output; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
$moduleInfo = $output->data; |
282
|
|
|
$mid = $moduleInfo->mid; |
283
|
|
|
$site_srl = $moduleInfo->site_srl; |
284
|
|
|
|
285
|
|
|
$moduleInfo->designSettings = new stdClass(); |
286
|
|
|
$moduleInfo->designSettings->layout = new stdClass(); |
287
|
|
|
$moduleInfo->designSettings->skin = new stdClass(); |
288
|
|
|
|
289
|
|
|
$oLayoutAdminModel = getAdminModel('layout'); |
290
|
|
|
$layoutSrlPc = ($moduleInfo->layout_srl == -1) ? $oLayoutAdminModel->getSiteDefaultLayout('P', $moduleInfo->site_srl) : $moduleInfo->layout_srl; |
291
|
|
|
$layoutSrlMobile = ($moduleInfo->mlayout_srl == -1) ? $oLayoutAdminModel->getSiteDefaultLayout('M', $moduleInfo->site_srl) : $moduleInfo->mlayout_srl; |
292
|
|
|
$skinNamePc = ($moduleInfo->is_skin_fix == 'N') ? $this->getModuleDefaultSkin($moduleInfo->module, 'P') : $moduleInfo->skin; |
293
|
|
|
$skinNameMobile = ($moduleInfo->is_mskin_fix == 'N') ? $this->getModuleDefaultSkin($moduleInfo->module, 'M') : $moduleInfo->mskin; |
294
|
|
|
|
295
|
|
|
$oLayoutModel = getModel('layout'); |
296
|
|
|
$layoutInfoPc = $layoutSrlPc ? $oLayoutModel->getLayoutRawData($layoutSrlPc, array('title')) : NULL; |
297
|
|
|
$layoutInfoMobile = $layoutSrlMobile ? $oLayoutModel->getLayoutRawData($layoutSrlMobile, array('title')) : NULL; |
298
|
|
|
$skinInfoPc = $this->loadSkinInfo(Modulehandler::getModulePath($moduleInfo->module), $skinNamePc); |
299
|
|
|
$skinInfoMobile = $this->loadSkinInfo(Modulehandler::getModulePath($moduleInfo->module), $skinNameMobile, 'm.skins'); |
300
|
|
|
if(!$skinInfoPc) |
301
|
|
|
{ |
302
|
|
|
$skinInfoPc = new stdClass(); |
303
|
|
|
$skinInfoPc->title = $skinNamePc; |
304
|
|
|
} |
305
|
|
|
if(!$skinInfoMobile) |
306
|
|
|
{ |
307
|
|
|
$skinInfoMobile = new stdClass(); |
308
|
|
|
$skinInfoMobile->title = $skinNameMobile; |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
$moduleInfo->designSettings->layout->pcIsDefault = $moduleInfo->layout_srl == -1 ? 1 : 0; |
312
|
|
|
$moduleInfo->designSettings->layout->pc = $layoutInfoPc->title; |
313
|
|
|
$moduleInfo->designSettings->layout->mobileIsDefault = $moduleInfo->mlayout_srl == -1 ? 1 : 0; |
314
|
|
|
$moduleInfo->designSettings->layout->mobile = $layoutInfoMobile->title; |
315
|
|
|
$moduleInfo->designSettings->skin->pcIsDefault = $moduleInfo->is_skin_fix == 'N' ? 1 : 0; |
316
|
|
|
$moduleInfo->designSettings->skin->pc = $skinInfoPc->title; |
317
|
|
|
$moduleInfo->designSettings->skin->mobileIsDefault = $moduleInfo->is_mskin_fix == 'N' ? 1 : 0; |
318
|
|
|
$moduleInfo->designSettings->skin->mobile = $skinInfoMobile->title; |
319
|
|
|
|
320
|
|
|
$module_srl = false; |
|
|
|
|
321
|
|
|
$mid_info = false; |
322
|
|
|
|
323
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
324
|
|
|
if($oCacheHandler->isSupport()) |
325
|
|
|
{ |
326
|
|
|
$object_key = 'module_srl:'.$mid.'_'.$site_srl; |
327
|
|
|
$module_srl_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
328
|
|
|
$module_srl = $oCacheHandler->get($module_srl_cache_key); |
329
|
|
View Code Duplication |
if($module_srl) |
330
|
|
|
{ |
331
|
|
|
$object_key = 'mid_info:' . $module_srl; |
332
|
|
|
$module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
333
|
|
|
$mid_info = $oCacheHandler->get($module_info_cache_key); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
if($mid_info === false) |
337
|
|
|
{ |
338
|
|
|
$oCacheHandler->put($module_srl_cache_key, $output->data->module_srl); |
339
|
|
|
|
340
|
|
|
$object_key = 'mid_info:' . $output->data->module_srl; |
341
|
|
|
$module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
342
|
|
|
$oCacheHandler->put($module_info_cache_key, $moduleInfo); |
343
|
|
|
} |
344
|
|
|
else |
345
|
|
|
{ |
346
|
|
|
$mid_info->designSettings = $moduleInfo->designSettings; |
347
|
|
|
$moduleInfo = $mid_info; |
348
|
|
|
} |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
$moduleInfo = $this->addModuleExtraVars($moduleInfo); |
352
|
|
|
|
353
|
|
|
if($moduleInfo->module == 'page' && $moduleInfo->page_type != 'ARTICLE') |
354
|
|
|
{ |
355
|
|
|
unset($moduleInfo->skin); |
356
|
|
|
unset($moduleInfo->mskin); |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
$this->add('module_info_by_menu_item_srl', $moduleInfo); |
360
|
|
|
|
361
|
|
|
return $moduleInfo; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* @brief Get module information corresponding to module_srl |
366
|
|
|
*/ |
367
|
|
|
function getModuleInfoByModuleSrl($module_srl, $columnList = array()) |
368
|
|
|
{ |
369
|
|
|
$mid_info = false; |
370
|
|
|
|
371
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
372
|
|
|
if($oCacheHandler->isSupport()) |
373
|
|
|
{ |
374
|
|
|
$object_key = 'mid_info:' . $module_srl; |
375
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
376
|
|
|
$mid_info = $oCacheHandler->get($cache_key); |
377
|
|
|
} |
378
|
|
|
|
379
|
|
View Code Duplication |
if($mid_info === false) |
380
|
|
|
{ |
381
|
|
|
// Get data |
382
|
|
|
$args = new stdClass(); |
383
|
|
|
$args->module_srl = $module_srl; |
384
|
|
|
$output = executeQuery('module.getMidInfo', $args); |
385
|
|
|
if(!$output->toBool()) return; |
386
|
|
|
|
387
|
|
|
$mid_info = $output->data; |
388
|
|
|
$this->applyDefaultSkin($mid_info); |
389
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $mid_info); |
|
|
|
|
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
if($mid_info && count($columnList)) |
393
|
|
|
{ |
394
|
|
|
$module_info = new stdClass(); |
395
|
|
|
foreach($mid_info as $key => $item) |
|
|
|
|
396
|
|
|
{ |
397
|
|
|
if(in_array($key, $columnList)) |
398
|
|
|
{ |
399
|
|
|
$module_info->$key = $item; |
400
|
|
|
} |
401
|
|
|
} |
402
|
|
|
} |
403
|
|
|
else $module_info = $mid_info; |
404
|
|
|
|
405
|
|
|
$oModuleController = getController('module'); |
|
|
|
|
406
|
|
|
|
407
|
|
|
$this->applyDefaultSkin($module_info); |
|
|
|
|
408
|
|
|
return $this->addModuleExtraVars($module_info); |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* Apply default skin info |
413
|
|
|
* |
414
|
|
|
* @param stdClass $moduleInfo Module information |
415
|
|
|
*/ |
416
|
|
|
private function applyDefaultSkin(&$moduleInfo) |
417
|
|
|
{ |
418
|
|
|
if($moduleInfo->is_skin_fix == 'N') |
419
|
|
|
{ |
420
|
|
|
$moduleInfo->skin = '/USE_DEFAULT/'; |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
if($moduleInfo->is_mskin_fix == 'N') |
424
|
|
|
{ |
425
|
|
|
$moduleInfo->mskin = '/USE_DEFAULT/'; |
426
|
|
|
} |
427
|
|
|
} |
428
|
|
|
/** |
429
|
|
|
* @brief Get module information corresponding to layout_srl |
430
|
|
|
*/ |
431
|
|
|
function getModulesInfoByLayout($layout_srl, $columnList = array()) |
432
|
|
|
{ |
433
|
|
|
// Imported data |
434
|
|
|
$args = new stdClass; |
435
|
|
|
$args->layout_srl = $layout_srl; |
436
|
|
|
$output = executeQueryArray('module.getModulesByLayout', $args, $columnList); |
437
|
|
|
|
438
|
|
|
$count = count($output->data); |
439
|
|
|
|
440
|
|
|
$modules = array(); |
441
|
|
View Code Duplication |
for($i=0;$i<$count;$i++) |
442
|
|
|
{ |
443
|
|
|
$modules[] = $output->data[$i]; |
444
|
|
|
} |
445
|
|
|
return $this->addModuleExtraVars($modules); |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
/** |
449
|
|
|
* @brief Get module information corresponding to multiple module_srls |
450
|
|
|
*/ |
451
|
|
|
function getModulesInfo($module_srls, $columnList = array()) |
452
|
|
|
{ |
453
|
|
|
if(is_array($module_srls)) $module_srls = implode(',',$module_srls); |
454
|
|
|
$args = new stdClass(); |
455
|
|
|
$args->module_srls = $module_srls; |
456
|
|
|
$output = executeQueryArray('module.getModulesInfo', $args, $columnList); |
457
|
|
|
if(!$output->toBool()) return; |
458
|
|
|
return $this->addModuleExtraVars($output->data); |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* @brief Add extra vars to the module basic information |
463
|
|
|
*/ |
464
|
|
|
function addModuleExtraVars($module_info) |
465
|
|
|
{ |
466
|
|
|
// Process although one or more module informaion is requested |
467
|
|
|
if(!is_array($module_info)) $target_module_info = array($module_info); |
468
|
|
|
else $target_module_info = $module_info; |
469
|
|
|
// Get module_srl |
470
|
|
|
$module_srls = array(); |
471
|
|
|
foreach($target_module_info as $key => $val) |
472
|
|
|
{ |
473
|
|
|
$module_srl = $val->module_srl; |
474
|
|
|
if(!$module_srl) continue; |
475
|
|
|
$module_srls[] = $val->module_srl; |
476
|
|
|
} |
477
|
|
|
// Extract extra information of the module and skin |
478
|
|
|
$extra_vars = $this->getModuleExtraVars($module_srls); |
479
|
|
|
if(!count($module_srls) || !count($extra_vars)) return $module_info; |
480
|
|
|
|
481
|
|
|
foreach($target_module_info as $key => $val) |
482
|
|
|
{ |
483
|
|
|
if(!$extra_vars[$val->module_srl] || !count($extra_vars[$val->module_srl])) continue; |
484
|
|
|
foreach($extra_vars[$val->module_srl] as $k => $v) |
485
|
|
|
{ |
486
|
|
|
if($target_module_info[$key]->{$k}) continue; |
487
|
|
|
$target_module_info[$key]->{$k} = $v; |
488
|
|
|
} |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
if(is_array($module_info)) return $target_module_info; |
492
|
|
|
return $target_module_info[0]; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
/** |
496
|
|
|
* @brief Get a complete list of mid, which is created in the DB |
497
|
|
|
*/ |
498
|
|
|
function getMidList($args = null, $columnList = array()) |
499
|
|
|
{ |
500
|
|
|
$list = false; |
501
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
502
|
|
|
if($oCacheHandler->isSupport()) |
503
|
|
|
{ |
504
|
|
|
if(count($args) === 1 && isset($args->site_srl)) |
505
|
|
|
{ |
506
|
|
|
$object_key = 'module:mid_list_' . $args->site_srl; |
507
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
508
|
|
|
$list = $oCacheHandler->get($cache_key); |
509
|
|
|
} |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
if($list === false) |
513
|
|
|
{ |
514
|
|
View Code Duplication |
if($oCacheHandler->isSupport() && count($args) === 1 && isset($args->site_srl)) |
515
|
|
|
{ |
516
|
|
|
$columnList = array(); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
$output = executeQuery('module.getMidList', $args, $columnList); |
520
|
|
|
if(!$output->toBool()) return $output; |
521
|
|
|
$list = $output->data; |
522
|
|
|
|
523
|
|
View Code Duplication |
if($oCacheHandler->isSupport() && count($args) === 1 && isset($args->site_srl)) |
524
|
|
|
{ |
525
|
|
|
$oCacheHandler->put($cache_key, $list); |
|
|
|
|
526
|
|
|
} |
527
|
|
|
} |
528
|
|
|
if(!$list) return; |
529
|
|
|
|
530
|
|
|
if(!is_array($list)) $list = array($list); |
531
|
|
|
|
532
|
|
|
foreach($list as $val) |
533
|
|
|
{ |
534
|
|
|
$mid_list[$val->mid] = $val; |
|
|
|
|
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
return $mid_list; |
|
|
|
|
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* @brief Get a complete list of module_srl, which is created in the DB |
542
|
|
|
*/ |
543
|
|
|
function getModuleSrlList($args = null, $columnList = array()) |
544
|
|
|
{ |
545
|
|
|
$output = executeQueryArray('module.getMidList', $args, $columnList); |
546
|
|
|
if(!$output->toBool()) return $output; |
547
|
|
|
|
548
|
|
|
$list = $output->data; |
549
|
|
|
if(!$list) return; |
550
|
|
|
|
551
|
|
|
return $list; |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* @brief Return an array of module_srl corresponding to a mid list |
556
|
|
|
*/ |
557
|
|
|
function getModuleSrlByMid($mid) |
558
|
|
|
{ |
559
|
|
|
if($mid && !is_array($mid)) $mid = explode(',',$mid); |
560
|
|
|
if(is_array($mid)) $mid = "'".implode("','",$mid)."'"; |
561
|
|
|
|
562
|
|
|
$site_module_info = Context::get('site_module_info'); |
563
|
|
|
|
564
|
|
|
$args = new stdClass; |
565
|
|
|
$args->mid = $mid; |
566
|
|
|
if($site_module_info) $args->site_srl = $site_module_info->site_srl; |
567
|
|
|
$output = executeQuery('module.getModuleSrlByMid', $args); |
568
|
|
|
if(!$output->toBool()) return $output; |
569
|
|
|
|
570
|
|
|
$list = $output->data; |
571
|
|
|
if(!$list) return; |
572
|
|
|
if(!is_array($list)) $list = array($list); |
573
|
|
|
|
574
|
|
|
foreach($list as $key => $val) |
575
|
|
|
{ |
576
|
|
|
$module_srl_list[] = $val->module_srl; |
|
|
|
|
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
return $module_srl_list; |
|
|
|
|
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
/** |
583
|
|
|
* @brief Get forward value by the value of act |
584
|
|
|
*/ |
585
|
|
|
function getActionForward($act) |
586
|
|
|
{ |
587
|
|
|
$action_forward = false; |
588
|
|
|
// cache controll |
589
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
590
|
|
|
if($oCacheHandler->isSupport()) |
591
|
|
|
{ |
592
|
|
|
$cache_key = 'action_forward'; |
593
|
|
|
$action_forward = $oCacheHandler->get($cache_key); |
594
|
|
|
} |
595
|
|
|
|
596
|
|
|
// retrieve and caching all registered action_forward |
597
|
|
|
if($action_forward === false) |
598
|
|
|
{ |
599
|
|
|
$args = new stdClass(); |
600
|
|
|
$output = executeQueryArray('module.getActionForward',$args); |
601
|
|
|
if(!$output->toBool()) return new stdClass; |
602
|
|
|
if(!$output->data) $output->data = array(); |
603
|
|
|
|
604
|
|
|
$action_forward = array(); |
605
|
|
|
foreach($output->data as $item) |
606
|
|
|
{ |
607
|
|
|
$action_forward[$item->act] = $item; |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
if($oCacheHandler->isSupport()) |
611
|
|
|
{ |
612
|
|
|
$oCacheHandler->put($cache_key, $action_forward); |
|
|
|
|
613
|
|
|
} |
614
|
|
|
} |
615
|
|
|
|
616
|
|
|
if($action_forward[$act]) |
617
|
|
|
{ |
618
|
|
|
return $action_forward[$act]; |
619
|
|
|
} |
620
|
|
|
else |
621
|
|
|
{ |
622
|
|
|
return new stdClass(); |
623
|
|
|
} |
624
|
|
|
} |
625
|
|
|
|
626
|
|
|
/** |
627
|
|
|
* @brief Get a list of all triggers on the trigger_name |
628
|
|
|
*/ |
629
|
|
|
function getTriggers($trigger_name, $called_position) |
630
|
|
|
{ |
631
|
|
|
if(is_null($GLOBALS['__triggers__'])) |
632
|
|
|
{ |
633
|
|
|
$triggers = FALSE; |
634
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
635
|
|
|
if($oCacheHandler->isSupport()) |
636
|
|
|
{ |
637
|
|
|
$cache_key = 'triggers'; |
638
|
|
|
$triggers = $oCacheHandler->get($cache_key); |
639
|
|
|
} |
640
|
|
|
if($triggers === FALSE) |
641
|
|
|
{ |
642
|
|
|
$output = executeQueryArray('module.getTriggers'); |
643
|
|
|
$triggers = $output->data; |
644
|
|
|
if($output->toBool() && $oCacheHandler->isSupport()) |
645
|
|
|
{ |
646
|
|
|
$oCacheHandler->put($cache_key, $triggers); |
|
|
|
|
647
|
|
|
} |
648
|
|
|
} |
649
|
|
|
foreach($triggers as $item) |
650
|
|
|
{ |
651
|
|
|
$GLOBALS['__triggers__'][$item->trigger_name][$item->called_position][] = $item; |
652
|
|
|
} |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
return $GLOBALS['__triggers__'][$trigger_name][$called_position]; |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
/** |
659
|
|
|
* @brief Get specific triggers from the trigger_name |
660
|
|
|
*/ |
661
|
|
|
function getTrigger($trigger_name, $module, $type, $called_method, $called_position) |
662
|
|
|
{ |
663
|
|
|
$triggers = $this->getTriggers($trigger_name, $called_position); |
664
|
|
|
|
665
|
|
|
if($triggers && is_array($triggers)) |
666
|
|
|
{ |
667
|
|
|
foreach($triggers as $item) |
668
|
|
|
{ |
669
|
|
|
if($item->module == $module && $item->type == $type && $item->called_method == $called_method) |
670
|
|
|
{ |
671
|
|
|
return $item; |
672
|
|
|
} |
673
|
|
|
} |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
return NULL; |
677
|
|
|
} |
678
|
|
|
|
679
|
|
|
/** |
680
|
|
|
* @brief Get module extend |
681
|
|
|
*/ |
682
|
|
|
function getModuleExtend($parent_module, $type, $kind='') |
683
|
|
|
{ |
684
|
|
|
$key = $parent_module.'.'.$kind.'.'.$type; |
685
|
|
|
|
686
|
|
|
$module_extend_info = $this->loadModuleExtends(); |
687
|
|
|
if(array_key_exists($key, $module_extend_info)) |
688
|
|
|
{ |
689
|
|
|
return $module_extend_info[$key]; |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
return false; |
693
|
|
|
} |
694
|
|
|
|
695
|
|
|
/** |
696
|
|
|
* @brief Get all the module extend |
697
|
|
|
*/ |
698
|
|
|
function loadModuleExtends() |
699
|
|
|
{ |
700
|
|
|
$cache_file = './files/config/module_extend.php'; |
701
|
|
|
$cache_file = FileHandler::getRealPath($cache_file); |
702
|
|
|
|
703
|
|
|
if(!isset($GLOBALS['__MODULE_EXTEND__'])) |
704
|
|
|
{ |
705
|
|
|
// check pre install |
706
|
|
|
if(file_exists(FileHandler::getRealPath('./files')) && !file_exists($cache_file)) |
707
|
|
|
{ |
708
|
|
|
$arr = array(); |
709
|
|
|
$output = executeQueryArray('module.getModuleExtend'); |
710
|
|
|
if($output->data) |
711
|
|
|
{ |
712
|
|
|
foreach($output->data as $v) |
713
|
|
|
{ |
714
|
|
|
$arr[] = sprintf("'%s.%s.%s' => '%s'", $v->parent_module, $v->kind, $v->type, $v->extend_module); |
715
|
|
|
} |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
$str = '<?PHP return array(%s); ?>'; |
719
|
|
|
$str = sprintf($str, join(',',$arr)); |
720
|
|
|
|
721
|
|
|
FileHandler::writeFile($cache_file, $str); |
722
|
|
|
} |
723
|
|
|
|
724
|
|
|
|
725
|
|
|
if(file_exists($cache_file)) |
726
|
|
|
{ |
727
|
|
|
$GLOBALS['__MODULE_EXTEND__'] = include($cache_file); |
728
|
|
|
} |
729
|
|
|
else |
730
|
|
|
{ |
731
|
|
|
$GLOBALS['__MODULE_EXTEND__'] = array(); |
732
|
|
|
} |
733
|
|
|
} |
734
|
|
|
|
735
|
|
|
return $GLOBALS['__MODULE_EXTEND__']; |
736
|
|
|
} |
737
|
|
|
|
738
|
|
|
/** |
739
|
|
|
* @brief Get information from conf/info.xml |
740
|
|
|
*/ |
741
|
|
|
function getModuleInfoXml($module) |
742
|
|
|
{ |
743
|
|
|
// Get a path of the requested module. Return if not exists. |
744
|
|
|
$module_path = ModuleHandler::getModulePath($module); |
745
|
|
|
if(!$module_path) return; |
746
|
|
|
// Read the xml file for module skin information |
747
|
|
|
$xml_file = sprintf("%s/conf/info.xml", $module_path); |
748
|
|
|
if(!file_exists($xml_file)) return; |
749
|
|
|
|
750
|
|
|
$oXmlParser = new XmlParser(); |
751
|
|
|
$tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); |
752
|
|
|
$xml_obj = $tmp_xml_obj->module; |
753
|
|
|
|
754
|
|
|
if(!$xml_obj) return; |
755
|
|
|
|
756
|
|
|
// Module Information |
757
|
|
|
$module_info = new stdClass(); |
758
|
|
|
if($xml_obj->version && $xml_obj->attrs->version == '0.2') |
759
|
|
|
{ |
760
|
|
|
// module format 0.2 |
761
|
|
|
$module_info->title = $xml_obj->title->body; |
762
|
|
|
$module_info->description = $xml_obj->description->body; |
763
|
|
|
$module_info->version = $xml_obj->version->body; |
764
|
|
|
$module_info->homepage = $xml_obj->link->body; |
765
|
|
|
$module_info->category = $xml_obj->category->body; |
766
|
|
|
if(!$module_info->category) $module_info->category = 'service'; |
767
|
|
|
sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); |
|
|
|
|
768
|
|
|
$module_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
769
|
|
|
$module_info->license = $xml_obj->license->body; |
770
|
|
|
$module_info->license_link = $xml_obj->license->attrs->link; |
771
|
|
|
|
772
|
|
View Code Duplication |
if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author; |
|
|
|
|
773
|
|
|
else $author_list = $xml_obj->author; |
774
|
|
|
|
775
|
|
View Code Duplication |
foreach($author_list as $author) |
776
|
|
|
{ |
777
|
|
|
$author_obj = new stdClass(); |
778
|
|
|
$author_obj->name = $author->name->body; |
779
|
|
|
$author_obj->email_address = $author->attrs->email_address; |
780
|
|
|
$author_obj->homepage = $author->attrs->link; |
781
|
|
|
$module_info->author[] = $author_obj; |
782
|
|
|
} |
783
|
|
|
} |
784
|
|
|
else |
785
|
|
|
{ |
786
|
|
|
// module format 0.1 |
787
|
|
|
$module_info->title = $xml_obj->title->body; |
788
|
|
|
$module_info->description = $xml_obj->author->description->body; |
789
|
|
|
$module_info->version = $xml_obj->attrs->version; |
790
|
|
|
$module_info->category = $xml_obj->attrs->category; |
791
|
|
|
if(!$module_info->category) $module_info->category = 'service'; |
792
|
|
|
sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); |
793
|
|
|
$module_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
794
|
|
|
$author_obj = new stdClass(); |
795
|
|
|
$author_obj->name = $xml_obj->author->name->body; |
796
|
|
|
$author_obj->email_address = $xml_obj->author->attrs->email_address; |
797
|
|
|
$author_obj->homepage = $xml_obj->author->attrs->link; |
798
|
|
|
$module_info->author[] = $author_obj; |
799
|
|
|
} |
800
|
|
|
// Add admin_index by using action information |
801
|
|
|
$action_info = $this->getModuleActionXml($module); |
802
|
|
|
$module_info->admin_index_act = $action_info->admin_index_act; |
803
|
|
|
$module_info->default_index_act = $action_info->default_index_act; |
804
|
|
|
$module_info->setup_index_act = $action_info->setup_index_act; |
805
|
|
|
$module_info->simple_setup_index_act = $action_info->simple_setup_index_act; |
806
|
|
|
|
807
|
|
|
return $module_info; |
808
|
|
|
} |
809
|
|
|
|
810
|
|
|
/** |
811
|
|
|
* @brief Return permisson and action data by conf/module.xml in the module |
812
|
|
|
* Cache it because it takes too long to parse module.xml file |
813
|
|
|
* When caching, add codes so to include it directly |
814
|
|
|
* This is apparently good for performance, but not sure about its side-effects |
815
|
|
|
*/ |
816
|
|
|
function getModuleActionXml($module) |
817
|
|
|
{ |
818
|
|
|
// Get a path of the requested module. Return if not exists. |
819
|
|
|
$class_path = ModuleHandler::getModulePath($module); |
820
|
|
|
if(!$class_path) return; |
821
|
|
|
|
822
|
|
|
// Check if module.xml exists in the path. Return if not exist |
823
|
|
|
$xml_file = sprintf("%sconf/module.xml", $class_path); |
824
|
|
|
if(!file_exists($xml_file)) return; |
825
|
|
|
|
826
|
|
|
// Check if cached file exists |
827
|
|
|
$cache_file = sprintf(_XE_PATH_ . "files/cache/module_info/%s.%s.%s.php", $module, Context::getLangType(), __XE_VERSION__); |
828
|
|
|
|
829
|
|
|
// Update if no cache file exists or it is older than xml file |
830
|
|
|
if(!file_exists($cache_file) || filemtime($cache_file) < filemtime($xml_file) || $re_cache) |
|
|
|
|
831
|
|
|
{ |
832
|
|
|
$info = new stdClass(); |
833
|
|
|
$buff = array(); // /< Set buff variable to use in the cache file |
834
|
|
|
$buff[] = '<?php if(!defined("__XE__")) exit();'; |
835
|
|
|
$buff[] = '$info = new stdClass;'; |
836
|
|
|
$buff['default_index_act'] = '$info->default_index_act = \'%s\';'; |
837
|
|
|
$buff['setup_index_act'] = '$info->setup_index_act=\'%s\';'; |
838
|
|
|
$buff['simple_setup_index_act'] = '$info->simple_setup_index_act=\'%s\';'; |
839
|
|
|
$buff['admin_index_act'] = '$info->admin_index_act = \'%s\';'; |
840
|
|
|
|
841
|
|
|
$xml_obj = XmlParser::loadXmlFile($xml_file); // /< Read xml file and convert it to xml object |
842
|
|
|
|
843
|
|
|
if(!count($xml_obj->module)) return; // /< Error occurs if module tag doesn't included in the xml |
844
|
|
|
|
845
|
|
|
$grants = $xml_obj->module->grants->grant; // /< Permission information |
846
|
|
|
$permissions = $xml_obj->module->permissions->permission; // /< Acting permission |
847
|
|
|
$menus = $xml_obj->module->menus->menu; |
848
|
|
|
$actions = $xml_obj->module->actions->action; // /< Action list (required) |
849
|
|
|
|
850
|
|
|
$default_index = $admin_index = ''; |
|
|
|
|
851
|
|
|
|
852
|
|
|
// Arrange permission information |
853
|
|
|
if($grants) |
854
|
|
|
{ |
855
|
|
|
if(is_array($grants)) $grant_list = $grants; |
856
|
|
|
else $grant_list[] = $grants; |
|
|
|
|
857
|
|
|
|
858
|
|
|
$info->grant = new stdClass(); |
859
|
|
|
$buff[] = '$info->grant = new stdClass;'; |
860
|
|
|
foreach($grant_list as $grant) |
861
|
|
|
{ |
862
|
|
|
$name = $grant->attrs->name; |
863
|
|
|
$default = $grant->attrs->default?$grant->attrs->default:'guest'; |
864
|
|
|
$title = $grant->title->body; |
865
|
|
|
|
866
|
|
|
$info->grant->{$name} = new stdClass(); |
867
|
|
|
$info->grant->{$name}->title = $title; |
868
|
|
|
$info->grant->{$name}->default = $default; |
869
|
|
|
|
870
|
|
|
$buff[] = sprintf('$info->grant->%s = new stdClass;', $name); |
871
|
|
|
$buff[] = sprintf('$info->grant->%s->title=\'%s\';', $name, $title); |
872
|
|
|
$buff[] = sprintf('$info->grant->%s->default=\'%s\';', $name, $default); |
873
|
|
|
} |
874
|
|
|
} |
875
|
|
|
// Permissions to grant |
876
|
|
|
if($permissions) |
877
|
|
|
{ |
878
|
|
|
if(is_array($permissions)) $permission_list = $permissions; |
879
|
|
|
else $permission_list[] = $permissions; |
|
|
|
|
880
|
|
|
|
881
|
|
|
$buff[] = '$info->permission = new stdClass;'; |
882
|
|
|
|
883
|
|
|
$info->permission = new stdClass(); |
884
|
|
|
foreach($permission_list as $permission) |
885
|
|
|
{ |
886
|
|
|
$action = $permission->attrs->action; |
887
|
|
|
$target = $permission->attrs->target; |
888
|
|
|
|
889
|
|
|
$info->permission->{$action} = $target; |
890
|
|
|
|
891
|
|
|
$buff[] = sprintf('$info->permission->%s = \'%s\';', $action, $target); |
892
|
|
|
} |
893
|
|
|
} |
894
|
|
|
// for admin menus |
895
|
|
|
if($menus) |
896
|
|
|
{ |
897
|
|
|
if(is_array($menus)) $menu_list = $menus; |
898
|
|
|
else $menu_list[] = $menus; |
|
|
|
|
899
|
|
|
|
900
|
|
|
$buff[] = '$info->menu = new stdClass;'; |
901
|
|
|
$info->menu = new stdClass(); |
902
|
|
|
foreach($menu_list as $menu) |
903
|
|
|
{ |
904
|
|
|
$menu_name = $menu->attrs->name; |
905
|
|
|
$menu_title = is_array($menu->title) ? $menu->title[0]->body : $menu->title->body; |
906
|
|
|
$menu_type = $menu->attrs->type; |
907
|
|
|
|
908
|
|
|
$info->menu->{$menu_name} = new stdClass(); |
909
|
|
|
$info->menu->{$menu_name}->title = $menu_title; |
910
|
|
|
$info->menu->{$menu_name}->acts = array(); |
911
|
|
|
$info->menu->{$menu_name}->type = $menu_type; |
912
|
|
|
|
913
|
|
|
$buff[] = sprintf('$info->menu->%s = new stdClass;', $menu_name); |
914
|
|
|
$buff[] = sprintf('$info->menu->%s->title=\'%s\';', $menu_name, $menu_title); |
915
|
|
|
$buff[] = sprintf('$info->menu->%s->type=\'%s\';', $menu_name, $menu_type); |
916
|
|
|
} |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
// actions |
920
|
|
|
if($actions) |
921
|
|
|
{ |
922
|
|
|
if(is_array($actions)) $action_list = $actions; |
923
|
|
|
else $action_list[] = $actions; |
|
|
|
|
924
|
|
|
|
925
|
|
|
$buff[] = '$info->action = new stdClass;'; |
926
|
|
|
$info->action = new stdClass(); |
927
|
|
|
foreach($action_list as $action) |
928
|
|
|
{ |
929
|
|
|
$name = $action->attrs->name; |
930
|
|
|
|
931
|
|
|
$type = $action->attrs->type; |
932
|
|
|
$grant = $action->attrs->grant?$action->attrs->grant:'guest'; |
933
|
|
|
$standalone = $action->attrs->standalone=='false'?'false':'true'; |
934
|
|
|
$ruleset = $action->attrs->ruleset?$action->attrs->ruleset:''; |
935
|
|
|
$method = $action->attrs->method?$action->attrs->method:''; |
936
|
|
|
$check_csrf = $action->attrs->check_csrf=='false'?'false':'true'; |
937
|
|
|
$meta_noindex = $action->attrs->{'meta-noindex'} === 'true' ? 'true' : 'false'; |
938
|
|
|
|
939
|
|
|
$index = $action->attrs->index; |
940
|
|
|
$admin_index = $action->attrs->admin_index; |
941
|
|
|
$setup_index = $action->attrs->setup_index; |
942
|
|
|
$simple_setup_index = $action->attrs->simple_setup_index; |
943
|
|
|
$menu_index = $action->attrs->menu_index; |
944
|
|
|
|
945
|
|
|
$info->action->{$name} = new stdClass(); |
946
|
|
|
$info->action->{$name}->type = $type; |
947
|
|
|
$info->action->{$name}->grant = $grant; |
948
|
|
|
$info->action->{$name}->standalone = $standalone; |
949
|
|
|
$info->action->{$name}->ruleset = $ruleset; |
950
|
|
|
$info->action->{$name}->method = $method; |
951
|
|
|
$info->action->{$name}->check_csrf = $check_csrf; |
952
|
|
|
$info->action->{$name}->meta_noindex = $meta_noindex; |
953
|
|
|
if($action->attrs->menu_name) |
954
|
|
|
{ |
955
|
|
|
if($menu_index == 'true') |
956
|
|
|
{ |
957
|
|
|
$info->menu->{$action->attrs->menu_name}->index = $name; |
958
|
|
|
$buff[] = sprintf('$info->menu->%s->index=\'%s\';', $action->attrs->menu_name, $name); |
959
|
|
|
} |
960
|
|
|
if(is_array($info->menu->{$action->attrs->menu_name}->acts)) |
961
|
|
|
{ |
962
|
|
|
$info->menu->{$action->attrs->menu_name}->acts[] = $name; |
963
|
|
|
$currentKey = array_search($name, $info->menu->{$action->attrs->menu_name}->acts); |
964
|
|
|
} |
965
|
|
|
|
966
|
|
|
$buff[] = sprintf('$info->menu->%s->acts[%d]=\'%s\';', $action->attrs->menu_name, $currentKey, $name); |
|
|
|
|
967
|
|
|
$i++; |
|
|
|
|
968
|
|
|
} |
969
|
|
|
|
970
|
|
|
$buff[] = sprintf('$info->action->%s = new stdClass;', $name); |
971
|
|
|
$buff[] = sprintf('$info->action->%s->type=\'%s\';', $name, $type); |
972
|
|
|
$buff[] = sprintf('$info->action->%s->grant=\'%s\';', $name, $grant); |
973
|
|
|
$buff[] = sprintf('$info->action->%s->standalone=\'%s\';', $name, $standalone); |
974
|
|
|
$buff[] = sprintf('$info->action->%s->ruleset=\'%s\';', $name, $ruleset); |
975
|
|
|
$buff[] = sprintf('$info->action->%s->method=\'%s\';', $name, $method); |
976
|
|
|
$buff[] = sprintf('$info->action->%s->check_csrf=\'%s\';', $name, $check_csrf); |
977
|
|
|
$buff[] = sprintf('$info->action->%s->meta_noindex=\'%s\';', $name, $meta_noindex); |
978
|
|
|
|
979
|
|
|
if($index=='true') |
980
|
|
|
{ |
981
|
|
|
$default_index_act = $name; |
982
|
|
|
$info->default_index_act = $name; |
983
|
|
|
} |
984
|
|
|
if($admin_index=='true') |
985
|
|
|
{ |
986
|
|
|
$admin_index_act = $name; |
987
|
|
|
$info->admin_index_act = $name; |
988
|
|
|
} |
989
|
|
|
if($setup_index=='true') |
990
|
|
|
{ |
991
|
|
|
$setup_index_act = $name; |
992
|
|
|
$info->setup_index_act = $name; |
993
|
|
|
} |
994
|
|
|
if($simple_setup_index=='true') |
995
|
|
|
{ |
996
|
|
|
$simple_setup_index_act = $name; |
997
|
|
|
$info->simple_setup_index_act = $name; |
998
|
|
|
} |
999
|
|
|
} |
1000
|
|
|
} |
1001
|
|
|
$buff['default_index_act'] = sprintf($buff['default_index_act'], $default_index_act); |
|
|
|
|
1002
|
|
|
$buff['setup_index_act'] = sprintf($buff['setup_index_act'], $setup_index_act); |
|
|
|
|
1003
|
|
|
$buff['simple_setup_index_act'] = sprintf($buff['simple_setup_index_act'], $simple_setup_index_act); |
|
|
|
|
1004
|
|
|
$buff['admin_index_act'] = sprintf($buff['admin_index_act'], $admin_index_act); |
|
|
|
|
1005
|
|
|
|
1006
|
|
|
$buff[] = 'return $info;'; |
1007
|
|
|
|
1008
|
|
|
$buff = implode(PHP_EOL, $buff); |
1009
|
|
|
|
1010
|
|
|
FileHandler::writeFile($cache_file, $buff); |
1011
|
|
|
|
1012
|
|
|
return $info; |
1013
|
|
|
} |
1014
|
|
|
|
1015
|
|
|
if(file_exists($cache_file)) return include($cache_file); |
1016
|
|
|
} |
1017
|
|
|
|
1018
|
|
|
/** |
1019
|
|
|
* Get a skin list for js API. |
1020
|
|
|
* return void |
1021
|
|
|
*/ |
1022
|
|
|
public function getModuleSkinInfoList() |
1023
|
|
|
{ |
1024
|
|
|
$module = Context::get('module_type'); |
1025
|
|
|
|
1026
|
|
|
if($module == 'ARTICLE') |
1027
|
|
|
{ |
1028
|
|
|
$module = 'page'; |
1029
|
|
|
} |
1030
|
|
|
|
1031
|
|
|
$skinType = Context::get('skin_type'); |
1032
|
|
|
|
1033
|
|
|
$path = ModuleHandler::getModulePath($module); |
1034
|
|
|
$dir = ($skinType == 'M') ? 'm.skins' : 'skins'; |
1035
|
|
|
$skin_list = $this->getSkins($path, $dir); |
1036
|
|
|
|
1037
|
|
|
$this->add('skin_info_list', $skin_list); |
1038
|
|
|
} |
1039
|
|
|
|
1040
|
|
|
/** |
1041
|
|
|
* @brief Get a list of skins for the module |
1042
|
|
|
* Return file analysis of skin and skin.xml |
1043
|
|
|
*/ |
1044
|
|
|
function getSkins($path, $dir = 'skins') |
1045
|
|
|
{ |
1046
|
|
|
if(substr($path, -1) == '/') |
1047
|
|
|
{ |
1048
|
|
|
$path = substr($path, 0, -1); |
1049
|
|
|
} |
1050
|
|
|
|
1051
|
|
|
$skin_path = sprintf("%s/%s/", $path, $dir); |
1052
|
|
|
$list = FileHandler::readDir($skin_path); |
1053
|
|
|
if(!count($list)) return; |
1054
|
|
|
|
1055
|
|
|
natcasesort($list); |
1056
|
|
|
|
1057
|
|
|
foreach($list as $skin_name) |
1058
|
|
|
{ |
1059
|
|
|
if(!is_dir($skin_path . $skin_name)) |
1060
|
|
|
{ |
1061
|
|
|
continue; |
1062
|
|
|
} |
1063
|
|
|
unset($skin_info); |
1064
|
|
|
$skin_info = $this->loadSkinInfo($path, $skin_name, $dir); |
1065
|
|
|
if(!$skin_info) |
1066
|
|
|
{ |
1067
|
|
|
$skin_info = new stdClass(); |
1068
|
|
|
$skin_info->title = $skin_name; |
1069
|
|
|
} |
1070
|
|
|
|
1071
|
|
|
$skin_list[$skin_name] = $skin_info; |
|
|
|
|
1072
|
|
|
} |
1073
|
|
|
|
1074
|
|
|
$tmpPath = strtr($path, array('/' => ' ')); |
1075
|
|
|
$tmpPath = trim($tmpPath); |
1076
|
|
|
$module = array_pop(explode(' ', $tmpPath)); |
|
|
|
|
1077
|
|
|
|
1078
|
|
|
if($dir == 'skins') |
1079
|
|
|
{ |
1080
|
|
|
$oAdminModel = getAdminModel('admin'); |
1081
|
|
|
$themesInfo = $oAdminModel->getThemeList(); |
1082
|
|
|
|
1083
|
|
|
foreach($themesInfo as $themeName => $info) |
1084
|
|
|
{ |
1085
|
|
|
$skinInfos = $info->skin_infos; |
1086
|
|
|
if(isset($skinInfos[$module]) && $skinInfos[$module]->is_theme) |
1087
|
|
|
{ |
1088
|
|
|
$themeSkinInfo = $GLOBALS['__ThemeModuleSkin__'][$module]['skins'][$skinInfos[$module]->name]; |
1089
|
|
|
$skin_list[$skinInfos[$module]->name] = $themeSkinInfo; |
|
|
|
|
1090
|
|
|
} |
1091
|
|
|
} |
1092
|
|
|
} |
1093
|
|
|
|
1094
|
|
|
$siteInfo = Context::get('site_module_info'); |
1095
|
|
|
$oMenuAdminModel = getAdminModel('menu'); |
1096
|
|
|
$installedMenuTypes = $oMenuAdminModel->getModuleListInSitemap($siteInfo->site_srl); |
1097
|
|
|
$moduleName = $module; |
1098
|
|
|
if($moduleName === 'page') |
1099
|
|
|
{ |
1100
|
|
|
$moduleName = 'ARTICLE'; |
1101
|
|
|
} |
1102
|
|
|
if(array_key_exists($moduleName, $installedMenuTypes)) |
1103
|
|
|
{ |
1104
|
|
|
if($dir == 'skins') |
1105
|
|
|
{ |
1106
|
|
|
$type = 'P'; |
1107
|
|
|
} |
1108
|
|
|
else |
1109
|
|
|
{ |
1110
|
|
|
$type = 'M'; |
1111
|
|
|
} |
1112
|
|
|
$defaultSkinName = $this->getModuleDefaultSkin($module, $type, $site_info->site_srl); |
|
|
|
|
1113
|
|
|
|
1114
|
|
|
if(isset($defaultSkinName)) |
1115
|
|
|
{ |
1116
|
|
|
$defaultSkinInfo = $this->loadSkinInfo($path, $defaultSkinName, $dir); |
1117
|
|
|
|
1118
|
|
|
$useDefault = new stdClass(); |
1119
|
|
|
$useDefault->title = Context::getLang('use_site_default_skin') . ' (' . $defaultSkinInfo->title . ')'; |
1120
|
|
|
|
1121
|
|
|
$useDefaultList['/USE_DEFAULT/'] = $useDefault; |
|
|
|
|
1122
|
|
|
|
1123
|
|
|
$skin_list = array_merge($useDefaultList, $skin_list); |
1124
|
|
|
} |
1125
|
|
|
} |
1126
|
|
|
|
1127
|
|
|
return $skin_list; |
1128
|
|
|
} |
1129
|
|
|
|
1130
|
|
|
/** |
1131
|
|
|
* @brief Get skin information on a specific location |
1132
|
|
|
*/ |
1133
|
|
|
function loadSkinInfo($path, $skin, $dir = 'skins') |
1134
|
|
|
{ |
1135
|
|
|
// Read xml file having skin information |
1136
|
|
|
if(substr($path,-1)!='/') $path .= '/'; |
1137
|
|
|
$skin_xml_file = sprintf("%s%s/%s/skin.xml", $path, $dir, $skin); |
1138
|
|
|
if(!file_exists($skin_xml_file)) return; |
1139
|
|
|
// Create XmlParser object |
1140
|
|
|
$oXmlParser = new XmlParser(); |
1141
|
|
|
$_xml_obj = $oXmlParser->loadXmlFile($skin_xml_file); |
1142
|
|
|
// Return if no skin information is |
1143
|
|
|
if(!$_xml_obj->skin) return; |
1144
|
|
|
$xml_obj = $_xml_obj->skin; |
1145
|
|
|
// Skin Name |
1146
|
|
|
$skin_info = new stdClass(); |
1147
|
|
|
$skin_info->title = $xml_obj->title->body; |
1148
|
|
|
// Author information |
1149
|
|
|
if($xml_obj->version && $xml_obj->attrs->version == '0.2') |
1150
|
|
|
{ |
1151
|
|
|
// skin format v0.2 |
1152
|
|
|
sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); |
|
|
|
|
1153
|
|
|
$skin_info->version = $xml_obj->version->body; |
1154
|
|
|
$skin_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
1155
|
|
|
$skin_info->homepage = $xml_obj->link->body; |
1156
|
|
|
$skin_info->license = $xml_obj->license->body; |
1157
|
|
|
$skin_info->license_link = $xml_obj->license->attrs->link; |
1158
|
|
|
$skin_info->description = $xml_obj->description->body; |
1159
|
|
|
|
1160
|
|
View Code Duplication |
if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author; |
|
|
|
|
1161
|
|
|
else $author_list = $xml_obj->author; |
1162
|
|
|
|
1163
|
|
View Code Duplication |
foreach($author_list as $author) |
1164
|
|
|
{ |
1165
|
|
|
$author_obj = new stdClass(); |
1166
|
|
|
$author_obj->name = $author->name->body; |
1167
|
|
|
$author_obj->email_address = $author->attrs->email_address; |
1168
|
|
|
$author_obj->homepage = $author->attrs->link; |
1169
|
|
|
$skin_info->author[] = $author_obj; |
1170
|
|
|
} |
1171
|
|
|
// List extra vars |
1172
|
|
|
if($xml_obj->extra_vars) |
1173
|
|
|
{ |
1174
|
|
|
$extra_var_groups = $xml_obj->extra_vars->group; |
1175
|
|
|
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars; |
1176
|
|
|
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups); |
1177
|
|
|
|
1178
|
|
|
foreach($extra_var_groups as $group) |
1179
|
|
|
{ |
1180
|
|
|
$extra_vars = $group->var; |
1181
|
|
|
if(!$extra_vars) |
1182
|
|
|
{ |
1183
|
|
|
continue; |
1184
|
|
|
} |
1185
|
|
|
if(!is_array($group->var)) $extra_vars = array($group->var); |
1186
|
|
|
|
1187
|
|
|
foreach($extra_vars as $key => $val) |
1188
|
|
|
{ |
1189
|
|
|
$obj = new stdClass(); |
1190
|
|
|
if(!$val->attrs->type) { $val->attrs->type = 'text'; } |
1191
|
|
|
|
1192
|
|
|
$obj->group = $group->title->body; |
1193
|
|
|
$obj->name = $val->attrs->name; |
1194
|
|
|
$obj->title = $val->title->body; |
1195
|
|
|
$obj->type = $val->attrs->type; |
1196
|
|
|
$obj->description = $val->description->body; |
1197
|
|
|
$obj->value = $extra_vals->{$obj->name}; |
|
|
|
|
1198
|
|
|
$obj->default = $val->attrs->default; |
1199
|
|
|
if(strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); } |
|
|
|
|
1200
|
|
|
if($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); } |
1201
|
|
|
// Get an option list from 'select'type |
1202
|
|
|
if(is_array($val->options)) |
1203
|
|
|
{ |
1204
|
|
|
$option_count = count($val->options); |
1205
|
|
|
|
1206
|
|
|
for($i = 0; $i < $option_count; $i++) |
1207
|
|
|
{ |
1208
|
|
|
$obj->options[$i] = new stdClass(); |
1209
|
|
|
$obj->options[$i]->title = $val->options[$i]->title->body; |
1210
|
|
|
$obj->options[$i]->value = $val->options[$i]->attrs->value; |
1211
|
|
|
} |
1212
|
|
|
} |
1213
|
|
|
else |
1214
|
|
|
{ |
1215
|
|
|
$obj->options[0] = new stdClass(); |
1216
|
|
|
$obj->options[0]->title = $val->options->title->body; |
1217
|
|
|
$obj->options[0]->value = $val->options->attrs->value; |
1218
|
|
|
} |
1219
|
|
|
|
1220
|
|
|
$skin_info->extra_vars[] = $obj; |
1221
|
|
|
} |
1222
|
|
|
} |
1223
|
|
|
} |
1224
|
|
|
} |
1225
|
|
|
else |
1226
|
|
|
{ |
1227
|
|
|
// skin format v0.1 |
1228
|
|
|
sscanf($xml_obj->maker->attrs->date, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); |
1229
|
|
|
|
1230
|
|
|
$skin_info->version = $xml_obj->version->body; |
1231
|
|
|
$skin_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
1232
|
|
|
$skin_info->homepage = $xml_obj->link->body; |
1233
|
|
|
$skin_info->license = $xml_obj->license->body; |
1234
|
|
|
$skin_info->license_link = $xml_obj->license->attrs->link; |
1235
|
|
|
$skin_info->description = $xml_obj->maker->description->body; |
1236
|
|
|
|
1237
|
|
|
$skin_info->author[0] = new stdClass(); |
1238
|
|
|
$skin_info->author[0]->name = $xml_obj->maker->name->body; |
1239
|
|
|
$skin_info->author[0]->email_address = $xml_obj->maker->attrs->email_address; |
1240
|
|
|
$skin_info->author[0]->homepage = $xml_obj->maker->attrs->link; |
1241
|
|
|
// Variables used in the skin |
1242
|
|
|
$extra_var_groups = $xml_obj->extra_vars->group; |
1243
|
|
|
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars; |
1244
|
|
|
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups); |
1245
|
|
|
|
1246
|
|
|
foreach($extra_var_groups as $group) |
1247
|
|
|
{ |
1248
|
|
|
$extra_vars = $group->var; |
1249
|
|
|
|
1250
|
|
|
if($extra_vars) |
1251
|
|
|
{ |
1252
|
|
|
if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
1253
|
|
|
|
1254
|
|
|
foreach($extra_vars as $var) |
1255
|
|
|
{ |
1256
|
|
|
unset($obj); |
1257
|
|
|
unset($options); |
1258
|
|
|
|
1259
|
|
|
$group = $group->title->body; |
1260
|
|
|
$name = $var->attrs->name; |
1261
|
|
|
$type = $var->attrs->type; |
1262
|
|
|
$title = $var->title->body; |
1263
|
|
|
$description = $var->description->body; |
1264
|
|
|
// Get an option list from 'select'type. |
1265
|
|
|
if(is_array($var->default)) |
1266
|
|
|
{ |
1267
|
|
|
$option_count = count($var->default); |
1268
|
|
|
|
1269
|
|
|
for($i = 0; $i < $option_count; $i++) |
1270
|
|
|
{ |
1271
|
|
|
$options[$i]->title = $var->default[$i]->body; |
|
|
|
|
1272
|
|
|
$options[$i]->value = $var->default[$i]->body; |
1273
|
|
|
} |
1274
|
|
|
} |
1275
|
|
|
else |
1276
|
|
|
{ |
1277
|
|
|
$options[0]->title = $var->default->body; |
1278
|
|
|
$options[0]->value = $var->default->body; |
1279
|
|
|
} |
1280
|
|
|
|
1281
|
|
|
$width = $var->attrs->width; |
1282
|
|
|
$height = $var->attrs->height; |
1283
|
|
|
|
1284
|
|
|
unset($obj); |
1285
|
|
|
$obj->group = $group; |
|
|
|
|
1286
|
|
|
$obj->title = $title; |
|
|
|
|
1287
|
|
|
$obj->description = $description; |
|
|
|
|
1288
|
|
|
$obj->name = $name; |
|
|
|
|
1289
|
|
|
$obj->type = $type; |
|
|
|
|
1290
|
|
|
$obj->options = $options; |
|
|
|
|
1291
|
|
|
$obj->width = $width; |
|
|
|
|
1292
|
|
|
$obj->height = $height; |
|
|
|
|
1293
|
|
|
$obj->default = $options[0]->value; |
|
|
|
|
1294
|
|
|
|
1295
|
|
|
$skin_info->extra_vars[] = $obj; |
|
|
|
|
1296
|
|
|
} |
1297
|
|
|
} |
1298
|
|
|
} |
1299
|
|
|
} |
1300
|
|
|
|
1301
|
|
|
// colorset |
1302
|
|
|
$colorset = $xml_obj->colorset->color; |
1303
|
|
|
if($colorset) |
1304
|
|
|
{ |
1305
|
|
|
if(!is_array($colorset)) $colorset = array($colorset); |
1306
|
|
|
|
1307
|
|
|
foreach($colorset as $color) |
1308
|
|
|
{ |
1309
|
|
|
$name = $color->attrs->name; |
1310
|
|
|
$title = $color->title->body; |
1311
|
|
|
$screenshot = $color->attrs->src; |
1312
|
|
|
if($screenshot) |
1313
|
|
|
{ |
1314
|
|
|
$screenshot = sprintf("%s%s/%s/%s", $path, $dir, $skin, $screenshot); |
1315
|
|
|
if(!file_exists($screenshot)) $screenshot = ""; |
1316
|
|
|
} |
1317
|
|
|
else $screenshot = ""; |
1318
|
|
|
|
1319
|
|
|
$obj = new stdClass(); |
1320
|
|
|
$obj->name = $name; |
1321
|
|
|
$obj->title = $title; |
1322
|
|
|
$obj->screenshot = $screenshot; |
1323
|
|
|
$skin_info->colorset[] = $obj; |
1324
|
|
|
} |
1325
|
|
|
} |
1326
|
|
|
// Menu type (settings for layout) |
1327
|
|
|
if($xml_obj->menus->menu) |
1328
|
|
|
{ |
1329
|
|
|
$menus = $xml_obj->menus->menu; |
1330
|
|
|
if(!is_array($menus)) $menus = array($menus); |
1331
|
|
|
|
1332
|
|
|
$menu_count = count($menus); |
1333
|
|
|
$skin_info->menu_count = $menu_count; |
1334
|
|
|
for($i=0;$i<$menu_count;$i++) |
1335
|
|
|
{ |
1336
|
|
|
unset($obj); |
1337
|
|
|
|
1338
|
|
|
$obj->name = $menus[$i]->attrs->name; |
|
|
|
|
1339
|
|
|
if($menus[$i]->attrs->default == "true") $obj->default = true; |
1340
|
|
|
$obj->title = $menus[$i]->title->body; |
1341
|
|
|
$obj->maxdepth = $menus[$i]->maxdepth->body; |
1342
|
|
|
|
1343
|
|
|
$skin_info->menu->{$obj->name} = $obj; |
1344
|
|
|
} |
1345
|
|
|
} |
1346
|
|
|
|
1347
|
|
|
$thumbnail = sprintf("%s%s/%s/thumbnail.png", $path, $dir, $skin); |
1348
|
|
|
$skin_info->thumbnail = (file_exists($thumbnail))?$thumbnail:null; |
1349
|
|
|
return $skin_info; |
1350
|
|
|
} |
1351
|
|
|
|
1352
|
|
|
/** |
1353
|
|
|
* @brief Return the number of modules which are registered on a virtual site |
1354
|
|
|
*/ |
1355
|
|
|
function getModuleCount($site_srl, $module = null) |
1356
|
|
|
{ |
1357
|
|
|
$args = new stdClass; |
1358
|
|
|
$args->site_srl = $site_srl; |
1359
|
|
|
if(!is_null($module)) $args->module = $module; |
1360
|
|
|
$output = executeQuery('module.getModuleCount', $args); |
1361
|
|
|
return $output->data->count; |
1362
|
|
|
} |
1363
|
|
|
|
1364
|
|
|
/** |
1365
|
|
|
* @brief Return module configurations |
1366
|
|
|
* Global configuration is used to manage board, member and others |
1367
|
|
|
*/ |
1368
|
|
View Code Duplication |
function getModuleConfig($module, $site_srl = 0) |
|
|
|
|
1369
|
|
|
{ |
1370
|
|
|
$config = false; |
1371
|
|
|
// cache controll |
1372
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
1373
|
|
|
if($oCacheHandler->isSupport()) |
1374
|
|
|
{ |
1375
|
|
|
$object_key = 'module_config:' . $module . '_' . $site_srl; |
1376
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
1377
|
|
|
$config = $oCacheHandler->get($cache_key); |
1378
|
|
|
} |
1379
|
|
|
|
1380
|
|
|
if($config === false) |
1381
|
|
|
{ |
1382
|
|
|
if(!$GLOBALS['__ModuleConfig__'][$site_srl][$module]) |
1383
|
|
|
{ |
1384
|
|
|
$args = new stdClass(); |
1385
|
|
|
$args->module = $module; |
1386
|
|
|
$args->site_srl = $site_srl; |
1387
|
|
|
$output = executeQuery('module.getModuleConfig', $args); |
1388
|
|
|
if($output->data->config) $config = unserialize($output->data->config); |
1389
|
|
|
else $config = null; |
1390
|
|
|
|
1391
|
|
|
//insert in cache |
1392
|
|
|
if($oCacheHandler->isSupport()) |
1393
|
|
|
{ |
1394
|
|
|
$oCacheHandler->put($cache_key, $config); |
|
|
|
|
1395
|
|
|
} |
1396
|
|
|
$GLOBALS['__ModuleConfig__'][$site_srl][$module] = $config; |
1397
|
|
|
} |
1398
|
|
|
return $GLOBALS['__ModuleConfig__'][$site_srl][$module]; |
1399
|
|
|
} |
1400
|
|
|
|
1401
|
|
|
return $config; |
1402
|
|
|
} |
1403
|
|
|
|
1404
|
|
|
/** |
1405
|
|
|
* @brief Return the module configuration of mid |
1406
|
|
|
* Manage mid configurations which depend on module |
1407
|
|
|
*/ |
1408
|
|
View Code Duplication |
function getModulePartConfig($module, $module_srl) |
|
|
|
|
1409
|
|
|
{ |
1410
|
|
|
$config = false; |
1411
|
|
|
// cache controll |
1412
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
1413
|
|
|
if($oCacheHandler->isSupport()) |
1414
|
|
|
{ |
1415
|
|
|
$object_key = 'module_part_config:'.$module.'_'.$module_srl; |
1416
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
1417
|
|
|
$config = $oCacheHandler->get($cache_key); |
1418
|
|
|
} |
1419
|
|
|
|
1420
|
|
|
if($config === false) |
1421
|
|
|
{ |
1422
|
|
|
if(!isset($GLOBALS['__ModulePartConfig__'][$module][$module_srl])) |
1423
|
|
|
{ |
1424
|
|
|
$args = new stdClass(); |
1425
|
|
|
$args->module = $module; |
1426
|
|
|
$args->module_srl = $module_srl; |
1427
|
|
|
$output = executeQuery('module.getModulePartConfig', $args); |
1428
|
|
|
if($output->data->config) $config = unserialize($output->data->config); |
1429
|
|
|
else $config = null; |
1430
|
|
|
|
1431
|
|
|
//insert in cache |
1432
|
|
|
if($oCacheHandler->isSupport()) |
1433
|
|
|
{ |
1434
|
|
|
$oCacheHandler->put($cache_key, $config); |
|
|
|
|
1435
|
|
|
} |
1436
|
|
|
$GLOBALS['__ModulePartConfig__'][$module][$module_srl] = $config; |
1437
|
|
|
} |
1438
|
|
|
return $GLOBALS['__ModulePartConfig__'][$module][$module_srl]; |
1439
|
|
|
} |
1440
|
|
|
|
1441
|
|
|
return $config; |
1442
|
|
|
} |
1443
|
|
|
|
1444
|
|
|
/** |
1445
|
|
|
* @brief Get all of module configurations for each mid |
1446
|
|
|
*/ |
1447
|
|
|
function getModulePartConfigs($module, $site_srl = 0) |
1448
|
|
|
{ |
1449
|
|
|
$args = new stdClass(); |
1450
|
|
|
$args->module = $module; |
1451
|
|
|
if($site_srl) $args->site_srl = $site_srl; |
1452
|
|
|
$output = executeQueryArray('module.getModulePartConfigs', $args); |
1453
|
|
|
if(!$output->toBool() || !$output->data) return array(); |
1454
|
|
|
|
1455
|
|
|
foreach($output->data as $key => $val) |
1456
|
|
|
{ |
1457
|
|
|
$result[$val->module_srl] = unserialize($val->config); |
|
|
|
|
1458
|
|
|
} |
1459
|
|
|
return $result; |
|
|
|
|
1460
|
|
|
} |
1461
|
|
|
|
1462
|
|
|
/** |
1463
|
|
|
* @brief Get a list of module category |
1464
|
|
|
*/ |
1465
|
|
|
function getModuleCategories($moduleCategorySrl = array()) |
1466
|
|
|
{ |
1467
|
|
|
$args = new stdClass(); |
1468
|
|
|
$args->moduleCategorySrl = $moduleCategorySrl; |
1469
|
|
|
// Get data from the DB |
1470
|
|
|
$output = executeQuery('module.getModuleCategories', $args); |
1471
|
|
|
if(!$output->toBool()) return $output; |
1472
|
|
|
$list = $output->data; |
1473
|
|
|
if(!$list) return; |
1474
|
|
|
if(!is_array($list)) $list = array($list); |
1475
|
|
|
|
1476
|
|
|
foreach($list as $val) |
1477
|
|
|
{ |
1478
|
|
|
$category_list[$val->module_category_srl] = $val; |
|
|
|
|
1479
|
|
|
} |
1480
|
|
|
return $category_list; |
|
|
|
|
1481
|
|
|
} |
1482
|
|
|
|
1483
|
|
|
/** |
1484
|
|
|
* @brief Get content from the module category |
1485
|
|
|
*/ |
1486
|
|
|
function getModuleCategory($module_category_srl) |
1487
|
|
|
{ |
1488
|
|
|
// Get data from the DB |
1489
|
|
|
$args = new stdClass; |
1490
|
|
|
$args->module_category_srl = $module_category_srl; |
1491
|
|
|
$output = executeQuery('module.getModuleCategory', $args); |
1492
|
|
|
if(!$output->toBool()) return $output; |
1493
|
|
|
return $output->data; |
1494
|
|
|
} |
1495
|
|
|
|
1496
|
|
|
/** |
1497
|
|
|
* @brief Get xml information of the module |
1498
|
|
|
*/ |
1499
|
|
|
function getModulesXmlInfo() |
1500
|
|
|
{ |
1501
|
|
|
// Get a list of downloaded and installed modules |
1502
|
|
|
$searched_list = FileHandler::readDir('./modules'); |
1503
|
|
|
$searched_count = count($searched_list); |
1504
|
|
|
if(!$searched_count) return; |
1505
|
|
|
sort($searched_list); |
1506
|
|
|
|
1507
|
|
|
for($i=0;$i<$searched_count;$i++) |
1508
|
|
|
{ |
1509
|
|
|
// Module name |
1510
|
|
|
$module_name = $searched_list[$i]; |
1511
|
|
|
|
1512
|
|
|
$path = ModuleHandler::getModulePath($module_name); |
1513
|
|
|
// Get information of the module |
1514
|
|
|
$info = $this->getModuleInfoXml($module_name); |
1515
|
|
|
unset($obj); |
1516
|
|
|
|
1517
|
|
|
if(!isset($info)) continue; |
1518
|
|
|
$info->module = $module_name; |
1519
|
|
|
$info->created_table_count = $created_table_count; |
|
|
|
|
1520
|
|
|
$info->table_count = $table_count; |
|
|
|
|
1521
|
|
|
$info->path = $path; |
1522
|
|
|
$info->admin_index_act = $info->admin_index_act; |
1523
|
|
|
$list[] = $info; |
|
|
|
|
1524
|
|
|
} |
1525
|
|
|
return $list; |
|
|
|
|
1526
|
|
|
} |
1527
|
|
|
|
1528
|
|
|
function checkNeedInstall($module_name) |
1529
|
|
|
{ |
1530
|
|
|
$oDB = &DB::getInstance(); |
1531
|
|
|
$info = null; |
|
|
|
|
1532
|
|
|
|
1533
|
|
|
$moduledir = ModuleHandler::getModulePath($module_name); |
1534
|
|
|
if(file_exists(FileHandler::getRealPath($moduledir."schemas"))) |
1535
|
|
|
{ |
1536
|
|
|
$tmp_files = FileHandler::readDir($moduledir."schemas", '/(\.xml)$/'); |
1537
|
|
|
$table_count = count($tmp_files); |
1538
|
|
|
// Check if the table is created |
1539
|
|
|
$created_table_count = 0; |
1540
|
|
View Code Duplication |
for($j=0;$j<count($tmp_files);$j++) |
|
|
|
|
1541
|
|
|
{ |
1542
|
|
|
list($table_name) = explode(".",$tmp_files[$j]); |
1543
|
|
|
if($oDB->isTableExists($table_name)) $created_table_count ++; |
1544
|
|
|
} |
1545
|
|
|
// Check if DB is installed |
1546
|
|
|
if($table_count > $created_table_count) return true; |
1547
|
|
|
else return false; |
1548
|
|
|
} |
1549
|
|
|
return false; |
1550
|
|
|
} |
1551
|
|
|
|
1552
|
|
|
function checkNeedUpdate($module_name) |
1553
|
|
|
{ |
1554
|
|
|
// Check if it is upgraded to module.class.php on each module |
1555
|
|
|
$oDummy = getModule($module_name, 'class'); |
1556
|
|
|
if($oDummy && method_exists($oDummy, "checkUpdate")) |
1557
|
|
|
{ |
1558
|
|
|
return $oDummy->checkUpdate(); |
1559
|
|
|
} |
1560
|
|
|
return false; |
1561
|
|
|
} |
1562
|
|
|
|
1563
|
|
|
/** |
1564
|
|
|
* @brief 업데이트 적용 여부 확인 |
1565
|
|
|
* @param array|string $update_id |
1566
|
|
|
* @return Boolean |
1567
|
|
|
*/ |
1568
|
|
|
public function needUpdate($update_id) |
1569
|
|
|
{ |
1570
|
|
|
if(!is_array($update_id)) $update_id = array($update_id); |
1571
|
|
|
|
1572
|
|
|
$args = new stdClass(); |
1573
|
|
|
$args->update_id = implode(',', $update_id); |
1574
|
|
|
$output = executeQueryArray('module.getModuleUpdateLog', $args); |
1575
|
|
|
|
1576
|
|
|
if(!!$output->error) return false; |
1577
|
|
|
if(!$output->data) $output->data = array(); |
1578
|
|
|
if(count($update_id) === count($output->data)) return false; |
1579
|
|
|
|
1580
|
|
|
return true; |
1581
|
|
|
} |
1582
|
|
|
|
1583
|
|
|
/** |
1584
|
|
|
* @brief Get a type and information of the module |
1585
|
|
|
*/ |
1586
|
|
|
function getModuleList() |
1587
|
|
|
{ |
1588
|
|
|
// Create DB Object |
1589
|
|
|
$oDB = &DB::getInstance(); |
1590
|
|
|
// Get a list of downloaded and installed modules |
1591
|
|
|
$searched_list = FileHandler::readDir('./modules', '/^([a-zA-Z0-9_-]+)$/'); |
1592
|
|
|
sort($searched_list); |
1593
|
|
|
|
1594
|
|
|
$searched_count = count($searched_list); |
1595
|
|
|
if(!$searched_count) return; |
1596
|
|
|
|
1597
|
|
|
for($i=0;$i<$searched_count;$i++) |
1598
|
|
|
{ |
1599
|
|
|
// module name |
1600
|
|
|
$module_name = $searched_list[$i]; |
1601
|
|
|
|
1602
|
|
|
$path = ModuleHandler::getModulePath($module_name); |
1603
|
|
|
if(!is_dir(FileHandler::getRealPath($path))) continue; |
1604
|
|
|
|
1605
|
|
|
// Get the number of xml files to create a table in schemas |
1606
|
|
|
$tmp_files = FileHandler::readDir($path.'schemas', '/(\.xml)$/'); |
1607
|
|
|
$table_count = count($tmp_files); |
1608
|
|
|
// Check if the table is created |
1609
|
|
|
$created_table_count = 0; |
1610
|
|
View Code Duplication |
for($j=0;$j<$table_count;$j++) |
1611
|
|
|
{ |
1612
|
|
|
list($table_name) = explode('.',$tmp_files[$j]); |
1613
|
|
|
if($oDB->isTableExists($table_name)) $created_table_count ++; |
1614
|
|
|
} |
1615
|
|
|
// Get information of the module |
1616
|
|
|
$info = NULL; |
|
|
|
|
1617
|
|
|
$info = $this->getModuleInfoXml($module_name); |
|
|
|
|
1618
|
|
|
|
1619
|
|
|
if(!$info) continue; |
1620
|
|
|
|
1621
|
|
|
$info->module = $module_name; |
1622
|
|
|
$info->category = $info->category; |
1623
|
|
|
$info->created_table_count = $created_table_count; |
1624
|
|
|
$info->table_count = $table_count; |
1625
|
|
|
$info->path = $path; |
1626
|
|
|
$info->admin_index_act = $info->admin_index_act; |
1627
|
|
|
// Check if DB is installed |
1628
|
|
|
if($table_count > $created_table_count) $info->need_install = true; |
1629
|
|
|
else $info->need_install = false; |
1630
|
|
|
// Check if it is upgraded to module.class.php on each module |
1631
|
|
|
$oDummy = null; |
|
|
|
|
1632
|
|
|
$oDummy = getModule($module_name, 'class'); |
1633
|
|
|
if($oDummy && method_exists($oDummy, "checkUpdate")) |
1634
|
|
|
{ |
1635
|
|
|
$info->need_update = $oDummy->checkUpdate(); |
1636
|
|
|
} |
1637
|
|
|
else |
1638
|
|
|
{ |
1639
|
|
|
continue; |
1640
|
|
|
} |
1641
|
|
|
|
1642
|
|
|
$list[] = $info; |
|
|
|
|
1643
|
|
|
} |
1644
|
|
|
return $list; |
|
|
|
|
1645
|
|
|
} |
1646
|
|
|
|
1647
|
|
|
/** |
1648
|
|
|
* @brief Combine module_srls with domain of sites |
1649
|
|
|
* Because XE DBHandler doesn't support left outer join, |
1650
|
|
|
* it should be as same as $Output->data[]->module_srl. |
1651
|
|
|
*/ |
1652
|
|
|
function syncModuleToSite(&$data) |
1653
|
|
|
{ |
1654
|
|
|
if(!$data) return; |
1655
|
|
|
|
1656
|
|
|
if(is_array($data)) |
1657
|
|
|
{ |
1658
|
|
|
foreach($data as $key => $val) |
1659
|
|
|
{ |
1660
|
|
|
$module_srls[] = $val->module_srl; |
|
|
|
|
1661
|
|
|
} |
1662
|
|
|
if(!count($module_srls)) return; |
|
|
|
|
1663
|
|
|
} |
1664
|
|
|
else |
1665
|
|
|
{ |
1666
|
|
|
$module_srls[] = $data->module_srl; |
1667
|
|
|
} |
1668
|
|
|
|
1669
|
|
|
$args = new stdClass(); |
1670
|
|
|
$args->module_srls = implode(',',$module_srls); |
1671
|
|
|
$output = executeQueryArray('module.getModuleSites', $args); |
1672
|
|
|
if(!$output->data) return array(); |
1673
|
|
|
foreach($output->data as $key => $val) |
1674
|
|
|
{ |
1675
|
|
|
$modules[$val->module_srl] = $val; |
|
|
|
|
1676
|
|
|
} |
1677
|
|
|
|
1678
|
|
|
if(is_array($data)) |
1679
|
|
|
{ |
1680
|
|
|
foreach($data as $key => $val) |
1681
|
|
|
{ |
1682
|
|
|
$data[$key]->domain = $modules[$val->module_srl]->domain; |
|
|
|
|
1683
|
|
|
} |
1684
|
|
|
} |
1685
|
|
|
else |
1686
|
|
|
{ |
1687
|
|
|
$data->domain = $modules[$data->module_srl]->domain; |
1688
|
|
|
} |
1689
|
|
|
} |
1690
|
|
|
|
1691
|
|
|
/** |
1692
|
|
|
* @brief Check if it is an administrator of site_module_info |
1693
|
|
|
*/ |
1694
|
|
|
function isSiteAdmin($member_info, $site_srl = null) |
1695
|
|
|
{ |
1696
|
|
|
if(!$member_info->member_srl) return false; |
1697
|
|
|
if($member_info->is_admin == 'Y') return true; |
1698
|
|
|
|
1699
|
|
|
$args = new stdClass(); |
1700
|
|
View Code Duplication |
if(!isset($site_srl)) |
1701
|
|
|
{ |
1702
|
|
|
$site_module_info = Context::get('site_module_info'); |
1703
|
|
|
if(!$site_module_info) return; |
1704
|
|
|
$args->site_srl = $site_module_info->site_srl; |
1705
|
|
|
} |
1706
|
|
|
else |
1707
|
|
|
{ |
1708
|
|
|
$args->site_srl = $site_srl; |
1709
|
|
|
} |
1710
|
|
|
|
1711
|
|
|
$args->member_srl = $member_info->member_srl; |
1712
|
|
|
$output = executeQuery('module.isSiteAdmin', $args); |
1713
|
|
|
if($output->data->member_srl == $args->member_srl) return true; |
1714
|
|
|
return false; |
1715
|
|
|
} |
1716
|
|
|
|
1717
|
|
|
/** |
1718
|
|
|
* @brief Get admin information of the site |
1719
|
|
|
*/ |
1720
|
|
|
function getSiteAdmin($site_srl) |
1721
|
|
|
{ |
1722
|
|
|
$args = new stdClass; |
1723
|
|
|
$args->site_srl = $site_srl; |
1724
|
|
|
$output = executeQueryArray('module.getSiteAdmin', $args); |
1725
|
|
|
return $output->data; |
1726
|
|
|
} |
1727
|
|
|
|
1728
|
|
|
/** |
1729
|
|
|
* @brief Get admin ID of the module |
1730
|
|
|
*/ |
1731
|
|
|
function getAdminId($module_srl) |
1732
|
|
|
{ |
1733
|
|
|
$obj = new stdClass(); |
1734
|
|
|
$obj->module_srl = $module_srl; |
1735
|
|
|
$output = executeQueryArray('module.getAdminID', $obj); |
1736
|
|
|
if(!$output->toBool() || !$output->data) return; |
1737
|
|
|
|
1738
|
|
|
return $output->data; |
1739
|
|
|
} |
1740
|
|
|
|
1741
|
|
|
/** |
1742
|
|
|
* @brief Get extra vars of the module |
1743
|
|
|
* Extra information, not in the modules table |
1744
|
|
|
*/ |
1745
|
|
|
function getModuleExtraVars($list_module_srl) |
1746
|
|
|
{ |
1747
|
|
|
$extra_vars = array(); |
1748
|
|
|
$get_module_srls = array(); |
1749
|
|
|
if(!is_array($list_module_srl)) $list_module_srl = array($list_module_srl); |
1750
|
|
|
|
1751
|
|
|
$vars = false; |
|
|
|
|
1752
|
|
|
// cache controll |
1753
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
1754
|
|
|
if($oCacheHandler->isSupport()) |
1755
|
|
|
{ |
1756
|
|
|
foreach($list_module_srl as $module_srl) |
1757
|
|
|
{ |
1758
|
|
|
$object_key = 'module_extra_vars:'.$module_srl; |
1759
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
1760
|
|
|
$vars = $oCacheHandler->get($cache_key); |
1761
|
|
|
|
1762
|
|
|
if($vars) |
1763
|
|
|
{ |
1764
|
|
|
$extra_vars[$module_srl] = $vars; |
1765
|
|
|
} |
1766
|
|
|
else |
1767
|
|
|
{ |
1768
|
|
|
$get_module_srls[] = $module_srl; |
1769
|
|
|
} |
1770
|
|
|
} |
1771
|
|
|
} |
1772
|
|
|
else |
1773
|
|
|
{ |
1774
|
|
|
$get_module_srls = $list_module_srl; |
1775
|
|
|
} |
1776
|
|
|
|
1777
|
|
|
if(count($get_module_srls) > 0) |
1778
|
|
|
{ |
1779
|
|
|
$args = new stdClass(); |
1780
|
|
|
$args->module_srl = implode(',', $get_module_srls); |
1781
|
|
|
$output = executeQueryArray('module.getModuleExtraVars', $args); |
1782
|
|
|
|
1783
|
|
|
if(!$output->toBool()) |
1784
|
|
|
{ |
1785
|
|
|
return; |
1786
|
|
|
} |
1787
|
|
|
|
1788
|
|
|
if(!$output->data) |
1789
|
|
|
{ |
1790
|
|
|
foreach($get_module_srls as $module_srl) |
1791
|
|
|
{ |
1792
|
|
|
$extra_vars[$module_srl] = new stdClass; |
1793
|
|
|
} |
1794
|
|
|
} |
1795
|
|
|
foreach($output->data as $key => $val) |
1796
|
|
|
{ |
1797
|
|
|
if(in_array($val->name, array('mid','module')) || $val->value == 'Array') continue; |
1798
|
|
|
|
1799
|
|
|
if(!isset($extra_vars[$val->module_srl])) |
1800
|
|
|
{ |
1801
|
|
|
$extra_vars[$val->module_srl] = new stdClass(); |
1802
|
|
|
} |
1803
|
|
|
$extra_vars[$val->module_srl]->{$val->name} = $val->value; |
1804
|
|
|
|
1805
|
|
View Code Duplication |
if($oCacheHandler->isSupport()) |
1806
|
|
|
{ |
1807
|
|
|
$object_key = 'module_extra_vars:'.$val->module_srl; |
1808
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
1809
|
|
|
$oCacheHandler->put($cache_key, $extra_vars[$val->module_srl]); |
1810
|
|
|
} |
1811
|
|
|
} |
1812
|
|
|
} |
1813
|
|
|
|
1814
|
|
|
return $extra_vars; |
1815
|
|
|
} |
1816
|
|
|
|
1817
|
|
|
/** |
1818
|
|
|
* @brief Get skin information of the module |
1819
|
|
|
*/ |
1820
|
|
View Code Duplication |
function getModuleSkinVars($module_srl) |
|
|
|
|
1821
|
|
|
{ |
1822
|
|
|
$skin_vars = false; |
1823
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
1824
|
|
|
if($oCacheHandler->isSupport()) |
1825
|
|
|
{ |
1826
|
|
|
$object_key = 'module_skin_vars:'.$module_srl; |
1827
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
1828
|
|
|
$skin_vars = $oCacheHandler->get($cache_key); |
1829
|
|
|
} |
1830
|
|
|
|
1831
|
|
|
if($skin_vars === false) |
1832
|
|
|
{ |
1833
|
|
|
$args = new stdClass(); |
1834
|
|
|
$args->module_srl = $module_srl; |
1835
|
|
|
$output = executeQueryArray('module.getModuleSkinVars',$args); |
1836
|
|
|
if(!$output->toBool()) return; |
1837
|
|
|
|
1838
|
|
|
$skin_vars = array(); |
1839
|
|
|
foreach($output->data as $vars) |
1840
|
|
|
{ |
1841
|
|
|
$skin_vars[$vars->name] = $vars; |
1842
|
|
|
} |
1843
|
|
|
|
1844
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $skin_vars); |
|
|
|
|
1845
|
|
|
} |
1846
|
|
|
|
1847
|
|
|
return $skin_vars; |
1848
|
|
|
} |
1849
|
|
|
|
1850
|
|
|
/** |
1851
|
|
|
* Get default skin name |
1852
|
|
|
*/ |
1853
|
|
|
function getModuleDefaultSkin($module_name, $skin_type = 'P', $site_srl = 0, $updateCache = true) |
1854
|
|
|
{ |
1855
|
|
|
$target = ($skin_type == 'M') ? 'mskin' : 'skin'; |
1856
|
|
|
if(!$site_srl) $site_srl = 0; |
1857
|
|
|
|
1858
|
|
|
$designInfoFile = sprintf(_XE_PATH_.'files/site_design/design_%s.php', $site_srl); |
1859
|
|
|
if(is_readable($designInfoFile)) |
1860
|
|
|
{ |
1861
|
|
|
include($designInfoFile); |
1862
|
|
|
|
1863
|
|
|
$skinName = $designInfo->module->{$module_name}->{$target}; |
|
|
|
|
1864
|
|
|
} |
1865
|
|
|
if(!$skinName) |
|
|
|
|
1866
|
|
|
{ |
1867
|
|
|
$dir = ($skin_type == 'M') ? 'm.skins/' : 'skins/'; |
1868
|
|
|
$moduleSkinPath = ModuleHandler::getModulePath($module_name).$dir; |
1869
|
|
|
|
1870
|
|
|
if(is_dir($moduleSkinPath.'default')) |
1871
|
|
|
{ |
1872
|
|
|
$skinName = 'default'; |
1873
|
|
|
} |
1874
|
|
|
else if(is_dir($moduleSkinPath.'xe_default')) |
1875
|
|
|
{ |
1876
|
|
|
$skinName = 'xe_default'; |
1877
|
|
|
} |
1878
|
|
|
else |
1879
|
|
|
{ |
1880
|
|
|
$skins = FileHandler::readDir($moduleSkinPath); |
1881
|
|
|
if(count($skins) > 0) |
1882
|
|
|
{ |
1883
|
|
|
$skinName = $skins[0]; |
1884
|
|
|
} |
1885
|
|
|
else |
1886
|
|
|
{ |
1887
|
|
|
$skinName = NULL; |
1888
|
|
|
} |
1889
|
|
|
} |
1890
|
|
|
|
1891
|
|
|
if($updateCache && $skinName) |
|
|
|
|
1892
|
|
|
{ |
1893
|
|
|
if(!isset($designInfo->module->{$module_name})) $designInfo->module->{$module_name} = new stdClass(); |
|
|
|
|
1894
|
|
|
$designInfo->module->{$module_name}->{$target} = $skinName; |
|
|
|
|
1895
|
|
|
|
1896
|
|
|
$oAdminController = getAdminController('admin'); |
1897
|
|
|
$oAdminController->makeDefaultDesignFile($designInfo, $site_srl); |
|
|
|
|
1898
|
|
|
} |
1899
|
|
|
} |
1900
|
|
|
|
1901
|
|
|
return $skinName; |
1902
|
|
|
} |
1903
|
|
|
|
1904
|
|
|
/** |
1905
|
|
|
* @brief Combine skin information with module information |
1906
|
|
|
*/ |
1907
|
|
|
function syncSkinInfoToModuleInfo(&$module_info) |
1908
|
|
|
{ |
1909
|
|
|
if(!$module_info->module_srl) return; |
1910
|
|
|
|
1911
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
|
|
|
|
1912
|
|
|
if(Mobile::isFromMobilePhone()) |
1913
|
|
|
{ |
1914
|
|
|
$skin_vars = $this->getModuleMobileSkinVars($module_info->module_srl); |
1915
|
|
|
} |
1916
|
|
|
else |
1917
|
|
|
{ |
1918
|
|
|
$skin_vars = $this->getModuleSkinVars($module_info->module_srl); |
1919
|
|
|
} |
1920
|
|
|
|
1921
|
|
|
if(!$skin_vars) return; |
1922
|
|
|
|
1923
|
|
|
foreach($skin_vars as $name => $val) |
|
|
|
|
1924
|
|
|
{ |
1925
|
|
|
if(isset($module_info->{$name})) continue; |
1926
|
|
|
$module_info->{$name} = $val->value; |
1927
|
|
|
} |
1928
|
|
|
} |
1929
|
|
|
|
1930
|
|
|
/** |
1931
|
|
|
* Get mobile skin information of the module |
1932
|
|
|
* @param $module_srl Sequence of module |
1933
|
|
|
* @return array |
1934
|
|
|
*/ |
1935
|
|
View Code Duplication |
function getModuleMobileSkinVars($module_srl) |
|
|
|
|
1936
|
|
|
{ |
1937
|
|
|
$skin_vars = false; |
1938
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
1939
|
|
|
if($oCacheHandler->isSupport()) |
1940
|
|
|
{ |
1941
|
|
|
$object_key = 'module_mobile_skin_vars:'.$module_srl; |
1942
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
1943
|
|
|
$skin_vars = $oCacheHandler->get($cache_key); |
1944
|
|
|
} |
1945
|
|
|
|
1946
|
|
|
if($skin_vars === false) |
1947
|
|
|
{ |
1948
|
|
|
$args = new stdClass(); |
1949
|
|
|
$args->module_srl = $module_srl; |
1950
|
|
|
$output = executeQueryArray('module.getModuleMobileSkinVars',$args); |
1951
|
|
|
if(!$output->toBool() || !$output->data) return; |
1952
|
|
|
|
1953
|
|
|
$skin_vars = array(); |
1954
|
|
|
foreach($output->data as $vars) |
1955
|
|
|
{ |
1956
|
|
|
$skin_vars[$vars->name] = $vars; |
1957
|
|
|
} |
1958
|
|
|
|
1959
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $skin_vars); |
|
|
|
|
1960
|
|
|
} |
1961
|
|
|
|
1962
|
|
|
return $skin_vars; |
1963
|
|
|
} |
1964
|
|
|
|
1965
|
|
|
/** |
1966
|
|
|
* Combine skin information with module information |
1967
|
|
|
* @param $module_info Module information |
1968
|
|
|
*/ |
1969
|
|
|
function syncMobileSkinInfoToModuleInfo(&$module_info) |
1970
|
|
|
{ |
1971
|
|
|
if(!$module_info->module_srl) return; |
1972
|
|
|
$skin_vars = false; |
1973
|
|
|
// cache controll |
1974
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
1975
|
|
View Code Duplication |
if($oCacheHandler->isSupport()) |
1976
|
|
|
{ |
1977
|
|
|
$object_key = 'module_mobile_skin_vars:'.$module_info->module_srl; |
1978
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
1979
|
|
|
$skin_vars = $oCacheHandler->get($cache_key); |
1980
|
|
|
} |
1981
|
|
View Code Duplication |
if($skin_vars === false) |
1982
|
|
|
{ |
1983
|
|
|
$args = new stdClass; |
1984
|
|
|
$args->module_srl = $module_info->module_srl; |
1985
|
|
|
$output = executeQueryArray('module.getModuleMobileSkinVars',$args); |
1986
|
|
|
if(!$output->toBool()) return; |
1987
|
|
|
$skin_vars = $output->data; |
1988
|
|
|
|
1989
|
|
|
//insert in cache |
1990
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $skin_vars); |
|
|
|
|
1991
|
|
|
} |
1992
|
|
|
if(!$skin_vars) return; |
1993
|
|
|
|
1994
|
|
|
foreach($output->data as $val) |
|
|
|
|
1995
|
|
|
{ |
1996
|
|
|
if(isset($module_info->{$val->name})) continue; |
1997
|
|
|
$module_info->{$val->name} = $val->value; |
1998
|
|
|
} |
1999
|
|
|
} |
2000
|
|
|
|
2001
|
|
|
/** |
2002
|
|
|
* @brief Return permission by using module info, xml info and member info |
2003
|
|
|
*/ |
2004
|
|
|
function getGrant($module_info, $member_info, $xml_info = '') |
2005
|
|
|
{ |
2006
|
|
|
$grant = new stdClass(); |
2007
|
|
|
|
2008
|
|
|
if(!$xml_info) |
2009
|
|
|
{ |
2010
|
|
|
$module = $module_info->module; |
2011
|
|
|
$xml_info = $this->getModuleActionXml($module); |
2012
|
|
|
} |
2013
|
|
|
// Set variables to grant group permission |
2014
|
|
|
$module_srl = $module_info->module_srl; |
2015
|
|
|
$grant_info = $xml_info->grant; |
2016
|
|
View Code Duplication |
if($member_info->member_srl) |
2017
|
|
|
{ |
2018
|
|
|
if(is_array($member_info->group_list)) $group_list = array_keys($member_info->group_list); |
2019
|
|
|
else $group_list = array(); |
2020
|
|
|
} |
2021
|
|
|
else |
2022
|
|
|
{ |
2023
|
|
|
$group_list = array(); |
2024
|
|
|
} |
2025
|
|
|
// If module_srl doesn't exist(if unable to set permissions) |
2026
|
|
|
if(!$module_srl) |
2027
|
|
|
{ |
2028
|
|
|
$grant->access = true; |
2029
|
|
|
if($this->isSiteAdmin($member_info, $module_info->site_srl)) |
2030
|
|
|
{ |
2031
|
|
|
$grant->access = $grant->manager = $grant->is_site_admin = true; |
2032
|
|
|
} |
2033
|
|
|
|
2034
|
|
|
$grant->is_admin = $grant->manager = ($member_info->is_admin == 'Y') ? true : false; |
2035
|
|
|
} |
2036
|
|
|
else |
2037
|
|
|
{ |
2038
|
|
|
// If module_srl exists |
2039
|
|
|
// Get a type of granted permission |
2040
|
|
|
$grant->access = $grant->manager = $grant->is_site_admin = ($member_info->is_admin=='Y'||$this->isSiteAdmin($member_info, $module_info->site_srl))?true:false; |
2041
|
|
|
$grant->is_admin = ($member_info->is_admin == 'Y') ? true : false; |
2042
|
|
|
// If a just logged-in member is, check if the member is a module administrator |
2043
|
|
|
if(!$grant->manager && $member_info->member_srl) |
2044
|
|
|
{ |
2045
|
|
|
$args = new stdClass(); |
2046
|
|
|
$args->module_srl = $module_srl; |
2047
|
|
|
$args->member_srl = $member_info->member_srl; |
2048
|
|
|
$output = executeQuery('module.getModuleAdmin',$args); |
2049
|
|
|
if($output->data && $output->data->member_srl == $member_info->member_srl) $grant->manager = true; |
2050
|
|
|
} |
2051
|
|
|
// If not an administrator, get information from the DB and grant manager privilege. |
2052
|
|
|
if(!$grant->manager) |
2053
|
|
|
{ |
2054
|
|
|
$args = new stdClass(); |
2055
|
|
|
// If planet, get permission settings from the planet home |
2056
|
|
|
if($module_info->module == 'planet') |
2057
|
|
|
{ |
2058
|
|
|
$output = executeQueryArray('module.getPlanetGrants', $args); |
2059
|
|
|
} |
2060
|
|
|
else |
2061
|
|
|
{ |
2062
|
|
|
$args = new stdClass; |
2063
|
|
|
$args->module_srl = $module_srl; |
2064
|
|
|
$output = executeQueryArray('module.getModuleGrants', $args); |
2065
|
|
|
} |
2066
|
|
|
|
2067
|
|
|
$grant_exists = $granted = array(); |
2068
|
|
|
|
2069
|
|
|
if($output->data) |
2070
|
|
|
{ |
2071
|
|
|
// Arrange names and groups who has privileges |
2072
|
|
|
foreach($output->data as $val) |
2073
|
|
|
{ |
2074
|
|
|
$grant_exists[$val->name] = true; |
2075
|
|
|
if($granted[$val->name]) continue; |
2076
|
|
|
// Log-in member only |
2077
|
|
|
if($val->group_srl == -1) |
2078
|
|
|
{ |
2079
|
|
|
$granted[$val->name] = true; |
2080
|
|
|
if($member_info->member_srl) $grant->{$val->name} = true; |
2081
|
|
|
// Site-joined member only |
2082
|
|
|
} |
2083
|
|
|
elseif($val->group_srl == -2) |
2084
|
|
|
{ |
2085
|
|
|
$granted[$val->name] = true; |
2086
|
|
|
// Do not grant any permission for non-logged member |
2087
|
|
|
if(!$member_info->member_srl) $grant->{$val->name} = false; |
2088
|
|
|
// Log-in member |
2089
|
|
|
else |
2090
|
|
|
{ |
2091
|
|
|
$site_module_info = Context::get('site_module_info'); |
2092
|
|
|
// Permission granted if no information of the currently connected site exists |
2093
|
|
|
if(!$site_module_info->site_srl) $grant->{$val->name} = true; |
2094
|
|
|
// Permission is not granted if information of the currently connected site exists |
2095
|
|
|
elseif(count($group_list)) $grant->{$val->name} = true; |
2096
|
|
|
} |
2097
|
|
|
// All of non-logged members |
2098
|
|
|
} |
2099
|
|
|
elseif($val->group_srl == -3) |
2100
|
|
|
{ |
2101
|
|
|
$granted[$val->name] = true; |
2102
|
|
|
$grant->{$val->name} = ($grant->is_admin || $grant->is_site_admin); |
2103
|
|
|
} |
2104
|
|
|
elseif($val->group_srl == 0) |
2105
|
|
|
{ |
2106
|
|
|
$granted[$val->name] = true; |
2107
|
|
|
$grant->{$val->name} = true; |
2108
|
|
|
// If a target is a group |
2109
|
|
|
} |
2110
|
|
|
else |
2111
|
|
|
{ |
2112
|
|
|
if($group_list && count($group_list) && in_array($val->group_srl, $group_list)) |
|
|
|
|
2113
|
|
|
{ |
2114
|
|
|
$grant->{$val->name} = true; |
2115
|
|
|
$granted[$val->name] = true; |
2116
|
|
|
} |
2117
|
|
|
} |
2118
|
|
|
} |
2119
|
|
|
} |
2120
|
|
|
// Separate processing for the virtual group access |
2121
|
|
|
if(!$grant_exists['access']) $grant->access = true; |
2122
|
|
|
if(count($grant_info)) |
2123
|
|
|
{ |
2124
|
|
|
foreach($grant_info as $grant_name => $grant_item) |
2125
|
|
|
{ |
2126
|
|
|
if($grant_exists[$grant_name]) continue; |
2127
|
|
|
switch($grant_item->default) |
2128
|
|
|
{ |
2129
|
|
|
case 'guest' : |
2130
|
|
|
$grant->{$grant_name} = true; |
2131
|
|
|
break; |
2132
|
|
|
case 'member' : |
2133
|
|
|
if($member_info->member_srl) $grant->{$grant_name} = true; |
2134
|
|
|
else $grant->{$grant_name} = false; |
2135
|
|
|
break; |
2136
|
|
|
case 'site' : |
2137
|
|
|
$site_module_info = Context::get('site_module_info'); |
2138
|
|
|
if($member_info->member_srl && (($site_module_info->site_srl && count($group_list)) || !$site_module_info->site_srl)) $grant->{$grant_name} = true; |
2139
|
|
|
else $grant->{$grant_name} = false; |
2140
|
|
|
break; |
2141
|
|
|
case 'manager' : |
2142
|
|
|
case 'root' : |
2143
|
|
|
if($member_info->is_admin == 'Y') $grant->{$grant_name} = true; |
2144
|
|
|
else $grant->{$grant_name} = false; |
2145
|
|
|
break; |
2146
|
|
|
} |
2147
|
|
|
} |
2148
|
|
|
} |
2149
|
|
|
} |
2150
|
|
|
// Set true to grant all privileges if an administrator is |
2151
|
|
|
if($grant->manager) |
2152
|
|
|
{ |
2153
|
|
|
$grant->access = true; |
2154
|
|
|
if(count($grant_info)) |
2155
|
|
|
{ |
2156
|
|
|
foreach($grant_info as $key => $val) |
2157
|
|
|
{ |
2158
|
|
|
$grant->{$key} = true; |
2159
|
|
|
} |
2160
|
|
|
} |
2161
|
|
|
} |
2162
|
|
|
} |
2163
|
|
|
return $grant; |
2164
|
|
|
} |
2165
|
|
|
|
2166
|
|
|
function getModuleFileBox($module_filebox_srl) |
2167
|
|
|
{ |
2168
|
|
|
$args = new stdClass(); |
2169
|
|
|
$args->module_filebox_srl = $module_filebox_srl; |
2170
|
|
|
return executeQuery('module.getModuleFileBox', $args); |
2171
|
|
|
} |
2172
|
|
|
|
2173
|
|
|
function getModuleFileBoxList() |
2174
|
|
|
{ |
2175
|
|
|
$oModuleModel = getModel('module'); |
2176
|
|
|
|
2177
|
|
|
$args = new stdClass(); |
2178
|
|
|
$args->page = Context::get('page'); |
2179
|
|
|
$args->list_count = 5; |
2180
|
|
|
$args->page_count = 5; |
2181
|
|
|
$output = executeQuery('module.getModuleFileBoxList', $args); |
2182
|
|
|
$output = $oModuleModel->unserializeAttributes($output); |
2183
|
|
|
return $output; |
2184
|
|
|
} |
2185
|
|
|
|
2186
|
|
|
function unserializeAttributes($module_filebox_list) |
2187
|
|
|
{ |
2188
|
|
|
if(is_array($module_filebox_list->data)) |
2189
|
|
|
{ |
2190
|
|
|
foreach($module_filebox_list->data as &$item) |
2191
|
|
|
{ |
2192
|
|
|
if(empty($item->comment)) |
2193
|
|
|
{ |
2194
|
|
|
continue; |
2195
|
|
|
} |
2196
|
|
|
|
2197
|
|
|
$attributes = explode(';', $item->comment); |
2198
|
|
|
foreach($attributes as $attribute) |
2199
|
|
|
{ |
2200
|
|
|
$values = explode(':', $attribute); |
2201
|
|
|
if((count($values) % 2) ==1) |
2202
|
|
|
{ |
2203
|
|
|
for($i=2;$i<count($values);$i++) |
|
|
|
|
2204
|
|
|
{ |
2205
|
|
|
$values[1].=":".$values[$i]; |
2206
|
|
|
} |
2207
|
|
|
} |
2208
|
|
|
$atts[$values[0]]=$values[1]; |
|
|
|
|
2209
|
|
|
} |
2210
|
|
|
$item->attributes = $atts; |
|
|
|
|
2211
|
|
|
unset($atts); |
2212
|
|
|
} |
2213
|
|
|
} |
2214
|
|
|
return $module_filebox_list; |
2215
|
|
|
} |
2216
|
|
|
|
2217
|
|
|
function getFileBoxListHtml() |
2218
|
|
|
{ |
2219
|
|
|
$logged_info = Context::get('logged_info'); |
2220
|
|
|
if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) return new BaseObject(-1, 'msg_not_permitted'); |
2221
|
|
|
$link = parse_url($_SERVER["HTTP_REFERER"]); |
2222
|
|
|
$link_params = explode('&',$link['query']); |
2223
|
|
|
foreach ($link_params as $param) |
2224
|
|
|
{ |
2225
|
|
|
$param = explode("=",$param); |
2226
|
|
|
if($param[0] == 'selected_widget') $selected_widget = $param[1]; |
2227
|
|
|
} |
2228
|
|
|
$oWidgetModel = getModel('widget'); |
2229
|
|
|
if($selected_widget) $widget_info = $oWidgetModel->getWidgetInfo($selected_widget); |
|
|
|
|
2230
|
|
|
Context::set('allow_multiple', $widget_info->extra_var->images->allow_multiple); |
|
|
|
|
2231
|
|
|
|
2232
|
|
|
$oModuleModel = getModel('module'); |
2233
|
|
|
$output = $oModuleModel->getModuleFileBoxList(); |
2234
|
|
|
Context::set('filebox_list', $output->data); |
2235
|
|
|
|
2236
|
|
|
$page = Context::get('page'); |
2237
|
|
|
if (!$page) $page = 1; |
2238
|
|
|
Context::set('page', $page); |
2239
|
|
|
Context::set('page_navigation', $output->page_navigation); |
2240
|
|
|
|
2241
|
|
|
$security = new Security(); |
2242
|
|
|
$security->encodeHTML('filebox_list..comment', 'filebox_list..attributes.'); |
2243
|
|
|
|
2244
|
|
|
$oTemplate = &TemplateHandler::getInstance(); |
2245
|
|
|
$html = $oTemplate->compile(_XE_PATH_ . 'modules/module/tpl/', 'filebox_list_html'); |
2246
|
|
|
|
2247
|
|
|
$this->add('html', $html); |
2248
|
|
|
} |
2249
|
|
|
|
2250
|
|
|
function getModuleFileBoxPath($module_filebox_srl) |
2251
|
|
|
{ |
2252
|
|
|
return sprintf("./files/attach/filebox/%s",getNumberingPath($module_filebox_srl,3)); |
2253
|
|
|
} |
2254
|
|
|
|
2255
|
|
|
/** |
2256
|
|
|
* @brief Return ruleset cache file path |
2257
|
|
|
* @param module, act |
2258
|
|
|
*/ |
2259
|
|
|
function getValidatorFilePath($module, $ruleset, $mid=null) |
2260
|
|
|
{ |
2261
|
|
|
// load dynamic ruleset xml file |
2262
|
|
|
if(strpos($ruleset, '@') !== false) |
2263
|
|
|
{ |
2264
|
|
|
$rulsetFile = str_replace('@', '', $ruleset); |
2265
|
|
|
$xml_file = sprintf('./files/ruleset/%s.xml', $rulsetFile); |
2266
|
|
|
return FileHandler::getRealPath($xml_file); |
2267
|
|
|
} |
2268
|
|
|
else if (strpos($ruleset, '#') !== false) |
2269
|
|
|
{ |
2270
|
|
|
$rulsetFile = str_replace('#', '', $ruleset).'.'.$mid; |
2271
|
|
|
$xml_file = sprintf('./files/ruleset/%s.xml', $rulsetFile); |
2272
|
|
|
if(is_readable($xml_file)) |
2273
|
|
|
return FileHandler::getRealPath($xml_file); |
2274
|
|
|
else{ |
2275
|
|
|
$ruleset = str_replace('#', '', $ruleset); |
2276
|
|
|
} |
2277
|
|
|
|
2278
|
|
|
} |
2279
|
|
|
// Get a path of the requested module. Return if not exists. |
2280
|
|
|
$class_path = ModuleHandler::getModulePath($module); |
2281
|
|
|
if(!$class_path) return; |
2282
|
|
|
|
2283
|
|
|
// Check if module.xml exists in the path. Return if not exist |
2284
|
|
|
$xml_file = sprintf("%sruleset/%s.xml", $class_path, $ruleset); |
2285
|
|
|
if(!file_exists($xml_file)) return; |
2286
|
|
|
|
2287
|
|
|
return $xml_file; |
2288
|
|
|
} |
2289
|
|
|
|
2290
|
|
|
function getLangListByLangcodeForAutoComplete() |
2291
|
|
|
{ |
2292
|
|
|
$keyword = Context::get('search_keyword'); |
|
|
|
|
2293
|
|
|
|
2294
|
|
|
$requestVars = Context::getRequestVars(); |
2295
|
|
|
|
2296
|
|
|
$args = new stdClass; |
2297
|
|
|
$args->site_srl = (int)$requestVars->site_srl; |
|
|
|
|
2298
|
|
|
$args->page = 1; // /< Page |
2299
|
|
|
$args->list_count = 100; // /< the number of posts to display on a single page |
2300
|
|
|
$args->page_count = 5; // /< the number of pages that appear in the page navigation |
2301
|
|
|
$args->sort_index = 'name'; |
2302
|
|
|
$args->order_type = 'asc'; |
2303
|
|
|
$args->search_keyword = Context::get('search_keyword'); // /< keyword to search*/ |
2304
|
|
|
|
2305
|
|
|
$output = executeQueryArray('module.getLangListByLangcode', $args); |
2306
|
|
|
|
2307
|
|
|
$list = array(); |
2308
|
|
|
|
2309
|
|
|
if($output->toBool()) |
2310
|
|
|
{ |
2311
|
|
|
foreach((array)$output->data as $code_info) |
2312
|
|
|
{ |
2313
|
|
|
unset($codeInfo); |
2314
|
|
|
$codeInfo = array('name'=>'$user_lang->'.$code_info->name, 'value'=>$code_info->value); |
2315
|
|
|
$list[] = $codeInfo; |
2316
|
|
|
} |
2317
|
|
|
} |
2318
|
|
|
$this->add('results', $list); |
2319
|
|
|
} |
2320
|
|
|
|
2321
|
|
|
/** |
2322
|
|
|
* @brief already instance created module list |
2323
|
|
|
*/ |
2324
|
|
|
function getModuleListByInstance($site_srl = 0, $columnList = array()) |
2325
|
|
|
{ |
2326
|
|
|
$args = new stdClass(); |
2327
|
|
|
$args->site_srl = $site_srl; |
2328
|
|
|
$output = executeQueryArray('module.getModuleListByInstance', $args, $columnList); |
2329
|
|
|
return $output; |
2330
|
|
|
} |
2331
|
|
|
|
2332
|
|
|
function getLangByLangcode() |
2333
|
|
|
{ |
2334
|
|
|
$langCode = Context::get('langCode'); |
2335
|
|
|
if (!$langCode) return; |
2336
|
|
|
|
2337
|
|
|
$oModuleController = getController('module'); |
2338
|
|
|
$oModuleController->replaceDefinedLangCode($langCode); |
2339
|
|
|
|
2340
|
|
|
$this->add('lang', $langCode); |
2341
|
|
|
} |
2342
|
|
|
} |
2343
|
|
|
/* End of file module.model.php */ |
2344
|
|
|
/* Location: ./modules/module/module.model.php */ |
2345
|
|
|
|
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: