|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
|
3
|
|
|
/** |
|
4
|
|
|
* @class layoutModel |
|
5
|
|
|
* @author NAVER ([email protected]) |
|
6
|
|
|
* @version 0.1 |
|
7
|
|
|
* Model class of the layout module |
|
8
|
|
|
*/ |
|
9
|
|
|
class layoutModel extends layout |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Check user layout temp |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
var $useUserLayoutTemp = null; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Initialization |
|
19
|
|
|
* @return void |
|
20
|
|
|
*/ |
|
21
|
|
|
function init() |
|
22
|
|
|
{ |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Get a layout list created in the DB |
|
27
|
|
|
* If you found a new list, it means that the layout list is inserted to the DB |
|
28
|
|
|
* @deprecated |
|
29
|
|
|
* @param int $site_srl |
|
30
|
|
|
* @param string $layout_type (P : PC, M : Mobile) |
|
31
|
|
|
* @param array $columnList |
|
32
|
|
|
* @return array layout lists in site |
|
33
|
|
|
*/ |
|
34
|
|
|
function getLayoutList($site_srl = 0, $layout_type="P", $columnList = array()) |
|
35
|
|
|
{ |
|
36
|
|
|
if(!$site_srl) |
|
37
|
|
|
{ |
|
38
|
|
|
$site_module_info = Context::get('site_module_info'); |
|
39
|
|
|
$site_srl = (int)$site_module_info->site_srl; |
|
40
|
|
|
} |
|
41
|
|
|
$args = new stdClass(); |
|
42
|
|
|
$args->site_srl = $site_srl; |
|
43
|
|
|
$args->layout_type = $layout_type; |
|
44
|
|
|
$output = executeQueryArray('layout.getLayoutList', $args, $columnList); |
|
45
|
|
|
|
|
46
|
|
|
foreach($output->data as $no => &$val) |
|
47
|
|
|
{ |
|
48
|
|
|
if(!$this->isExistsLayoutFile($val->layout, $layout_type)) |
|
49
|
|
|
{ |
|
50
|
|
|
unset($output->data[$no]); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$oLayoutAdminModel = getAdminModel('layout'); |
|
55
|
|
|
$siteDefaultLayoutSrl = $oLayoutAdminModel->getSiteDefaultLayout($layout_type, $site_srl); |
|
56
|
|
|
if($siteDefaultLayoutSrl) |
|
57
|
|
|
{ |
|
58
|
|
|
$siteDefaultLayoutInfo = $this->getlayout($siteDefaultLayoutSrl); |
|
59
|
|
|
$newLayout = sprintf('%s, %s', $siteDefaultLayoutInfo->title, $siteDefaultLayoutInfo->layout); |
|
60
|
|
|
$siteDefaultLayoutInfo->layout_srl = -1; |
|
61
|
|
|
$siteDefaultLayoutInfo->title = Context::getLang('use_site_default_layout'); |
|
62
|
|
|
$siteDefaultLayoutInfo->layout = $newLayout; |
|
63
|
|
|
|
|
64
|
|
|
array_unshift($output->data, $siteDefaultLayoutInfo); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return $output->data; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Get the list layout instance with thumbnail link. for setting design. |
|
72
|
|
|
* |
|
73
|
|
|
* @return void |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getLayoutInstanceListForJSONP() |
|
76
|
|
|
{ |
|
77
|
|
|
$siteSrl = Context::get('site_srl'); |
|
78
|
|
|
$layoutType = Context::get('layout_type'); |
|
79
|
|
|
|
|
80
|
|
|
$layoutList = $this->getLayoutInstanceList($siteSrl, $layoutType); |
|
81
|
|
|
$thumbs = array(); |
|
82
|
|
|
|
|
83
|
|
|
foreach($layoutList as $key => $val) |
|
84
|
|
|
{ |
|
85
|
|
|
if($thumbs[$val->layouts]) |
|
86
|
|
|
{ |
|
87
|
|
|
$val->thumbnail = $thumbs[$val->layouts]; |
|
88
|
|
|
continue; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
$token = explode('|@|', $val->layout); |
|
92
|
|
|
if(count($token) == 2) |
|
93
|
|
|
{ |
|
94
|
|
|
$thumbnailPath = sprintf('./themes/%s/layouts/%s/thumbnail.png' , $token[0], $token[1]); |
|
95
|
|
|
} |
|
96
|
|
|
else |
|
97
|
|
|
{ |
|
98
|
|
|
$thumbnailPath = sprintf('./layouts/%s/thumbnail.png' , $val->layout); |
|
99
|
|
|
} |
|
100
|
|
|
if(is_readable($thumbnailPath)) |
|
101
|
|
|
{ |
|
102
|
|
|
$val->thumbnail = $thumbnailPath; |
|
103
|
|
|
} |
|
104
|
|
|
else |
|
105
|
|
|
{ |
|
106
|
|
|
$val->thumbnail = sprintf('./modules/layout/tpl/img/noThumbnail.png'); |
|
107
|
|
|
} |
|
108
|
|
|
$thumbs[$val->layout] = $val->thumbnail; |
|
109
|
|
|
} |
|
110
|
|
|
$this->add('layout_list', $layoutList); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Get layout instance list |
|
115
|
|
|
* @param int $siteSrl |
|
116
|
|
|
* @param string $layoutType (P : PC, M : Mobile) |
|
117
|
|
|
* @param string $layout name of layout |
|
118
|
|
|
* @param array $columnList |
|
119
|
|
|
* @return array layout lists in site |
|
120
|
|
|
*/ |
|
121
|
|
|
function getLayoutInstanceList($siteSrl = 0, $layoutType = 'P', $layout = null, $columnList = array()) |
|
122
|
|
|
{ |
|
123
|
|
|
if (!$siteSrl) |
|
124
|
|
|
{ |
|
125
|
|
|
$siteModuleInfo = Context::get('site_module_info'); |
|
126
|
|
|
$siteSrl = (int)$siteModuleInfo->site_srl; |
|
127
|
|
|
} |
|
128
|
|
|
$args = new stdClass(); |
|
129
|
|
|
$args->site_srl = $siteSrl; |
|
130
|
|
|
$args->layout_type = $layoutType; |
|
131
|
|
|
$args->layout = $layout; |
|
132
|
|
|
$output = executeQueryArray('layout.getLayoutList', $args, $columnList); |
|
133
|
|
|
|
|
134
|
|
|
// Create instance name list |
|
135
|
|
|
$instanceList = array(); |
|
136
|
|
View Code Duplication |
if(is_array($output->data)) |
|
137
|
|
|
{ |
|
138
|
|
|
foreach($output->data as $no => $iInfo) |
|
139
|
|
|
{ |
|
140
|
|
|
if($this->isExistsLayoutFile($iInfo->layout, $layoutType)) |
|
141
|
|
|
{ |
|
142
|
|
|
$instanceList[] = $iInfo->layout; |
|
143
|
|
|
} |
|
144
|
|
|
else |
|
145
|
|
|
{ |
|
146
|
|
|
unset($output->data[$no]); |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
// Create downloaded name list |
|
152
|
|
|
$downloadedList = array(); |
|
153
|
|
|
$titleList = array(); |
|
154
|
|
|
$_downloadedList = $this->getDownloadedLayoutList($layoutType); |
|
155
|
|
|
if(is_array($_downloadedList)) |
|
156
|
|
|
{ |
|
157
|
|
|
foreach($_downloadedList as $dLayoutInfo) |
|
158
|
|
|
{ |
|
159
|
|
|
$downloadedList[$dLayoutInfo->layout] = $dLayoutInfo->layout; |
|
160
|
|
|
$titleList[$dLayoutInfo->layout] = $dLayoutInfo->title; |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
if($layout) |
|
|
|
|
|
|
165
|
|
|
{ |
|
166
|
|
|
if(count($instanceList) < 1 && $downloadedList[$layout]) |
|
167
|
|
|
{ |
|
168
|
|
|
$insertArgs = new stdClass(); |
|
169
|
|
|
$insertArgs->site_srl = $siteSrl; |
|
170
|
|
|
$insertArgs->layout_srl = getNextSequence(); |
|
171
|
|
|
$insertArgs->layout = $layout; |
|
172
|
|
|
$insertArgs->title = $titleList[$layout]; |
|
173
|
|
|
$insertArgs->layout_type = $layoutType; |
|
174
|
|
|
|
|
175
|
|
|
$oLayoutAdminController = getAdminController('layout'); |
|
176
|
|
|
$oLayoutAdminController->insertLayout($insertArgs); |
|
177
|
|
|
$isCreateInstance = TRUE; |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
else |
|
181
|
|
|
{ |
|
182
|
|
|
// Get downloaded name list have no instance |
|
183
|
|
|
$noInstanceList = array_diff($downloadedList, $instanceList); |
|
184
|
|
|
foreach($noInstanceList as $layoutName) |
|
185
|
|
|
{ |
|
186
|
|
|
$insertArgs = new stdClass(); |
|
187
|
|
|
$insertArgs->site_srl = $siteSrl; |
|
188
|
|
|
$insertArgs->layout_srl = getNextSequence(); |
|
189
|
|
|
$insertArgs->layout = $layoutName; |
|
190
|
|
|
$insertArgs->title = $titleList[$layoutName]; |
|
191
|
|
|
$insertArgs->layout_type = $layoutType; |
|
192
|
|
|
|
|
193
|
|
|
$oLayoutAdminController = getAdminController('layout'); |
|
194
|
|
|
$oLayoutAdminController->insertLayout($insertArgs); |
|
195
|
|
|
$isCreateInstance = TRUE; |
|
196
|
|
|
} |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
// If create layout instance, reload instance list |
|
200
|
|
|
if($isCreateInstance) |
|
|
|
|
|
|
201
|
|
|
{ |
|
202
|
|
|
$output = executeQueryArray('layout.getLayoutList', $args, $columnList); |
|
203
|
|
|
|
|
204
|
|
View Code Duplication |
if(is_array($output->data)) |
|
205
|
|
|
{ |
|
206
|
|
|
foreach($output->data as $no => $iInfo) |
|
207
|
|
|
{ |
|
208
|
|
|
if(!$this->isExistsLayoutFile($iInfo->layout, $layoutType)) |
|
209
|
|
|
{ |
|
210
|
|
|
unset($output->data[$no]); |
|
211
|
|
|
} |
|
212
|
|
|
} |
|
213
|
|
|
} |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
return $output->data; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* If exists layout file returns true |
|
221
|
|
|
* |
|
222
|
|
|
* @param string $layout layout name |
|
223
|
|
|
* @param string $layoutType P or M |
|
224
|
|
|
* @return bool |
|
225
|
|
|
*/ |
|
226
|
|
|
function isExistsLayoutFile($layout, $layoutType) |
|
227
|
|
|
{ |
|
228
|
|
|
//TODO If remove a support themes, remove this codes also. |
|
229
|
|
|
if($layoutType == 'P') |
|
230
|
|
|
{ |
|
231
|
|
|
$pathPrefix = _XE_PATH_ . 'layouts/'; |
|
232
|
|
|
$themePathFormat = _XE_PATH_ . 'themes/%s/layouts/%s'; |
|
233
|
|
|
} |
|
234
|
|
|
else |
|
235
|
|
|
{ |
|
236
|
|
|
$pathPrefix = _XE_PATH_ . 'm.layouts/'; |
|
237
|
|
|
$themePathFormat = _XE_PATH_ . 'themes/%s/m.layouts/%s'; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
if(strpos($layout, '|@|') !== FALSE) |
|
241
|
|
|
{ |
|
242
|
|
|
list($themeName, $layoutName) = explode('|@|', $layout); |
|
243
|
|
|
$path = sprintf($themePathFormat, $themeName, $layoutName); |
|
244
|
|
|
} |
|
245
|
|
|
else |
|
246
|
|
|
{ |
|
247
|
|
|
$path = $pathPrefix . $layout; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
return is_readable($path . '/layout.html'); |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* Get one of layout information created in the DB |
|
255
|
|
|
* Return DB info + XML info of the generated layout |
|
256
|
|
|
* @param int $layout_srl |
|
257
|
|
|
* @return object info of layout |
|
258
|
|
|
*/ |
|
259
|
|
|
function getLayout($layout_srl) |
|
260
|
|
|
{ |
|
261
|
|
|
// Get information from the DB |
|
262
|
|
|
$args = new stdClass(); |
|
263
|
|
|
$args->layout_srl = $layout_srl; |
|
264
|
|
|
$output = executeQuery('layout.getLayout', $args); |
|
265
|
|
|
if(!$output->data) return; |
|
266
|
|
|
|
|
267
|
|
|
// Return xml file informaton after listing up the layout and extra_vars |
|
268
|
|
|
$layout_info = $this->getLayoutInfo($layout, $output->data, $output->data->layout_type); |
|
|
|
|
|
|
269
|
|
|
|
|
270
|
|
|
return $layout_info; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
function getLayoutRawData($layout_srl, $columnList = array()) |
|
274
|
|
|
{ |
|
275
|
|
|
$args = new stdClass(); |
|
276
|
|
|
$args->layout_srl = $layout_srl; |
|
277
|
|
|
$output = executeQuery('layout.getLayout', $args, $columnList); |
|
278
|
|
|
if(!$output->toBool()) |
|
279
|
|
|
{ |
|
280
|
|
|
return; |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
return $output->data; |
|
284
|
|
|
} |
|
285
|
|
|
|
|
286
|
|
|
/** |
|
287
|
|
|
* Get a layout path |
|
288
|
|
|
* @param string $layout_name |
|
289
|
|
|
* @param string $layout_type (P : PC, M : Mobile) |
|
290
|
|
|
* @return string path of layout |
|
291
|
|
|
*/ |
|
292
|
|
|
function getLayoutPath($layout_name = "", $layout_type = "P") |
|
293
|
|
|
{ |
|
294
|
|
|
$layout_parse = explode('|@|', $layout_name); |
|
295
|
|
|
if(count($layout_parse) > 1) |
|
296
|
|
|
{ |
|
297
|
|
|
$class_path = './themes/'.$layout_parse[0].'/layouts/'.$layout_parse[1].'/'; |
|
298
|
|
|
} |
|
299
|
|
|
else if($layout_name == 'faceoff') |
|
300
|
|
|
{ |
|
301
|
|
|
$class_path = './modules/layout/faceoff/'; |
|
302
|
|
|
} |
|
303
|
|
|
else if($layout_type == "M") |
|
304
|
|
|
{ |
|
305
|
|
|
$class_path = sprintf("./m.layouts/%s/", $layout_name); |
|
306
|
|
|
} |
|
307
|
|
|
else |
|
308
|
|
|
{ |
|
309
|
|
|
$class_path = sprintf('./layouts/%s/', $layout_name); |
|
310
|
|
|
} |
|
311
|
|
|
if(is_dir($class_path)) return $class_path; |
|
312
|
|
|
return ""; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
/** |
|
316
|
|
|
* Get a type and information of the layout |
|
317
|
|
|
* A type of downloaded layout |
|
318
|
|
|
* @param string $layout_type (P : PC, M : Mobile) |
|
319
|
|
|
* @param boolean $withAutoinstallInfo |
|
320
|
|
|
* @return array info of layout |
|
321
|
|
|
*/ |
|
322
|
|
|
function getDownloadedLayoutList($layout_type = "P", $withAutoinstallInfo = false) |
|
323
|
|
|
{ |
|
324
|
|
|
if ($withAutoinstallInfo) $oAutoinstallModel = getModel('autoinstall'); |
|
325
|
|
|
|
|
326
|
|
|
// Get a list of downloaded layout and installed layout |
|
327
|
|
|
$searched_list = $this->_getInstalledLayoutDirectories($layout_type); |
|
328
|
|
|
$searched_count = count($searched_list); |
|
329
|
|
|
if(!$searched_count) return; |
|
330
|
|
|
|
|
331
|
|
|
// natcasesort($searched_list); |
|
332
|
|
|
// Return information for looping searched list of layouts |
|
333
|
|
|
$list = array(); |
|
334
|
|
View Code Duplication |
for($i=0;$i<$searched_count;$i++) |
|
335
|
|
|
{ |
|
336
|
|
|
// Name of the layout |
|
337
|
|
|
$layout = $searched_list[$i]; |
|
338
|
|
|
// Get information of the layout |
|
339
|
|
|
$layout_info = $this->getLayoutInfo($layout, null, $layout_type); |
|
340
|
|
|
|
|
341
|
|
|
if(!$layout_info) |
|
342
|
|
|
{ |
|
343
|
|
|
continue; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
if($withAutoinstallInfo) |
|
347
|
|
|
{ |
|
348
|
|
|
// get easyinstall remove url |
|
349
|
|
|
$packageSrl = $oAutoinstallModel->getPackageSrlByPath($layout_info->path); |
|
|
|
|
|
|
350
|
|
|
$layout_info->remove_url = $oAutoinstallModel->getRemoveUrlByPackageSrl($packageSrl); |
|
351
|
|
|
|
|
352
|
|
|
// get easyinstall need update |
|
353
|
|
|
$package = $oAutoinstallModel->getInstalledPackages($packageSrl); |
|
354
|
|
|
$layout_info->need_update = $package[$packageSrl]->need_update; |
|
355
|
|
|
|
|
356
|
|
|
// get easyinstall update url |
|
357
|
|
|
if($layout_info->need_update) |
|
358
|
|
|
{ |
|
359
|
|
|
$layout_info->update_url = $oAutoinstallModel->getUpdateUrlByPackageSrl($packageSrl); |
|
360
|
|
|
} |
|
361
|
|
|
} |
|
362
|
|
|
$list[] = $layout_info; |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
usort($list, array($this, 'sortLayoutByTitle')); |
|
366
|
|
|
return $list; |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
|
|
/** |
|
370
|
|
|
* Sort layout by title |
|
371
|
|
|
*/ |
|
372
|
|
|
function sortLayoutByTitle($a, $b) |
|
373
|
|
|
{ |
|
374
|
|
|
if(!$a->title) |
|
375
|
|
|
{ |
|
376
|
|
|
$a->title = $a->layout; |
|
377
|
|
|
} |
|
378
|
|
|
|
|
379
|
|
|
if(!$b->title) |
|
380
|
|
|
{ |
|
381
|
|
|
$b->title = $b->layout; |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
$aTitle = strtolower($a->title); |
|
385
|
|
|
$bTitle = strtolower($b->title); |
|
386
|
|
|
|
|
387
|
|
|
if($aTitle == $bTitle) |
|
388
|
|
|
{ |
|
389
|
|
|
return 0; |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
return ($aTitle < $bTitle) ? -1 : 1; |
|
393
|
|
|
} |
|
394
|
|
|
|
|
395
|
|
|
/** |
|
396
|
|
|
* Get a count of layout |
|
397
|
|
|
* @param string $layoutType (P : PC, M : Mobile) |
|
398
|
|
|
* @return int |
|
399
|
|
|
*/ |
|
400
|
|
|
function getInstalledLayoutCount($layoutType = 'P') |
|
401
|
|
|
{ |
|
402
|
|
|
$searchedList = $this->_getInstalledLayoutDirectories($layoutType); |
|
403
|
|
|
return count($searchedList); |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
/** |
|
407
|
|
|
* Get list of layouts directory |
|
408
|
|
|
* @param string $layoutType (P : PC, M : Mobile) |
|
409
|
|
|
* @return array |
|
410
|
|
|
*/ |
|
411
|
|
|
function _getInstalledLayoutDirectories($layoutType = 'P') |
|
412
|
|
|
{ |
|
413
|
|
|
if($layoutType == 'M') |
|
414
|
|
|
{ |
|
415
|
|
|
$directory = './m.layouts'; |
|
416
|
|
|
$globalValueKey = 'MOBILE_LAYOUT_DIRECTOIES'; |
|
417
|
|
|
} |
|
418
|
|
|
else |
|
419
|
|
|
{ |
|
420
|
|
|
$directory = './layouts'; |
|
421
|
|
|
$globalValueKey = 'PC_LAYOUT_DIRECTORIES'; |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
|
|
if($GLOBALS[$globalValueKey]) return $GLOBALS[$globalValueKey]; |
|
425
|
|
|
|
|
426
|
|
|
$searchedList = FileHandler::readDir($directory); |
|
427
|
|
|
if (!$searchedList) $searchedList = array(); |
|
|
|
|
|
|
428
|
|
|
$GLOBALS[$globalValueKey] = $searchedList; |
|
429
|
|
|
|
|
430
|
|
|
return $searchedList; |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
|
|
/** |
|
434
|
|
|
* Get information by reading conf/info.xml in the module |
|
435
|
|
|
* It uses caching to reduce time for xml parsing .. |
|
436
|
|
|
* @param string $layout |
|
437
|
|
|
* @param object $info |
|
438
|
|
|
* @param string $layoutType (P : PC, M : Mobile) |
|
|
|
|
|
|
439
|
|
|
* @return object info of layout |
|
440
|
|
|
*/ |
|
441
|
|
|
function getLayoutInfo($layout, $info = null, $layout_type = "P") |
|
442
|
|
|
{ |
|
443
|
|
|
if($info) |
|
444
|
|
|
{ |
|
445
|
|
|
$layout_title = $info->title; |
|
446
|
|
|
$layout = $info->layout; |
|
447
|
|
|
$layout_srl = $info->layout_srl; |
|
448
|
|
|
$site_srl = $info->site_srl; |
|
449
|
|
|
$vars = unserialize($info->extra_vars); |
|
450
|
|
|
|
|
451
|
|
|
if($info->module_srl) |
|
452
|
|
|
{ |
|
453
|
|
|
$layout_path = preg_replace('/([a-zA-Z0-9\_\.]+)(\.html)$/','',$info->layout_path); |
|
454
|
|
|
$xml_file = sprintf('%sskin.xml', $layout_path); |
|
455
|
|
|
} |
|
456
|
|
|
} |
|
457
|
|
|
|
|
458
|
|
|
// Get a path of the requested module. Return if not exists. |
|
459
|
|
|
if(!$layout_path) $layout_path = $this->getLayoutPath($layout, $layout_type); |
|
|
|
|
|
|
460
|
|
|
if(!is_dir($layout_path)) return; |
|
461
|
|
|
|
|
462
|
|
|
// Read the xml file for module skin information |
|
463
|
|
|
if(!$xml_file) $xml_file = sprintf("%sconf/info.xml", $layout_path); |
|
|
|
|
|
|
464
|
|
|
if(!file_exists($xml_file)) |
|
465
|
|
|
{ |
|
466
|
|
|
$layout_info = new stdClass; |
|
467
|
|
|
$layout_info->title = $layout; |
|
468
|
|
|
$layout_info->layout = $layout; |
|
469
|
|
|
$layout_info->path = $layout_path; |
|
470
|
|
|
$layout_info->layout_title = $layout_title; |
|
|
|
|
|
|
471
|
|
|
if(!$layout_info->layout_type) |
|
472
|
|
|
{ |
|
473
|
|
|
$layout_info->layout_type = $layout_type; |
|
474
|
|
|
} |
|
475
|
|
|
return $layout_info; |
|
476
|
|
|
} |
|
477
|
|
|
|
|
478
|
|
|
// Include the cache file if it is valid and then return $layout_info variable |
|
479
|
|
|
if(!$layout_srl) |
|
480
|
|
|
{ |
|
481
|
|
|
$cache_file = $this->getLayoutCache($layout, Context::getLangType(), $layout_type); |
|
482
|
|
|
} |
|
483
|
|
|
else |
|
484
|
|
|
{ |
|
485
|
|
|
$cache_file = $this->getUserLayoutCache($layout_srl, Context::getLangType()); |
|
|
|
|
|
|
486
|
|
|
} |
|
487
|
|
|
|
|
488
|
|
|
if(file_exists($cache_file)&&filemtime($cache_file)>filemtime($xml_file)) |
|
489
|
|
|
{ |
|
490
|
|
|
include($cache_file); |
|
491
|
|
|
|
|
492
|
|
|
if($layout_info->extra_var && $vars) |
|
|
|
|
|
|
493
|
|
|
{ |
|
494
|
|
|
foreach($vars as $key => $value) |
|
|
|
|
|
|
495
|
|
|
{ |
|
496
|
|
|
if(!$layout_info->extra_var->{$key} && !$layout_info->{$key}) |
|
|
|
|
|
|
497
|
|
|
{ |
|
498
|
|
|
$layout_info->{$key} = $value; |
|
|
|
|
|
|
499
|
|
|
} |
|
500
|
|
|
} |
|
501
|
|
|
} |
|
502
|
|
|
|
|
503
|
|
|
if(!$layout_info->title) |
|
|
|
|
|
|
504
|
|
|
{ |
|
505
|
|
|
$layout_info->title = $layout; |
|
|
|
|
|
|
506
|
|
|
} |
|
507
|
|
|
|
|
508
|
|
|
return $layout_info; |
|
|
|
|
|
|
509
|
|
|
} |
|
510
|
|
|
// If no cache file exists, parse the xml and then return the variable. |
|
511
|
|
|
$oXmlParser = new XmlParser(); |
|
512
|
|
|
$tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); |
|
513
|
|
|
|
|
514
|
|
|
if($tmp_xml_obj->layout) $xml_obj = $tmp_xml_obj->layout; |
|
515
|
|
|
elseif($tmp_xml_obj->skin) $xml_obj = $tmp_xml_obj->skin; |
|
516
|
|
|
|
|
517
|
|
|
if(!$xml_obj) return; |
|
|
|
|
|
|
518
|
|
|
|
|
519
|
|
|
$buff = array(); |
|
520
|
|
|
$buff[] = '$layout_info = new stdClass;'; |
|
521
|
|
|
$buff[] = sprintf('$layout_info->site_srl = "%s";', $site_srl); |
|
|
|
|
|
|
522
|
|
|
|
|
523
|
|
|
if($xml_obj->version && $xml_obj->attrs->version == '0.2') |
|
524
|
|
|
{ |
|
525
|
|
|
// Layout title, version and other information |
|
526
|
|
|
sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); |
|
|
|
|
|
|
527
|
|
|
$date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
|
528
|
|
|
$buff[] = sprintf('$layout_info->layout = "%s";', $layout); |
|
529
|
|
|
$buff[] = sprintf('$layout_info->type = "%s";', $xml_obj->attrs->type); |
|
530
|
|
|
$buff[] = sprintf('$layout_info->path = "%s";', $layout_path); |
|
531
|
|
|
$buff[] = sprintf('$layout_info->title = "%s";', $xml_obj->title->body); |
|
532
|
|
|
$buff[] = sprintf('$layout_info->description = "%s";', $xml_obj->description->body); |
|
533
|
|
|
$buff[] = sprintf('$layout_info->version = "%s";', $xml_obj->version->body); |
|
534
|
|
|
$buff[] = sprintf('$layout_info->date = "%s";', $date); |
|
535
|
|
|
$buff[] = sprintf('$layout_info->homepage = "%s";', $xml_obj->link->body); |
|
536
|
|
|
$buff[] = sprintf('$layout_info->layout_srl = $layout_srl;'); |
|
537
|
|
|
$buff[] = sprintf('$layout_info->layout_title = $layout_title;'); |
|
538
|
|
|
$buff[] = sprintf('$layout_info->license = "%s";', $xml_obj->license->body); |
|
539
|
|
|
$buff[] = sprintf('$layout_info->license_link = "%s";', $xml_obj->license->attrs->link); |
|
540
|
|
|
$buff[] = sprintf('$layout_info->layout_type = "%s";', $layout_type); |
|
541
|
|
|
|
|
542
|
|
|
// Author information |
|
543
|
|
View Code Duplication |
if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author; |
|
|
|
|
|
|
544
|
|
|
else $author_list = $xml_obj->author; |
|
545
|
|
|
|
|
546
|
|
|
$buff[] = '$layout_info->author = array();'; |
|
547
|
|
|
for($i=0, $c=count($author_list); $i<$c; $i++) |
|
548
|
|
|
{ |
|
549
|
|
|
$buff[] = sprintf('$layout_info->author[%d] = new stdClass;', $i); |
|
550
|
|
|
$buff[] = sprintf('$layout_info->author[%d]->name = "%s";', $i, $author_list[$i]->name->body); |
|
551
|
|
|
$buff[] = sprintf('$layout_info->author[%d]->email_address = "%s";', $i, $author_list[$i]->attrs->email_address); |
|
552
|
|
|
$buff[] = sprintf('$layout_info->author[%d]->homepage = "%s";', $i, $author_list[$i]->attrs->link); |
|
553
|
|
|
} |
|
554
|
|
|
|
|
555
|
|
|
// Extra vars (user defined variables to use in a template) |
|
556
|
|
|
$extra_var_groups = $xml_obj->extra_vars->group; |
|
557
|
|
|
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars; |
|
558
|
|
|
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups); |
|
559
|
|
|
|
|
560
|
|
|
$buff[] = '$layout_info->extra_var = new stdClass;'; |
|
561
|
|
|
$extra_var_count = 0; |
|
562
|
|
|
foreach($extra_var_groups as $group) |
|
563
|
|
|
{ |
|
564
|
|
|
$extra_vars = $group->var; |
|
565
|
|
|
if($extra_vars) |
|
566
|
|
|
{ |
|
567
|
|
|
if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
568
|
|
|
|
|
569
|
|
|
$count = count($extra_vars); |
|
570
|
|
|
$extra_var_count += $count; |
|
571
|
|
|
|
|
572
|
|
|
for($i=0;$i<$count;$i++) |
|
573
|
|
|
{ |
|
574
|
|
|
unset($var, $options); |
|
575
|
|
|
$var = $extra_vars[$i]; |
|
576
|
|
|
$name = $var->attrs->name; |
|
577
|
|
|
|
|
578
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s = new stdClass;', $name); |
|
579
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->group = "%s";', $name, $group->title->body); |
|
580
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->title = "%s";', $name, $var->title->body); |
|
581
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->type = "%s";', $name, $var->attrs->type); |
|
582
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->value = $vars->%s;', $name, $name); |
|
583
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->description = "%s";', $name, str_replace('"','\"',$var->description->body)); |
|
584
|
|
|
|
|
585
|
|
|
$options = $var->options; |
|
586
|
|
|
if(!$options) continue; |
|
587
|
|
|
if(!is_array($options)) $options = array($options); |
|
588
|
|
|
|
|
589
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->options = array();', $var->attrs->name); |
|
590
|
|
|
$options_count = count($options); |
|
591
|
|
|
$thumbnail_exist = false; |
|
592
|
|
|
for($j=0; $j < $options_count; $j++) |
|
593
|
|
|
{ |
|
594
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->options["%s"] = new stdClass;', $var->attrs->name, $options[$j]->attrs->value); |
|
595
|
|
|
$thumbnail = $options[$j]->attrs->src; |
|
596
|
|
|
if($thumbnail) |
|
597
|
|
|
{ |
|
598
|
|
|
$thumbnail = $layout_path.$thumbnail; |
|
599
|
|
|
if(file_exists($thumbnail)) |
|
600
|
|
|
{ |
|
601
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->options["%s"]->thumbnail = "%s";', $var->attrs->name, $options[$j]->attrs->value, $thumbnail); |
|
602
|
|
|
if(!$thumbnail_exist) |
|
603
|
|
|
{ |
|
604
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->thumbnail_exist = true;', $var->attrs->name); |
|
605
|
|
|
$thumbnail_exist = true; |
|
606
|
|
|
} |
|
607
|
|
|
} |
|
608
|
|
|
} |
|
609
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->options["%s"]->val = "%s";', $var->attrs->name, $options[$j]->attrs->value, $options[$j]->title->body); |
|
610
|
|
|
} |
|
611
|
|
|
} |
|
612
|
|
|
} |
|
613
|
|
|
} |
|
614
|
|
|
$buff[] = sprintf('$layout_info->extra_var_count = "%s";', $extra_var_count); |
|
615
|
|
|
// Menu |
|
616
|
|
|
if($xml_obj->menus->menu) |
|
617
|
|
|
{ |
|
618
|
|
|
$menus = $xml_obj->menus->menu; |
|
619
|
|
|
if(!is_array($menus)) $menus = array($menus); |
|
620
|
|
|
|
|
621
|
|
|
$menu_count = count($menus); |
|
622
|
|
|
$buff[] = sprintf('$layout_info->menu_count = "%s";', $menu_count); |
|
623
|
|
|
$buff[] = '$layout_info->menu = new stdClass;'; |
|
624
|
|
|
for($i=0;$i<$menu_count;$i++) |
|
625
|
|
|
{ |
|
626
|
|
|
$name = $menus[$i]->attrs->name; |
|
627
|
|
|
if($menus[$i]->attrs->default == "true") $buff[] = sprintf('$layout_info->default_menu = "%s";', $name); |
|
628
|
|
|
$buff[] = sprintf('$layout_info->menu->%s = new stdClass;', $name); |
|
629
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->name = "%s";',$name, $menus[$i]->attrs->name); |
|
630
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->title = "%s";',$name, $menus[$i]->title->body); |
|
631
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->maxdepth = "%s";',$name, $menus[$i]->attrs->maxdepth); |
|
632
|
|
|
|
|
633
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->menu_srl = $vars->%s;', $name, $name); |
|
634
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->xml_file = "./files/cache/menu/".$vars->%s.".xml.php";',$name, $name); |
|
635
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->php_file = "./files/cache/menu/".$vars->%s.".php";',$name, $name); |
|
636
|
|
|
} |
|
637
|
|
|
} |
|
638
|
|
|
} |
|
639
|
|
|
else |
|
640
|
|
|
{ |
|
641
|
|
|
// Layout title, version and other information |
|
642
|
|
|
sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); |
|
643
|
|
|
$date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
|
644
|
|
|
$buff[] = sprintf('$layout_info->layout = "%s";', $layout); |
|
645
|
|
|
$buff[] = sprintf('$layout_info->path = "%s";', $layout_path); |
|
646
|
|
|
$buff[] = sprintf('$layout_info->title = "%s";', $xml_obj->title->body); |
|
647
|
|
|
$buff[] = sprintf('$layout_info->description = "%s";', $xml_obj->author->description->body); |
|
648
|
|
|
$buff[] = sprintf('$layout_info->version = "%s";', $xml_obj->attrs->version); |
|
649
|
|
|
$buff[] = sprintf('$layout_info->date = "%s";', $date); |
|
650
|
|
|
$buff[] = sprintf('$layout_info->layout_srl = $layout_srl;'); |
|
651
|
|
|
$buff[] = sprintf('$layout_info->layout_title = $layout_title;'); |
|
652
|
|
|
// Author information |
|
653
|
|
|
$buff[] = sprintf('$layout_info->author[0]->name = "%s";', $xml_obj->author->name->body); |
|
654
|
|
|
$buff[] = sprintf('$layout_info->author[0]->email_address = "%s";', $xml_obj->author->attrs->email_address); |
|
655
|
|
|
$buff[] = sprintf('$layout_info->author[0]->homepage = "%s";', $xml_obj->author->attrs->link); |
|
656
|
|
|
// Extra vars (user defined variables to use in a template) |
|
657
|
|
|
$extra_var_groups = $xml_obj->extra_vars->group; |
|
658
|
|
|
if(!$extra_var_groups) $extra_var_groups = $xml_obj->extra_vars; |
|
659
|
|
|
if(!is_array($extra_var_groups)) $extra_var_groups = array($extra_var_groups); |
|
660
|
|
|
foreach($extra_var_groups as $group) |
|
661
|
|
|
{ |
|
662
|
|
|
$extra_vars = $group->var; |
|
663
|
|
|
if($extra_vars) |
|
664
|
|
|
{ |
|
665
|
|
|
if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
666
|
|
|
|
|
667
|
|
|
$extra_var_count = count($extra_vars); |
|
668
|
|
|
|
|
669
|
|
|
$buff[] = sprintf('$layout_info->extra_var_count = "%s";', $extra_var_count); |
|
670
|
|
|
for($i=0;$i<$extra_var_count;$i++) |
|
671
|
|
|
{ |
|
672
|
|
|
unset($var, $options); |
|
673
|
|
|
$var = $extra_vars[$i]; |
|
674
|
|
|
$name = $var->attrs->name; |
|
675
|
|
|
|
|
676
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->group = "%s";', $name, $group->title->body); |
|
677
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->title = "%s";', $name, $var->title->body); |
|
678
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->type = "%s";', $name, $var->attrs->type); |
|
679
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->value = $vars->%s;', $name, $name); |
|
680
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->description = "%s";', $name, str_replace('"','\"',$var->description->body)); |
|
681
|
|
|
|
|
682
|
|
|
$options = $var->options; |
|
683
|
|
|
if(!$options) continue; |
|
684
|
|
|
|
|
685
|
|
|
if(!is_array($options)) $options = array($options); |
|
686
|
|
|
$options_count = count($options); |
|
687
|
|
|
for($j=0;$j<$options_count;$j++) |
|
688
|
|
|
{ |
|
689
|
|
|
$buff[] = sprintf('$layout_info->extra_var->%s->options["%s"]->val = "%s";', $var->attrs->name, $options[$j]->value->body, $options[$j]->title->body); |
|
690
|
|
|
} |
|
691
|
|
|
} |
|
692
|
|
|
} |
|
693
|
|
|
} |
|
694
|
|
|
// Menu |
|
695
|
|
|
if($xml_obj->menus->menu) |
|
696
|
|
|
{ |
|
697
|
|
|
$menus = $xml_obj->menus->menu; |
|
698
|
|
|
if(!is_array($menus)) $menus = array($menus); |
|
699
|
|
|
|
|
700
|
|
|
$menu_count = count($menus); |
|
701
|
|
|
$buff[] = sprintf('$layout_info->menu_count = "%s";', $menu_count); |
|
702
|
|
|
for($i=0;$i<$menu_count;$i++) |
|
703
|
|
|
{ |
|
704
|
|
|
$name = $menus[$i]->attrs->name; |
|
705
|
|
|
if($menus[$i]->attrs->default == "true") $buff[] = sprintf('$layout_info->default_menu = "%s";', $name); |
|
706
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->name = "%s";',$name, $name); |
|
707
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->title = "%s";',$name, $menus[$i]->title->body); |
|
708
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->maxdepth = "%s";',$name, $menus[$i]->maxdepth->body); |
|
709
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->menu_srl = $vars->%s;', $name, $name); |
|
710
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->xml_file = "./files/cache/menu/".$vars->%s.".xml.php";',$name, $name); |
|
711
|
|
|
$buff[] = sprintf('$layout_info->menu->%s->php_file = "./files/cache/menu/".$vars->%s.".php";',$name, $name); |
|
712
|
|
|
} |
|
713
|
|
|
} |
|
714
|
|
|
} |
|
715
|
|
|
|
|
716
|
|
|
// header_script |
|
717
|
|
|
$oModuleModel = getModel('module'); |
|
718
|
|
|
$layout_config = $oModuleModel->getModulePartConfig('layout', $layout_srl); |
|
719
|
|
|
$header_script = trim($layout_config->header_script); |
|
720
|
|
|
|
|
721
|
|
|
if($header_script) |
|
722
|
|
|
{ |
|
723
|
|
|
$buff[] = sprintf(' $layout_info->header_script = "%s"; ', str_replace(array('$','"'),array('\$','\\"'),$header_script)); |
|
724
|
|
|
} |
|
725
|
|
|
|
|
726
|
|
|
FileHandler::writeFile($cache_file, '<?php if(!defined("__XE__")) exit(); ' . join(PHP_EOL, $buff)); |
|
727
|
|
|
if(FileHandler::exists($cache_file)) include($cache_file); |
|
|
|
|
|
|
728
|
|
|
|
|
729
|
|
|
if(!$layout_info->title) |
|
|
|
|
|
|
730
|
|
|
{ |
|
731
|
|
|
$layout_info->title = $layout; |
|
|
|
|
|
|
732
|
|
|
} |
|
733
|
|
|
|
|
734
|
|
|
return $layout_info; |
|
|
|
|
|
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
/** |
|
738
|
|
|
* Return a list of images which are uploaded on the layout setting page |
|
739
|
|
|
* @param int $layout_srl |
|
740
|
|
|
* @return array image list in layout |
|
741
|
|
|
*/ |
|
742
|
|
|
function getUserLayoutImageList($layout_srl) |
|
743
|
|
|
{ |
|
744
|
|
|
return FileHandler::readDir($this->getUserLayoutImagePath($layout_srl)); |
|
745
|
|
|
} |
|
746
|
|
|
|
|
747
|
|
|
/** |
|
748
|
|
|
* Get ini configurations and make them an array. |
|
749
|
|
|
* @param int $layout_srl |
|
750
|
|
|
* @param string $layout_name |
|
751
|
|
|
* @return array |
|
752
|
|
|
*/ |
|
753
|
|
|
function getUserLayoutIniConfig($layout_srl, $layout_name=null) |
|
754
|
|
|
{ |
|
755
|
|
|
$file = $this->getUserLayoutIni($layout_srl); |
|
756
|
|
|
if($layout_name && FileHandler::exists($file) === FALSE) |
|
|
|
|
|
|
757
|
|
|
{ |
|
758
|
|
|
FileHandler::copyFile($this->getDefaultLayoutIni($layout_name),$this->getUserLayoutIni($layout_srl)); |
|
759
|
|
|
} |
|
760
|
|
|
|
|
761
|
|
|
return FileHandler::readIniFile($file); |
|
762
|
|
|
} |
|
763
|
|
|
|
|
764
|
|
|
/** |
|
765
|
|
|
* get user layout path |
|
766
|
|
|
* @param int $layout_srl |
|
767
|
|
|
* @return string |
|
768
|
|
|
*/ |
|
769
|
|
|
function getUserLayoutPath($layout_srl) |
|
770
|
|
|
{ |
|
771
|
|
|
return sprintf("./files/faceOff/%s", getNumberingPath($layout_srl,3)); |
|
772
|
|
|
} |
|
773
|
|
|
|
|
774
|
|
|
/** |
|
775
|
|
|
* get user layout image path |
|
776
|
|
|
* @param int $layout_srl |
|
777
|
|
|
* @return string |
|
778
|
|
|
*/ |
|
779
|
|
|
function getUserLayoutImagePath($layout_srl) |
|
780
|
|
|
{ |
|
781
|
|
|
return $this->getUserLayoutPath($layout_srl). 'images/'; |
|
782
|
|
|
} |
|
783
|
|
|
|
|
784
|
|
|
/** |
|
785
|
|
|
* css which is set by an administrator on the layout setting page |
|
786
|
|
|
* @param int $layout_srl |
|
787
|
|
|
* @return string |
|
788
|
|
|
*/ |
|
789
|
|
|
function getUserLayoutCss($layout_srl) |
|
790
|
|
|
{ |
|
791
|
|
|
return $this->getUserLayoutPath($layout_srl). 'layout.css'; |
|
792
|
|
|
} |
|
793
|
|
|
|
|
794
|
|
|
/** |
|
795
|
|
|
* Import faceoff css from css module handler |
|
796
|
|
|
* @param int $layout_srl |
|
797
|
|
|
* @return string |
|
798
|
|
|
*/ |
|
799
|
|
|
function getUserLayoutFaceOffCss($layout_srl) |
|
800
|
|
|
{ |
|
801
|
|
|
if($this->useUserLayoutTemp == 'temp') return; |
|
802
|
|
|
return $this->_getUserLayoutFaceOffCss($layout_srl); |
|
803
|
|
|
} |
|
804
|
|
|
|
|
805
|
|
|
/** |
|
806
|
|
|
* Import faceoff css from css module handler |
|
807
|
|
|
* @param int $layout_srl |
|
808
|
|
|
* @return string |
|
809
|
|
|
*/ |
|
810
|
|
|
function _getUserLayoutFaceOffCss($layout_srl) |
|
811
|
|
|
{ |
|
812
|
|
|
return $this->getUserLayoutPath($layout_srl). 'faceoff.css'; |
|
813
|
|
|
} |
|
814
|
|
|
|
|
815
|
|
|
/** |
|
816
|
|
|
* get user layout tmp html |
|
817
|
|
|
* @param int $layout_srl |
|
818
|
|
|
* @return string |
|
819
|
|
|
*/ |
|
820
|
|
|
function getUserLayoutTempFaceOffCss($layout_srl) |
|
821
|
|
|
{ |
|
822
|
|
|
return $this->getUserLayoutPath($layout_srl). 'tmp.faceoff.css'; |
|
823
|
|
|
} |
|
824
|
|
|
|
|
825
|
|
|
/** |
|
826
|
|
|
* user layout html |
|
827
|
|
|
* @param int $layout_srl |
|
828
|
|
|
* @return string |
|
829
|
|
|
*/ |
|
830
|
|
View Code Duplication |
function getUserLayoutHtml($layout_srl) |
|
|
|
|
|
|
831
|
|
|
{ |
|
832
|
|
|
$src = $this->getUserLayoutPath($layout_srl). 'layout.html'; |
|
833
|
|
|
if($this->useUserLayoutTemp == 'temp') |
|
834
|
|
|
{ |
|
835
|
|
|
$temp = $this->getUserLayoutTempHtml($layout_srl); |
|
836
|
|
|
if(FileHandler::exists($temp) === FALSE) FileHandler::copyFile($src,$temp); |
|
837
|
|
|
return $temp; |
|
838
|
|
|
} |
|
839
|
|
|
|
|
840
|
|
|
return $src; |
|
841
|
|
|
} |
|
842
|
|
|
|
|
843
|
|
|
/** |
|
844
|
|
|
* user layout tmp html |
|
845
|
|
|
* @param int $layout_srl |
|
846
|
|
|
* @return string |
|
847
|
|
|
*/ |
|
848
|
|
|
function getUserLayoutTempHtml($layout_srl) |
|
849
|
|
|
{ |
|
850
|
|
|
return $this->getUserLayoutPath($layout_srl). 'tmp.layout.html'; |
|
851
|
|
|
} |
|
852
|
|
|
|
|
853
|
|
|
/** |
|
854
|
|
|
* user layout ini |
|
855
|
|
|
* @param int $layout_srl |
|
856
|
|
|
* @return string |
|
857
|
|
|
*/ |
|
858
|
|
View Code Duplication |
function getUserLayoutIni($layout_srl) |
|
|
|
|
|
|
859
|
|
|
{ |
|
860
|
|
|
$src = $this->getUserLayoutPath($layout_srl). 'layout.ini'; |
|
861
|
|
|
if($this->useUserLayoutTemp == 'temp') |
|
862
|
|
|
{ |
|
863
|
|
|
$temp = $this->getUserLayoutTempIni($layout_srl); |
|
864
|
|
|
if(!file_exists(FileHandler::getRealPath($temp))) FileHandler::copyFile($src,$temp); |
|
865
|
|
|
return $temp; |
|
866
|
|
|
} |
|
867
|
|
|
|
|
868
|
|
|
return $src; |
|
869
|
|
|
} |
|
870
|
|
|
|
|
871
|
|
|
/** |
|
872
|
|
|
* user layout tmp ini |
|
873
|
|
|
* @param int $layout_srl |
|
874
|
|
|
* @return string |
|
875
|
|
|
*/ |
|
876
|
|
|
function getUserLayoutTempIni($layout_srl) |
|
877
|
|
|
{ |
|
878
|
|
|
return $this->getUserLayoutPath($layout_srl). 'tmp.layout.ini'; |
|
879
|
|
|
} |
|
880
|
|
|
|
|
881
|
|
|
/** |
|
882
|
|
|
* user layout cache |
|
883
|
|
|
* TODO It may need to remove the file itself |
|
884
|
|
|
* @param int $layout_srl |
|
885
|
|
|
* @param string $lang_type |
|
886
|
|
|
* @return string |
|
887
|
|
|
*/ |
|
888
|
|
|
function getUserLayoutCache($layout_srl,$lang_type) |
|
889
|
|
|
{ |
|
890
|
|
|
return $this->getUserLayoutPath($layout_srl). "{$lang_type}.cache.php"; |
|
891
|
|
|
} |
|
892
|
|
|
|
|
893
|
|
|
/** |
|
894
|
|
|
* layout cache |
|
895
|
|
|
* @param int $layout_srl |
|
|
|
|
|
|
896
|
|
|
* @param string $lang_type |
|
897
|
|
|
* @return string |
|
898
|
|
|
*/ |
|
899
|
|
|
function getLayoutCache($layout_name,$lang_type,$layout_type='P') |
|
900
|
|
|
{ |
|
901
|
|
|
if($layout_type=='P') |
|
902
|
|
|
{ |
|
903
|
|
|
return sprintf("%sfiles/cache/layout/%s.%s.cache.php", _XE_PATH_, $layout_name,$lang_type); |
|
904
|
|
|
} |
|
905
|
|
|
else |
|
906
|
|
|
{ |
|
907
|
|
|
return sprintf("%sfiles/cache/layout/m.%s.%s.cache.php", _XE_PATH_, $layout_name,$lang_type); |
|
908
|
|
|
} |
|
909
|
|
|
} |
|
910
|
|
|
|
|
911
|
|
|
/** |
|
912
|
|
|
* default layout ini to prevent arbitrary changes by a user |
|
913
|
|
|
* @param string $layout_name |
|
914
|
|
|
* @return string |
|
915
|
|
|
*/ |
|
916
|
|
|
function getDefaultLayoutIni($layout_name) |
|
917
|
|
|
{ |
|
918
|
|
|
return $this->getDefaultLayoutPath($layout_name). 'layout.ini'; |
|
|
|
|
|
|
919
|
|
|
} |
|
920
|
|
|
|
|
921
|
|
|
/** |
|
922
|
|
|
* default layout html to prevent arbitrary changes by a user |
|
923
|
|
|
* @param string $layout_name |
|
924
|
|
|
* @return string |
|
925
|
|
|
*/ |
|
926
|
|
|
function getDefaultLayoutHtml($layout_name) |
|
927
|
|
|
{ |
|
928
|
|
|
return $this->getDefaultLayoutPath($layout_name). 'layout.html'; |
|
|
|
|
|
|
929
|
|
|
} |
|
930
|
|
|
|
|
931
|
|
|
/** |
|
932
|
|
|
* default layout css to prevent arbitrary changes by a user |
|
933
|
|
|
* @param string $layout_name |
|
934
|
|
|
* @return string |
|
935
|
|
|
*/ |
|
936
|
|
|
function getDefaultLayoutCss($layout_name) |
|
937
|
|
|
{ |
|
938
|
|
|
return $this->getDefaultLayoutPath($layout_name). 'css/layout.css'; |
|
|
|
|
|
|
939
|
|
|
} |
|
940
|
|
|
|
|
941
|
|
|
/** |
|
942
|
|
|
* default layout path to prevent arbitrary changes by a user |
|
943
|
|
|
* @deprecated |
|
944
|
|
|
* @return string |
|
945
|
|
|
*/ |
|
946
|
|
|
function getDefaultLayoutPath() |
|
947
|
|
|
{ |
|
948
|
|
|
return "./modules/layout/faceoff/"; |
|
949
|
|
|
} |
|
950
|
|
|
|
|
951
|
|
|
/** |
|
952
|
|
|
* faceoff is |
|
953
|
|
|
* @param string $layout_name |
|
954
|
|
|
* @return boolean (true : faceoff, false : layout) |
|
955
|
|
|
*/ |
|
956
|
|
|
function useDefaultLayout($layout_name) |
|
957
|
|
|
{ |
|
958
|
|
|
$info = $this->getLayoutInfo($layout_name); |
|
959
|
|
|
return ($info->type == 'faceoff'); |
|
960
|
|
|
} |
|
961
|
|
|
|
|
962
|
|
|
/** |
|
963
|
|
|
* Set user layout as temporary save mode |
|
964
|
|
|
* @param string $flag (default 'temp') |
|
965
|
|
|
* @return void |
|
966
|
|
|
*/ |
|
967
|
|
|
function setUseUserLayoutTemp($flag='temp') |
|
968
|
|
|
{ |
|
969
|
|
|
$this->useUserLayoutTemp = $flag; |
|
970
|
|
|
} |
|
971
|
|
|
|
|
972
|
|
|
/** |
|
973
|
|
|
* Temp file list for User Layout |
|
974
|
|
|
* @param int $layout_srl |
|
975
|
|
|
* @return array temp files info |
|
976
|
|
|
*/ |
|
977
|
|
|
function getUserLayoutTempFileList($layout_srl) |
|
978
|
|
|
{ |
|
979
|
|
|
return array( |
|
980
|
|
|
$this->getUserLayoutTempHtml($layout_srl), |
|
981
|
|
|
$this->getUserLayoutTempFaceOffCss($layout_srl), |
|
982
|
|
|
$this->getUserLayoutTempIni($layout_srl) |
|
983
|
|
|
); |
|
984
|
|
|
} |
|
985
|
|
|
|
|
986
|
|
|
/** |
|
987
|
|
|
* Saved file list for User Layout |
|
988
|
|
|
* @param int $layout_srl |
|
989
|
|
|
* @return array files info |
|
990
|
|
|
*/ |
|
991
|
|
|
function getUserLayoutFileList($layout_srl) |
|
992
|
|
|
{ |
|
993
|
|
|
$file_list = array( |
|
994
|
|
|
basename($this->getUserLayoutHtml($layout_srl)), |
|
995
|
|
|
basename($this->getUserLayoutFaceOffCss($layout_srl)), |
|
996
|
|
|
basename($this->getUserLayoutIni($layout_srl)), |
|
997
|
|
|
basename($this->getUserLayoutCss($layout_srl)) |
|
998
|
|
|
); |
|
999
|
|
|
|
|
1000
|
|
|
$image_path = $this->getUserLayoutImagePath($layout_srl); |
|
1001
|
|
|
$image_list = FileHandler::readDir($image_path,'/(.*(?:swf|jpg|jpeg|gif|bmp|png)$)/i'); |
|
1002
|
|
|
|
|
1003
|
|
|
foreach($image_list as $image) |
|
1004
|
|
|
{ |
|
1005
|
|
|
$file_list[] = 'images/' . $image; |
|
1006
|
|
|
} |
|
1007
|
|
|
return $file_list; |
|
1008
|
|
|
} |
|
1009
|
|
|
|
|
1010
|
|
|
/** |
|
1011
|
|
|
* faceOff related services for the operation run out |
|
1012
|
|
|
* @deprecated |
|
1013
|
|
|
* @param object $layout_info |
|
1014
|
|
|
* @return void |
|
1015
|
|
|
*/ |
|
1016
|
|
|
function doActivateFaceOff(&$layout_info) |
|
1017
|
|
|
{ |
|
1018
|
|
|
$layout_info->faceoff_ini_config = $this->getUserLayoutIniConfig($layout_info->layout_srl, $layout_info->layout); |
|
1019
|
|
|
// faceoff layout CSS |
|
1020
|
|
|
Context::addCSSFile($this->getDefaultLayoutCss($layout_info->layout)); |
|
|
|
|
|
|
1021
|
|
|
// CSS generated in the layout manager |
|
1022
|
|
|
$faceoff_layout_css = $this->getUserLayoutFaceOffCss($layout_info->layout_srl); |
|
1023
|
|
|
if($faceoff_layout_css) Context::addCSSFile($faceoff_layout_css); |
|
|
|
|
|
|
1024
|
|
|
// CSS output for the widget |
|
1025
|
|
|
Context::loadFile($this->module_path.'/tpl/css/widget.css', true); |
|
|
|
|
|
|
1026
|
|
|
if($layout_info->extra_var->colorset->value == 'black') Context::loadFile($this->module_path.'/tpl/css/[email protected]', true); |
|
|
|
|
|
|
1027
|
|
|
else Context::loadFile($this->module_path.'/tpl/css/[email protected]', true); |
|
|
|
|
|
|
1028
|
|
|
// Different page displayed upon user's permission |
|
1029
|
|
|
$logged_info = Context::get('logged_info'); |
|
1030
|
|
|
// Display edit button for faceoff layout |
|
1031
|
|
|
if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin')===false && ($logged_info->is_admin == 'Y' || $logged_info->is_site_admin)) |
|
1032
|
|
|
{ |
|
1033
|
|
|
Context::addHtmlFooter('<div class="faceOffManager" style="height: 23px; position: fixed; right: 3px; top: 3px;"><a href="'.getUrl('','mid',Context::get('mid'),'act','dispLayoutAdminLayoutModify','delete_tmp','Y').'">'.Context::getLang('cmd_layout_edit').'</a></div>'); |
|
1034
|
|
|
} |
|
1035
|
|
|
// Display menu when editing the faceOff page |
|
1036
|
|
|
if(Context::get('act')=='dispLayoutAdminLayoutModify' && ($logged_info->is_admin == 'Y' || $logged_info->is_site_admin)) |
|
1037
|
|
|
{ |
|
1038
|
|
|
$oTemplate = &TemplateHandler::getInstance(); |
|
1039
|
|
|
Context::addBodyHeader($oTemplate->compile($this->module_path.'/tpl', 'faceoff_layout_menu')); |
|
|
|
|
|
|
1040
|
|
|
} |
|
1041
|
|
|
} |
|
1042
|
|
|
} |
|
1043
|
|
|
/* End of file layout.model.php */ |
|
1044
|
|
|
/* Location: ./modules/layout/layout.model.php */ |
|
1045
|
|
|
|
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: