mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@229 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
120be5cf60
commit
a5d3a12268
14 changed files with 127 additions and 145 deletions
47
modules/addon/addon.controller.php
Normal file
47
modules/addon/addon.controller.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* @class addonController
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief addon 모듈의 Controller class
|
||||
**/
|
||||
|
||||
class addonController extends addon {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 애드온 활성화
|
||||
*
|
||||
* addons라는 테이블에 애드온의 이름을 등록하는 것으로 활성화를 시키게 된다
|
||||
**/
|
||||
function procActivate() {
|
||||
$addon = Context::get('addon');
|
||||
if(!$addon) return;
|
||||
|
||||
$oDB = &DB::getInstance();
|
||||
$args->addon = $addon;
|
||||
$output = $oDB->executeQuery('addon.insertAddon', $args);
|
||||
$this->setRedirectUrl("./?module=admin&act=dispAddonList");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 애드온 비활성화
|
||||
*
|
||||
* addons라는 테이블에 애드온의 이름을 제거하는 것으로 비활성화를 시키게 된다
|
||||
**/
|
||||
function procDeactivate() {
|
||||
$addon = Context::get('addon');
|
||||
if(!$addon) return;
|
||||
|
||||
$oDB = &DB::getInstance();
|
||||
$args->addon = $addon;
|
||||
$output = $oDB->executeQuery('addon.deleteAddon', $args);
|
||||
$this->setRedirectUrl("./?module=admin&act=dispAddonList");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -14,115 +14,28 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief addon의 conf/addon.xml 을 통해 grant(권한) 및 action 데이터를 return
|
||||
*
|
||||
* addon.xml 파일의 경우 파싱하는데 시간이 걸리기에 캐싱을 한다...
|
||||
* 캐싱을 할때 바로 include 할 수 있도록 역시 코드까지 추가하여 캐싱을 한다.
|
||||
* 이게 퍼포먼스 상으로는 좋은데 어떤 부정적인 결과를 유도할지는 잘 모르겠...
|
||||
* @brief 애드온의 경로를 구함
|
||||
**/
|
||||
function getModuleActionXml($addon) {
|
||||
// 요청된 모듈의 경로를 구한다. 없으면 return
|
||||
$class_path = ModuleHandler::getModulePath($addon);
|
||||
if(!$class_path) return;
|
||||
function getAddonPath($addon_name) {
|
||||
$class_path = sprintf('./files/addons/%s/', $addon_name);
|
||||
if(is_dir($class_path)) return $class_path;
|
||||
|
||||
// 해당 경로에 addon.xml 파일이 있는지 체크한다. 없으면 return
|
||||
$xml_file = sprintf("%sconf/addon.xml", $class_path);
|
||||
if(!file_exists($xml_file)) return;
|
||||
$class_path = sprintf('./addons/%s/', $addon_name);
|
||||
if(is_dir($class_path)) return $class_path;
|
||||
|
||||
// 캐시된 파일이 있는지 확인
|
||||
$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;
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함
|
||||
**/
|
||||
function getModuleInfoXml($addon) {
|
||||
function getAddonInfoXml($addon) {
|
||||
// 요청된 모듈의 경로를 구한다. 없으면 return
|
||||
$addon_path = ModuleHandler::getModulePath($addon);
|
||||
$addon_path = $this->getAddonPath($addon);
|
||||
if(!$addon_path) return;
|
||||
|
||||
// 현재 선택된 모듈의 스킨의 정보 xml 파일을 읽음
|
||||
$xml_file = sprintf("%s/conf/info.xml", $addon_path);
|
||||
$xml_file = sprintf("%sconf/info.xml", $addon_path);
|
||||
if(!file_exists($xml_file)) return;
|
||||
|
||||
$oXmlParser = new XmlParser();
|
||||
|
|
@ -156,12 +69,25 @@
|
|||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 활성화된 애드온 목록을 구해옴
|
||||
**/
|
||||
function getActivatedAddons() {
|
||||
$oDB = &DB::getInstance();
|
||||
$args->list_order = 'addon';
|
||||
$output = $oDB->executeQuery('addon.getAddons', $args);
|
||||
if(!$output->data) return array();
|
||||
|
||||
$activated_count = count($output->data);
|
||||
for($i=0;$i<$activated_count;$i++) {
|
||||
$addon = $output->data[$i];
|
||||
$addon_list[] = $addon->addon;
|
||||
}
|
||||
return $addon_list;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<module>
|
||||
<actions />
|
||||
<actions>
|
||||
<action name="procActivate" type="controller" />
|
||||
<action name="procDeactivate" type="controller" />
|
||||
</actions>
|
||||
</module>
|
||||
|
|
|
|||
8
modules/addon/queries/deleteAddon.xml
Normal file
8
modules/addon/queries/deleteAddon.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="deleteAddon" action="delete">
|
||||
<tables>
|
||||
<table name="addons" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="addon" var="addon" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
8
modules/addon/queries/getAddons.xml
Normal file
8
modules/addon/queries/getAddons.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="getAddons" action="select">
|
||||
<tables>
|
||||
<table name="addons" />
|
||||
</tables>
|
||||
<navigation>
|
||||
<index var="list_order" default="addon" order="asc" />
|
||||
</navigation>
|
||||
</query>
|
||||
9
modules/addon/queries/insertAddon.xml
Normal file
9
modules/addon/queries/insertAddon.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<query id="insertAddon" action="insert">
|
||||
<tables>
|
||||
<table name="addons" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="addon" var="addon" notnull="notnull" />
|
||||
<column name="regdate" var="regdate" default="curdate()" />
|
||||
</columns>
|
||||
</query>
|
||||
4
modules/addon/schemas/addons.xml
Normal file
4
modules/addon/schemas/addons.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<table name="addons">
|
||||
<column name="addon" type="varchar" size="250" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="regdate" type="date" index="idx_regdate" />
|
||||
</table>
|
||||
|
|
@ -67,9 +67,12 @@
|
|||
* @brief 애드온의 종류와 정보를 구함
|
||||
**/
|
||||
function getAddonList() {
|
||||
// addon model 객체 생성
|
||||
// addon model 객체 생성
|
||||
$oAddonModel = &getModel('addon');
|
||||
|
||||
// activated된 애드온 목록을 구함
|
||||
$activated_addons = $oAddonModel->getActivatedAddons();
|
||||
|
||||
// DB 객체 생성
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
|
|
@ -85,28 +88,17 @@
|
|||
$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 ++;
|
||||
}
|
||||
$path = $oAddonModel->getAddonPath($addon_name);
|
||||
|
||||
// 해당 애드온의 정보를 구함
|
||||
$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;
|
||||
|
||||
if(in_array($addon_name, $activated_addons)) $info->activated = true;
|
||||
else $info->activated = false;
|
||||
|
||||
$list[] = $info;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,27 +4,29 @@
|
|||
<td>{$lang->version}</td>
|
||||
<td>{$lang->author}</td>
|
||||
<td>{$lang->date}</td>
|
||||
<td>{$lang->table_count}</td>
|
||||
<td>{$lang->installed_path}</td>
|
||||
<td>{$lang->use}</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-->
|
||||
({$val->addon})
|
||||
</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>
|
||||
<td rowspan="2">
|
||||
<!--@if($val->activated)-->
|
||||
<a href="./?module=admin&mo=addon&addon={$val->addon}&act=procActivate">{$lang->notuse}</a>
|
||||
<!--@else-->
|
||||
<a href="./?module=admin&mo=addon&addon={$val->addon}&act=procDeactivate">{$lang->use}</a>
|
||||
<!--@end-->
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<td colspan="4">
|
||||
{nl2br($val->author->description)}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -145,7 +145,6 @@
|
|||
'./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',
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
<table name="module_addon">
|
||||
<column name="module_addon_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="module_srl" type="number" size="11" notnull="notnull" index="idx_module_srl" />
|
||||
<column name="addon" type="varchar" size="80" notnull="notnull" />
|
||||
<column name="act" type="varchar" size="40" notnull="notnull" />
|
||||
<column name="mode" type="varchar" size="6" notnull="notnull" default="before" />
|
||||
<column name="config" type="text" />
|
||||
<column name="regdate" type="date" />
|
||||
</table>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<table name="module_plugin">
|
||||
<column name="module_plugin_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="module_srl" type="number" size="11" notnull="notnull" index="idx_module_srl" />
|
||||
<column name="plugin" type="varchar" size="80" notnull="notnull" />
|
||||
<column name="config" type="text" />
|
||||
<column name="regdate" type="date" />
|
||||
</table>
|
||||
Loading…
Add table
Add a link
Reference in a new issue