35 $editor_default_config =
$oModuleModel->getModuleConfig(
'editor');
37 if(!is_object($editor_config)) $editor_config =
new stdClass();
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();
49 if(!$editor_config->editor_height)
51 $editor_config->editor_height = ($editor_default_config->editor_height) ? $editor_default_config->editor_height : 500;
53 if(!$editor_config->comment_editor_height)
55 $editor_config->comment_editor_height = ($editor_default_config->comment_editor_height) ? $editor_default_config->comment_editor_height : 120;
57 if(!$editor_config->editor_skin)
59 $editor_config->editor_skin = ($editor_default_config->editor_skin) ? $editor_default_config->editor_skin :
'ckeditor';
61 if(!$editor_config->comment_editor_skin)
63 $editor_config->comment_editor_skin = ($editor_default_config->comment_editor_skin) ? $editor_default_config->comment_editor_skin :
'ckeditor';
65 if(!$editor_config->content_style)
67 $editor_config->content_style = ($editor_default_config->content_style) ? $editor_default_config->content_style :
'ckeditor_light';
69 if(!$editor_config->content_font && $editor_default_config->content_font)
71 $editor_config->content_font = $editor_default_config->content_font;
73 if(!$editor_config->content_font_size && $editor_default_config->content_font_size)
75 $editor_config->content_font_size = $editor_default_config->content_font_size;
77 if(!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset)
79 $editor_config->sel_editor_colorset = $editor_default_config->sel_editor_colorset;
81 if(!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset)
83 $editor_config->sel_comment_editor_colorset = $editor_default_config->sel_comment_editor_colorset;
85 if(!$editor_config->comment_content_style && $editor_default_config->comment_content_style)
87 $editor_config->comment_content_style = $editor_default_config->comment_content_style;
90 return $editor_config;
95 $drComponentPath =
_XE_PATH_ .
'modules/editor/skins/dreditor/drcomponents/';
100 $drComponentInfo = array();
103 foreach($drComponentList as $i => $drComponent)
108 $path = sprintf(
'%s%s/tpl/',$drComponentPath,$drComponent);
109 $obj->html = $oTemplate->compile($path,$drComponent);
110 $drComponentInfo[$drComponent] =
$obj;
120 $component_path = sprintf(
'%s/skins/dreditor/drcomponents/%s/', $this->module_path, $drComponentName);
122 $xml_file = sprintf(
'%sinfo.xml', $component_path);
123 $cache_file = sprintf(
'./files/cache/editor/dr_%s.%s.php', $drComponentName, $lang_type);
125 if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file))
127 include($cache_file);
132 $xml_doc = $oParser->loadXmlFile($xml_file);
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;
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);
154 if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author;
155 else $author_list = $xml_doc->component->author;
157 for($i=0; $i < count($author_list); $i++)
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);
165 $extra_vars = $xml_doc->component->extra_vars->var;
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;
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);
186 include($cache_file);
195 function getEditor($upload_target_srl = 0, $option = null)
201 if($upload_target_srl)
203 $option->editor_sequence = $upload_target_srl;
205 if(!$option->allow_fileupload) $allow_fileupload =
false;
206 else $allow_fileupload =
true;
208 if(!$option->content_style) $option->content_style =
'ckeditor_light';
210 Context::set(
'content_style_path',
getScriptPath() . ltrim($this->module_path,
'./') .
'styles/' . $option->content_style);
212 Context::set(
'content_font', addslashes($option->content_font));
213 Context::set(
'content_font_size', $option->content_font_size);
216 if(!$option->enable_autosave) $enable_autosave =
false;
217 elseif(
Context::get($option->primary_key_name)) $enable_autosave =
false;
218 else $enable_autosave =
true;
220 if(!$option->enable_default_component) $enable_default_component =
false;
221 else $enable_default_component =
true;
223 if(!$option->enable_component) $enable_component =
false;
224 else $enable_component =
true;
226 if($option->disable_html) $html_mode =
false;
227 else $html_mode =
true;
229 if(!$option->height) $editor_height = 300;
230 else $editor_height = $option->height;
232 $editor_height = 150;
235 $skin = $option->skin;
236 if(!$skin) $skin =
'ckeditor';
238 $colorset = $option->colorset;
239 if(!$colorset) $colorset =
'moono';
244 if($skin==
'dreditor')
246 $this->loadDrComponents();
255 $saved_doc = $this->getSavedDoc($upload_target_srl);
264 if($option->editor_sequence) $editor_sequence = $option->editor_sequence;
267 if(!$_SESSION[
'_editor_sequence_']) $_SESSION[
'_editor_sequence_'] = 1;
268 $editor_sequence = $_SESSION[
'_editor_sequence_'] ++;
275 if($allow_fileupload)
279 $file_config = $oFileModel->getUploadConfig();
280 $file_config->allowed_attach_size = $file_config->allowed_attach_size*1024*1024;
281 $file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024;
285 $upload_status = $oFileModel->getUploadStatus();
289 $oFileController->setUploadInfo($editor_sequence, $upload_target_srl);
291 if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl);
302 Context::set(
'editor_primary_key_name', $option->primary_key_name);
304 Context::set(
'editor_content_key_name', $option->content_key_name);
310 $site_srl = (int)$site_module_info->site_srl;
311 if($enable_component)
315 $component_list = $this->getComponentList(
true, $site_srl);
320 Context::set(
'enable_default_component', $enable_default_component);
332 Context::set(
'editor_manual_start', $option->manual_start);
337 $tpl_path = sprintf(
'%sskins/%s/', $this->module_path, $skin);
338 $tpl_file =
'editor.html';
340 if(!file_exists($tpl_path.$tpl_file))
343 $tpl_path = sprintf(
'%sskins/%s/', $this->module_path, $skin);
351 return $oTemplate->compile($tpl_path, $tpl_file);
364 $editor_config = $this->getEditorConfig(
$module_srl);
366 $config =
new stdClass();
367 $config->module_type = $type;
370 if($type ==
'document')
372 $config->editor_skin = $editor_config->editor_skin;
373 $config->content_style = $editor_config->content_style;
374 $config->content_font = $editor_config->content_font;
375 $config->content_font_size = $editor_config->content_font_size;
376 $config->sel_editor_colorset = $editor_config->sel_editor_colorset;
377 $config->upload_file_grant = $editor_config->upload_file_grant;
378 $config->enable_default_component_grant = $editor_config->enable_default_component_grant;
379 $config->enable_component_grant = $editor_config->enable_component_grant;
380 $config->enable_html_grant = $editor_config->enable_html_grant;
381 $config->editor_height = $editor_config->editor_height;
382 $config->enable_autosave = $editor_config->enable_autosave;
386 $config->editor_skin = $editor_config->comment_editor_skin;
387 $config->content_style = $editor_config->comment_content_style;
388 $config->content_font = $editor_config->content_font;
389 $config->content_font_size = $editor_config->content_font_size;
390 $config->sel_editor_colorset = $editor_config->sel_comment_editor_colorset;
391 $config->upload_file_grant = $editor_config->comment_upload_file_grant;
392 $config->enable_default_component_grant = $editor_config->enable_comment_default_component_grant;
393 $config->enable_component_grant = $editor_config->enable_comment_component_grant;
394 $config->enable_html_grant = $editor_config->enable_comment_html_grant;
395 $config->editor_height = $editor_config->comment_editor_height;
396 $config->enable_autosave =
'N';
406 $group_list = array();
409 $option =
new stdClass();
410 $option->module_type = $config->module_type;
411 $option->skin = $config->editor_skin;
412 $option->content_style = $config->content_style;
413 $option->content_font = $config->content_font;
414 $option->content_font_size = $config->content_font_size;
415 $option->colorset = $config->sel_editor_colorset;
417 $option->allow_fileupload =
false;
418 if(
$logged_info->is_admin==
'Y') $option->allow_fileupload =
true;
419 elseif(count($config->upload_file_grant))
421 foreach($group_list as $group_srl => $group_info)
423 if(in_array($group_srl, $config->upload_file_grant))
425 $option->allow_fileupload =
true;
430 else $option->allow_fileupload =
true;
432 $option->enable_default_component =
false;
433 if(
$logged_info->is_admin==
'Y') $option->enable_default_component =
true;
434 elseif(count($config->enable_default_component_grant))
436 foreach($group_list as $group_srl => $group_info)
438 if(in_array($group_srl, $config->enable_default_component_grant))
440 $option->enable_default_component =
true;
445 else $option->enable_default_component =
true;
447 $option->enable_component =
false;
448 if(
$logged_info->is_admin==
'Y') $option->enable_component =
true;
449 elseif(count($config->enable_component_grant))
451 foreach($group_list as $group_srl => $group_info)
453 if(in_array($group_srl, $config->enable_component_grant))
455 $option->enable_component =
true;
460 else $option->enable_component =
true;
462 $enable_html =
false;
464 elseif(count($config->enable_html_grant))
466 foreach($group_list as $group_srl => $group_info)
468 if(in_array($group_srl, $config->enable_html_grant))
475 else $enable_html =
true;
477 if($enable_html) $option->disable_html =
false;
478 else $option->disable_html =
true;
480 $option->height = $config->editor_height;
482 $option->enable_autosave = $config->enable_autosave==
'Y'?
true:
false;
484 $option->primary_key_name = $primary_key_name;
485 $option->content_key_name = $content_key_name;
487 return $this->getEditor($upload_target_srl, $option);
495 $auto_save_args =
new stdClass();
496 $auto_save_args->module_srl =
Context::get(
'module_srl');
498 if(!$auto_save_args->module_srl)
500 $current_module_info =
Context::get(
'current_module_info');
501 $auto_save_args->module_srl = $current_module_info->module_srl;
511 $auto_save_args->certify_key = $_COOKIE[
'autosave_certify_key_' . $auto_save_args->module_srl];
514 if(!$auto_save_args->certify_key) $auto_save_args->ipaddress = $_SERVER[
'REMOTE_ADDR'];
520 if(!$saved_doc)
return;
522 if($saved_doc->certify_key && !isset($auto_save_args->certify_key))
530 if($oSaved->isExists())
return;
533 if($saved_doc->document_srl && $upload_target_srl && !
Context::get(
'document_srl'))
535 $saved_doc->module_srl = $auto_save_args->module_srl;
537 $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl);
539 else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl;
541 $saved_doc->certify_key = $auto_save_args->certify_key;
543 $oEditorController->deleteSavedDoc(
false);
544 $oEditorController->doSaveDoc($saved_doc);
556 if(!preg_match(
'/^[a-zA-Z0-9_-]+$/',$component) || !preg_match(
'/^[0-9]+$/', $editor_sequence . $site_srl))
return;
558 if(!$this->loaded_component_list[$component][$editor_sequence])
561 $class_path = sprintf(
'%scomponents/%s/', $this->module_path, $component);
562 $class_file = sprintf(
'%s%s.class.php', $class_path, $component);
563 if(!file_exists($class_file))
return new BaseObject(-1, sprintf(
Context::getLang(
'msg_component_is_not_founded'), $component));
565 require_once($class_file);
566 $oComponent =
new $component($editor_sequence, $class_path);
569 $component_info = $this->getComponent($component, $site_srl);
570 $oComponent->setInfo($component_info);
571 $this->loaded_component_list[$component][$editor_sequence] = $oComponent;
574 return $this->loaded_component_list[$component][$editor_sequence];
594 if($filter_enabled) $cache_file .=
'filter.';
595 if($site_srl) $cache_file .= $site_srl.
'.';
596 $cache_file .=
'php';
602 $cache_key = array();
604 if ($filter_enabled) $cache_key[] =
'filter';
605 if ($site_srl) $cache_key[] = $site_srl;
607 return 'editor.component_list:' . implode(
'.', $cache_key);
615 $component_list =
false;
618 if($oCacheHandler->isSupport()) {
619 $cache_key = $this->getComponentListCacheKey(
false, $site_srl);
620 $component_list = $oCacheHandler->get($cache_key);
623 if($from_db || $component_list ===
false)
626 $component_list = $oEditorController->makeCache(
false, $site_srl);
630 if(!$component_list)
return array();
639 $group_list = array();
642 if(count($component_list))
644 foreach($component_list as $key => $val)
646 if(!trim($key))
continue;
647 if(!is_dir(
_XE_PATH_.
'modules/editor/components/'.$key))
650 return $this->getComponentList($filter_enabled, $site_srl);
652 if(!$filter_enabled)
continue;
653 if($val->enabled ==
"N")
655 unset($component_list->{$key});
659 if($val->target_group)
668 foreach($group_list as $group_srl)
670 if(in_array($group_srl, $val->target_group)) $is_granted =
true;
672 if(!$is_granted) $val->enabled =
"N";
675 if($val->enabled !=
"N" && $val->mid_list)
678 if(!in_array($mid, $val->mid_list)) $val->enabled =
"N";
680 if($val->enabled ==
"N")
682 unset($component_list->{$key});
687 return $component_list;
695 $args =
new stdClass();
696 $args->component_name = $component_name;
700 $args->site_srl = $site_srl;
709 if(!
$output->data)
return false;
711 $component_name = $component->component_name;
714 $xml_info = $this->getComponentXmlInfo($component_name);
715 $xml_info->enabled = $component->enabled;
717 $xml_info->target_group = array();
719 $xml_info->mid_list = array();
721 if($component->extra_vars)
727 $xml_info->target_group =
$extra_vars->target_group;
737 if($xml_info->extra_vars)
739 foreach($xml_info->extra_vars as $key => $val)
741 $xml_info->extra_vars->{$key}->value =
$extra_vars->{$key};
757 $component_path = sprintf(
'%s/components/%s/', $this->module_path, $component);
759 $xml_file = sprintf(
'%sinfo.xml', $component_path);
760 $cache_file = sprintf(
'./files/cache/editor/%s.%s.php', $component, $lang_type);
763 if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file))
765 include($cache_file);
771 $xml_doc = $oParser->loadXmlFile($xml_file);
774 $component_info =
new stdClass;
775 $component_info->author = array();
776 $component_info->extra_vars =
new stdClass;
777 $component_info->component_name = $component;
778 $component_info->title = $xml_doc->component->title->body;
780 if($xml_doc->component->version)
782 $component_info->description = str_replace(
'\n',
"\n", $xml_doc->component->description->body);
783 $component_info->version = $xml_doc->component->version->body;
784 $component_info->date = $xml_doc->component->date->body;
785 $component_info->homepage = $xml_doc->component->link->body;
786 $component_info->license = $xml_doc->component->license->body;
787 $component_info->license_link = $xml_doc->component->license->attrs->link;
791 sscanf($xml_doc->component->author->attrs->date,
'%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d);
792 $date = sprintf(
'%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
794 $component_info->description = str_replace(
'\n',
"\n", $xml_doc->component->author->description->body);
795 $component_info->version = $xml_doc->component->attrs->version;
796 $component_info->date = $date;
798 $component_info->author = array();
799 $component_info->author[0]->name = $xml_doc->component->author->name->body;
800 $component_info->author[0]->email_address = $xml_doc->component->author->attrs->email_address;
801 $component_info->author[0]->homepage = $xml_doc->component->author->attrs->link;
805 $author_list = array();
806 if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author;
807 else $author_list = $xml_doc->component->author;
809 for($i = 0; $i < count($author_list); $i++)
811 $author =
new stdClass;
812 $author->name = $author_list[$i]->name->body;
813 $author->email_address = $author_list[$i]->attrs->email_address;
814 $author->homepage = $author_list[$i]->attrs->link;
815 $component_info->author[] = $author;
823 if(!$extra_var_groups)
827 if(!is_array($extra_var_groups))
829 $extra_var_groups = array($extra_var_groups);
832 foreach($extra_var_groups as $group)
835 if(!is_array($group->var))
847 $obj =
new stdClass();
850 $val->attrs =
new stdClass();
852 if(!$val->attrs->type)
854 $val->attrs->type =
'text';
857 $obj->group = $group->title->body;
858 $obj->name = $val->attrs->name;
859 $obj->title = $val->title->body;
860 $obj->type = $val->attrs->type;
861 $obj->description = $val->description->body;
864 $obj->value = $extra_vals->{
$obj->name};
866 if(strpos(
$obj->value,
'|@|') != FALSE)
868 $obj->value = explode(
'|@|',
$obj->value);
870 if(
$obj->type ==
'mid_list' && !is_array(
$obj->value))
876 if($val->options && !is_array($val->options))
878 $val->options = array($val->options);
881 for($i = 0, $c = count($val->options); $i < $c; $i++)
883 $obj->options[$i] =
new stdClass();
884 $obj->options[$i]->title = $val->options[$i]->title->body;
885 $obj->options[$i]->value = $val->options[$i]->attrs->value;
888 $component_info->extra_vars->{
$obj->name} =
$obj;
894 $buff[] =
'<?php if(!defined(\'__XE__\')) exit();';
895 $buff[] =
'$xml_info = ' . var_export($component_info, TRUE) .
';';
896 $buff = str_replace(
'stdClass::__set_state',
'(object)', implode(PHP_EOL, $buff));
900 return $component_info;
getComponentListCacheKey($filter_enabled=true, $site_srl=0)
getController($module_name)
if(file_exists(_XE_PATH_. 'config/config.user.inc.php')) if(!defined('__DEBUG__')) if(!defined('__DEBUG_OUTPUT__')) if(!defined('__DEBUG_PROTECT__')) if(!defined('__DEBUG_PROTECT_IP__')) if(!defined('__DEBUG_DB_OUTPUT__')) if(!defined('__LOG_SLOW_QUERY__')) if(!defined('__LOG_SLOW_TRIGGER__')) if(!defined('__LOG_SLOW_ADDON__')) if(!defined('__LOG_SLOW_WIDGET__')) if(!defined('__DEBUG_QUERY__')) if(!defined('__OB_GZHANDLER_ENABLE__')) if(!defined('__ENABLE_PHPUNIT_TEST__')) if(!defined('__PROXY_SERVER__')) if(!defined('__ERROR_LOG__')) if(!defined('__DISABLE_DEFAULT_CSS__')) if(!defined('__AUTO_OPCACHE_INVALIDATE__')) if((__DEBUG_OUTPUT__==2)&&version_compare(PHP_VERSION, '6.0.0')===-1) if(version_compare(PHP_VERSION, '5.3.0') >=0) $GLOBALS['__xe_autoload_file_map']
& getInstance($target= 'object', $info=null, $always_use_file=false)
getSavedDoc($upload_target_srl)
Get information which has been auto-saved.
foreach($sitemap as $id=> &$val) $extra_vars
set($key, $val, $set_to_get_vars=0)
writeFile($filename, $buff, $mode="w")
model class of the editor odule
getEditor($upload_target_srl=0, $option=null)
Return the editor template You can call upload_target_srl when modifying content The upload_target_sr...
$xml_info
an object containing the module description extracted from XML file
getDrComponentXmlInfo($drComponentName)
$module_srl
integer value to represent a run-time instance of Module (XE Module)
getCacheFile($filter_enabled=true, $site_srl=0)
Return the cache file name of editor component list.
getComponentObject($component, $editor_sequence=0, $site_srl=0)
create objects of the component
getEditorSkinList()
Return a list of the editor skin.
getEditorConfig($module_srl=null)
Return the editor.
getModuleEditor($type= 'document', $module_srl, $upload_target_srl, $primary_key_name, $content_key_name)
Return editor template which contains settings of each module Result of getModuleEditor() is as same ...
high class of the editor odule
getComponentList($filter_enabled=true, $site_srl=0, $from_db=false)
Return a component list (DB Information included)
getComponentXmlInfo($component)
Read xml information of the component.
readDir($path, $filter= '', $to_lower=FALSE, $concat_prefix=FALSE)
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
getComponent($component_name, $site_srl=0)
Get xml and db information of the component.
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang