XE Smartphone 애드온에서 iui를 제거하고 자체 제작한 UI 로 변경

(아직 PC 브라우저에서 최적화 되었고 iphone, 옴니아등에서의 최적화는 다시 진행할 예정입니다)
cafeXE, planet, page모듈에서도 스마트폰에 어울리는 컨텐츠로 스마트폰 환경을 제공하도록 수정


git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6283 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2009-05-06 07:56:01 +00:00
parent 4f8e98ddb0
commit e48e2900e4
45 changed files with 590 additions and 1150 deletions

View file

@ -1,106 +1,109 @@
<?php
class smartphoneXE {
var $module_info = null;
var $content = null;
var $oModule = null;
var $menuList = null;
var $output = null;
function isFromSmartPhone()
{
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$iphoneForce = Context::get('iphone');
return $iphoneForce || $userAgent && (strpos($userAgent, 'iPod') || strpos($userAgent, 'iPhone') || strpos($userAgent, 'PPC')) ;
var $parent_url = null;
var $prev_url = null;
var $next_url = null;
var $content = null;
function isFromSmartPhone() {
return Context::get('smartphone') || preg_match('/(iPopd|iPhone|PPC)/',$_SERVER['HTTP_USER_AGENT']);
}
function &getInstance()
{
static $instance = null;
if($instnace == null)
{
$instance = new smartphoneXE();
return $instance;
function haveSmartphoneModule($module) {
return $oModule =& getModule($module, 'smartphone') && method_exists($oModule,'procSmartPhone');
}
function smartphoneXE($oModule, $module_info, $output) {
$this->oModule = $oModule;
$this->module_info = $module_info;
if(!$this->module_info->menu_srl) {
$oMenuModel = &getAdminModel('menu');
$menus = $oMenuModel->getMenus($this->module_info->site_srl);
if($menus[0]) $this->module_info->menu_srl = $menus[0]->menu_srl;
}
if($this->module_info->menu_srl) {
$menu_cache_file = sprintf(_XE_PATH_.'files/cache/menu/%d.php', $this->module_info->menu_srl);
if(!file_exists($menu_cache_file)) return;
@include $menu_cache_file;
Context::addHtmlHeader(sprintf('<script type="text/javascript"> var xeMenus = { %s } </script>', $this->_getAllItems($menu->list)));
$this->_setParentUrl($menu->list);
}
}
function setModuleInstance(&$oModule) {
if($this->oModule) return;
$this->oModule = $oModule;
function _setParentUrl($menu_list) {
if(!count($menu_list)) return;
foreach($menu_list as $key => $val) {
if(!$val['text']) continue;
if($val['list'] && $this->_setParentUrl($val['list'])) {
$href = $val['href'];
if(preg_match('/^[a-z0-9_]+$/i',$val['url'])) $href = getUrl('','mid',$val['url'],'smartphone','true');
else $href = $val['href'];
$this->setParentUrl($href);
return false;
}
if($val['url']==Context::get('mid')) return true;
}
return false;
}
function _getAllItems($menu_list, $depth=0) {
if(!count($menu_list)) return;
$output = '';
foreach($menu_list as $menu_item)
{
if($output) $output .= ",";
$key = $menu_item['text'];
$val = $menu_item['url'];
if($menu_item['list']) {
$childs = '{'.$this->_getAllItems($menu_item['list'], $depth+1).'}';
} else {
$childs = 'null';
}
$output .= sprintf('"%s" : { "url" : "%s", "childs" : %s } ',str_replace('"','\"',$key), str_replace('"','\"',$val), $childs);
}
return $output;
}
function procSmartPhone() {
if(is_a($this->output, 'Object') || is_subclass_of($this->output, 'Object')) {
$this->setContent($this->output->getMessage());
return;
}
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 {
$this->setContent('요청하신 모듈은 스마트폰을 지원하지 않습니다');
}
}
function setContent($content) {
$this->content = $content;
}
function setModuleInfo(&$module_info)
{
if($this->module_info) return;
$this->module_info = $module_info;
function setParentUrl($url) {
$this->parent_url = $url;
}
function procSmartPhone()
{
if(!$this->module_info) return;
$oModule =& getModule($this->module_info->module, 'smartphone');
if(!$oModule || !method_exists($oModule, 'procSmartPhone') ) return;
$vars = get_object_vars($this->oModule);
if(count($vars)) foreach($vars as $key => $val) $oModule->{$key} = $val;
return $oModule->procSmartPhone($this);
function setPrevUrl($url) {
$this->prev_url = $url;
}
function getAllItems(&$menu_list, $node_srl = 0, $node_text= "Main Menu")
{
if($node_srl == 0) $this->menuList = array();
$obj = null;
$obj->text = $node_text;
$obj->list = array();
foreach($menu_list as $menu_node_srl => $menu_item)
{
$it = null;
if(!preg_match('/^([a-zA-Z0-9\_\-]+)$/', $menu_item['url'])) { continue; }
if($menu_item["list"] && count($menu_item["list"]) > 0)
{
$this->getAllItems($menu_item["list"], $menu_node_srl, $menu_item["text"]);
}
$it->text = $menu_item["text"];
$it->url = $menu_item["url"];
$obj->list[$menu_node_srl] = $it;
}
$this->menuList[$node_srl] = $obj;
function setNextUrl($url) {
$this->next_url = $url;
}
function setMenu()
{
$menu_cache_file = sprintf(_XE_PATH_.'files/cache/menu/%d.php', $this->module_info->menu_srl);
if(!file_exists($menu_cache_file)) return;
include $menu_cache_file;
$this->getAllItems($menu->list);
Context::set('menus', $this->menuList);
}
function display()
{
Context::set('layout', 'none');
$act = Context::get('act');
if($act)
{
$content = $this->procSmartPhone();
}
else
{
Context::set('module_info', $this->module_info);
$this->setMenu();
$oModule =& getModule($this->module_info->module, 'smartphone');
if($oModule && method_exists($oModule, 'procSmartPhone') ) Context::set('bHavePhoneMethod', true);
$oTemplate = new TemplateHandler();
$oContext = &Context::getInstance();
$content = $oTemplate->compile(_XE_PATH_."addons/smartphone/tpl", "layout");
}
print $content;
exit();
}
}
?>