#495 addon모듈 XML 포맷 재정비

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4391 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
bnu 2008-07-20 03:28:58 +00:00
parent ef014baa03
commit 495dd1155a
16 changed files with 167 additions and 94 deletions

View file

@ -85,21 +85,34 @@
if(!$xml_obj) return;
// DB에 설정된 내역을 가져온다
$db_args->addon = $addon;
$output = executeQuery('addon.getAddonInfo',$db_args);
$extra_vals = unserialize($output->data->extra_vars);
if($extra_vals->mid_list) {
$addon_info->mid_list = $extra_vals->mid_list;
} else {
$addon_info->mid_list = array();
}
// 애드온 정보
if($xml_obj->version && $xml_obj->attrs->version == '0.2') {
// addon format 0.2
// addon format v0.2
sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
$addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
$addon_info->title = $xml_obj->title->body;
$addon_info->description = trim($xml_obj->description->body);
$addon_info->version = $xml_obj->version->body;
$addon_info->homepage = $xml_obj->link->body;
sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
$addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
$addon_info->license = $xml_obj->license->body;
$addon_info->license_link = $xml_obj->license->attrs->link;
if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author;
else $author_list = $xml_obj->author;
foreach($author_list as $author) {
unset($author_obj);
$author_obj->name = $author->name->body;
@ -108,6 +121,90 @@
$addon_info->author[] = $author_obj;
}
// 확장변수를 정리
if($xml_obj->extra_vars) {
$extra_var_groups = $xml_obj->extra_vars->group;
if(!$extra_var_groups) $extra_var_groups = $xml_obj->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) {
unset($obj);
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;
$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에서 option목록을 구한다.
if(is_array($val->options)) {
$option_count = count($val->options);
for($i = 0; $i < $option_count; $i++) {
$obj->options[$i]->title = $val->options[$i]->title->body;
$obj->options[$i]->value = $val->options[$i]->attrs->value;
}
} else {
$obj->options[0]->title = $val->options[0]->title->body;
$obj->options[0]->value = $val->options[0]->attrs->value;
}
$addon_info->extra_vars[] = $obj;
}
}
}
// history
if($xml_obj->history) {
if(!is_array($xml_obj->history)) $history[] = $xml_obj->history;
else $history = $xml_obj->history;
foreach($history as $item) {
unset($obj);
if($item->author) {
(!is_array($item->author)) ? $obj->author_list[] = $item->author : $obj->author_list = $item->author;
foreach($obj->author_list as $author) {
unset($author_obj);
$author_obj->name = $author->name->body;
$author_obj->email_address = $author->attrs->email_address;
$author_obj->homepage = $author->attrs->link;
$obj->author[] = $author_obj;
}
}
$obj->name = $item->name->body;
$obj->email_address = $item->attrs->email_address;
$obj->homepage = $item->attrs->link;
$obj->version = $item->attrs->version;
$obj->date = $item->attrs->date;
$obj->description = $item->description->body;
if($item->log) {
(!is_array($item->log)) ? $obj->log[] = $item->log : $obj->log = $item->log;
foreach($obj->log as $log) {
unset($log_obj);
$log_obj->text = $log->body;
$log_obj->link = $log->attrs->link;
$obj->logs[] = $log_obj;
}
}
$addon_info->history[] = $obj;
}
}
} else {
// addon format 0.1
$addon_info->addon_name = $addon;
@ -121,95 +218,47 @@
$author_obj->homepage = $xml_obj->author->attrs->link;
$addon_info->author[] = $author_obj;
}
if($xml_obj->extra_vars) {
// 확장변수를 정리
$extra_var_groups = $xml_obj->extra_vars->group;
if(!$extra_var_groups) $extra_var_groups = $xml_obj->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);
// history
if($xml_obj->history) {
if(!is_array($xml_obj->history)) $history[] = $xml_obj->history;
else $history = $xml_obj->history;
foreach($extra_vars as $key => $val) {
unset($obj);
if(!$val->type->body) { $val->type->body = 'text'; }
foreach($history as $item) {
unset($obj);
$obj->group = $group->title->body;
$obj->name = $val->attrs->name;
$obj->title = $val->title->body;
$obj->type = $val->type->body;
$obj->description = $val->description->body;
$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); }
if($item->author) {
(!is_array($item->author)) ? $obj->author_list[] = $item->author : $obj->author_list = $item->author;
// 'select'type에서 option목록을 구한다.
if(is_array($val->options)) {
$option_count = count($val->options);
foreach($obj->author_list as $author) {
unset($author_obj);
$author_obj->name = $author->name->body;
$author_obj->email_address = $author->attrs->email_address;
$author_obj->homepage = $author->attrs->link;
$obj->author[] = $author_obj;
}
}
$obj->name = $item->name->body;
$obj->email_address = $item->attrs->email_address;
$obj->homepage = $item->attrs->link;
$obj->version = $item->attrs->version;
$obj->date = $item->attrs->date;
$obj->description = $item->description->body;
if($item->log) {
(!is_array($item->log)) ? $obj->log[] = $item->log : $obj->log = $item->log;
foreach($obj->log as $log) {
$obj->logs[] = $log->body;
}
}
$addon_info->history[] = $obj;
}
}
// DB에 설정된 내역을 가져온다
$db_args->addon = $addon;
$output = executeQuery('addon.getAddonInfo',$db_args);
$extra_vals = unserialize($output->data->extra_vars);
if($extra_vals->mid_list) {
$addon_info->mid_list = $extra_vals->mid_list;
} else {
$addon_info->mid_list = array();
}
if($xml_obj->extra_vars) {
// 확장변수를 정리
$extra_var_groups = $xml_obj->extra_vars->group;
if(!$extra_var_groups) $extra_var_groups = $xml_obj->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) {
unset($obj);
if(!$val->type->body) { $val->type->body = 'text'; }
$obj->group = $group->title->body;
$obj->name = $val->attrs->name;
$obj->title = $val->title->body;
$obj->type = $val->type->body;
$obj->description = $val->description->body;
$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에서 option목록을 구한다.
if(is_array($val->options)) {
$option_count = count($val->options);
for($i = 0; $i < $option_count; $i++) {
$obj->options[$i]->title = $val->options[$i]->title->body;
$obj->options[$i]->value = $val->options[$i]->value->body;
for($i = 0; $i < $option_count; $i++) {
$obj->options[$i]->title = $val->options[$i]->title->body;
$obj->options[$i]->value = $val->options[$i]->value->body;
}
}
}
$addon_info->extra_vars[] = $obj;
$addon_info->extra_vars[] = $obj;
}
}
}
}
return $addon_info;
}