smartphone 애드온의 접근 권한 오류 출력 및 스마트폰 네비게이션 개선

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6406 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2009-05-26 02:03:15 +00:00
parent cdeb3f36cc
commit e57019217f
3 changed files with 65 additions and 49 deletions

View file

@ -74,45 +74,44 @@
return $output;
}
function procSmartPhone() {
function procSmartPhone($msg = null) {
if(preg_match('/(iPopd|iPhone)/',$_SERVER['HTTP_USER_AGENT'])) {
Context::addHtmlHeader('<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>');
} else if(preg_match('/PPC/',$_SERVER['HTTP_USER_AGENT'])) {
Context::addHtmlHeader('<meta name="viewport" content="width=240; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>');
}
if(is_a($this->output, 'Object') || is_subclass_of($this->output, 'Object')) {
$this->setContent($this->output->getMessage());
if(is_a($this->output, 'Object') || is_subclass_of($this->output, 'Object') || $msg) {
if($msg) $this->setContent(Context::getLang($msg));
else $this->setContent($this->output->getMessage());
return;
}
if($_GET['mid'] || $_GET['document_srl']) {
if($this->haveSmartphoneModule($this->module_info->module)) {
$oSmartPhoneModule =& getModule($this->module_info->module, 'smartphone');
$vars = get_object_vars($this->oModule);
if(count($vars)) foreach($vars as $key => $val) $oSmartPhoneModule->{$key} = $val;
$oSmartPhoneModule->procSmartPhone($this);
} else {
switch(Context::getLangType()) {
case 'ko' :
$msg = '스마트폰을 지원하지 않는 모듈입니다';
break;
case 'jp' :
$msg = 'このモジュールをサポートしていません。';
break;
case 'zh-TW' :
$msg = '該模塊不支持。';
break;
case 'zh-CN' :
$msg = '该模块不支持。';
break;
default :
$msg = 'This module is not supported.';
break;
}
$this->setContent($msg);
if($this->haveSmartphoneModule($this->module_info->module)) {
$oSmartPhoneModule =& getModule($this->module_info->module, 'smartphone');
$vars = get_object_vars($this->oModule);
if(count($vars)) foreach($vars as $key => $val) $oSmartPhoneModule->{$key} = $val;
$oSmartPhoneModule->procSmartPhone($this);
} else {
switch(Context::getLangType()) {
case 'ko' :
$msg = '스마트폰을 지원하지 않는 모듈입니다';
break;
case 'jp' :
$msg = 'このモジュールをサポートしていません。';
break;
case 'zh-TW' :
$msg = '該模塊不支持。';
break;
case 'zh-CN' :
$msg = '该模块不支持。';
break;
default :
$msg = 'This module is not supported.';
break;
}
}
$this->setContent($msg);
}
}
function setContent($content) {

View file

@ -1,19 +1,31 @@
<?PHP
if(!defined("__ZBXE__")) exit();
if(Context::get('module')=='admin' || $called_position != 'after_module_proc' ) return;
if(Context::get('module')=='admin') return;
require_once(_XE_PATH_.'addons/smartphone/classes/smartphone.class.php');
if(!smartphoneXE::isFromSmartPhone()) return;
$oSmartphoneXE = new smartphoneXE($this, $this->module_info, $output);
$oSmartphoneXE->procSmartPhone();
if($called_position == 'after_module_proc' ) {
$oSmartphoneXE = new smartphoneXE($this, $this->module_info, $output);
$oSmartphoneXE->procSmartPhone();
Context::set('layout', 'none');
Context::set('smart_content', $oSmartphoneXE->content);
Context::set('parent_url', $oSmartphoneXE->parent_url);
Context::set('prev_url', $oSmartphoneXE->prev_url);
Context::set('next_url', $oSmartphoneXE->next_url);
$this->setTemplatePath('addons/smartphone/tpl');
$this->setTemplateFile('layout');
Context::set('layout', 'none');
Context::set('smart_content', $oSmartphoneXE->content);
Context::set('parent_url', $oSmartphoneXE->parent_url);
Context::set('prev_url', $oSmartphoneXE->prev_url);
Context::set('next_url', $oSmartphoneXE->next_url);
$this->setTemplatePath('addons/smartphone/tpl');
$this->setTemplateFile('layout');
} elseif($called_position == 'before_module_proc' && !$this->grant->access) {
$oSmartphoneXE = new smartphoneXE($this, $this->module_info, $output);
$oSmartphoneXE->procSmartPhone('msg_not_permitted_act');
Context::set('layout', 'none');
Context::set('smart_content', $oSmartphoneXE->content);
Context::set('parent_url', $oSmartphoneXE->parent_url);
Context::set('prev_url', $oSmartphoneXE->prev_url);
Context::set('next_url', $oSmartphoneXE->next_url);
$this->setTemplatePath('addons/smartphone/tpl');
$this->setTemplateFile('layout');
}
?>

View file

@ -1,4 +1,5 @@
var xeSmartMenu = null;
var xeSmartUpperMenu = null;
function showXEMenu() {
if(!xeSmartMenu) {
@ -40,9 +41,12 @@ function showXEMenu() {
}
if(xeSmartMenu.css('display')=='none' && typeof(xeMenus)!='undefined') {
xeSmartUpperMenu = null;
var menu = findSmartNode(xeMenus);
if(!menu) menu = xeMenus;
var html = '<ul>';
if(location.href.getQuery('mid')) html += '<li><a href="'+current_url.setQuery('mid','')+'">&lt; go Home &gt;</a></li>';
if(xeSmartUpperMenu) html += '<li><a href="'+current_url.setQuery('mid',xeSmartUpperMenu.url)+'">&lt; go Upper &gt;</a></li>';
for(var text in menu) {
if(!text) continue;
var url = menu[text].url;
@ -77,20 +81,21 @@ function showXEMenu() {
}
function findSmartNode(nodes) {
if(typeof(current_mid)=='undefined') return;
var mid = current_mid;
if(location.href.indexOf(mid)<0&&location.href.indexOf('document_srl')<0) mid = null;
var mid = current_url.getQuery('mid');
if(typeof(mid)=='undefined'||!mid) return nodes;
for(var text in nodes) {
if(!text) continue;
if(nodes[text].url == mid) {
if(nodes[text].childs) return nodes[text].childs;
}
if(nodes[text].childs && nodes[text].childs.length) {
if(nodes[text].childs) {
var n = findSmartNode(nodes[text].childs);
if(n) return n;
if(n) {
xeSmartUpperMenu = nodes[text];
return n;
}
}
if(nodes[text].url == mid) {
if(nodes[text].childs) return nodes[text].childs;
return nodes;
}
}
return null;
}
if(!location.href.getQuery('mid')&&!location.href.getQuery('document_srl')) jQuery(document).ready(showXEMenu);