From 143600306daa9eec80456a87dd5ce8e312fb59ed Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 9 Jul 2020 16:37:04 +0900 Subject: [PATCH] Clean up editor module --- .../FrontEndFileHandler.class.php | 2 +- common/framework/parsers/baseparser.php | 46 +++ .../parsers/editorcomponentparser.php | 62 ++++ modules/editor/editor.admin.view.php | 32 +-- modules/editor/editor.class.php | 4 +- modules/editor/editor.controller.php | 15 +- modules/editor/editor.model.php | 272 ++++++------------ modules/editor/editor.view.php | 12 +- 8 files changed, 215 insertions(+), 230 deletions(-) create mode 100644 common/framework/parsers/editorcomponentparser.php diff --git a/classes/frontendfile/FrontEndFileHandler.class.php b/classes/frontendfile/FrontEndFileHandler.class.php index 15f8b87b4..1e6fc1dc4 100644 --- a/classes/frontendfile/FrontEndFileHandler.class.php +++ b/classes/frontendfile/FrontEndFileHandler.class.php @@ -290,7 +290,7 @@ class FrontEndFileHandler extends Handler return; } - $default_font_config = Context::get('default_font_config') ?: getController('editor')->default_font_config; + $default_font_config = Context::get('default_font_config') ?: EditorModel::$default_font_config; $file->vars['enable_xe_btn_styles'] = (defined('DISABLE_XE_BTN_STYLES') && DISABLE_XE_BTN_STYLES) ? 'false' : 'true'; $file->vars['enable_xe_msg_styles'] = (defined('DISABLE_XE_MSG_STYLES') && DISABLE_XE_MSG_STYLES) ? 'false' : 'true'; $file->vars = array_merge($file->vars, $default_font_config); diff --git a/common/framework/parsers/baseparser.php b/common/framework/parsers/baseparser.php index 4fd57565b..82dd7ee9f 100644 --- a/common/framework/parsers/baseparser.php +++ b/common/framework/parsers/baseparser.php @@ -57,4 +57,50 @@ abstract class BaseParser // If there are no child elements, return an empty string. return ''; } + + /** + * Parse extra_vars. + * + * @param SimpleXMLElement $extra_vars + * @param string $lang + * @return object + */ + protected static function _getExtraVars(\SimpleXMLElement $extra_vars, string $lang): \stdClass + { + $result = new \stdClass; + $group_name = $extra_vars->getName() === 'group' ? self::_getChildrenByLang($extra_vars, 'title', $lang) : null; + foreach ($extra_vars->group ?: [] as $group) + { + $group_result = self::_getExtraVars($group, $lang); + foreach ($group_result as $key => $val) + { + $result->{$key} = $val; + } + } + foreach ($extra_vars->var ?: [] as $var) + { + $item = new \stdClass; + $item->group = $group_name; + $item->name = trim($var['name']); + $item->type = trim($var['type']); + $item->title = self::_getChildrenByLang($var, 'title', $lang); + $item->description = str_replace('\\n', "\n", self::_getChildrenByLang($var, 'description', $lang)); + $item->default = trim($var['default']) ?: null; + $item->value = null; + if ($var->options) + { + $item->options = array(); + foreach ($var->options as $option) + { + $option_item = new \stdClass; + $option_item->title = self::_getChildrenByLang($option, 'title', $lang); + $option_item->value = trim($option['value']); + $item->options[$option_item->value] = $option_item; + } + } + + $result->{$item->name} = $item; + } + return $result; + } } diff --git a/common/framework/parsers/editorcomponentparser.php b/common/framework/parsers/editorcomponentparser.php new file mode 100644 index 000000000..0ab4c73fd --- /dev/null +++ b/common/framework/parsers/editorcomponentparser.php @@ -0,0 +1,62 @@ +component_name = $component_name; + + // Get basic information. + $info->title = self::_getChildrenByLang($xml, 'title', $lang); + $info->description = self::_getChildrenByLang($xml, 'description', $lang); + $info->version = trim($xml->version); + $info->date = date('Ymd', strtotime($xml->date . 'T12:00:00Z')); + $info->homepage = trim($xml->homepage); + $info->license = trim($xml->license); + $info->license_link = trim($xml->license['link']); + $info->author = array(); + + foreach ($xml->author as $author) + { + $author_info = new \stdClass; + $author_info->name = self::_getChildrenByLang($author, 'name', $lang); + $author_info->email_address = trim($author['email_address']); + $author_info->homepage = trim($author['link']); + $info->author[] = $author_info; + } + + // Get extra_vars. + if ($xml->extra_vars) + { + $info->extra_vars = self::_getExtraVars($xml->extra_vars, $lang); + } + + // Return the complete result. + return $info; + } +} diff --git a/modules/editor/editor.admin.view.php b/modules/editor/editor.admin.view.php index 8edcdde89..7eb6dcecd 100644 --- a/modules/editor/editor.admin.view.php +++ b/modules/editor/editor.admin.view.php @@ -22,15 +22,14 @@ class editorAdminView extends editor { // Get module config $oEditorModel = getModel('editor'); - $oModuleModel = getModel('module'); - $editor_config = $oModuleModel->getModuleConfig('editor'); + $editor_config = ModuleModel::getModuleConfig('editor'); if (!is_object($editor_config)) { $editor_config = new stdClass(); } // Use default config for missing values. - foreach ($this->default_editor_config as $key => $val) + foreach (self::$default_editor_config as $key => $val) { if (!isset($editor_config->$key)) { @@ -48,7 +47,7 @@ class editorAdminView extends editor continue; } - $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $skin); + $skin_info = ModuleModel::loadSkinInfo($this->module_path, $skin); foreach ($skin_info->colorset ?: [] as $colorset) { unset($colorset->screenshot); @@ -100,36 +99,31 @@ class editorAdminView extends editor */ function dispEditorAdminSetupComponent() { - $site_module_info = Context::get('site_module_info'); - $site_srl = (int)$site_module_info->site_srl; - - $component_name = Context::get('component_name'); // Get information of the editor component $oEditorModel = getModel('editor'); - $component = $oEditorModel->getComponent($component_name,$site_srl); - + $component_name = Context::get('component_name'); + $component = $oEditorModel->getComponent($component_name); if(!$component->component_name) { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - Context::set('component', $component); + // Get a group list to set a group - $oMemberModel = getModel('member'); - $group_list = $oMemberModel->getGroups($site_srl); + $group_list = MemberModel::getGroups(0); Context::set('group_list', $group_list); - // Get a mid list - $oModuleModel = getModel('module'); + // Get a mid list $args =new stdClass(); - $args->site_srl = $site_srl; + $args->site_srl = 0; $columnList = array('module_srl', 'mid', 'module_category_srl', 'browser_title'); - $mid_list = $oModuleModel->getMidList($args, $columnList); + $mid_list = ModuleModel::getMidList($args, $columnList); + // Combination of module_category and module if(!$args->site_srl) { // Get a list of module category - $module_categories = $oModuleModel->getModuleCategories(); + $module_categories = ModuleModel::getModuleCategories(); if(!is_array($mid_list)) $mid_list = array($mid_list); foreach($mid_list as $module_srl => $module) @@ -139,9 +133,9 @@ class editorAdminView extends editor } else { + $module_categories = array(new stdClass); $module_categories[0]->list = $mid_list; } - Context::set('mid_list',$module_categories); //Security diff --git a/modules/editor/editor.class.php b/modules/editor/editor.class.php index 687db71eb..1d9c51f3a 100644 --- a/modules/editor/editor.class.php +++ b/modules/editor/editor.class.php @@ -10,7 +10,7 @@ class editor extends ModuleObject /** * @brief Default font config */ - public $default_font_config = array( + public static $default_font_config = array( 'default_font_family' => 'inherit', 'default_font_size' => '13px', 'default_line_height' => '160%', @@ -21,7 +21,7 @@ class editor extends ModuleObject /** * @brief Default editor config */ - public $default_editor_config = array( + public static $default_editor_config = array( 'editor_skin' => 'ckeditor', 'editor_colorset' => 'moono-lisa', 'editor_height' => 300, diff --git a/modules/editor/editor.controller.php b/modules/editor/editor.controller.php index 057f623ed..e6d4ecacc 100644 --- a/modules/editor/editor.controller.php +++ b/modules/editor/editor.controller.php @@ -93,18 +93,17 @@ class editorController extends editor $target_module_srl = array_map('trim', explode(',', $target_module_srl)); $logged_info = Context::get('logged_info'); $module_srl = array(); - $oModuleModel = getModel('module'); foreach ($target_module_srl as $srl) { if (!$srl) continue; - $module_info = $oModuleModel->getModuleInfoByModuleSrl($srl); + $module_info = ModuleModel::getModuleInfoByModuleSrl($srl); if (!$module_info->module_srl) { throw new Rhymix\Framework\Exceptions\InvalidRequest; } - $module_grant = $oModuleModel->getGrant($module_info, $logged_info); + $module_grant = ModuleModel::getGrant($module_info, $logged_info); if (!$module_grant->manager) { throw new Rhymix\Framework\Exceptions\NotPermitted; @@ -220,7 +219,7 @@ class editorController extends editor if ($editor_config) { - $default_font_config = $this->default_font_config; + $default_font_config = self::$default_font_config; if ($editor_config->content_font) $default_font_config['default_font_family'] = $editor_config->content_font; if ($editor_config->content_font_size) $default_font_config['default_font_size'] = $editor_config->content_font_size; if ($editor_config->content_line_height) $default_font_config['default_line_height'] = $editor_config->content_line_height; @@ -230,7 +229,7 @@ class editorController extends editor } else { - Context::set('default_font_config', $this->default_font_config); + Context::set('default_font_config', self::$default_font_config); } } @@ -381,8 +380,7 @@ class editorController extends editor return; } - $oDocumentModel = getModel('document'); - $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); + $oSaved = DocumentModel::getDocument($saved_doc->document_srl); if(!$oSaved->isExists()) { if($mode) @@ -512,8 +510,7 @@ class editorController extends editor function triggerCopyModule(&$obj) { - $oModuleModel = getModel('module'); - $editorConfig = $oModuleModel->getModulePartConfig('editor', $obj->originModuleSrl); + $editorConfig = ModuleModel::getModulePartConfig('editor', $obj->originModuleSrl); $oModuleController = getController('module'); if(is_array($obj->moduleSrlList)) diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 36e8a8982..b66a0327f 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -7,7 +7,12 @@ */ class editorModel extends editor { - var $loaded_component_list = array(); + /** + * Cache + */ + protected static $_module_config = array(); + protected static $_loaded_component_list = array(); + /** * @brief Return the editor * @@ -21,21 +26,20 @@ class editorModel extends editor /** * @brief Return editor config for each module */ - function getEditorConfig($module_srl = null) + public static function getEditorConfig($module_srl = null) { // Load editor config for current module. - $oModuleModel = getModel('module'); if ($module_srl) { - if (!$GLOBALS['__editor_module_config__'][$module_srl]) + if (!self::$_module_config[$module_srl]) { - $GLOBALS['__editor_module_config__'][$module_srl] = $oModuleModel->getModulePartConfig('editor', $module_srl); - } - $editor_config = $GLOBALS['__editor_module_config__'][$module_srl]; - if (!is_object($editor_config)) - { - $editor_config = new stdClass; + self::$_module_config[$module_srl] = ModuleModel::getModulePartConfig('editor', $module_srl); + if (!is_object(self::$_module_config[$module_srl])) + { + self::$_module_config[$module_srl] = new stdClass; + } } + $editor_config = self::$_module_config[$module_srl]; } else { @@ -53,7 +57,7 @@ class editorModel extends editor if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); // Load the default config for editor module. - $editor_default_config = $oModuleModel->getModuleConfig('editor') ?: new stdClass; + $editor_default_config = ModuleModel::getModuleConfig('editor') ?: new stdClass; // Check whether we should use the default config. if($editor_config->default_editor_settings !== 'Y' && $editor_default_config->editor_skin && $editor_config->editor_skin && $editor_default_config->editor_skin !== $editor_config->editor_skin) @@ -66,7 +70,7 @@ class editorModel extends editor } // Apply the default config for missing values. - foreach ($this->default_editor_config as $key => $val) + foreach (self::$default_editor_config as $key => $val) { if ($editor_config->default_editor_settings === 'Y' || !isset($editor_config->$key)) { @@ -77,11 +81,14 @@ class editorModel extends editor return $editor_config; } - function getSkinConfig($skin_name) + /** + * @brief Return skin config + */ + public static function getSkinConfig($skin_name) { $skin_config = new stdClass; - if($skin_info = getModel('module')->loadSkinInfo($this->module_path, $skin_name)) + if($skin_info = ModuleModel::loadSkinInfo('./modules/editor', $skin_name)) { foreach ($skin_info->extra_vars as $val) { @@ -97,8 +104,14 @@ class editorModel extends editor * You can call upload_target_srl when modifying content * The upload_target_srl is used for a routine to check if an attachment exists */ - function getEditor($upload_target_srl = 0, $option = null) + public static function getEditor($upload_target_srl = 0, $option = null) { + // Initialize options. + if (!is_object($option)) + { + $option = new stdClass; + + } // Set editor sequence and upload options. if ($upload_target_srl) { @@ -118,17 +131,17 @@ class editorModel extends editor { $option->editor_skin = $option->skin; } - if (!$option->editor_skin || !file_exists($this->module_path . 'skins/' . $option->editor_skin . '/editor.html') || starts_with('xpresseditor', $option->editor_skin) || starts_with('dreditor', $option->editor_skin)) + if (!$option->editor_skin || !file_exists('./modules/editor/skins/' . $option->editor_skin . '/editor.html') || starts_with('xpresseditor', $option->editor_skin) || starts_with('dreditor', $option->editor_skin)) { - $option->editor_skin = $this->default_editor_config['editor_skin']; + $option->editor_skin = self::$default_editor_config['editor_skin']; } if (!$option->editor_colorset) { - $option->editor_colorset = $option->colorset ?: ($option->sel_editor_colorset ?: $this->default_editor_config['editor_colorset']); + $option->editor_colorset = $option->colorset ?: ($option->sel_editor_colorset ?: self::$default_editor_config['editor_colorset']); } if (!$option->editor_height) { - $option->editor_height = $option->height ?: $this->default_editor_config['editor_height']; + $option->editor_height = $option->height ?: self::$default_editor_config['editor_height']; } if ($option->editor_skin === 'ckeditor' && !in_array($option->editor_colorset, array('moono', 'moono-dark', 'moono-lisa'))) { @@ -139,7 +152,7 @@ class editorModel extends editor $option->editor_colorset = 'light'; } Context::set('skin', $option->editor_skin); - Context::set('editor_path', $this->module_path . 'skins/' . $option->editor_skin . '/'); + Context::set('editor_path', './modules/editor/skins/' . $option->editor_skin . '/'); Context::set('colorset', $option->editor_colorset); Context::set('editor_height', $option->editor_height); Context::set('editor_toolbar', $option->editor_toolbar); @@ -152,7 +165,7 @@ class editorModel extends editor Context::set('content_line_height', $option->content_line_height); Context::set('content_paragraph_spacing', $option->content_paragraph_spacing); Context::set('content_word_break', $option->content_word_break); - Context::set('editor_autoinsert_types', $option->autoinsert_types ?? ($option->autoinsert_image !== 'none' ? $this->default_editor_config['autoinsert_types'] : [])); + Context::set('editor_autoinsert_types', $option->autoinsert_types ?? ($option->autoinsert_image !== 'none' ? self::$default_editor_config['autoinsert_types'] : [])); Context::set('editor_autoinsert_position', $option->autoinsert_position ?? $option->autoinsert_image); Context::set('editor_additional_css', $option->additional_css); Context::set('editor_additional_plugins', $option->additional_plugins); @@ -168,7 +181,7 @@ class editorModel extends editor $option->enable_autosave = toBool($option->enable_autosave) && !Context::get($option->primary_key_name); if ($option->enable_autosave) { - Context::set('saved_doc', $this->getSavedDoc($upload_target_srl)); + Context::set('saved_doc', self::getSavedDoc($upload_target_srl)); } Context::set('enable_autosave', $option->enable_autosave); @@ -181,7 +194,7 @@ class editorModel extends editor { if(!Context::get('component_list')) { - $component_list = $this->getComponentList(true); + $component_list = self::getComponentList(true); Context::set('component_list', $component_list); } } @@ -198,8 +211,7 @@ class editorModel extends editor if($option->allow_fileupload) { // Get file upload limits - $oFileModel = getModel('file'); - $file_config = $oFileModel->getUploadConfig(); + $file_config = FileModel::getUploadConfig(); $file_config->allowed_attach_size = $file_config->allowed_attach_size*1024*1024; $file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024; @@ -224,13 +236,13 @@ class editorModel extends editor Context::set('file_config',$file_config); // Configure upload status such as file size - $upload_status = $oFileModel->getUploadStatus(); + $upload_status = FileModel::getUploadStatus(); Context::set('upload_status', $upload_status); // Upload enabled (internally caching) $oFileController = getController('file'); $oFileController->setUploadInfo($option->editor_sequence, $upload_target_srl); // Check if the file already exists - if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); + if($upload_target_srl) $files_count = FileModel::getFilesCount($upload_target_srl); } Context::set('files_count', (int)$files_count); @@ -252,10 +264,10 @@ class editorModel extends editor * 2 types of editors supported; document and comment. * 2 types of editors can be used on a single module. For instance each for original post and reply port. */ - function getModuleEditor($type = 'document', $module_srl, $upload_target_srl, $primary_key_name, $content_key_name) + public static function getModuleEditor($type = 'document', $module_srl, $upload_target_srl, $primary_key_name, $content_key_name) { // Get editor settings of the module - $editor_config = $this->getEditorConfig($module_srl); + $editor_config = self::getEditorConfig($module_srl); // Check mobile status $is_mobile = Mobile::isFromMobilePhone() || \Rhymix\Framework\UA::isMobile(); @@ -397,13 +409,13 @@ class editorModel extends editor // Other settings $option->primary_key_name = $primary_key_name; $option->content_key_name = $content_key_name; - return $this->getEditor($upload_target_srl, $option); + return self::getEditor($upload_target_srl, $option); } /** * @brief Get information which has been auto-saved */ - function getSavedDoc($upload_target_srl) + public static function getSavedDoc($upload_target_srl) { $auto_save_args = new stdClass(); $auto_save_args->module_srl = Context::get('module_srl'); @@ -444,8 +456,7 @@ class editorModel extends editor } // Check if the auto-saved document already exists - $oDocumentModel = getModel('document'); - $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); + $oSaved = DocumentModel::getDocument($saved_doc->document_srl); if($oSaved->isExists()) return; // Move all the files if the auto-saved data contains document_srl and file @@ -480,33 +491,38 @@ class editorModel extends editor /** * @brief create objects of the component */ - function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) + public static function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) { - if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; + if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) + { + return new BaseObject(-1, 'msg_component_is_not_founded', $component); + } - if(!$this->loaded_component_list[$component][$editor_sequence]) + if(!self::$_loaded_component_list[$component][$editor_sequence]) { // Create an object of the component and execute - $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); + $class_path = sprintf('./modules/editor/components/%s/', $component); $class_file = sprintf('%s%s.class.php', $class_path, $component); if(!file_exists($class_file)) return new BaseObject(-1, 'msg_component_is_not_founded', $component); + // Create an object after loading the class file require_once($class_file); $oComponent = new $component($editor_sequence, $class_path); if(!$oComponent) return new BaseObject(-1, 'msg_component_is_not_founded', $component); + // Add configuration information - $component_info = $this->getComponent($component, $site_srl); + $component_info = self::getComponent($component, $site_srl); $oComponent->setInfo($component_info); - $this->loaded_component_list[$component][$editor_sequence] = $oComponent; + self::$_loaded_component_list[$component][$editor_sequence] = $oComponent; } - return $this->loaded_component_list[$component][$editor_sequence]; + return self::$_loaded_component_list[$component][$editor_sequence]; } /** * @brief Return a list of the editor skin */ - function getEditorSkinList() + public static function getEditorSkinList() { return FileHandler::readDir('./modules/editor/skins'); } @@ -514,7 +530,7 @@ class editorModel extends editor /** * @brief Return a component list (DB Information included) */ - function getComponentList($filter_enabled = true, $site_srl = 0, $from_db = false) + public static function getComponentList($filter_enabled = true, $site_srl = 0, $from_db = false) { $cache_key = 'editor:components:' . ($filter_enabled ? 'enabled' : 'all'); $component_list = $from_db ? null : Rhymix\Framework\Cache::get($cache_key); @@ -541,7 +557,7 @@ class editorModel extends editor if(!trim($key)) continue; if(!is_dir(\RX_BASEDIR.'modules/editor/components/'.$key)) { - return $this->getComponentList($filter_enabled, 0, true); + return self::getComponentList($filter_enabled, 0, true); } if(!$filter_enabled) continue; if($val->enabled == "N") @@ -584,7 +600,7 @@ class editorModel extends editor /** * @brief Get xml and db information of the component */ - function getComponent($component_name) + public static function getComponent($component_name) { $args = new stdClass(); $args->component_name = $component_name; @@ -596,7 +612,7 @@ class editorModel extends editor $component_name = $component->component_name; unset($xml_info); - $xml_info = $this->getComponentXmlInfo($component_name); + $xml_info = self::getComponentXmlInfo($component_name); $xml_info->enabled = $component->enabled; $xml_info->target_group = array(); @@ -634,156 +650,30 @@ class editorModel extends editor /** * @brief Read xml information of the component */ - function getComponentXmlInfo($component) + public static function getComponentXmlInfo($component) { - $lang_type = Context::getLangType(); - // Get xml file path of the requested components $component = preg_replace('/[^a-zA-Z0-9-_]/', '', $component); - $component_path = sprintf('%s/components/%s/', $this->module_path, $component); + $component_path = sprintf('%s/components/%s/', './modules/editor', $component); $xml_file = sprintf('%sinfo.xml', $component_path); - $cache_file = sprintf('./files/cache/editor/%s.%s.php', $component, $lang_type); - - // Include and return xml file information if cached file exists - if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) + $xml_mtime = filemtime($xml_file); + $lang_type = Context::getLangType(); + + // Get from cache + $cache_key = sprintf('editor:component:%s:%s:%d', $component, $lang_type, $xml_mtime); + $info = Rhymix\Framework\Cache::get($cache_key); + if ($info !== null && FALSE) { - include($cache_file); - - return $xml_info; + return $info; } - - $oParser = new XmlParser(); - $xml_doc = $oParser->loadXmlFile($xml_file); - - // Component information listed - $component_info = new stdClass; - $component_info->author = array(); - $component_info->extra_vars = new stdClass; - $component_info->component_name = $component; - $component_info->title = $xml_doc->component->title->body; - - if($xml_doc->component->version) - { - $component_info->description = str_replace('\n', "\n", $xml_doc->component->description->body); - $component_info->version = $xml_doc->component->version->body; - $component_info->date = $xml_doc->component->date->body; - $component_info->homepage = $xml_doc->component->link->body; - $component_info->license = $xml_doc->component->license->body; - $component_info->license_link = $xml_doc->component->license->attrs->link; - } - else - { - sscanf($xml_doc->component->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); - $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); - - $component_info->description = str_replace('\n', "\n", $xml_doc->component->author->description->body); - $component_info->version = $xml_doc->component->attrs->version; - $component_info->date = $date; - - $component_info->author = array(); - $component_info->author[0]->name = $xml_doc->component->author->name->body; - $component_info->author[0]->email_address = $xml_doc->component->author->attrs->email_address; - $component_info->author[0]->homepage = $xml_doc->component->author->attrs->link; - } - - // Author information - $author_list = array(); - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; - else $author_list = $xml_doc->component->author; - - for($i = 0; $i < count($author_list); $i++) - { - $author = new stdClass; - $author->name = $author_list[$i]->name->body; - $author->email_address = $author_list[$i]->attrs->email_address; - $author->homepage = $author_list[$i]->attrs->link; - $component_info->author[] = $author; - } - - // List extra variables (text type only for editor component) - $extra_vars = $xml_doc->component->extra_vars; - if($extra_vars) - { - $extra_var_groups = $extra_vars->group; - if(!$extra_var_groups) - { - $extra_var_groups = $extra_vars; - } - if(!is_array($extra_var_groups)) - { - $extra_var_groups = array($extra_var_groups); - } - - foreach($extra_var_groups as $group) - { - $extra_vars = $group->var; - if(!is_array($group->var)) - { - $extra_vars = array($group->var); - } - - foreach($extra_vars as $key => $val) - { - if(!$val) - { - continue; - } - - $obj = new stdClass(); - if(!$val->attrs) - { - $val->attrs = new stdClass(); - } - if(!$val->attrs->type) - { - $val->attrs->type = 'text'; - } - - $obj->group = $group->title->body; - $obj->name = $val->attrs->name; - $obj->title = $val->title->body; - $obj->type = $val->attrs->type; - $obj->description = $val->description->body; - if($obj->name) - { - $obj->value = $extra_vals->{$obj->name}; - } - if(strpos($obj->value, '|@|') != FALSE) - { - $obj->value = explode('|@|', $obj->value); - } - if($obj->type == 'mid_list' && !is_array($obj->value)) - { - $obj->value = array($obj->value); - } - - // 'Select'type obtained from the option list. - if($val->options && !is_array($val->options)) - { - $val->options = array($val->options); - } - - for($i = 0, $c = count($val->options); $i < $c; $i++) - { - $obj->options[$i] = new stdClass(); - $obj->options[$i]->title = $val->options[$i]->title->body; - $obj->options[$i]->value = $val->options[$i]->attrs->value; - } - - $component_info->extra_vars->{$obj->name} = $obj; - } - } - } - - $buff = array(); - $buff[] = 'getEditorConfig($obj->module_srl); + $config = self::getEditorConfig($obj->module_srl); // Get editor skin if (in_array($type, array('document', 'comment'))) @@ -810,7 +700,7 @@ class editorModel extends editor // if not inserted converter, Get converter from skin if (!$converter) { - $converter = $this->getSkinConfig($skin)->converter; + $converter = self::getSkinConfig($skin)->converter; } // if not inserted converter, Check diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index dbfc5df7f..c50254528 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -125,7 +125,6 @@ class editorView extends editor } // Get editors settings - $oModuleModel = getModel('module'); $oEditorModel = getModel('editor'); $editor_config = $oEditorModel->getEditorConfig($current_module_srl); if (!is_object($editor_config)) @@ -134,7 +133,7 @@ class editorView extends editor } // Use default config for missing values. - foreach ($this->default_editor_config as $key => $val) + foreach (self::$default_editor_config as $key => $val) { if (!isset($editor_config->$key)) { @@ -152,7 +151,7 @@ class editorView extends editor continue; } - $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $skin); + $skin_info = ModuleModel::loadSkinInfo($this->module_path, $skin); foreach ($skin_info->colorset ?: [] as $colorset) { unset($colorset->screenshot); @@ -164,9 +163,7 @@ class editorView extends editor Context::set('editor_skin_list', $editor_skin_list); // Get a group list - $oMemberModel = getModel('member'); - $site_module_info = Context::get('site_module_info'); - $group_list = $oMemberModel->getGroups($site_module_info->site_srl); + $group_list = MemberModel::getGroups(); Context::set('group_list', $group_list); //Security @@ -193,8 +190,7 @@ class editorView extends editor function dispEditorSkinColorset() { $skin = Context::get('skin'); - $oModuleModel = getModel('module'); - $skin_info = $oModuleModel->loadSkinInfo($this->module_path,$skin); + $skin_info = ModuleModel::loadSkinInfo($this->module_path,$skin); $colorset = $skin_info->colorset; Context::set('colorset', $colorset); }