mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 01:23:32 +09:00
mobileXE 시험버전 추가
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4318 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
009d74143f
commit
819f5e7709
8 changed files with 683 additions and 0 deletions
96
addons/mobile/classes/hdml.class.php
Normal file
96
addons/mobile/classes/hdml.class.php
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* HDML Library ver 0.1
|
||||
* @author zero <zero@zeroboard.com>
|
||||
**/
|
||||
class wap extends mobileXE {
|
||||
|
||||
/**
|
||||
* @brief hdml 헤더 출력
|
||||
**/
|
||||
function printHeader() {
|
||||
header("Content-Type:text/x-hdml; charset=".$this->charset);
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
print '<hdml version=3.0 ttl=0 markable=true>';
|
||||
print "\n";
|
||||
print $this->hasChilds()?'<choice name=main>':'<display>';
|
||||
print "\n";
|
||||
|
||||
if($this->upperUrl) {
|
||||
$url = $this->upperUrl;
|
||||
printf('<action type=soft1 task=go dest="%s" label="%s">%s', $url->url, $url->text, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 제목을 출력
|
||||
**/
|
||||
function printTitle() {
|
||||
if($this->totalPage > $this->mobilePage) $titlePageStr = sprintf("(%d/%d)",$this->mobilePage, $this->totalPage);
|
||||
printf('<b><%s%s>%s', $this->title,$titlePageStr,"\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 내용을 출력
|
||||
* hasChilds()가 있으면 목록형을 그렇지 않으면 컨텐츠를 출력
|
||||
**/
|
||||
function printContent() {
|
||||
if($this->hasChilds()) {
|
||||
foreach($this->getChilds() as $key => $val) {
|
||||
if(!$val['link']) continue;
|
||||
printf('<ce task=go label="%s" dest="%s">%s%s',Context::getLang('cmd_select'), $val['href'], $val['text'], "\n");
|
||||
}
|
||||
} else {
|
||||
printf('<wrap>%s<br>%s', $this->getContent(),"\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 버튼을 출력함
|
||||
**/
|
||||
function printBtn() {
|
||||
// 메뉴 형식
|
||||
if($this->hasChilds()) {
|
||||
if($this->prevUrl) {
|
||||
$url = $this->prevUrl;
|
||||
printf('<ce task=go label="%s" dest="%s">%s%s', $url->text, $url->url, $url->text, "\n");
|
||||
}
|
||||
if($this->nextUrl) {
|
||||
$url = $this->nextUrl;
|
||||
printf('<ce task=go label="%s" dest="%s">%s%s', $url->text, $url->url, $url->text, "\n");
|
||||
}
|
||||
if($this->homeUrl) {
|
||||
$url = $this->homeUrl;
|
||||
printf('<ce task=go label="%s" dest="%s">%s%s', $url->text, $url->url, $url->text, "\n");
|
||||
}
|
||||
// 컨텐츠 형식
|
||||
} else {
|
||||
if($this->prevUrl) {
|
||||
$url = $this->prevUrl;
|
||||
printf('<a task=gosub label="%s" dest="%s">%s</a>', $url->text, $url->url, $url->text);
|
||||
}
|
||||
if($this->nextUrl) {
|
||||
$url = $this->nextUrl;
|
||||
printf('<a task=gosub label="%s" dest="%s">%s</a>', $url->text, $url->url, $url->text);
|
||||
}
|
||||
if($this->homeUrl) {
|
||||
$url = $this->homeUrl;
|
||||
printf('<a task=gosub label="%s" dest="%s">%s</a>', $url->text, $url->url, $url->text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 푸터 정보를 출력
|
||||
**/
|
||||
function printFooter() {
|
||||
print $this->hasChilds()?'</choice>':'</display>';
|
||||
print "\n";
|
||||
print("</hdml>");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
63
addons/mobile/classes/mhtml.class.php
Normal file
63
addons/mobile/classes/mhtml.class.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* mhtml Library ver 0.1
|
||||
* @author zero <zero@zeroboard.com>
|
||||
**/
|
||||
class wap extends mobileXE {
|
||||
|
||||
/**
|
||||
* @brief hdml 헤더 출력
|
||||
**/
|
||||
function printHeader() {
|
||||
print("<html>\n");
|
||||
}
|
||||
|
||||
// 제목을 출력
|
||||
function printTitle() {
|
||||
if($this->totalPage > $this->mobilePage) $titlePageStr = sprintf("(%d/%d)",$this->mobilePage, $this->totalPage);
|
||||
printf('<%s%s><br>%s', $this->title,$titlePageStr,"\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 내용을 출력
|
||||
* hasChilds()가 있으면 목록형을 그렇지 않으면 컨텐츠를 출력
|
||||
**/
|
||||
function printContent() {
|
||||
if($this->hasChilds()) {
|
||||
foreach($this->getChilds() as $key => $val) {
|
||||
if(!$val['link']) continue;
|
||||
printf('<a href="%s" accesskey="%s">%s</a><br>%s', $val['href'], $this->getNo(), $val['text'], "\n");
|
||||
}
|
||||
} else {
|
||||
print $this->getContent()."\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 버튼을 출력함
|
||||
**/
|
||||
function printBtn() {
|
||||
if($this->prevUrl) {
|
||||
$url = $this->prevUrl;
|
||||
printf('<a href="%s">%s</a><br>%s', $url->url, $url->text, "\n");
|
||||
}
|
||||
if($this->nextUrl) {
|
||||
$url = $this->nextUrl;
|
||||
printf('<a href="%s">%s</a><br>%s', $url->url, $url->text, "\n");
|
||||
}
|
||||
if($this->upperUrl) {
|
||||
$url = $this->upperUrl;
|
||||
printf('<btn href="%s" name="%s">%s', $url->url, $url->text, "\n");
|
||||
}
|
||||
if($this->homeUrl) {
|
||||
$url = $this->homeUrl;
|
||||
printf('<a btn="%s" href="%s">%s</a>%s', $url->text, $url->url, $url->text, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
// 푸터 정보를 출력
|
||||
function printFooter() {
|
||||
print("</html>\n");
|
||||
}
|
||||
}
|
||||
?>
|
||||
247
addons/mobile/classes/mobile.class.php
Normal file
247
addons/mobile/classes/mobile.class.php
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
<?php
|
||||
/**
|
||||
* Mobile XE Library Class ver 0.1
|
||||
* @author zero <zero@zeroboard.com>
|
||||
* @brief WAP 태그 출력을 위한 라이브러리
|
||||
**/
|
||||
|
||||
class mobileXE {
|
||||
|
||||
// 기본 url
|
||||
var $homeUrl = NULL;
|
||||
var $upperUrl = NULL;
|
||||
var $nextUrl = NULL;
|
||||
var $prevUrl = NULL;
|
||||
|
||||
// 메뉴 네비게이션을 위한 변수
|
||||
var $childs = null;
|
||||
|
||||
// 기본 변수
|
||||
var $title = NULL;
|
||||
var $content = NULL;
|
||||
var $mobilePage = 0;
|
||||
var $totalPage = 1;
|
||||
var $charset = 'euc-kr';
|
||||
var $no = 0;
|
||||
|
||||
// Deck size
|
||||
var $deckSize = 500;
|
||||
|
||||
// getInstance
|
||||
function &getInstance() {
|
||||
static $instance = null;
|
||||
|
||||
if(!$instance) {
|
||||
|
||||
$browserType = mobileXE::getBrowserType();
|
||||
if(!$browserType) return;
|
||||
|
||||
$class_file = sprintf('%saddons/mobile/classes/%s.class.php', _XE_PATH_, $browserType);
|
||||
require_once($class_file);
|
||||
|
||||
Context::loadLang(_XE_PATH_.'addons/mobile/lang');
|
||||
|
||||
$instance = new wap();
|
||||
|
||||
$mobilePage = (int)Context::get('mpage');
|
||||
if(!$mobilePage) $mobilePage = 1;
|
||||
$instance->setMobilePage($mobilePage);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 접속 브라우저의 헤더를 판단하여 브라우저 타입을 return
|
||||
* 모바일 브라우저가 아닐 경우 null return
|
||||
**/
|
||||
function getBrowserType() {
|
||||
// 브라우저 타입을 판별
|
||||
$browserAccept = $_SERVER['HTTP_ACCEPT'];
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||
$wap_sid = $_SERVER['HTTP_X_UP_SUBNO'];
|
||||
|
||||
if(eregi("SKT11", $userAgent)) $browserType = "wml";
|
||||
elseif(eregi("hdml", $browserAccept)) $browserType = "hdml";
|
||||
elseif(eregi("CellPhone", $userAgent)) $browserType = "mhtml";
|
||||
else $browserType = "html";
|
||||
|
||||
$browserType = 'mhtml';
|
||||
// class 지정 (html일 경우 동작 하지 않도록 함)
|
||||
if($browserType == 'html') return null;
|
||||
|
||||
return $browserType;
|
||||
}
|
||||
|
||||
// charset 지정
|
||||
function setCharSet($charset = 'utf-8') {
|
||||
if(!$charset) $charset = 'utf-8';
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
// 모바일 기기의 용량 제한에 다른 가상 페이지 지정
|
||||
function setMobilePage($page=1) {
|
||||
if(!$page) $page = 1;
|
||||
$this->mobilePage = $page;
|
||||
}
|
||||
|
||||
// 목록형 데이터 설정을 위한 child menu지정
|
||||
function setChilds($childs) {
|
||||
// menu개수가 9개 이상일 경우 자체 페이징 처리
|
||||
$menu_count = count($childs);
|
||||
if($menu_count>9) {
|
||||
$startNum = ($this->mobilePage-1)*9;
|
||||
$idx = 0;
|
||||
$new_childs = array();
|
||||
foreach($childs as $k => $v) {
|
||||
if($idx >= $startNum && $idx < $startNum+9) {
|
||||
$new_childs[$k] = $v;
|
||||
}
|
||||
$idx ++;
|
||||
}
|
||||
$childs = $new_childs;
|
||||
|
||||
$this->totalPage = (int)(($menu_count-1)/9)+1;
|
||||
|
||||
// next/prevUrl 지정
|
||||
if($this->mobilePage>1) {
|
||||
$url = getUrl('mid',$_GET['mid'],'mpage',$this->mobilePage-1);
|
||||
$text = sprintf('%s (%d/%d)', Context::getLang('cmd_prev'), $this->mobilePage-1, $this->totalPage);
|
||||
$this->setPrevUrl($url, $text);
|
||||
}
|
||||
|
||||
if($this->mobilePage<$this->totalPage) {
|
||||
$url = getUrl('mid',$_GET['mid'],'mpage',$this->mobilePage+1);
|
||||
$text = sprintf('%s (%d/%d)', Context::getLang('cmd_next'), $this->mobilePage+1, $this->totalPage);
|
||||
$this->setNextUrl($url, $text);
|
||||
}
|
||||
}
|
||||
$this->childs = $childs;
|
||||
}
|
||||
|
||||
// menu 출력대상이 있는지 확인
|
||||
function hasChilds() {
|
||||
return count($this->childs)?true:0;
|
||||
}
|
||||
|
||||
// child menu반환
|
||||
function getChilds() {
|
||||
return $this->childs;
|
||||
}
|
||||
|
||||
// title 지정
|
||||
function setTitle($title) {
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
// title 반환
|
||||
function getTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
// 컨텐츠 지정
|
||||
function setContent($content) {
|
||||
$content = str_replace(array('&','<','>','"','&nbsp;'), array('&','<','>','"',' '), strip_tags($content));
|
||||
|
||||
// 모바일의 경우 한 덱에 필요한 사이즈가 적어서 내용을 모두 페이지로 나눔
|
||||
$contents = array();
|
||||
while($content) {
|
||||
$tmp = cut_str($content, $this->deckSize, '');
|
||||
$contents[] = $tmp;
|
||||
$content = substr($content, strlen($tmp));
|
||||
}
|
||||
|
||||
$this->totalPage = count($contents);
|
||||
|
||||
// next/prevUrl 지정
|
||||
if($this->mobilePage>1) {
|
||||
$url = getUrl('mid',$_GET['mid'],'mpage',$this->mobilePage-1);
|
||||
$text = sprintf('%s (%d/%d)', Context::getLang('cmd_prev'), $this->mobilePage-1, $this->totalPage);
|
||||
$this->setPrevUrl($url, $text);
|
||||
}
|
||||
|
||||
if($this->mobilePage<$this->totalPage) {
|
||||
$url = getUrl('mid',$_GET['mid'],'mpage',$this->mobilePage+1);
|
||||
$text = sprintf('%s (%d/%d)', Context::getLang('cmd_next'), $this->mobilePage+1, $this->totalPage);
|
||||
$this->setNextUrl($url, $text);
|
||||
}
|
||||
|
||||
$this->content = $contents[$this->mobilePage-1];
|
||||
}
|
||||
|
||||
// 컨텐츠 반환
|
||||
function getContent() {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
// home url 지정
|
||||
function setHomeUrl($url, $text) {
|
||||
if(!$url) $url = '#';
|
||||
$this->homeUrl->url = $url;
|
||||
$this->homeUrl->text = $text;
|
||||
}
|
||||
|
||||
// upper url 지정
|
||||
function setUpperUrl($url, $text) {
|
||||
if(!$url) $url = '#';
|
||||
$this->upperUrl->url = $url;
|
||||
$this->upperUrl->text = $text;
|
||||
}
|
||||
|
||||
// prev url 지정
|
||||
function setPrevUrl($url, $text) {
|
||||
if(!$url) $url = '#';
|
||||
$this->prevUrl->url = $url;
|
||||
$this->prevUrl->text = $text;
|
||||
}
|
||||
|
||||
// next url 지정
|
||||
function setNextUrl($url, $text) {
|
||||
if(!$url) $url = '#';
|
||||
$this->nextUrl->url = $url;
|
||||
$this->nextUrl->text = $text;
|
||||
}
|
||||
|
||||
// display
|
||||
function display() {
|
||||
ob_start();
|
||||
|
||||
// 헤더를 출력
|
||||
$this->printHeader();
|
||||
|
||||
// 제목을 출력
|
||||
$this->printTitle();
|
||||
|
||||
// 내용 출력
|
||||
$this->printContent();
|
||||
|
||||
// 버튼 출력
|
||||
$this->printBtn();
|
||||
|
||||
// 푸터를 출력
|
||||
$this->printFooter();
|
||||
|
||||
$content = ob_get_clean();
|
||||
|
||||
debugPrint($content);
|
||||
// 변환 후 출력
|
||||
if(strtolower($this->charset) == 'utf-8') print $content;
|
||||
else print iconv('UTF-8',$this->charset, $content);
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
// 페이지 이동
|
||||
function movepage($url) {
|
||||
header("location:$url");
|
||||
exit();
|
||||
}
|
||||
|
||||
// 목록등에서 일련 번호를 리턴한다
|
||||
function getNo() {
|
||||
$this->no++;
|
||||
$str = $this->no;
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
?>
|
||||
17
addons/mobile/classes/mobile.func.php
Normal file
17
addons/mobile/classes/mobile.func.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
function getListedItems($menu, &$listed_items, &$mid_list) {
|
||||
if(!count($menu)) return;
|
||||
foreach($menu as $node_srl => $item) {
|
||||
if(preg_match('/^([a-zA-Z0-9\_\-]+)$/', $item['url'])) {
|
||||
$mid = $item['mid'] = $item['url'];
|
||||
$mid_list[$node_srl] = $mid;
|
||||
} else {
|
||||
$mid = $item['mid'] = null;
|
||||
}
|
||||
|
||||
$listed_items[$mid] = $item;
|
||||
getListedItems($item['list'], $listed_items, $mid_list);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
74
addons/mobile/classes/wml.class.php
Normal file
74
addons/mobile/classes/wml.class.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* WML Library ver 0.1
|
||||
* @author zero <zero@zeroboard.com>
|
||||
**/
|
||||
class wap extends mobileXE {
|
||||
|
||||
/**
|
||||
* @brief wml 헤더 출력
|
||||
**/
|
||||
function printHeader() {
|
||||
header("Content-Type: text/vnd.wap.wml");
|
||||
header("charset: ".$this->charset);
|
||||
print("<?xml version=\"1.0\" encoding=\"".$this->charset."\"?><!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
|
||||
print("<wml>\n<card>\n<p>\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 제목을 출력
|
||||
**/
|
||||
function printTitle() {
|
||||
if($this->totalPage > $this->mobilePage) $titlePageStr = sprintf("(%d/%d)",$this->mobilePage, $this->totalPage);
|
||||
printf('<%s%s><br/>%s', $this->title,$titlePageStr,"\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 내용을 출력
|
||||
* hasChilds()가 있으면 목록형을 그렇지 않으면 컨텐츠를 출력
|
||||
**/
|
||||
function printContent() {
|
||||
if($this->hasChilds()) {
|
||||
foreach($this->getChilds() as $key => $val) {
|
||||
if(!$val['link']) continue;
|
||||
printf('<do type="%s" label="%s"><go href="%s" /></do>%s', $this->getNo(), $val['text'], $val['href'], "\n");
|
||||
}
|
||||
} else {
|
||||
printf('%s<br/>%s', str_replace("<br>","<br/>",$this->getContent()),"\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 버튼을 출력함
|
||||
**/
|
||||
function printBtn() {
|
||||
if($this->prevUrl) {
|
||||
$url = $this->prevUrl;
|
||||
printf('<do type="%s" label="%s"><go href="%s"/></do>%s', $this->getNo(), $url->text, $url->url, "\n");
|
||||
}
|
||||
if($this->nextUrl) {
|
||||
$url = $this->nextUrl;
|
||||
printf('<do type="%s" label="%s"><go href="%s"/></do>%s', $this->getNo(), $url->text, $url->url, "\n");
|
||||
}
|
||||
if($this->homeUrl) {
|
||||
$url = $this->homeUrl;
|
||||
printf('<do type="access" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
|
||||
}
|
||||
if($this->upperUrl) {
|
||||
$url = $this->upperUrl;
|
||||
printf('<do type="vnd.up" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
// 푸터 정보를 출력
|
||||
function printFooter() {
|
||||
print("</p>\n</card>\n</wml>");
|
||||
}
|
||||
|
||||
// 목록등에서 일련 번호를 리턴한다
|
||||
function getNo() {
|
||||
return "vnd.skmn".parent::getNo();
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue