git-svn-id: http://xe-core.googlecode.com/svn/trunk@228 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-03-05 04:20:40 +00:00
parent b60c71d589
commit 120be5cf60
11 changed files with 300 additions and 11 deletions

View file

@ -0,0 +1,11 @@
<?php
/**
* @class addon
* @author zero (zero@nzeo.com)
* @brief addon 모듈의 high class
**/
class addon extends ModuleObject {
}
?>

View file

@ -0,0 +1,167 @@
<?php
/**
* @class addonModel
* @author zero (zero@nzeo.com)
* @brief addon 모듈의 Model class
**/
class addonModel extends addon {
/**
* @brief 초기화
**/
function init() {
}
/**
* @brief addon의 conf/addon.xml 통해 grant(권한) action 데이터를 return
*
* addon.xml 파일의 경우 파싱하는데 시간이 걸리기에 캐싱을 한다...
* 캐싱을 할때 바로 include 있도록 역시 코드까지 추가하여 캐싱을 한다.
* 이게 퍼포먼스 상으로는 좋은데 어떤 부정적인 결과를 유도할지는 모르겠...
**/
function getModuleActionXml($addon) {
// 요청된 모듈의 경로를 구한다. 없으면 return
$class_path = ModuleHandler::getModulePath($addon);
if(!$class_path) return;
// 해당 경로에 addon.xml 파일이 있는지 체크한다. 없으면 return
$xml_file = sprintf("%sconf/addon.xml", $class_path);
if(!file_exists($xml_file)) return;
// 캐시된 파일이 있는지 확인
$cache_file = sprintf("./files/cache/addon_info/%s.php", $addon);
// 캐시 파일이 없거나 캐시 파일이 xml 파일보다 오래되었으면 내용 다시 갱신
if(!file_exists($cache_file) || filectime($cache_file)<filectime($xml_file)) {
$buff = ""; ///< 캐시 파일에 쓸 buff 변수 설정
$xml_obj = XmlParser::loadXmlFile($xml_file); ///< xml 파일을 읽어서 xml object로 변환
if(!count($xml_obj->addon)) return; ///< xml 내용중에 addon 태그가 없다면 오류;;
$grants = $xml_obj->addon->grants->grant; ///< 권한 정보 (없는 경우도 있음)
$actions = $xml_obj->addon->actions->action; ///< action list (필수)
$default_index = $admin_index = '';
// 권한 정보의 정리
if($grants) {
if(is_array($grants)) $grant_list = $grants;
else $grant_list[] = $grants;
foreach($grant_list as $grant) {
$name = $grant->attrs->name;
$default = $grant->attrs->default?$grant->attrs->default:'guest';
$title = $grant->title->body;
$info->grant->{$name}->title = $title;
$info->grant->{$name}->default = $default;
$buff .= sprintf('$info->grant->%s->title=\'%s\';', $name, $title);
$buff .= sprintf('$info->grant->%s->default=\'%s\';', $name, $default);
}
}
// actions 정리
if($actions) {
if(is_array($actions)) $action_list = $actions;
else $action_list[] = $actions;
foreach($action_list as $action) {
$name = $action->attrs->name;
$type = $action->attrs->type;
$grant = $action->attrs->grant?$action->attrs->grant:'guest';
$standalone = $action->attrs->standalone=='true'?'true':'false';
$index = $action->attrs->index;
$admin_index = $action->attrs->admin_index;
$output->action->{$name}->type = $type;
$output->action->{$name}->grant = $grant;
$output->action->{$name}->standalone= $standalone;
$info->action->{$name}->type = $type;
$info->action->{$name}->grant = $grant;
$info->action->{$name}->standalone = $standalone=='true'?true:false;
$buff .= sprintf('$info->action->%s->type=\'%s\';', $name, $type);
$buff .= sprintf('$info->action->%s->grant=\'%s\';', $name, $grant);
$buff .= sprintf('$info->action->%s->standalone=%s;', $name, $standalone);
if($index=='true') {
$default_index_act = $name;
$info->default_index_act = $name;
}
if($admin_index=='true') {
$admin_index_act = $name;
$info->admin_index_act = $name;
}
}
}
$buff = sprintf('<?php if(!__ZB5__) exit();$info->default_index_act = \'%s\';$info->admin_index_act = \'%s\';%s?>', $default_index_act, $admin_index_act, $buff);
FileHandler::writeFile($cache_file, $buff);
return $info;
}
include $cache_file;
return $info;
}
/**
* @brief 모듈의 conf/info.xml 읽어서 정보를 구함
**/
function getModuleInfoXml($addon) {
// 요청된 모듈의 경로를 구한다. 없으면 return
$addon_path = ModuleHandler::getModulePath($addon);
if(!$addon_path) return;
// 현재 선택된 모듈의 스킨의 정보 xml 파일을 읽음
$xml_file = sprintf("%s/conf/info.xml", $addon_path);
if(!file_exists($xml_file)) return;
$oXmlParser = new XmlParser();
$tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file);
$xml_obj = $tmp_xml_obj->addon;
if(!$xml_obj) return;
$info->title = $xml_obj->title->body;
// 작성자 정보
$addon_info->title = $xml_obj->title->body;
$addon_info->version = $xml_obj->attrs->version;
$addon_info->author->name = $xml_obj->author->name->body;
$addon_info->author->email_address = $xml_obj->author->attrs->email_address;
$addon_info->author->homepage = $xml_obj->author->attrs->link;
$addon_info->author->date = $xml_obj->author->attrs->date;
$addon_info->author->description = $xml_obj->author->description->body;
// history
if(!is_array($xml_obj->history->author)) $history[] = $xml_obj->history->author;
else $history = $xml_obj->history->author;
foreach($history as $item) {
unset($obj);
$obj->name = $item->name->body;
$obj->email_address = $item->attrs->email_address;
$obj->homepage = $item->attrs->link;
$obj->date = $item->attrs->date;
$obj->description = $item->description->body;
$addon_info->history[] = $obj;
}
// action 정보를 얻어서 admin_index를 추가
$action_info = $this->getModuleActionXml($addon);
$addon_info->admin_index_act = $action_info->admin_index_act;
return $addon_info;
}
}
?>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<module version="0.1">
<title xml:lang="ko">애드온 관리</title>
<title xml:lang="en">addon management</title>
<author email_address="zero@zeroboard.com" link="http://www.zeroboard.com" date="2007. 2. 28">
<name xml:lang="ko">제로</name>
<name xml:lang="en">zero</name>
<description xml:lang="ko">애드온 관리 모듈</description>
<description xml:lang="en">addon management</description>
</author>
</module>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<module>
<actions />
</module>

View file

@ -63,5 +63,54 @@
return $list;
}
/**
* @brief 애드온의 종류와 정보를 구함
**/
function getAddonList() {
// addon model 객체 생성
$oAddonModel = &getModel('addon');
// DB 객체 생성
$oDB = &DB::getInstance();
// 다운받은 애드온과 설치된 애드온의 목록을 구함
$downloaded_list = FileHandler::readDir('./files/addons');
$installed_list = FileHandler::readDir('./addons');
$searched_list = array_merge($downloaded_list, $installed_list);
$searched_count = count($searched_list);
if(!$searched_count) return;
for($i=0;$i<$searched_count;$i++) {
// 애드온의 이름
$addon_name = $searched_list[$i];
// 애드온의 경로 (files/addons가 우선)
$path = AddonHandler::getAddonPath($addon_name);
// schemas내의 테이블 생성 xml파일수를 구함
$tmp_files = FileHandler::readDir($path."schemas");
$table_count = count($tmp_files);
// 테이블이 설치되어 있는지 체크
$created_table_count = 0;
for($j=0;$j<count($tmp_files);$j++) {
list($table_name) = explode(".",$tmp_files[$j]);
if($oDB->isTableExists($table_name)) $created_table_count ++;
}
// 해당 애드온의 정보를 구함
$info = $oAddonModel->getAddonInfoXml($addon_name);
unset($obj);
$info->addon = $addon_name;
$info->created_table_count = $created_table_count;
$info->table_count = $table_count;
$info->path = $path;
$info->admin_index_act = $info->admin_index_act;
$list[] = $info;
}
return $list;
}
}
?>

View file

@ -66,7 +66,7 @@
* @brief 모듈의 목록을 보여줌
**/
function dispModuleList() {
// 관리자 모듈 목록을 세팅
// 모듈 목록을 세팅
$oAdminModel = &getModel('admin');
$module_list = $oAdminModel->getModuleList();
Context::set('module_list', $module_list);
@ -74,6 +74,18 @@
$this->setTemplateFile('module_list');
}
/**
* @brief 애드온의 목록을 보여줌
**/
function dispAddonList() {
// 애드온 목록을 세팅
$oAdminModel = &getModel('admin');
$addon_list = $oAdminModel->getAddonList();
Context::set('addon_list', $addon_list);
$this->setTemplateFile('addon_list');
}
/**
* @brief 관리자 로그인 페이지 출력
**/

View file

@ -3,6 +3,7 @@
<actions>
<action name="dispIndex" type="view" standalone="true" index="true"/>
<action name="dispModuleList" type="view" standalone="true" />
<action name="dispAddonList" type="view" standalone="true" />
<action name="dispLogin" type="view" standalone="true" />
<action name="dispLogout" type="view" standalone="true" />

View file

@ -11,11 +11,12 @@
$lang->item_layout = "레이아웃";
$lang->module_name = "모듈 이름";
$lang->module_version = "버전";
$lang->module_author = "제작자";
$lang->module_table_count = "테이블수";
$lang->module_date = "제작일";
$lang->module_installed_path = "설치경로";
$lang->addon_name = "애드온 이름";
$lang->version = "버전";
$lang->author = "제작자";
$lang->table_count = "테이블수";
$lang->date = "제작일";
$lang->installed_path = "설치경로";
$lang->msg_is_not_administrator = '관리자만 접속이 가능합니다';
?>

View file

@ -0,0 +1,32 @@
<table border="1" width="100%">
<tr>
<td>{$lang->addon_name}</td>
<td>{$lang->version}</td>
<td>{$lang->author}</td>
<td>{$lang->date}</td>
<td>{$lang->table_count}</td>
<td>{$lang->installed_path}</td>
</tr>
<!--@foreach($addon_list as $key => $val)-->
<tr>
<td rowspan="2">
<!--@if($val->admin_index_act)-->
<a href="#" onclick="location.href='{getUrl('mo',$val->module,'act',$val->admin_index_act)}'">{$val->title}</a> <br /> ({$val->module})
<!--@else-->
{$val->title} <br />
({$val->module})
<!--@end-->
</td>
<td>{$val->version}</td>
<td><a href="#" onclick="window.open('{$val->author->homepage}')">{$val->author->name}</a></td>
<td>{$val->author->date}</td>
<td>{$val->created_table_count}/{$val->table_count}</td>
<td>{$val->path}</td>
</tr>
<tr>
<td colspan="5">
{nl2br($val->author->description)}
</td>
</tr>
<!--@end-->
</table>

View file

@ -1,11 +1,11 @@
<table border="1" width="100%">
<tr>
<td>{$lang->module_name}</td>
<td>{$lang->module_version}</td>
<td>{$lang->module_author}</td>
<td>{$lang->module_date}</td>
<td>{$lang->module_table_count}</td>
<td>{$lang->module_installed_path}</td>
<td>{$lang->version}</td>
<td>{$lang->author}</td>
<td>{$lang->date}</td>
<td>{$lang->table_count}</td>
<td>{$lang->installed_path}</td>
</tr>
<!--@foreach($module_list as $key => $val)-->
<tr>

View file

@ -145,6 +145,7 @@
'./files/cache/js_filter_compiled',
'./files/cache/template_compiled',
'./files/cache/module_info',
'./files/cache/addon_info',
'./files/attach',
'./files/attach/images',
'./files/attach/binaries',