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@283 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
d2a2e56df4
commit
5e9d217f35
16 changed files with 408 additions and 1 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<!-- 게시판 정보 -->
|
||||
<div>
|
||||
{number_format($total_count)},
|
||||
{$lang->total_count} {number_format($total_count)},
|
||||
{$lang->page_count} : {number_format($page)} / {number_format($total_page)}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
13
modules/layout/addon.class.php
Normal file
13
modules/layout/addon.class.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @class addon
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief addon 모듈의 high class
|
||||
**/
|
||||
|
||||
class addon extends ModuleObject {
|
||||
|
||||
var $cache_file = "./files/cache/activated_addons.cache.php";
|
||||
|
||||
}
|
||||
?>
|
||||
74
modules/layout/addon.controller.php
Normal file
74
modules/layout/addon.controller.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* @class addonController
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief addon 모듈의 Controller class
|
||||
**/
|
||||
|
||||
class addonController extends addon {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 애드온의 활성/비활성 체인지
|
||||
**/
|
||||
function procToggleActivateAddon() {
|
||||
$oAddonModel = &getModel('addon');
|
||||
|
||||
// addon값을 받아옴
|
||||
$addon = Context::get('addon');
|
||||
if($addon) {
|
||||
// 활성화 되어 있으면 비활성화 시킴
|
||||
if($oAddonModel->isActivatedAddon($addon)) $this->doDeactivate($addon);
|
||||
|
||||
// 비활성화 되어 있으면 활성화 시킴
|
||||
else $this->doActivate($addon);
|
||||
}
|
||||
|
||||
// 모듈에서 애드온을 사용하기 위한 캐시 파일 생성
|
||||
$buff = "";
|
||||
$addon_list = $oAddonModel->getActivatedAddons();
|
||||
$addon_count = count($addon_list);
|
||||
for($i=0;$i<$addon_count;$i++) {
|
||||
$addon = trim($addon_list[$i]);
|
||||
if(!$addon) continue;
|
||||
|
||||
$buff .= sprintf(' include("./addons/%s/%s.addon.php"); ', $addon, $addon);
|
||||
}
|
||||
|
||||
$buff = sprintf('<?if(!__ZB5__)exit(); %s ?>', $buff);
|
||||
|
||||
FileHandler::writeFile($this->cache_file, $buff);
|
||||
|
||||
// 페이지를 애드온 목록으로 이동
|
||||
$this->setRedirectUrl("./?module=admin&act=dispAddonList");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 애드온 활성화
|
||||
*
|
||||
* addons라는 테이블에 애드온의 이름을 등록하는 것으로 활성화를 시키게 된다
|
||||
**/
|
||||
function doActivate($addon) {
|
||||
$oDB = &DB::getInstance();
|
||||
$args->addon = $addon;
|
||||
return $oDB->executeQuery('addon.insertAddon', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 애드온 비활성화
|
||||
*
|
||||
* addons라는 테이블에 애드온의 이름을 제거하는 것으로 비활성화를 시키게 된다
|
||||
**/
|
||||
function doDeactivate($addon) {
|
||||
$oDB = &DB::getInstance();
|
||||
$args->addon = $addon;
|
||||
return $oDB->executeQuery('addon.deleteAddon', $args);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
145
modules/layout/addon.model.php
Normal file
145
modules/layout/addon.model.php
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
/**
|
||||
* @class addonModel
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief addon 모듈의 Model class
|
||||
**/
|
||||
|
||||
class addonModel extends addon {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 애드온의 경로를 구함
|
||||
**/
|
||||
function getAddonPath($addon_name) {
|
||||
$class_path = sprintf('./files/addons/%s/', $addon_name);
|
||||
if(is_dir($class_path)) return $class_path;
|
||||
|
||||
$class_path = sprintf('./addons/%s/', $addon_name);
|
||||
if(is_dir($class_path)) return $class_path;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 애드온의 종류와 정보를 구함
|
||||
**/
|
||||
function getAddonList() {
|
||||
// activated된 애드온 목록을 구함
|
||||
$activated_addons = $this->getActivatedAddons();
|
||||
|
||||
// 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 = $this->getAddonPath($addon_name);
|
||||
|
||||
// 해당 애드온의 정보를 구함
|
||||
$info = $this->getAddonInfoXml($addon_name);
|
||||
unset($obj);
|
||||
|
||||
$info->addon = $addon_name;
|
||||
$info->path = $path;
|
||||
|
||||
if(in_array($addon_name, $activated_addons)) $info->activated = true;
|
||||
else $info->activated = false;
|
||||
|
||||
$list[] = $info;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함
|
||||
**/
|
||||
function getAddonInfoXml($addon) {
|
||||
// 요청된 모듈의 경로를 구한다. 없으면 return
|
||||
$addon_path = $this->getAddonPath($addon);
|
||||
if(!$addon_path) return;
|
||||
|
||||
// 현재 선택된 모듈의 스킨의 정보 xml 파일을 읽음
|
||||
$xml_file = sprintf("%sconf/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;
|
||||
}
|
||||
|
||||
return $addon_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 활성화된 애드온 목록을 구해옴
|
||||
**/
|
||||
function getActivatedAddons() {
|
||||
$oDB = &DB::getInstance();
|
||||
$args->list_order = 'addon';
|
||||
$output = $oDB->executeQuery('addon.getAddons', $args);
|
||||
if(!$output->data) return array();
|
||||
if(!is_array($output->data)) $output->data = array($output->data);
|
||||
|
||||
$activated_count = count($output->data);
|
||||
for($i=0;$i<$activated_count;$i++) {
|
||||
$addon = $output->data[$i];
|
||||
$addon_list[] = $addon->addon;
|
||||
}
|
||||
return $addon_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 애드온이 활성화 되어 있는지 체크
|
||||
**/
|
||||
function isActivatedAddon($addon) {
|
||||
$oDB = &DB::getInstance();
|
||||
$args->addon = $addon;
|
||||
$output = $oDB->executeQuery('addon.getAddonIsActivated', $args);
|
||||
if($output->data->count>0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
31
modules/layout/addon.view.php
Normal file
31
modules/layout/addon.view.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* @class addonView
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief addon 모듈의 View class
|
||||
**/
|
||||
|
||||
class addonView extends addon {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
$this->setTemplatePath($this->module_path.'tpl.admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 애드온 목록을 보여줌
|
||||
**/
|
||||
function dispAddonList() {
|
||||
// 애드온 목록을 세팅
|
||||
$oAddonModel = &getModel('addon');
|
||||
$addon_list = $oAddonModel->getAddonList();
|
||||
Context::set('addon_list', $addon_list);
|
||||
|
||||
$this->setTemplateFile('addon_list');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
11
modules/layout/conf/info.xml
Normal file
11
modules/layout/conf/info.xml
Normal 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>
|
||||
6
modules/layout/conf/module.xml
Normal file
6
modules/layout/conf/module.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<module>
|
||||
<actions>
|
||||
<action name="procToggleActivateAddon" type="controller" standalone="true" />
|
||||
</actions>
|
||||
</module>
|
||||
8
modules/layout/queries/deleteAddon.xml
Normal file
8
modules/layout/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>
|
||||
11
modules/layout/queries/getAddonIsActivated.xml
Normal file
11
modules/layout/queries/getAddonIsActivated.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<query id="getAddonIsActivated" action="select">
|
||||
<tables>
|
||||
<table name="addons" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="addon" var="addon" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
8
modules/layout/queries/getAddons.xml
Normal file
8
modules/layout/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/layout/queries/insertAddon.xml
Normal file
9
modules/layout/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/layout/schemas/addons.xml
Normal file
4
modules/layout/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>
|
||||
43
modules/layout/tpl.admin/addon_list.html
Normal file
43
modules/layout/tpl.admin/addon_list.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<!--%import("filter/toggle_activate_addon.xml")-->
|
||||
<!--%import("js/addon.js")-->
|
||||
|
||||
<!-- xml js filter를 이용하기 위한 데이터 전달용 form -->
|
||||
<form id="fo_addon" action="./" method="get">
|
||||
<input type="hidden" name="addon" value="" />
|
||||
</form>
|
||||
|
||||
<!-- 애드온의 목록 -->
|
||||
<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->installed_path}</td>
|
||||
<td>{$lang->use}</td>
|
||||
</tr>
|
||||
<!--@foreach($addon_list as $key => $val)-->
|
||||
<tr>
|
||||
<td rowspan="2">
|
||||
{$val->title} <br />
|
||||
({$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->path}</td>
|
||||
<td rowspan="2">
|
||||
<!--@if($val->activated)-->
|
||||
<a href="#" onclick="doToggleAddon('{$val->addon}');return false;">{$lang->notuse}</a>
|
||||
<!--@else-->
|
||||
<a href="#" onclick="doToggleAddon('{$val->addon}');return false;">{$lang->use}</a>
|
||||
<!--@end-->
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
{nl2br($val->author->description)}
|
||||
</td>
|
||||
</tr>
|
||||
<!--@end-->
|
||||
</table>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<filter name="toggle_activate_addon" module="addon" act="procToggleActivateAddon">
|
||||
<form>
|
||||
<node target="addon" required="true" />
|
||||
</form>
|
||||
<response>
|
||||
<tag name="error" />
|
||||
<tag name="message" />
|
||||
</response>
|
||||
</filter>
|
||||
9
modules/layout/tpl.admin/js/addon.js
Normal file
9
modules/layout/tpl.admin/js/addon.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* @brief 애드온의 활성/비활성 토글용 함수
|
||||
* fo_addon이라는 id를 가지는 form에 인자로 주어진 addon값을 세팅후 실행
|
||||
**/
|
||||
function doToggleAddon(addon) {
|
||||
var fo_obj = xGetElementById('fo_addon');
|
||||
fo_obj.addon.value = addon;
|
||||
procFilter(fo_obj, toggle_activate_addon);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue