#18985672 : separate mobile/pc for addons

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7576 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2010-07-02 09:46:00 +00:00
parent 074074623f
commit 7f325e46e9
16 changed files with 89 additions and 28 deletions

View file

@ -58,7 +58,7 @@
// 애드온 실행 // 애드온 실행
$called_position = 'before_display_content'; $called_position = 'before_display_content';
$oAddonController = &getController('addon'); $oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file); @include($addon_file);
if(method_exists($handler, "prepareToPrint")) $handler->prepareToPrint($output); if(method_exists($handler, "prepareToPrint")) $handler->prepareToPrint($output);

View file

@ -61,7 +61,7 @@
// execute addon (before module initialization) // execute addon (before module initialization)
$called_position = 'before_module_init'; $called_position = 'before_module_init';
$oAddonController = &getController('addon'); $oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file); @include($addon_file);
} }

View file

@ -246,7 +246,7 @@
// addon 실행(called_position 를 before_module_proc로 하여 호출) // addon 실행(called_position 를 before_module_proc로 하여 호출)
$called_position = 'before_module_proc'; $called_position = 'before_module_proc';
$oAddonController = &getController('addon'); $oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file); @include($addon_file);
if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) { if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) {
@ -270,7 +270,7 @@
// addon 실행(called_position 를 after_module_proc로 하여 호출) // addon 실행(called_position 를 after_module_proc로 하여 호출)
$called_position = 'after_module_proc'; $called_position = 'after_module_proc';
$oAddonController = &getController('addon'); $oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file); @include($addon_file);
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) { if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {

View file

@ -24,15 +24,17 @@
// addon값을 받아옴 // addon값을 받아옴
$addon = Context::get('addon'); $addon = Context::get('addon');
$type = Context::get('type');
if(!$type) $type = "pc";
if($addon) { if($addon) {
// 활성화 되어 있으면 비활성화 시킴 // 활성화 되어 있으면 비활성화 시킴
if($oAddonModel->isActivatedAddon($addon, $site_module_info->site_srl)) $this->doDeactivate($addon, $site_module_info->site_srl); if($oAddonModel->isActivatedAddon($addon, $site_module_info->site_srl, $type)) $this->doDeactivate($addon, $site_module_info->site_srl, $type);
// 비활성화 되어 있으면 활성화 시킴 // 비활성화 되어 있으면 활성화 시킴
else $this->doActivate($addon, $site_module_info->site_srl); else $this->doActivate($addon, $site_module_info->site_srl, $type);
} }
$this->makeCacheFile($site_module_info->site_srl); $this->makeCacheFile($site_module_info->site_srl, $type);
} }
/** /**
@ -50,7 +52,8 @@
$this->doSetup($addon_name, $args, $site_module_info->site_srl); $this->doSetup($addon_name, $args, $site_module_info->site_srl);
$this->makeCacheFile($site_module_info->site_srl); $this->makeCacheFile($site_module_info->site_srl, "pc");
$this->makeCacheFile($site_module_info->site_srl, "mobile");
} }
@ -71,9 +74,10 @@
* @brief 애드온 활성화 * @brief 애드온 활성화
* addons라는 테이블에 애드온의 활성화 상태를 on 시켜줌 * addons라는 테이블에 애드온의 활성화 상태를 on 시켜줌
**/ **/
function doActivate($addon, $site_srl = 0) { function doActivate($addon, $site_srl = 0, $type = "pc") {
$args->addon = $addon; $args->addon = $addon;
$args->is_used = 'Y'; if($type == "pc") $args->is_used = 'Y';
else $args->is_used_m = "Y";
if(!$site_srl) return executeQuery('addon.updateAddon', $args); if(!$site_srl) return executeQuery('addon.updateAddon', $args);
$args->site_srl = $site_srl; $args->site_srl = $site_srl;
return executeQuery('addon.updateSiteAddon', $args); return executeQuery('addon.updateSiteAddon', $args);
@ -84,9 +88,10 @@
* *
* addons라는 테이블에 애드온의 이름을 제거하는 것으로 비활성화를 시키게 된다 * addons라는 테이블에 애드온의 이름을 제거하는 것으로 비활성화를 시키게 된다
**/ **/
function doDeactivate($addon, $site_srl = 0) { function doDeactivate($addon, $site_srl = 0, $type = "pc") {
$args->addon = $addon; $args->addon = $addon;
$args->is_used = 'N'; if($type == "pc") $args->is_used = 'N';
else $args->is_used_m = 'N';
if(!$site_srl) return executeQuery('addon.updateAddon', $args); if(!$site_srl) return executeQuery('addon.updateAddon', $args);
$args->site_srl = $site_srl; $args->site_srl = $site_srl;
return executeQuery('addon.updateSiteAddon', $args); return executeQuery('addon.updateSiteAddon', $args);

View file

@ -50,6 +50,7 @@
$info->addon = $addon_name; $info->addon = $addon_name;
$info->path = $path; $info->path = $path;
$info->activated = false; $info->activated = false;
$info->mactivated = false;
// DB에 입력되어 있는지 확인 // DB에 입력되어 있는지 확인
if(!in_array($addon_name, array_keys($inserted_addons))) { if(!in_array($addon_name, array_keys($inserted_addons))) {
@ -60,6 +61,7 @@
// 활성화 되어 있는지 확인 // 활성화 되어 있는지 확인
} else { } else {
if($inserted_addons[$addon_name]->is_used=='Y') $info->activated = true; if($inserted_addons[$addon_name]->is_used=='Y') $info->activated = true;
if($inserted_addons[$addon_name]->is_used_m=='Y') $info->mactivated = true;
} }
$list[] = $info; $list[] = $info;
@ -292,12 +294,16 @@
/** /**
* @brief 애드온이 활성화 되어 있는지 체크 * @brief 애드온이 활성화 되어 있는지 체크
**/ **/
function isActivatedAddon($addon, $site_srl = 0) { function isActivatedAddon($addon, $site_srl = 0, $type = "pc") {
$args->addon = $addon; $args->addon = $addon;
if(!$site_srl) $output = executeQuery('addon.getAddonIsActivated', $args); if(!$site_srl) {
if($type == "pc") $output = executeQuery('addon.getAddonIsActivated', $args);
else $output = executeQuery('addon.getMAddonIsActivated', $args);
}
else { else {
$args->site_srl = $site_srl; $args->site_srl = $site_srl;
$output = executeQuery('addon.getSiteAddonIsActivated', $args); if($type == "pc") $output = executeQuery('addon.getSiteAddonIsActivated', $args);
else $output = executeQuery('addon.getSiteMAddonIsActivated', $args);
} }
if($output->data->count>0) return true; if($output->data->count>0) return true;
return false; return false;

View file

@ -7,7 +7,7 @@
class addon extends ModuleObject { class addon extends ModuleObject {
var $cache_file = "./files/cache/activated_addons.cache.php"; var $cache_file = "./files/cache/activated_addons.ache.php";
/** /**
* @brief 설치시 추가 작업이 필요할시 구현 * @brief 설치시 추가 작업이 필요할시 구현
@ -43,6 +43,9 @@
**/ **/
function checkUpdate() { function checkUpdate() {
if(file_exists($this->cache_file)) FileHandler::removeFile($this->cache_file); if(file_exists($this->cache_file)) FileHandler::removeFile($this->cache_file);
$oDB = &DB::getInstance();
if(!$oDB->isColumnExists("addons", "is_used_m")) return true;
if(!$oDB->isColumnExists("addons_site", "is_used_m")) return true;
return false; return false;
} }
@ -50,6 +53,13 @@
* @brief 업데이트 실행 * @brief 업데이트 실행
**/ **/
function moduleUpdate() { function moduleUpdate() {
$oDB = &DB::getInstance();
if(!$oDB->isColumnExists("addons", "is_used_m")) {
$oDB->addColumn("addons", "is_used_m", "char", 1, "N", true);
}
if(!$oDB->isColumnExists("addons_site", "is_used_m")) {
$oDB->addColumn("addons_site", "is_used_m", "char", 1, "N", true);
}
return new Object(); return new Object();
} }

View file

@ -17,20 +17,20 @@
/** /**
* @brief 메인/ 가상 사이트별 애드온 캐시 파일의 위치를 구함 * @brief 메인/ 가상 사이트별 애드온 캐시 파일의 위치를 구함
**/ **/
function getCacheFilePath() { function getCacheFilePath($type = "pc") {
$site_module_info = Context::get('site_module_info'); $site_module_info = Context::get('site_module_info');
$site_srl = $site_module_info->site_srl; $site_srl = $site_module_info->site_srl;
$addon_path = _XE_PATH_.'files/cache/addons/'; $addon_path = _XE_PATH_.'files/cache/addons/';
if($site_srl) $addon_file = $addon_path.$site_srl.'.acivated_addons.cache.php'; if($site_srl) $addon_file = $addon_path.$site_srl.$type.'.acivated_addons.cache.php';
else $addon_file = $addon_path.'acivated_addons.cache.php'; else $addon_file = $addon_path.$type.'acivated_addons.cache.php';
if($this->addon_file_called) return $addon_file; if($this->addon_file_called) return $addon_file;
$this->addon_file_called = true; $this->addon_file_called = true;
if(!is_dir($addon_path)) FileHandler::makeDir($addon_path); if(!is_dir($addon_path)) FileHandler::makeDir($addon_path);
if(!file_exists($addon_file)) $this->makeCacheFile($site_srl); if(!file_exists($addon_file)) $this->makeCacheFile($site_srl, $type);
return $addon_file; return $addon_file;
} }
@ -120,14 +120,15 @@
/** /**
* @brief 캐시 파일 생성 * @brief 캐시 파일 생성
**/ **/
function makeCacheFile($site_srl = 0) { function makeCacheFile($site_srl = 0, $type = "pc") {
// 모듈에서 애드온을 사용하기 위한 캐시 파일 생성 // 모듈에서 애드온을 사용하기 위한 캐시 파일 생성
$buff = ""; $buff = "";
$oAddonModel = &getAdminModel('addon'); $oAddonModel = &getAdminModel('addon');
$addon_list = $oAddonModel->getInsertedAddons($site_srl); $addon_list = $oAddonModel->getInsertedAddons($site_srl, $type);
foreach($addon_list as $addon => $val) { foreach($addon_list as $addon => $val) {
if($val->addon == "smartphone") continue; if($val->addon == "smartphone") continue;
if($val->is_used != 'Y' || !is_dir(_XE_PATH_.'addons/'.$addon) ) continue; if(!is_dir(_XE_PATH_.'addons/'.$addon)) continue;
if(($type == "pc" && $val->is_used != 'Y') || ($type == "mobile" && $val->is_used_m != 'Y')) continue;
$extra_vars = unserialize($val->extra_vars); $extra_vars = unserialize($val->extra_vars);
$mid_list = $extra_vars->mid_list; $mid_list = $extra_vars->mid_list;
@ -147,8 +148,8 @@
$addon_path = _XE_PATH_.'files/cache/addons/'; $addon_path = _XE_PATH_.'files/cache/addons/';
if(!is_dir($addon_path)) FileHandler::makeDir($addon_path); if(!is_dir($addon_path)) FileHandler::makeDir($addon_path);
if($site_srl) $addon_file = $addon_path.$site_srl.'.acivated_addons.cache.php'; if($site_srl) $addon_file = $addon_path.$site_srl.$type.'.acivated_addons.cache.php';
else $addon_file = $addon_path.'acivated_addons.cache.php'; else $addon_file = $addon_path.$type.'acivated_addons.cache.php';
FileHandler::writeFile($addon_file, $buff); FileHandler::writeFile($addon_file, $buff);
} }

View file

@ -0,0 +1,12 @@
<query id="getMAddonIsActivated" action="select">
<tables>
<table name="addons" />
</tables>
<columns>
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="addon" var="addon" notnull="notnull" />
<condition operation="equal" column="is_used_m" default="Y" notnull="notnull" pipe="and" />
</conditions>
</query>

View file

@ -1,4 +1,4 @@
<query id="getAddonIsActivated" action="select"> <query id="getSiteAddonIsActivated" action="select">
<tables> <tables>
<table name="addons_site" /> <table name="addons_site" />
</tables> </tables>

View file

@ -0,0 +1,13 @@
<query id="getSiteMAddonIsActivated" action="select">
<tables>
<table name="addons_site" />
</tables>
<columns>
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="site_srl" var="site_srl" notnull="notnull" />
<condition operation="equal" column="addon" var="addon" notnull="notnull" pipe="and" />
<condition operation="equal" column="is_used_m" default="Y" notnull="notnull" pipe="and" />
</conditions>
</query>

View file

@ -4,6 +4,7 @@
</tables> </tables>
<columns> <columns>
<column name="is_used" var="is_used" /> <column name="is_used" var="is_used" />
<column name="is_used_m" var="is_used_m" />
<column name="extra_vars" var="extra_vars" /> <column name="extra_vars" var="extra_vars" />
</columns> </columns>
<conditions> <conditions>

View file

@ -4,6 +4,7 @@
</tables> </tables>
<columns> <columns>
<column name="is_used" var="is_used" /> <column name="is_used" var="is_used" />
<column name="is_used_m" var="is_used_m" />
<column name="extra_vars" var="extra_vars" /> <column name="extra_vars" var="extra_vars" />
</columns> </columns>
<conditions> <conditions>

View file

@ -1,6 +1,7 @@
<table name="addons"> <table name="addons">
<column name="addon" type="varchar" size="250" notnull="notnull" primary_key="primary_key" /> <column name="addon" type="varchar" size="250" notnull="notnull" primary_key="primary_key" />
<column name="is_used" type="char" size="1" default="Y" notnull="notnull" /> <column name="is_used" type="char" size="1" default="Y" notnull="notnull" />
<column name="is_used_m" type="char" size="1" default="N" notnull="notnull" />
<column name="extra_vars" type="text" /> <column name="extra_vars" type="text" />
<column name="regdate" type="date" index="idx_regdate" /> <column name="regdate" type="date" index="idx_regdate" />
</table> </table>

View file

@ -2,6 +2,7 @@
<column name="site_srl" type="number" size="11" notnull="notnull" default="0" unique="unique_addon_site" /> <column name="site_srl" type="number" size="11" notnull="notnull" default="0" unique="unique_addon_site" />
<column name="addon" type="varchar" size="250" notnull="notnull" unique="unique_addon_site" /> <column name="addon" type="varchar" size="250" notnull="notnull" unique="unique_addon_site" />
<column name="is_used" type="char" size="1" default="Y" notnull="notnull" /> <column name="is_used" type="char" size="1" default="Y" notnull="notnull" />
<column name="is_used_m" type="char" size="1" default="N" notnull="notnull" />
<column name="extra_vars" type="text" /> <column name="extra_vars" type="text" />
<column name="regdate" type="date" index="idx_regdate" /> <column name="regdate" type="date" index="idx_regdate" />
</table> </table>

View file

@ -9,8 +9,10 @@ function doToggleAddon(addon) {
} }
// 관리자 제어판 페이지용 // 관리자 제어판 페이지용
function doToggleAddonInAdmin(obj, addon) { function doToggleAddonInAdmin(obj, addon, type) {
var params = new Array(); var params = new Array();
params['addon'] = addon; params['addon'] = addon;
if(typeof(type) == "undefined") type = "pc";
params['type'] = type;
exec_xml('addon','procAddonAdminToggleActivate',params,function() { if(/Active/.test(obj.className)) obj.className = "buttonSet buttonDisable"; else obj.className = "buttonSet buttonActive"; } ); exec_xml('addon','procAddonAdminToggleActivate',params,function() { if(/Active/.test(obj.className)) obj.className = "buttonSet buttonDisable"; else obj.className = "buttonSet buttonActive"; } );
} }

View file

@ -89,7 +89,8 @@
<tr> <tr>
<th><div>{$lang->addon}</div></th> <th><div>{$lang->addon}</div></th>
<th><div>{$lang->cmd_setup}</div></th> <th><div>{$lang->cmd_setup}</div></th>
<th><div>{$lang->status}</div></th> <th><div>PC</div></th>
<th><div>Mobile</div></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -104,6 +105,13 @@
<a href="#" onclick="doToggleAddonInAdmin(this, '{$val->addon}');return false;" title="{htmlspecialchars($lang->notuse)}" class="buttonSet buttonDisable"><span>{$lang->notuse}</span></a> <a href="#" onclick="doToggleAddonInAdmin(this, '{$val->addon}');return false;" title="{htmlspecialchars($lang->notuse)}" class="buttonSet buttonDisable"><span>{$lang->notuse}</span></a>
<!--@end--> <!--@end-->
</td> </td>
<td>
<!--@if($val->mactivated)-->
<a href="#" onclick="doToggleAddonInAdmin(this, '{$val->addon}', 'mobile');return false;" title="{htmlspecialchars($lang->use)}" class="buttonSet buttonActive"><span>{$lang->use}</span></a>
<!--@else-->
<a href="#" onclick="doToggleAddonInAdmin(this, '{$val->addon}', 'mobile');return false;" title="{htmlspecialchars($lang->notuse)}" class="buttonSet buttonDisable"><span>{$lang->notuse}</span></a>
<!--@end-->
</td>
</tr> </tr>
<!--@end--> <!--@end-->
</tbody> </tbody>