|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
|
3
|
|
|
/** |
|
4
|
|
|
* @class editorModel |
|
5
|
|
|
* @author NAVER ([email protected]) |
|
6
|
|
|
* @brief model class of the editor odule |
|
7
|
|
|
*/ |
|
8
|
|
|
class editorModel extends editor |
|
9
|
|
|
{ |
|
10
|
|
|
var $loaded_component_list = array(); |
|
11
|
|
|
/** |
|
12
|
|
|
* @brief Return the editor |
|
13
|
|
|
* |
|
14
|
|
|
* Editor internally generates editor_sequence from 1 to 30 for temporary use. |
|
15
|
|
|
* That means there is a limitation that more than 30 editors cannot be displayed on a single page. |
|
16
|
|
|
* |
|
17
|
|
|
* However, editor_sequence can be value from getNextSequence() in case of the modified or the auto-saved for file upload |
|
18
|
|
|
* |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @brief Return editor setting for each module |
|
23
|
|
|
*/ |
|
24
|
|
|
function getEditorConfig($module_srl = null) |
|
25
|
|
|
{ |
|
26
|
|
|
if(!$GLOBALS['__editor_module_config__'][$module_srl] && $module_srl) |
|
27
|
|
|
{ |
|
28
|
|
|
// Get trackback settings of the selected module |
|
29
|
|
|
$oModuleModel = getModel('module'); |
|
30
|
|
|
$GLOBALS['__editor_module_config__'][$module_srl] = $oModuleModel->getModulePartConfig('editor', $module_srl); |
|
31
|
|
|
} |
|
32
|
|
|
$editor_config = $GLOBALS['__editor_module_config__'][$module_srl]; |
|
33
|
|
|
|
|
34
|
|
|
$oModuleModel = getModel('module'); |
|
35
|
|
|
$editor_default_config = $oModuleModel->getModuleConfig('editor'); |
|
36
|
|
|
|
|
37
|
|
|
if(!is_object($editor_config)) $editor_config = new stdClass(); |
|
38
|
|
|
|
|
39
|
|
|
if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40
|
|
|
if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41
|
|
|
if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42
|
|
|
if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43
|
|
|
if(!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44
|
|
|
if(!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45
|
|
|
if(!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46
|
|
|
if(!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47
|
|
|
if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); |
|
48
|
|
|
|
|
49
|
|
|
if(!$editor_config->editor_height) |
|
50
|
|
|
{ |
|
51
|
|
|
$editor_config->editor_height = ($editor_default_config->editor_height) ? $editor_default_config->editor_height : 500; |
|
52
|
|
|
} |
|
53
|
|
|
if(!$editor_config->comment_editor_height) |
|
54
|
|
|
{ |
|
55
|
|
|
$editor_config->comment_editor_height = ($editor_default_config->comment_editor_height) ? $editor_default_config->comment_editor_height : 120; |
|
56
|
|
|
} |
|
57
|
|
|
if(!$editor_config->editor_skin) |
|
58
|
|
|
{ |
|
59
|
|
|
$editor_config->editor_skin = ($editor_default_config->editor_skin) ? $editor_default_config->editor_skin : 'ckeditor'; |
|
60
|
|
|
} |
|
61
|
|
|
if(!$editor_config->comment_editor_skin) |
|
62
|
|
|
{ |
|
63
|
|
|
$editor_config->comment_editor_skin = ($editor_default_config->comment_editor_skin) ? $editor_default_config->comment_editor_skin : 'ckeditor'; |
|
64
|
|
|
} |
|
65
|
|
|
if(!$editor_config->content_style) |
|
66
|
|
|
{ |
|
67
|
|
|
$editor_config->content_style = ($editor_default_config->content_style) ? $editor_default_config->content_style : 'ckeditor_light'; |
|
68
|
|
|
} |
|
69
|
|
|
if(!$editor_config->content_font && $editor_default_config->content_font) |
|
70
|
|
|
{ |
|
71
|
|
|
$editor_config->content_font = $editor_default_config->content_font; |
|
72
|
|
|
} |
|
73
|
|
|
if(!$editor_config->content_font_size && $editor_default_config->content_font_size) |
|
74
|
|
|
{ |
|
75
|
|
|
$editor_config->content_font_size = $editor_default_config->content_font_size; |
|
76
|
|
|
} |
|
77
|
|
|
if(!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) |
|
78
|
|
|
{ |
|
79
|
|
|
$editor_config->sel_editor_colorset = $editor_default_config->sel_editor_colorset; |
|
80
|
|
|
} |
|
81
|
|
|
if(!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset) |
|
82
|
|
|
{ |
|
83
|
|
|
$editor_config->sel_comment_editor_colorset = $editor_default_config->sel_comment_editor_colorset; |
|
84
|
|
|
} |
|
85
|
|
|
if(!$editor_config->comment_content_style && $editor_default_config->comment_content_style) |
|
86
|
|
|
{ |
|
87
|
|
|
$editor_config->comment_content_style = $editor_default_config->comment_content_style; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
return $editor_config; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
function loadDrComponents() |
|
94
|
|
|
{ |
|
95
|
|
|
$drComponentPath = _XE_PATH_ . 'modules/editor/skins/dreditor/drcomponents/'; |
|
96
|
|
|
$drComponentList = FileHandler::readDir($drComponentPath); |
|
97
|
|
|
|
|
98
|
|
|
$oTemplate = &TemplateHandler::getInstance(); |
|
99
|
|
|
|
|
100
|
|
|
$drComponentInfo = array(); |
|
101
|
|
|
if($drComponentList) |
|
|
|
|
|
|
102
|
|
|
{ |
|
103
|
|
|
foreach($drComponentList as $i => $drComponent) |
|
104
|
|
|
{ |
|
105
|
|
|
unset($obj); |
|
106
|
|
|
$obj = $this->getDrComponentXmlInfo($drComponent); |
|
107
|
|
|
Context::loadLang(sprintf('%s%s/lang/',$drComponentPath,$drComponent)); |
|
108
|
|
|
$path = sprintf('%s%s/tpl/',$drComponentPath,$drComponent); |
|
109
|
|
|
$obj->html = $oTemplate->compile($path,$drComponent); |
|
110
|
|
|
$drComponentInfo[$drComponent] = $obj; |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
Context::set('drComponentList',$drComponentInfo); |
|
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
function getDrComponentXmlInfo($drComponentName) |
|
117
|
|
|
{ |
|
118
|
|
|
$lang_type = Context::getLangType(); |
|
119
|
|
|
// Get the xml file path of requested component |
|
120
|
|
|
$component_path = sprintf('%s/skins/dreditor/drcomponents/%s/', $this->module_path, $drComponentName); |
|
|
|
|
|
|
121
|
|
|
|
|
122
|
|
|
$xml_file = sprintf('%sinfo.xml', $component_path); |
|
123
|
|
|
$cache_file = sprintf('./files/cache/editor/dr_%s.%s.php', $drComponentName, $lang_type); |
|
124
|
|
|
// Return information after including it after cached xml file exists |
|
125
|
|
View Code Duplication |
if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
126
|
|
|
{ |
|
127
|
|
|
include($cache_file); |
|
128
|
|
|
return $xml_info; |
|
|
|
|
|
|
129
|
|
|
} |
|
130
|
|
|
// Return after parsing and caching if the cached file does not exist |
|
131
|
|
|
$oParser = new XmlParser(); |
|
132
|
|
|
$xml_doc = $oParser->loadXmlFile($xml_file); |
|
133
|
|
|
|
|
134
|
|
|
$component_info->component_name = $drComponentName; |
|
|
|
|
|
|
135
|
|
|
$component_info->title = $xml_doc->component->title->body; |
|
136
|
|
|
$component_info->description = str_replace('\n', "\n", $xml_doc->component->description->body); |
|
137
|
|
|
$component_info->version = $xml_doc->component->version->body; |
|
138
|
|
|
$component_info->date = $xml_doc->component->date->body; |
|
139
|
|
|
$component_info->homepage = $xml_doc->component->link->body; |
|
140
|
|
|
$component_info->license = $xml_doc->component->license->body; |
|
141
|
|
|
$component_info->license_link = $xml_doc->component->license->attrs->link; |
|
142
|
|
|
|
|
143
|
|
|
$buff = '<?php if(!defined("__XE__")) exit(); '; |
|
144
|
|
|
$buff .= sprintf('$xml_info->component_name = "%s";', $component_info->component_name); |
|
145
|
|
|
$buff .= sprintf('$xml_info->title = "%s";', $component_info->title); |
|
146
|
|
|
$buff .= sprintf('$xml_info->description = "%s";', $component_info->description); |
|
147
|
|
|
$buff .= sprintf('$xml_info->version = "%s";', $component_info->version); |
|
148
|
|
|
$buff .= sprintf('$xml_info->date = "%s";', $component_info->date); |
|
149
|
|
|
$buff .= sprintf('$xml_info->homepage = "%s";', $component_info->homepage); |
|
150
|
|
|
$buff .= sprintf('$xml_info->license = "%s";', $component_info->license); |
|
151
|
|
|
$buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); |
|
152
|
|
|
|
|
153
|
|
|
// Author information |
|
154
|
|
View Code Duplication |
if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
|
|
|
|
|
155
|
|
|
else $author_list = $xml_doc->component->author; |
|
156
|
|
|
|
|
157
|
|
|
for($i=0; $i < count($author_list); $i++) |
|
|
|
|
|
|
158
|
|
|
{ |
|
159
|
|
|
$buff .= sprintf('$xml_info->author['.$i.']->name = "%s";', $author_list[$i]->name->body); |
|
160
|
|
|
$buff .= sprintf('$xml_info->author['.$i.']->email_address = "%s";', $author_list[$i]->attrs->email_address); |
|
161
|
|
|
$buff .= sprintf('$xml_info->author['.$i.']->homepage = "%s";', $author_list[$i]->attrs->link); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
// List extra variables (text type only in the editor component) |
|
165
|
|
|
$extra_vars = $xml_doc->component->extra_vars->var; |
|
166
|
|
|
if($extra_vars) |
|
167
|
|
|
{ |
|
168
|
|
|
if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
169
|
|
|
foreach($extra_vars as $key => $val) |
|
170
|
|
|
{ |
|
171
|
|
|
unset($obj); |
|
172
|
|
|
$key = $val->attrs->name; |
|
173
|
|
|
$title = $val->title->body; |
|
174
|
|
|
$description = $val->description->body; |
|
175
|
|
|
$xml_info->extra_vars->{$key}->title = $title; |
|
176
|
|
|
$xml_info->extra_vars->{$key}->description = $description; |
|
177
|
|
|
|
|
178
|
|
|
$buff .= sprintf('$xml_info->extra_vars->%s->%s = "%s";', $key, 'title', $title); |
|
179
|
|
|
$buff .= sprintf('$xml_info->extra_vars->%s->%s = "%s";', $key, 'description', $description); |
|
180
|
|
|
} |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
FileHandler::writeFile($cache_file, $buff, "w"); |
|
184
|
|
|
|
|
185
|
|
|
unset($xml_info); |
|
186
|
|
|
include($cache_file); |
|
187
|
|
|
return $xml_info; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* @brief Return the editor template |
|
192
|
|
|
* You can call upload_target_srl when modifying content |
|
193
|
|
|
* The upload_target_srl is used for a routine to check if an attachment exists |
|
194
|
|
|
*/ |
|
195
|
|
|
function getEditor($upload_target_srl = 0, $option = null) |
|
196
|
|
|
{ |
|
197
|
|
|
/** |
|
198
|
|
|
* Editor's default options |
|
199
|
|
|
*/ |
|
200
|
|
|
// Option setting to allow file upload |
|
201
|
|
|
if($upload_target_srl) |
|
202
|
|
|
{ |
|
203
|
|
|
$option->editor_sequence = $upload_target_srl; |
|
204
|
|
|
} |
|
205
|
|
|
if(!$option->allow_fileupload) $allow_fileupload = false; |
|
206
|
|
|
else $allow_fileupload = true; |
|
207
|
|
|
// content_style setting |
|
208
|
|
|
if(!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
209
|
|
|
Context::set('content_style', $option->content_style); |
|
210
|
|
|
Context::set('content_style_path', $this->module_path . 'styles/' . $option->content_style); |
|
|
|
|
|
|
211
|
|
|
// Default font setting |
|
212
|
|
|
Context::set('content_font', addslashes($option->content_font)); |
|
213
|
|
|
Context::set('content_font_size', $option->content_font_size); |
|
214
|
|
|
|
|
215
|
|
|
// Option setting to allow auto-save |
|
216
|
|
|
if(!$option->enable_autosave) $enable_autosave = false; |
|
217
|
|
|
elseif(Context::get($option->primary_key_name)) $enable_autosave = false; |
|
218
|
|
|
else $enable_autosave = true; |
|
219
|
|
|
// Option setting to allow the default editor component |
|
220
|
|
|
if(!$option->enable_default_component) $enable_default_component = false; |
|
221
|
|
|
else $enable_default_component = true; |
|
222
|
|
|
// Option setting to allow other extended components |
|
223
|
|
|
if(!$option->enable_component) $enable_component = false; |
|
224
|
|
|
else $enable_component = true; |
|
225
|
|
|
// Setting for html-mode |
|
226
|
|
|
if($option->disable_html) $html_mode = false; |
|
227
|
|
|
else $html_mode = true; |
|
228
|
|
|
// Set Height |
|
229
|
|
|
if(!$option->height) $editor_height = 300; |
|
230
|
|
|
else $editor_height = $option->height; |
|
231
|
|
|
// Skin Setting |
|
232
|
|
|
$skin = $option->skin; |
|
233
|
|
|
if(!$skin) $skin = 'ckeditor'; |
|
234
|
|
|
|
|
235
|
|
|
$colorset = $option->colorset; |
|
236
|
|
|
if(!$colorset) $colorset = 'moono'; |
|
237
|
|
|
Context::set('colorset', $colorset); |
|
238
|
|
|
Context::set('skin', $skin); |
|
239
|
|
|
Context::set('module_type', $option->module_type); |
|
240
|
|
|
|
|
241
|
|
|
if($skin=='dreditor') |
|
242
|
|
|
{ |
|
243
|
|
|
$this->loadDrComponents(); |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* Check the automatic backup feature (do not use if the post is edited) |
|
248
|
|
|
*/ |
|
249
|
|
|
if($enable_autosave) |
|
250
|
|
|
{ |
|
251
|
|
|
// Extract auto-saved data |
|
252
|
|
|
$saved_doc = $this->getSavedDoc($upload_target_srl); |
|
253
|
|
|
// Context setting auto-saved data |
|
254
|
|
|
Context::set('saved_doc', $saved_doc); |
|
255
|
|
|
} |
|
256
|
|
|
Context::set('enable_autosave', $enable_autosave); |
|
|
|
|
|
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* Extract editor's unique number (in order to display multiple editors on a single page) |
|
260
|
|
|
*/ |
|
261
|
|
|
if($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
262
|
|
|
else |
|
263
|
|
|
{ |
|
264
|
|
|
if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
265
|
|
|
$editor_sequence = $_SESSION['_editor_sequence_'] ++; |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* Upload setting by using configuration of the file module internally |
|
270
|
|
|
*/ |
|
271
|
|
|
$files_count = 0; |
|
272
|
|
|
if($allow_fileupload) |
|
273
|
|
|
{ |
|
274
|
|
|
$oFileModel = getModel('file'); |
|
275
|
|
|
// Get upload configuration to set on SWFUploader |
|
276
|
|
|
$file_config = $oFileModel->getUploadConfig(); |
|
277
|
|
|
$file_config->allowed_attach_size = $file_config->allowed_attach_size*1024*1024; |
|
278
|
|
|
$file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024; |
|
279
|
|
|
|
|
280
|
|
|
Context::set('file_config',$file_config); |
|
281
|
|
|
// Configure upload status such as file size |
|
282
|
|
|
$upload_status = $oFileModel->getUploadStatus(); |
|
283
|
|
|
Context::set('upload_status', $upload_status); |
|
284
|
|
|
// Upload enabled (internally caching) |
|
285
|
|
|
$oFileController = getController('file'); |
|
286
|
|
|
$oFileController->setUploadInfo($editor_sequence, $upload_target_srl); |
|
287
|
|
|
// Check if the file already exists |
|
288
|
|
|
if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
289
|
|
|
} |
|
290
|
|
|
Context::set('files_count', (int)$files_count); |
|
291
|
|
|
|
|
292
|
|
|
Context::set('allow_fileupload', $allow_fileupload); |
|
|
|
|
|
|
293
|
|
|
// Set editor_sequence value |
|
294
|
|
|
Context::set('editor_sequence', $editor_sequence); |
|
295
|
|
|
// Set the document number to upload_target_srl for file attachments |
|
296
|
|
|
// If a new document, upload_target_srl = 0. The value becomes changed when file attachment is requested |
|
297
|
|
|
Context::set('upload_target_srl', $upload_target_srl); |
|
298
|
|
|
// Set the primary key valueof the document or comments |
|
299
|
|
|
Context::set('editor_primary_key_name', $option->primary_key_name); |
|
300
|
|
|
// Set content column name to sync contents |
|
301
|
|
|
Context::set('editor_content_key_name', $option->content_key_name); |
|
302
|
|
|
|
|
303
|
|
|
/** |
|
304
|
|
|
* Check editor component |
|
305
|
|
|
*/ |
|
306
|
|
|
$site_module_info = Context::get('site_module_info'); |
|
307
|
|
|
$site_srl = (int)$site_module_info->site_srl; |
|
308
|
|
|
if($enable_component) |
|
309
|
|
|
{ |
|
310
|
|
|
if(!Context::get('component_list')) |
|
311
|
|
|
{ |
|
312
|
|
|
$component_list = $this->getComponentList(true, $site_srl); |
|
313
|
|
|
Context::set('component_list', $component_list); |
|
314
|
|
|
} |
|
315
|
|
|
} |
|
316
|
|
|
Context::set('enable_component', $enable_component); |
|
|
|
|
|
|
317
|
|
|
Context::set('enable_default_component', $enable_default_component); |
|
|
|
|
|
|
318
|
|
|
|
|
319
|
|
|
/** |
|
320
|
|
|
* Variable setting if html_mode is available |
|
321
|
|
|
*/ |
|
322
|
|
|
Context::set('html_mode', $html_mode); |
|
|
|
|
|
|
323
|
|
|
|
|
324
|
|
|
/** |
|
325
|
|
|
* Set a height of editor |
|
326
|
|
|
*/ |
|
327
|
|
|
Context::set('editor_height', $editor_height); |
|
328
|
|
|
// Check an option whether to start the editor manually |
|
329
|
|
|
Context::set('editor_manual_start', $option->manual_start); |
|
330
|
|
|
|
|
331
|
|
|
/** |
|
332
|
|
|
* Set a skin path to pre-compile the template |
|
333
|
|
|
*/ |
|
334
|
|
|
$tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
|
|
|
|
|
|
335
|
|
|
$tpl_file = 'editor.html'; |
|
336
|
|
|
|
|
337
|
|
|
if(!file_exists($tpl_path.$tpl_file)) |
|
338
|
|
|
{ |
|
339
|
|
|
$skin = 'ckeditor'; |
|
340
|
|
|
$tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
|
|
|
|
|
|
341
|
|
|
} |
|
342
|
|
|
Context::set('editor_path', $tpl_path); |
|
343
|
|
|
|
|
344
|
|
|
// load editor skin lang |
|
345
|
|
|
Context::loadLang($tpl_path.'lang'); |
|
346
|
|
|
// Return the compiled result from tpl file |
|
347
|
|
|
$oTemplate = TemplateHandler::getInstance(); |
|
348
|
|
|
return $oTemplate->compile($tpl_path, $tpl_file); |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
/** |
|
352
|
|
|
* @brief Return editor template which contains settings of each module |
|
353
|
|
|
* Result of getModuleEditor() is as same as getEditor(). But getModuleEditor()uses additional settings of each module to generate an editor |
|
354
|
|
|
* |
|
355
|
|
|
* 2 types of editors supported; document and comment. |
|
356
|
|
|
* 2 types of editors can be used on a single module. For instance each for original post and reply port. |
|
357
|
|
|
*/ |
|
358
|
|
|
function getModuleEditor($type = 'document', $module_srl, $upload_target_srl, $primary_key_name, $content_key_name) |
|
359
|
|
|
{ |
|
360
|
|
|
// Get editor settings of the module |
|
361
|
|
|
$editor_config = $this->getEditorConfig($module_srl); |
|
362
|
|
|
|
|
363
|
|
|
$config = new stdClass(); |
|
364
|
|
|
$config->module_type = $type; |
|
365
|
|
|
|
|
366
|
|
|
// Configurations listed according to a type |
|
367
|
|
|
if($type == 'document') |
|
368
|
|
|
{ |
|
369
|
|
|
$config->editor_skin = $editor_config->editor_skin; |
|
370
|
|
|
$config->content_style = $editor_config->content_style; |
|
371
|
|
|
$config->content_font = $editor_config->content_font; |
|
372
|
|
|
$config->content_font_size = $editor_config->content_font_size; |
|
373
|
|
|
$config->sel_editor_colorset = $editor_config->sel_editor_colorset; |
|
374
|
|
|
$config->upload_file_grant = $editor_config->upload_file_grant; |
|
375
|
|
|
$config->enable_default_component_grant = $editor_config->enable_default_component_grant; |
|
376
|
|
|
$config->enable_component_grant = $editor_config->enable_component_grant; |
|
377
|
|
|
$config->enable_html_grant = $editor_config->enable_html_grant; |
|
378
|
|
|
$config->editor_height = $editor_config->editor_height; |
|
379
|
|
|
$config->enable_autosave = $editor_config->enable_autosave; |
|
380
|
|
|
} |
|
381
|
|
|
else |
|
382
|
|
|
{ |
|
383
|
|
|
$config->editor_skin = $editor_config->comment_editor_skin; |
|
384
|
|
|
$config->content_style = $editor_config->comment_content_style; |
|
385
|
|
|
$config->content_font = $editor_config->content_font; |
|
386
|
|
|
$config->content_font_size = $editor_config->content_font_size; |
|
387
|
|
|
$config->sel_editor_colorset = $editor_config->sel_comment_editor_colorset; |
|
388
|
|
|
$config->upload_file_grant = $editor_config->comment_upload_file_grant; |
|
389
|
|
|
$config->enable_default_component_grant = $editor_config->enable_comment_default_component_grant; |
|
390
|
|
|
$config->enable_component_grant = $editor_config->enable_comment_component_grant; |
|
391
|
|
|
$config->enable_html_grant = $editor_config->enable_comment_html_grant; |
|
392
|
|
|
$config->editor_height = $editor_config->comment_editor_height; |
|
393
|
|
|
$config->enable_autosave = 'N'; |
|
394
|
|
|
} |
|
395
|
|
|
// Check a group_list of the currently logged-in user for permission check |
|
396
|
|
View Code Duplication |
if(Context::get('is_logged')) |
|
397
|
|
|
{ |
|
398
|
|
|
$logged_info = Context::get('logged_info'); |
|
399
|
|
|
$group_list = $logged_info->group_list; |
|
400
|
|
|
} |
|
401
|
|
|
else |
|
402
|
|
|
{ |
|
403
|
|
|
$group_list = array(); |
|
404
|
|
|
} |
|
405
|
|
|
// Pre-set option variables of editor |
|
406
|
|
|
$option = new stdClass(); |
|
407
|
|
|
$option->module_type = $config->module_type; |
|
408
|
|
|
$option->skin = $config->editor_skin; |
|
409
|
|
|
$option->content_style = $config->content_style; |
|
410
|
|
|
$option->content_font = $config->content_font; |
|
411
|
|
|
$option->content_font_size = $config->content_font_size; |
|
412
|
|
|
$option->colorset = $config->sel_editor_colorset; |
|
413
|
|
|
// Permission check for file upload |
|
414
|
|
|
$option->allow_fileupload = false; |
|
415
|
|
View Code Duplication |
if($logged_info->is_admin=='Y') $option->allow_fileupload = true; |
|
|
|
|
|
|
416
|
|
|
elseif(count($config->upload_file_grant)) |
|
417
|
|
|
{ |
|
418
|
|
|
foreach($group_list as $group_srl => $group_info) |
|
419
|
|
|
{ |
|
420
|
|
|
if(in_array($group_srl, $config->upload_file_grant)) |
|
421
|
|
|
{ |
|
422
|
|
|
$option->allow_fileupload = true; |
|
423
|
|
|
break; |
|
424
|
|
|
} |
|
425
|
|
|
} |
|
426
|
|
|
} |
|
427
|
|
|
else $option->allow_fileupload = true; |
|
428
|
|
|
// Permission check for using default components |
|
429
|
|
|
$option->enable_default_component = false; |
|
430
|
|
View Code Duplication |
if($logged_info->is_admin=='Y') $option->enable_default_component = true; |
|
431
|
|
|
elseif(count($config->enable_default_component_grant)) |
|
432
|
|
|
{ |
|
433
|
|
|
foreach($group_list as $group_srl => $group_info) |
|
434
|
|
|
{ |
|
435
|
|
|
if(in_array($group_srl, $config->enable_default_component_grant)) |
|
436
|
|
|
{ |
|
437
|
|
|
$option->enable_default_component = true; |
|
438
|
|
|
break; |
|
439
|
|
|
} |
|
440
|
|
|
} |
|
441
|
|
|
} |
|
442
|
|
|
else $option->enable_default_component = true; |
|
443
|
|
|
// Permisshion check for using extended components |
|
444
|
|
|
$option->enable_component = false; |
|
445
|
|
View Code Duplication |
if($logged_info->is_admin=='Y') $option->enable_component = true; |
|
446
|
|
|
elseif(count($config->enable_component_grant)) |
|
447
|
|
|
{ |
|
448
|
|
|
foreach($group_list as $group_srl => $group_info) |
|
449
|
|
|
{ |
|
450
|
|
|
if(in_array($group_srl, $config->enable_component_grant)) |
|
451
|
|
|
{ |
|
452
|
|
|
$option->enable_component = true; |
|
453
|
|
|
break; |
|
454
|
|
|
} |
|
455
|
|
|
} |
|
456
|
|
|
} |
|
457
|
|
|
else $option->enable_component = true; |
|
458
|
|
|
// HTML editing privileges |
|
459
|
|
|
$enable_html = false; |
|
460
|
|
View Code Duplication |
if($logged_info->is_admin=='Y') $enable_html = true; |
|
461
|
|
|
elseif(count($config->enable_html_grant)) |
|
462
|
|
|
{ |
|
463
|
|
|
foreach($group_list as $group_srl => $group_info) |
|
464
|
|
|
{ |
|
465
|
|
|
if(in_array($group_srl, $config->enable_html_grant)) |
|
466
|
|
|
{ |
|
467
|
|
|
$enable_html = true; |
|
468
|
|
|
break; |
|
469
|
|
|
} |
|
470
|
|
|
} |
|
471
|
|
|
} |
|
472
|
|
|
else $enable_html = true; |
|
473
|
|
|
|
|
474
|
|
|
if($enable_html) $option->disable_html = false; |
|
475
|
|
|
else $option->disable_html = true; |
|
476
|
|
|
// Set Height |
|
477
|
|
|
$option->height = $config->editor_height; |
|
478
|
|
|
// Set an option for Auto-save |
|
479
|
|
|
$option->enable_autosave = $config->enable_autosave=='Y'?true:false; |
|
480
|
|
|
// Other settings |
|
481
|
|
|
$option->primary_key_name = $primary_key_name; |
|
482
|
|
|
$option->content_key_name = $content_key_name; |
|
483
|
|
|
|
|
484
|
|
|
return $this->getEditor($upload_target_srl, $option); |
|
485
|
|
|
} |
|
486
|
|
|
|
|
487
|
|
|
/** |
|
488
|
|
|
* @brief Get information which has been auto-saved |
|
489
|
|
|
*/ |
|
490
|
|
|
function getSavedDoc($upload_target_srl) |
|
491
|
|
|
{ |
|
492
|
|
|
$auto_save_args = new stdClass(); |
|
493
|
|
|
// Find a document by using member_srl for logged-in user and ipaddress for non-logged user |
|
494
|
|
View Code Duplication |
if(Context::get('is_logged')) |
|
495
|
|
|
{ |
|
496
|
|
|
$logged_info = Context::get('logged_info'); |
|
497
|
|
|
$auto_save_args->member_srl = $logged_info->member_srl; |
|
498
|
|
|
} |
|
499
|
|
|
else |
|
500
|
|
|
{ |
|
501
|
|
|
$auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
502
|
|
|
} |
|
503
|
|
|
$auto_save_args->module_srl = Context::get('module_srl'); |
|
504
|
|
|
// Get the current module if module_srl doesn't exist |
|
505
|
|
|
if(!$auto_save_args->module_srl) |
|
506
|
|
|
{ |
|
507
|
|
|
$current_module_info = Context::get('current_module_info'); |
|
508
|
|
|
$auto_save_args->module_srl = $current_module_info->module_srl; |
|
509
|
|
|
} |
|
510
|
|
|
// Extract auto-saved data from the DB |
|
511
|
|
|
$output = executeQuery('editor.getSavedDocument', $auto_save_args); |
|
512
|
|
|
$saved_doc = $output->data; |
|
513
|
|
|
// Return null if no result is auto-saved |
|
514
|
|
|
if(!$saved_doc) return; |
|
515
|
|
|
// Check if the auto-saved document already exists |
|
516
|
|
|
$oDocumentModel = getModel('document'); |
|
517
|
|
|
$oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
|
518
|
|
|
if($oSaved->isExists()) return; |
|
519
|
|
|
// Move all the files if the auto-saved data contains document_srl and file |
|
520
|
|
|
// Then set document_srl to editor_sequence |
|
521
|
|
|
if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
|
522
|
|
|
{ |
|
523
|
|
|
$saved_doc->module_srl = $auto_save_args->module_srl; |
|
524
|
|
|
$oFileController = getController('file'); |
|
525
|
|
|
$oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl); |
|
526
|
|
|
} |
|
527
|
|
|
else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
528
|
|
|
// Change auto-saved data |
|
529
|
|
|
$oEditorController = getController('editor'); |
|
530
|
|
|
$oEditorController->deleteSavedDoc(false); |
|
531
|
|
|
$oEditorController->doSaveDoc($saved_doc); |
|
532
|
|
|
|
|
533
|
|
|
setUserSequence($saved_doc->document_srl); |
|
534
|
|
|
|
|
535
|
|
|
return $saved_doc; |
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
/** |
|
539
|
|
|
* @brief create objects of the component |
|
540
|
|
|
*/ |
|
541
|
|
|
function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) |
|
542
|
|
|
{ |
|
543
|
|
|
if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; |
|
544
|
|
|
|
|
545
|
|
|
if(!$this->loaded_component_list[$component][$editor_sequence]) |
|
546
|
|
|
{ |
|
547
|
|
|
// Create an object of the component and execute |
|
548
|
|
|
$class_path = sprintf('%scomponents/%s/', $this->module_path, $component); |
|
|
|
|
|
|
549
|
|
|
$class_file = sprintf('%s%s.class.php', $class_path, $component); |
|
550
|
|
View Code Duplication |
if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
551
|
|
|
// Create an object after loading the class file |
|
552
|
|
|
require_once($class_file); |
|
553
|
|
|
$oComponent = new $component($editor_sequence, $class_path); |
|
554
|
|
|
if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
555
|
|
|
// Add configuration information |
|
556
|
|
|
$component_info = $this->getComponent($component, $site_srl); |
|
557
|
|
|
$oComponent->setInfo($component_info); |
|
558
|
|
|
$this->loaded_component_list[$component][$editor_sequence] = $oComponent; |
|
559
|
|
|
} |
|
560
|
|
|
|
|
561
|
|
|
return $this->loaded_component_list[$component][$editor_sequence]; |
|
562
|
|
|
} |
|
563
|
|
|
|
|
564
|
|
|
/** |
|
565
|
|
|
* @brief Return a list of the editor skin |
|
566
|
|
|
*/ |
|
567
|
|
|
function getEditorSkinList() |
|
568
|
|
|
{ |
|
569
|
|
|
return FileHandler::readDir('./modules/editor/skins'); |
|
570
|
|
|
} |
|
571
|
|
|
|
|
572
|
|
|
/** |
|
573
|
|
|
* @brief Return the cache file name of editor component list |
|
574
|
|
|
*/ |
|
575
|
|
|
function getCacheFile($filter_enabled= true, $site_srl = 0) |
|
576
|
|
|
{ |
|
577
|
|
|
$lang = Context::getLangType(); |
|
578
|
|
|
$cache_path = _XE_PATH_.'files/cache/editor/cache/'; |
|
579
|
|
|
FileHandler::makeDir($cache_path); |
|
580
|
|
|
$cache_file = $cache_path.'component_list.' . $lang .'.'; |
|
581
|
|
|
if($filter_enabled) $cache_file .= 'filter.'; |
|
582
|
|
|
if($site_srl) $cache_file .= $site_srl.'.'; |
|
583
|
|
|
$cache_file .= 'php'; |
|
584
|
|
|
return $cache_file; |
|
585
|
|
|
} |
|
586
|
|
|
|
|
587
|
|
|
/** |
|
588
|
|
|
* @brief Return a component list (DB Information included) |
|
589
|
|
|
*/ |
|
590
|
|
|
function getComponentList($filter_enabled = true, $site_srl=0, $from_db=false) |
|
591
|
|
|
{ |
|
592
|
|
|
$cache_file = $this->getCacheFile(false, $site_srl); |
|
593
|
|
|
if($from_db || !file_exists($cache_file)) |
|
594
|
|
|
{ |
|
595
|
|
|
$oEditorController = getController('editor'); |
|
596
|
|
|
$oEditorController->makeCache(false, $site_srl); |
|
597
|
|
|
} |
|
598
|
|
|
|
|
599
|
|
|
if(!file_exists($cache_file)) return; |
|
600
|
|
|
include($cache_file); |
|
601
|
|
|
$logged_info = Context::get('logged_info'); |
|
602
|
|
|
if($logged_info && is_array($logged_info->group_list)) |
|
603
|
|
|
{ |
|
604
|
|
|
$group_list = array_keys($logged_info->group_list); |
|
605
|
|
|
} |
|
606
|
|
|
else |
|
607
|
|
|
{ |
|
608
|
|
|
$group_list = array(); |
|
609
|
|
|
} |
|
610
|
|
|
|
|
611
|
|
|
if(count($component_list)) |
|
612
|
|
|
{ |
|
613
|
|
|
foreach($component_list as $key => $val) |
|
|
|
|
|
|
614
|
|
|
{ |
|
615
|
|
|
if(!trim($key)) continue; |
|
616
|
|
|
if(!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
|
617
|
|
|
{ |
|
618
|
|
|
FileHandler::removeFile($cache_file); |
|
619
|
|
|
return $this->getComponentList($filter_enabled, $site_srl); |
|
620
|
|
|
} |
|
621
|
|
|
if(!$filter_enabled) continue; |
|
622
|
|
|
if($val->enabled == "N") |
|
623
|
|
|
{ |
|
624
|
|
|
unset($component_list->{$key}); |
|
625
|
|
|
continue; |
|
626
|
|
|
} |
|
627
|
|
|
if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
628
|
|
|
if($val->target_group) |
|
629
|
|
|
{ |
|
630
|
|
|
if(!$logged_info) |
|
631
|
|
|
{ |
|
632
|
|
|
$val->enabled = "N"; |
|
633
|
|
|
} |
|
634
|
|
|
else |
|
635
|
|
|
{ |
|
636
|
|
|
$is_granted = false; |
|
637
|
|
|
foreach($group_list as $group_srl) |
|
638
|
|
|
{ |
|
639
|
|
|
if(in_array($group_srl, $val->target_group)) $is_granted = true; |
|
640
|
|
|
} |
|
641
|
|
|
if(!$is_granted) $val->enabled = "N"; |
|
642
|
|
|
} |
|
643
|
|
|
} |
|
644
|
|
|
if($val->enabled != "N" && $val->mid_list) |
|
645
|
|
|
{ |
|
646
|
|
|
$mid = Context::get('mid'); |
|
647
|
|
|
if(!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
648
|
|
|
} |
|
649
|
|
|
if($val->enabled == "N") |
|
650
|
|
|
{ |
|
651
|
|
|
unset($component_list->{$key}); |
|
652
|
|
|
continue; |
|
653
|
|
|
} |
|
654
|
|
|
} |
|
655
|
|
|
} |
|
656
|
|
|
return $component_list; |
|
657
|
|
|
} |
|
658
|
|
|
|
|
659
|
|
|
/** |
|
660
|
|
|
* @brief Get xml and db information of the component |
|
661
|
|
|
*/ |
|
662
|
|
|
function getComponent($component_name, $site_srl = 0) |
|
663
|
|
|
{ |
|
664
|
|
|
$args = new stdClass(); |
|
665
|
|
|
$args->component_name = $component_name; |
|
666
|
|
|
|
|
667
|
|
|
if($site_srl) |
|
668
|
|
|
{ |
|
669
|
|
|
$args->site_srl = $site_srl; |
|
670
|
|
|
$output = executeQuery('editor.getSiteComponent', $args); |
|
671
|
|
|
} |
|
672
|
|
|
else |
|
673
|
|
|
{ |
|
674
|
|
|
$output = executeQuery('editor.getComponent', $args); |
|
675
|
|
|
} |
|
676
|
|
|
$component = $output->data; |
|
677
|
|
|
|
|
678
|
|
|
$component_name = $component->component_name; |
|
679
|
|
|
|
|
680
|
|
|
unset($xml_info); |
|
681
|
|
|
$xml_info = $this->getComponentXmlInfo($component_name); |
|
682
|
|
|
$xml_info->enabled = $component->enabled; |
|
683
|
|
|
|
|
684
|
|
|
$xml_info->target_group = array(); |
|
685
|
|
|
|
|
686
|
|
|
$xml_info->mid_list = array(); |
|
687
|
|
|
|
|
688
|
|
View Code Duplication |
if($component->extra_vars) |
|
689
|
|
|
{ |
|
690
|
|
|
$extra_vars = unserialize($component->extra_vars); |
|
691
|
|
|
|
|
692
|
|
|
if($extra_vars->target_group) |
|
693
|
|
|
{ |
|
694
|
|
|
$xml_info->target_group = $extra_vars->target_group; |
|
695
|
|
|
unset($extra_vars->target_group); |
|
696
|
|
|
} |
|
697
|
|
|
|
|
698
|
|
|
if($extra_vars->mid_list) |
|
699
|
|
|
{ |
|
700
|
|
|
$xml_info->mid_list = $extra_vars->mid_list; |
|
701
|
|
|
unset($extra_vars->mid_list); |
|
702
|
|
|
} |
|
703
|
|
|
|
|
704
|
|
|
if($xml_info->extra_vars) |
|
705
|
|
|
{ |
|
706
|
|
|
foreach($xml_info->extra_vars as $key => $val) |
|
707
|
|
|
{ |
|
708
|
|
|
$xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; |
|
709
|
|
|
} |
|
710
|
|
|
} |
|
711
|
|
|
} |
|
712
|
|
|
|
|
713
|
|
|
return $xml_info; |
|
714
|
|
|
} |
|
715
|
|
|
|
|
716
|
|
|
/** |
|
717
|
|
|
* @brief Read xml information of the component |
|
718
|
|
|
*/ |
|
719
|
|
|
function getComponentXmlInfo($component) |
|
720
|
|
|
{ |
|
721
|
|
|
$lang_type = Context::getLangType(); |
|
722
|
|
|
|
|
723
|
|
|
// Get xml file path of the requested components |
|
724
|
|
|
$component_path = sprintf('%s/components/%s/', $this->module_path, $component); |
|
|
|
|
|
|
725
|
|
|
|
|
726
|
|
|
$xml_file = sprintf('%sinfo.xml', $component_path); |
|
727
|
|
|
$cache_file = sprintf('./files/cache/editor/%s.%s.php', $component, $lang_type); |
|
728
|
|
|
|
|
729
|
|
|
// Include and return xml file information if cached file exists |
|
730
|
|
View Code Duplication |
if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
731
|
|
|
{ |
|
732
|
|
|
include($cache_file); |
|
733
|
|
|
|
|
734
|
|
|
return $xml_info; |
|
|
|
|
|
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
$oParser = new XmlParser(); |
|
738
|
|
|
$xml_doc = $oParser->loadXmlFile($xml_file); |
|
739
|
|
|
|
|
740
|
|
|
// Component information listed |
|
741
|
|
|
$component_info = new stdClass; |
|
742
|
|
|
$component_info->author = array(); |
|
743
|
|
|
$component_info->extra_vars = new stdClass; |
|
744
|
|
|
$component_info->component_name = $component; |
|
745
|
|
|
$component_info->title = $xml_doc->component->title->body; |
|
746
|
|
|
|
|
747
|
|
|
if($xml_doc->component->version) |
|
748
|
|
|
{ |
|
749
|
|
|
$component_info->description = str_replace('\n', "\n", $xml_doc->component->description->body); |
|
750
|
|
|
$component_info->version = $xml_doc->component->version->body; |
|
751
|
|
|
$component_info->date = $xml_doc->component->date->body; |
|
752
|
|
|
$component_info->homepage = $xml_doc->component->link->body; |
|
753
|
|
|
$component_info->license = $xml_doc->component->license->body; |
|
754
|
|
|
$component_info->license_link = $xml_doc->component->license->attrs->link; |
|
755
|
|
|
} |
|
756
|
|
|
else |
|
757
|
|
|
{ |
|
758
|
|
|
sscanf($xml_doc->component->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); |
|
|
|
|
|
|
759
|
|
|
$date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
|
760
|
|
|
|
|
761
|
|
|
$component_info->description = str_replace('\n', "\n", $xml_doc->component->author->description->body); |
|
762
|
|
|
$component_info->version = $xml_doc->component->attrs->version; |
|
763
|
|
|
$component_info->date = $date; |
|
764
|
|
|
|
|
765
|
|
|
$component_info->author = array(); |
|
766
|
|
|
$component_info->author[0]->name = $xml_doc->component->author->name->body; |
|
767
|
|
|
$component_info->author[0]->email_address = $xml_doc->component->author->attrs->email_address; |
|
768
|
|
|
$component_info->author[0]->homepage = $xml_doc->component->author->attrs->link; |
|
769
|
|
|
} |
|
770
|
|
|
|
|
771
|
|
|
// Author information |
|
772
|
|
|
$author_list = array(); |
|
773
|
|
View Code Duplication |
if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
774
|
|
|
else $author_list = $xml_doc->component->author; |
|
775
|
|
|
|
|
776
|
|
|
for($i = 0; $i < count($author_list); $i++) |
|
|
|
|
|
|
777
|
|
|
{ |
|
778
|
|
|
$author = new stdClass; |
|
779
|
|
|
$author->name = $author_list[$i]->name->body; |
|
780
|
|
|
$author->email_address = $author_list[$i]->attrs->email_address; |
|
781
|
|
|
$author->homepage = $author_list[$i]->attrs->link; |
|
782
|
|
|
$component_info->author[] = $author; |
|
783
|
|
|
} |
|
784
|
|
|
|
|
785
|
|
|
// List extra variables (text type only for editor component) |
|
786
|
|
|
$extra_vars = $xml_doc->component->extra_vars; |
|
787
|
|
View Code Duplication |
if($extra_vars) |
|
788
|
|
|
{ |
|
789
|
|
|
$extra_var_groups = $extra_vars->group; |
|
790
|
|
|
if(!$extra_var_groups) |
|
791
|
|
|
{ |
|
792
|
|
|
$extra_var_groups = $extra_vars; |
|
793
|
|
|
} |
|
794
|
|
|
if(!is_array($extra_var_groups)) |
|
795
|
|
|
{ |
|
796
|
|
|
$extra_var_groups = array($extra_var_groups); |
|
797
|
|
|
} |
|
798
|
|
|
|
|
799
|
|
|
foreach($extra_var_groups as $group) |
|
800
|
|
|
{ |
|
801
|
|
|
$extra_vars = $group->var; |
|
802
|
|
|
if(!is_array($group->var)) |
|
803
|
|
|
{ |
|
804
|
|
|
$extra_vars = array($group->var); |
|
805
|
|
|
} |
|
806
|
|
|
|
|
807
|
|
|
foreach($extra_vars as $key => $val) |
|
808
|
|
|
{ |
|
809
|
|
|
if(!$val) |
|
810
|
|
|
{ |
|
811
|
|
|
continue; |
|
812
|
|
|
} |
|
813
|
|
|
|
|
814
|
|
|
$obj = new stdClass(); |
|
815
|
|
|
if(!$val->attrs) |
|
816
|
|
|
{ |
|
817
|
|
|
$val->attrs = new stdClass(); |
|
818
|
|
|
} |
|
819
|
|
|
if(!$val->attrs->type) |
|
820
|
|
|
{ |
|
821
|
|
|
$val->attrs->type = 'text'; |
|
822
|
|
|
} |
|
823
|
|
|
|
|
824
|
|
|
$obj->group = $group->title->body; |
|
825
|
|
|
$obj->name = $val->attrs->name; |
|
826
|
|
|
$obj->title = $val->title->body; |
|
827
|
|
|
$obj->type = $val->attrs->type; |
|
828
|
|
|
$obj->description = $val->description->body; |
|
829
|
|
|
if($obj->name) |
|
830
|
|
|
{ |
|
831
|
|
|
$obj->value = $extra_vals->{$obj->name}; |
|
|
|
|
|
|
832
|
|
|
} |
|
833
|
|
|
if(strpos($obj->value, '|@|') != FALSE) |
|
|
|
|
|
|
834
|
|
|
{ |
|
835
|
|
|
$obj->value = explode('|@|', $obj->value); |
|
836
|
|
|
} |
|
837
|
|
|
if($obj->type == 'mid_list' && !is_array($obj->value)) |
|
838
|
|
|
{ |
|
839
|
|
|
$obj->value = array($obj->value); |
|
840
|
|
|
} |
|
841
|
|
|
|
|
842
|
|
|
// 'Select'type obtained from the option list. |
|
843
|
|
|
if($val->options && !is_array($val->options)) |
|
844
|
|
|
{ |
|
845
|
|
|
$val->options = array($val->options); |
|
846
|
|
|
} |
|
847
|
|
|
|
|
848
|
|
|
for($i = 0, $c = count($val->options); $i < $c; $i++) |
|
849
|
|
|
{ |
|
850
|
|
|
$obj->options[$i] = new stdClass(); |
|
851
|
|
|
$obj->options[$i]->title = $val->options[$i]->title->body; |
|
852
|
|
|
$obj->options[$i]->value = $val->options[$i]->attrs->value; |
|
853
|
|
|
} |
|
854
|
|
|
|
|
855
|
|
|
$component_info->extra_vars->{$obj->name} = $obj; |
|
856
|
|
|
} |
|
857
|
|
|
} |
|
858
|
|
|
} |
|
859
|
|
|
|
|
860
|
|
|
$buff = array(); |
|
861
|
|
|
$buff[] = '<?php if(!defined(\'__XE__\')) exit();'; |
|
862
|
|
|
$buff[] = '$xml_info = ' . var_export($component_info, TRUE) . ';'; |
|
863
|
|
|
$buff = str_replace('stdClass::__set_state', '(object)', implode(PHP_EOL, $buff)); |
|
864
|
|
|
|
|
865
|
|
|
FileHandler::writeFile($cache_file, $buff, 'w'); |
|
866
|
|
|
|
|
867
|
|
|
return $component_info; |
|
868
|
|
|
} |
|
869
|
|
|
} |
|
870
|
|
|
/* End of file editor.model.php */ |
|
871
|
|
|
/* Location: ./modules/editor/editor.model.php */ |
|
872
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.