From 7074da575187acedc636c356015dc43cbbee5d72 Mon Sep 17 00:00:00 2001 From: SMaker Date: Thu, 30 Jan 2014 14:53:20 +0900 Subject: [PATCH 1/2] =?UTF-8?q?editor=20=EB=AA=A8=EB=93=88=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/editor/editor.model.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 246c09286..10c5e7b93 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -718,6 +718,7 @@ class editorModel extends editor $buff .= sprintf('$xml_info->homepage = "%s";', $component_info->homepage); $buff .= sprintf('$xml_info->license = "%s";', $component_info->license); $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); + $buff .= '$xml_info->author = array();'; // Author information if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; else $author_list = $xml_doc->component->author; @@ -751,6 +752,8 @@ class editorModel extends editor $buff .= sprintf('$xml_info->description = "%s";', $xml_info->description); $buff .= sprintf('$xml_info->version = "%s";', $xml_info->version); $buff .= sprintf('$xml_info->date = "%s";', $xml_info->date); + $buff .= '$xml_info->author = array()'; + $buff .= '$xml_info->author[0] = new stdClass();'; $buff .= sprintf('$xml_info->author[0]->name = "%s";', $xml_info->author->name); $buff .= sprintf('$xml_info->author[0]->email_address = "%s";', $xml_info->author->email_address); $buff .= sprintf('$xml_info->author[0]->homepage = "%s";', $xml_info->author->homepage); @@ -760,14 +763,15 @@ class editorModel extends editor if($extra_vars) { if(!is_array($extra_vars)) $extra_vars = array($extra_vars); + + $buff .= '$xml_info->extra_vars = new stdClass();'; + foreach($extra_vars as $key => $val) { unset($obj); $key = $val->attrs->name; $title = $val->title->body; $description = $val->description->body; - $xml_info->extra_vars->{$key}->title = $title; - $xml_info->extra_vars->{$key}->description = $description; $buff .= sprintf('$xml_info->extra_vars->%s = new stdClass();', $key); $buff .= sprintf('$xml_info->extra_vars->%s->%s = "%s";', $key, 'title', $title); From ac24592624efdd8f7bbfa908b693ac53ac1a6f6f Mon Sep 17 00:00:00 2001 From: bnu Date: Sat, 1 Feb 2014 19:54:21 +0900 Subject: [PATCH 2/2] =?UTF-8?q?NOISSUE=20editor=20component=20cache=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20var=5Fexp?= =?UTF-8?q?ort=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/editor/editor.model.php | 108 +++++++++++++------------------- 1 file changed, 45 insertions(+), 63 deletions(-) diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 10c5e7b93..c070fb8fa 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -681,111 +681,93 @@ class editorModel extends editor function getComponentXmlInfo($component) { $lang_type = Context::getLangType(); + // Get xml file path of the requested components $component_path = sprintf('%s/components/%s/', $this->module_path, $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)) { include($cache_file); + return $xml_info; } - // Parse, cache and then return if the cached file doesn't exist + $oParser = new XmlParser(); $xml_doc = $oParser->loadXmlFile($xml_file); + // Component information listed - if($xml_doc->component->version && $xml_doc->component->attrs->version == '0.2') + $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 = new stdClass(); - $component_info->component_name = $component; - $component_info->title = $xml_doc->component->title->body; $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; - - $buff = 'component_name = "%s";', $component_info->component_name); - $buff .= sprintf('$xml_info->title = "%s";', $component_info->title); - $buff .= sprintf('$xml_info->description = "%s";', $component_info->description); - $buff .= sprintf('$xml_info->version = "%s";', $component_info->version); - $buff .= sprintf('$xml_info->date = "%s";', $component_info->date); - $buff .= sprintf('$xml_info->homepage = "%s";', $component_info->homepage); - $buff .= sprintf('$xml_info->license = "%s";', $component_info->license); - $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); - $buff .= '$xml_info->author = array();'; - // Author information - 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++) - { - $buff .= '$xml_info->author[' . $i .']= new stdClass();'; - $buff .= sprintf('$xml_info->author['.$i.']->name = "%s";', $author_list[$i]->name->body); - $buff .= sprintf('$xml_info->author['.$i.']->email_address = "%s";', $author_list[$i]->attrs->email_address); - $buff .= sprintf('$xml_info->author['.$i.']->homepage = "%s";', $author_list[$i]->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); - $xml_info = new stdClass(); - $xml_info->component_name = $component; - $xml_info->title = $xml_doc->component->title->body; - $xml_info->description = str_replace('\n', "\n", $xml_doc->component->author->description->body); - $xml_info->version = $xml_doc->component->attrs->version; - $xml_info->date = $date; - $xml_info->author->name = $xml_doc->component->author->name->body; - $xml_info->author->email_address = $xml_doc->component->author->attrs->email_address; - $xml_info->author->homepage = $xml_doc->component->author->attrs->link; - $buff = 'component_name = "%s";', $xml_info->component_name); - $buff .= sprintf('$xml_info->title = "%s";', $xml_info->title); - $buff .= sprintf('$xml_info->description = "%s";', $xml_info->description); - $buff .= sprintf('$xml_info->version = "%s";', $xml_info->version); - $buff .= sprintf('$xml_info->date = "%s";', $xml_info->date); - $buff .= '$xml_info->author = array()'; - $buff .= '$xml_info->author[0] = new stdClass();'; - $buff .= sprintf('$xml_info->author[0]->name = "%s";', $xml_info->author->name); - $buff .= sprintf('$xml_info->author[0]->email_address = "%s";', $xml_info->author->email_address); - $buff .= sprintf('$xml_info->author[0]->homepage = "%s";', $xml_info->author->homepage); + $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->var; if($extra_vars) { if(!is_array($extra_vars)) $extra_vars = array($extra_vars); - $buff .= '$xml_info->extra_vars = new stdClass();'; - foreach($extra_vars as $key => $val) { - unset($obj); $key = $val->attrs->name; - $title = $val->title->body; - $description = $val->description->body; - - $buff .= sprintf('$xml_info->extra_vars->%s = new stdClass();', $key); - $buff .= sprintf('$xml_info->extra_vars->%s->%s = "%s";', $key, 'title', $title); - $buff .= sprintf('$xml_info->extra_vars->%s->%s = "%s";', $key, 'description', $description); + $extra_var = new stdClass; + $extra_var->title = $val->title->body; + $extra_var->description = $val->description->body; + $component_info->extra_vars->{$key} = $extra_var; } } - $buff .= ' ?>'; + $buff = array(); + $buff[] = '