merge & tag 1.4.3

git-svn-id: http://xe-core.googlecode.com/svn/trunk@7597 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2010-07-06 08:29:10 +00:00
parent 762ebbf445
commit 289973781a
200 changed files with 2296 additions and 1827 deletions

View file

@ -158,22 +158,6 @@
if(file_exists(_XE_PATH_.'.htaccess')&&$this->db_info->use_rewrite == 'Y') $this->allow_rewrite = true;
else $this->allow_rewrite = false;
// add common JS/CSS files
$this->addJsFile("./common/js/jquery.js", true, '', -100000);
$this->addJsFile("./common/js/x.js");
$this->addJsFile("./common/js/common.js");
$this->addJsFile("./common/js/js_app.js");
$this->addJsFile("./common/js/xml_handler.js");
$this->addJsFile("./common/js/xml_js_filter.js");
$this->addCSSFile("./common/css/default.css");
$this->addCSSFile("./common/css/button.css");
// for admin page, add admin css
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0){
$this->addCssFile("./modules/admin/tpl/css/font.css", true, 'all', '',10000);
$this->addCssFile("./modules/admin/tpl/css/pagination.css", true, 'all', '', 100001);
$this->addCssFile("./modules/admin/tpl/css/admin.css", true, 'all', '', 100002);
}
// set locations for javascript use
if($_SERVER['REQUEST_METHOD'] == 'GET') {
@ -1179,7 +1163,7 @@
/**
* @brief js file을 추가
**/
function _addJsFile($file, $optimized, $targetie,$index) {
function _addJsFile($file, $optimized = true, $targetie = '',$index=null) {
if(strpos($file,'://')===false && $file{0}!='/' && $file{0}!='.') $file = './'.$file;
$file = preg_replace('@/\./|(?<!:)\/\/@', '/', $file);
while(strpos($file,'/../')) $file = preg_replace('/\/([^\/]+)\/\.\.\//s','/',$file,1);
@ -1277,7 +1261,7 @@
/**
* @brief CSS file 추가
**/
function _addCSSFile($file, $optimized, $media, $targetie, $index) {
function _addCSSFile($file, $optimized = true, $media = 'all', $targetie = '', $index = null) {
if(strpos($file,'://')===false && substr($file,0,1)!='/' && substr($file,0,1)!='.') $file = './'.$file;
$file = str_replace(array('/./','//'),'/',$file);
while(strpos($file,'/../')) $file = preg_replace('/\/([^\/]+)\/\.\.\//s','/',$file,1);

View file

@ -668,23 +668,44 @@
} else {
if(strpos($name,'.')!=false) {
list($prefix, $name) = explode('.',$name);
if (strpos ($prefix, "(")) {
$tmpval = explode ("(", $prefix);
$tmpval[1] = sprintf ('"%s"', $tmpval[1]);
$prefix = implode ("(", $tmpval);
$flag_of_function = true;
if (($now_matchs = preg_match_all ("/\(/", $prefix, $xtmp)) > 0) {
if ($now_matchs == 1) {
$tmpval = explode ("(", $prefix);
$tmpval[1] = sprintf ('"%s"', $tmpval[1]);
$prefix = implode ("(", $tmpval);
$tmpval = explode (")", $name);
$tmpval[0] = sprintf ('"%s"', $tmpval[0]);
$name = implode (")", $tmpval);
}
}
else $prefix = sprintf('"%s"',$prefix);
if ($flag_of_function === true) {
$tmpval = explode (")", $name);
$tmpval[0] = sprintf ('"%s"', $tmpval[0]);
$name = implode (")", $tmpval);
$flag_of_function = false;
else {
$prefix = sprintf('"%s"',$prefix);
$name = ($name == '*') ? $name : sprintf('"%s"',$name);
}
else $name = ($name == '*') ? $name : sprintf('"%s"',$name);
$xtmp = null;
$now_matchs = null;
$column_list[] = sprintf($click_count,sprintf('%s.%s', $prefix, $name)) . ($alias ? sprintf(' as %s',$alias) : '');
} elseif (($now_matchs = preg_match_all ("/\(/", $name, $xtmp)) > 0) {
if ($now_matchs == 1 && preg_match ("/[a-zA-Z0-9]*\(\*\)/", $name) < 1) {
$open_pos = strpos ($name, "(");
$close_pos = strpos ($name, ")");
if (preg_match ("/,/", $name)) {
$tmp_func_name = sprintf ('%s', substr ($name, 0, $open_pos));
$tmp_params = sprintf ('%s', substr ($name, $open_pos + 1, $close_pos - $open_pos - 1));
$tmpval = null;
$tmpval = explode (',', $tmp_params);
foreach ($tmpval as $tmp_param) {
$tmp_param_list[] = (!is_numeric ($tmp_param)) ? sprintf ('"%s"', $tmp_param) : $tmp_param;
}
$tmpval = implode (',', $tmp_param_list);
$name = sprintf ('%s(%s)', $tmp_func_name, $tmpval);
} else {
$name = sprintf ('%s("%s")',
substr ($name, 0, $open_pos),
substr ($name, $open_pos + 1, $close_pos - $open_pos - 1));
}
}
$column_list[] = sprintf ($click_count,$name) . ($alias ? sprintf (' as %s', $alias) : '');
} else {
$column_list[] = sprintf($click_count,$name) . ($alias ? sprintf(' as %s',$alias) : '');
}

View file

@ -13,6 +13,7 @@
var $content_size = 0; ///< 출력하는 컨텐츠의 사이즈
var $gz_enabled = false; ///< gzip 압축하여 컨텐츠 호출할 것인지에 대한 flag변수
var $handler = null;
/**
* @brief print either html or xml content given oModule object
@ -31,68 +32,25 @@
) $this->gz_enabled = true;
// request method에 따른 컨텐츠 결과물 추출
if(Context::get('xeVirtualRequestMethod')=='xml') $output = $this->_toVirtualXmlDoc($oModule);
else if(Context::getRequestMethod() == 'XMLRPC') {
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) $this->gz_enabled = false;
$output = $this->_toXmlDoc($oModule);
if(Context::get('xeVirtualRequestMethod')=='xml') {
require_once("./classes/display/VirtualXMLDisplayHandler.php");
$handler = new VirtualXMLDisplayHandler();
}
else if(Context::getRequestMethod() == 'XMLRPC') {
require_once("./classes/display/XMLDisplayHandler.php");
$handler = new XMLDisplayHandler();
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) $this->gz_enabled = false;
}
else if(Context::getRequestMethod() == 'JSON') {
require_once("./classes/display/JSONDisplayHandler.php");
$handler = new JSONDisplayHandler();
}
else {
require_once("./classes/display/HTMLDisplayHandler.php");
$handler = new HTMLDisplayHandler();
}
else if(Context::getRequestMethod() == 'JSON') $output = $this->_toJSON($oModule);
else $output = $this->_toHTMLDoc($oModule);
// HTML 출력 요청일 경우 레이아웃 컴파일과 더블어 완성된 코드를 제공
if(Context::getResponseMethod()=="HTML") {
// 관리자 모드일 경우 #xeAdmin id를 가지는 div 추가
if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin')>0) $output = '<div id="xeAdmin">'.$output.'</div>';
// 내용을 content라는 변수로 설정 (layout에서 {$output}에서 대체됨)
Context::set('content', $output);
// 레이아웃을 컴파일
$oTemplate = &TemplateHandler::getInstance();
// layout이라는 변수가 none으로 설정되면 기본 레이아웃으로 변경
if(Context::get('layout') != 'none') {
if(__DEBUG__==3) $start = getMicroTime();
$layout_path = $oModule->getLayoutPath();
$layout_file = $oModule->getLayoutFile();
$edited_layout_file = $oModule->getEditedLayoutFile();
// 현재 요청된 레이아웃 정보를 구함
$oLayoutModel = &getModel('layout');
$current_module_info = Context::get('current_module_info');
$layout_srl = $current_module_info->layout_srl;
// 레이아웃과 연결되어 있으면 레이아웃 컴파일
if($layout_srl > 0){
$layout_info = Context::get('layout_info');
// faceoff 레이아웃일 경우 별도 처리
if($layout_info && $layout_info->type == 'faceoff') {
$oLayoutModel->doActivateFaceOff($layout_info);
Context::set('layout_info', $layout_info);
}
// 관리자 레이아웃 수정화면에서 변경된 CSS가 있는지 조사
$edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl);
if(file_exists($edited_layout_css)) Context::addCSSFile($edited_layout_css,true,'all','',100);
}
if(!$layout_path) $layout_path = "./common/tpl";
if(!$layout_file) $layout_file = "default_layout";
$output = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file);
if(__DEBUG__==3) $GLOBALS['__layout_compile_elapsed__'] = getMicroTime()-$start;
if(preg_match('/MSIE/i',$_SERVER['HTTP_USER_AGENT']) && (Context::get("_use_ssl")=='optional'||Context::get("_use_ssl")=="always")) {
Context::addHtmlFooter('<iframe id="xeTmpIframe" name="xeTmpIframe" style="width:1px;height:1px;position:absolute;top:-2px;left:-2px;"></iframe>');
}
}
}
$output = $handler->toDoc($oModule);
// 출력하기 전에 trigger 호출 (before)
ModuleHandler::triggerCall('display', 'before', $output);
@ -100,58 +58,16 @@
// 애드온 실행
$called_position = 'before_display_content';
$oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath();
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file);
// HTML 출력일 경우 최종적으로 common layout을 씌워서 출력
if(Context::getResponseMethod()=="HTML") {
if(__DEBUG__==3) $start = getMicroTime();
// body 내의 <style ..></style>를 header로 이동
$output = preg_replace_callback('!<style(.*?)<\/style>!is', array($this,'moveStyleToHeader'), $output);
// 메타 파일 변경 (캐싱기능등으로 인해 위젯등에서 <!--Meta:경로--> 태그를 content에 넣는 경우가 있음
$output = preg_replace_callback('/<!--Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this,'transMeta'), $output);
// rewrite module 사용시 생기는 상대경로에 대한 처리를 함
if(Context::isAllowRewrite()) {
$url = parse_url(Context::getRequestUri());
$real_path = $url['path'];
$pattern = '/src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/s';
$output = preg_replace($pattern, 'src=$1'.$real_path.'$3/$4.$5$6', $output);
$pattern = '/href=("|\'){1}(\?[^"\']+)/s';
$output = preg_replace($pattern, 'href=$1'.$real_path.'$2', $output);
if(Context::get('vid')) {
$pattern = '/\/'.Context::get('vid').'\?([^=]+)=/is';
$output = preg_replace($pattern, '/?$1=', $output);
}
}
// 간혹 background-image에 url(none) 때문에 request가 한번 더 일어나는 경우가 생기는 것을 방지
$output = preg_replace('/url\((["\']?)none(["\']?)\)/is', 'none', $output);
if(__DEBUG__==3) $GLOBALS['__trans_content_elapsed__'] = getMicroTime()-$start;
// 불필요한 정보 제거
$output = preg_replace('/member\_\-([0-9]+)/s','member_0',$output);
// 최종 레이아웃 변환
Context::set('content', $output);
$output = $oTemplate->compile('./common/tpl', 'common_layout');
// 사용자 정의 언어 변환
$oModuleController = &getController('module');
$oModuleController->replaceDefinedLangCode($output);
}
if(method_exists($handler, "prepareToPrint")) $handler->prepareToPrint($output);
// header 출력
if($this->gz_enabled) header("Content-Encoding: gzip");
if(Context::getResponseMethod() == 'JSON') $this->_printJSONHeader();
else if(Context::getResponseMethod() != 'HTML') $this->_printXMLHeader();
else $this->_printHTMLHeader();
if(Context::getResponseMethod() == 'JSON') $this->_printJSONHeader();
else if(Context::getResponseMethod() != 'HTML') $this->_printXMLHeader();
else $this->_printHTMLHeader();
// debugOutput 출력
$this->content_size = strlen($output);
@ -165,117 +81,6 @@
ModuleHandler::triggerCall('display', 'after', $content);
}
/**
* @brief add given .css or .js file names in widget code to Context
* @param[in] $oModule the module object
**/
function transMeta($matches) {
if(substr($matches[1],'-4')=='.css') Context::addCSSFile($matches[1]);
elseif(substr($matches[1],'-3')=='.js') Context::addJSFile($matches[1]);
}
/**
* @brief add html style code extracted from html body to Context, which will be
* printed inside <header></header> later.
* @param[in] $oModule the module object
**/
function moveStyleToHeader($matches) {
Context::addHtmlHeader($matches[0]);
}
/**
* @brief produce JSON compliant cotent given a module object.
* @param[in] $oModule the module object
**/
function _toJSON(&$oModule) {
$variables = $oModule->getVariables();
$variables['error'] = $oModule->getError();
$variables['message'] = $oModule->getMessage();
$json = preg_replace("(\r\n|\n)",'\n',json_encode2($variables));
return $json;
}
/**
* @brief Produce virtualXML compliant content given a module object.\n
* @param[in] $oModule the module object
**/
function _toVirtualXmlDoc(&$oModule) {
$error = $oModule->getError();
$message = $oModule->getMessage();
$redirect_url = $oModule->get('redirect_url');
$request_uri = Context::get('xeRequestURI');
$request_url = Context::get('xeVirtualRequestUrl');
if(substr($request_url,-1)!='/') $request_url .= '/';
if($error === 0) {
if($message != 'success') $output->message = $message;
if($redirect_url) $output->url = $redirect_url;
else $output->url = $request_uri;
} else {
if($message != 'fail') $output->message = $message;
}
$html = '<script type="text/javascript">'."\n";
if($output->message) $html .= 'alert("'.$output->message.'");'."\n";
if($output->url) {
$url = preg_replace('/#(.+)$/i','',$output->url);
$html .= 'self.location.href = "'.$request_url.'common/tpl/redirect.html?redirect_url='.urlencode($url).'";'."\n";
}
$html .= '</script>'."\n";
return $html;
}
/**
* @brief Produce XML compliant content given a module object.\n
* @param[in] $oModule the module object
**/
function _toXmlDoc(&$oModule) {
$variables = $oModule->getVariables();
$xmlDoc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>\n";
$xmlDoc .= sprintf("<error>%s</error>\n",$oModule->getError());
$xmlDoc .= sprintf("<message>%s</message>\n",str_replace(array('<','>','&'),array('&lt;','&gt;','&amp;'),$oModule->getMessage()));
$xmlDoc .= $this->_makeXmlDoc($variables);
$xmlDoc .= "</response>";
return $xmlDoc;
}
/**
* @brief produce XML code given variable object\n
* @param[in] $oModule the module object
**/
function _makeXmlDoc($obj) {
if(!count($obj)) return;
$xmlDoc = '';
foreach($obj as $key => $val) {
if(is_numeric($key)) $key = 'item';
if(is_string($val)) $xmlDoc .= sprintf('<%s><![CDATA[%s]]></%s>%s', $key, $val, $key,"\n");
else if(!is_array($val) && !is_object($val)) $xmlDoc .= sprintf('<%s>%s</%s>%s', $key, $val, $key,"\n");
else $xmlDoc .= sprintf('<%s>%s%s</%s>%s',$key, "\n", $this->_makeXmlDoc($val), $key, "\n");
}
return $xmlDoc;
}
/**
* @brief Produce HTML compliant content given a module object.\n
* @param[in] $oModule the module object
**/
function _toHTMLDoc(&$oModule) {
// template handler 객체 생성
$oTemplate = &TemplateHandler::getInstance();
// module tpl 변환
$template_path = $oModule->getTemplatePath();
$tpl_file = $oModule->getTemplateFile();
return $oTemplate->compile($template_path, $tpl_file);
}
/**
* @brief Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
@ -428,42 +233,46 @@
}
}
/**
* @brief print a HTTP HEADER for XML, which is encoded in UTF-8
**/
function _printXMLHeader() {
header("Content-Type: text/xml; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
* @brief print a HTTP HEADER for XML, which is encoded in UTF-8
**/
function _printXMLHeader() {
header("Content-Type: text/xml; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
* @brief print a HTTP HEADER for HTML, which is encoded in UTF-8
**/
function _printHTMLHeader() {
header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
* @brief print a HTTP HEADER for JSON, which is encoded in UTF-8
**/
function _printJSONHeader() {
header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
* @brief print a HTTP HEADER for HTML, which is encoded in UTF-8
**/
function _printHTMLHeader() {
header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
* @brief print a HTTP HEADER for JSON, which is encoded in UTF-8
**/
function _printJSONHeader() {
header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
}
?>

View file

@ -0,0 +1,156 @@
<?php
class HTMLDisplayHandler {
/**
* @brief Produce HTML compliant content given a module object.\n
* @param[in] $oModule the module object
**/
function toDoc(&$oModule)
{
$oTemplate = &TemplateHandler::getInstance();
// compile module tpl
$template_path = $oModule->getTemplatePath();
$tpl_file = $oModule->getTemplateFile();
$output = $oTemplate->compile($template_path, $tpl_file);
// add #xeAdmin div for adminitration pages
if(Context::getResponseMethod() == 'HTML') {
if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin')>0) $output = '<div id="xeAdmin">'.$output.'</div>';
if(Context::get('layout') != 'none') {
if(__DEBUG__==3) $start = getMicroTime();
Context::set('content', $output);
$layout_path = $oModule->getLayoutPath();
$layout_file = $oModule->getLayoutFile();
$edited_layout_file = $oModule->getEditedLayoutFile();
// 현재 요청된 레이아웃 정보를 구함
$oLayoutModel = &getModel('layout');
$layout_info = Context::get('layout_info');
$layout_srl = $layout_info->layout_srl;
// 레이아웃과 연결되어 있으면 레이아웃 컴파일
if($layout_srl > 0){
// faceoff 레이아웃일 경우 별도 처리
if($layout_info && $layout_info->type == 'faceoff') {
$oLayoutModel->doActivateFaceOff($layout_info);
Context::set('layout_info', $layout_info);
}
// 관리자 레이아웃 수정화면에서 변경된 CSS가 있는지 조사
$edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl);
if(file_exists($edited_layout_css)) Context::addCSSFile($edited_layout_css,true,'all','',100);
}
if(!$layout_path) $layout_path = "./common/tpl";
if(!$layout_file) $layout_file = "default_layout";
$output = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file);
if(__DEBUG__==3) $GLOBALS['__layout_compile_elapsed__'] = getMicroTime()-$start;
if(preg_match('/MSIE/i',$_SERVER['HTTP_USER_AGENT']) && (Context::get("_use_ssl")=='optional'||Context::get("_use_ssl")=="always")) {
Context::addHtmlFooter('<iframe id="xeTmpIframe" name="xeTmpIframe" style="width:1px;height:1px;position:absolute;top:-2px;left:-2px;"></iframe>');
}
}
}
return $output;
}
function prepareToPrint(&$output) {
if(Context::getResponseMethod() != 'HTML') return;
if(__DEBUG__==3) $start = getMicroTime();
// body 내의 <style ..></style>를 header로 이동
$output = preg_replace_callback('!<style(.*?)<\/style>!is', array($this,'_moveStyleToHeader'), $output);
// 메타 파일 변경 (캐싱기능등으로 인해 위젯등에서 <!--Meta:경로--> 태그를 content에 넣는 경우가 있음
$output = preg_replace_callback('/<!--Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this,'_transMeta'), $output);
// rewrite module 사용시 생기는 상대경로에 대한 처리를 함
if(Context::isAllowRewrite()) {
$url = parse_url(Context::getRequestUri());
$real_path = $url['path'];
$pattern = '/src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/s';
$output = preg_replace($pattern, 'src=$1'.$real_path.'$3/$4.$5$6', $output);
$pattern = '/href=("|\'){1}(\?[^"\']+)/s';
$output = preg_replace($pattern, 'href=$1'.$real_path.'$2', $output);
if(Context::get('vid')) {
$pattern = '/\/'.Context::get('vid').'\?([^=]+)=/is';
$output = preg_replace($pattern, '/?$1=', $output);
}
}
// 간혹 background-image에 url(none) 때문에 request가 한번 더 일어나는 경우가 생기는 것을 방지
$output = preg_replace('/url\((["\']?)none(["\']?)\)/is', 'none', $output);
if(__DEBUG__==3) $GLOBALS['__trans_content_elapsed__'] = getMicroTime()-$start;
// 불필요한 정보 제거
$output = preg_replace('/member\_\-([0-9]+)/s','member_0',$output);
// 최종 레이아웃 변환
Context::set('content', $output);
$oTemplate = &TemplateHandler::getInstance();
if(Mobile::isFromMobilePhone()) {
$output = $oTemplate->compile('./common/tpl', 'mobile_layout');
}
else
{
$this->_loadJSCSS();
$output = $oTemplate->compile('./common/tpl', 'common_layout');
}
// 사용자 정의 언어 변환
$oModuleController = &getController('module');
$oModuleController->replaceDefinedLangCode($output);
}
/**
* @brief add html style code extracted from html body to Context, which will be
* printed inside <header></header> later.
* @param[in] $oModule the module object
**/
function _moveStyleToHeader($matches) {
Context::addHtmlHeader($matches[0]);
}
/**
* @brief add given .css or .js file names in widget code to Context
* @param[in] $oModule the module object
**/
function _transMeta($matches) {
if(substr($matches[1],'-4')=='.css') Context::addCSSFile($matches[1]);
elseif(substr($matches[1],'-3')=='.js') Context::addJSFile($matches[1]);
}
function _loadJSCSS()
{
$oContext =& Context::getInstance();
// add common JS/CSS files
$oContext->_addJsFile("./common/js/jquery.js", true, '', -100000);
//$oContext->_addJsFile("./common/js/jquery-1.4.2-full.js", true, '', -100000);
$oContext->_addJsFile("./common/js/x.js", true, '', -100000);
$oContext->_addJsFile("./common/js/common.js", true, '', -100000);
$oContext->_addJsFile("./common/js/js_app.js", true, '', -100000);
$oContext->_addJsFile("./common/js/xml_handler.js", true, '', -100000);
$oContext->_addJsFile("./common/js/xml_js_filter.js", true, '', -100000);
$oContext->_addCSSFile("./common/css/default.css", true, 'all', '', -100000);
$oContext->_addCSSFile("./common/css/button.css", true, 'all', '', -100000);
// for admin page, add admin css
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0){
$oContext->_addCSSFile("./modules/admin/tpl/css/font.css", true, 'all', '',10000);
$oContext->_addCSSFile("./modules/admin/tpl/css/pagination.css", true, 'all', '', 100001);
$oContext->_addCSSFile("./modules/admin/tpl/css/admin.css", true, 'all', '', 100002);
}
}
}

View file

@ -0,0 +1,12 @@
<?php
class JSONDisplayHandler {
function toDoc(&$oModule)
{
$variables = $oModule->getVariables();
$variables['error'] = $oModule->getError();
$variables['message'] = $oModule->getMessage();
$json = preg_replace("(\r\n|\n)",'\n',json_encode2($variables));
return $json;
}
}

View file

@ -0,0 +1,37 @@
<?php
class VirtualXMLDisplayHandler {
/**
* @brief Produce virtualXML compliant content given a module object.\n
* @param[in] $oModule the module object
**/
function toDoc(&$oModule)
{
$error = $oModule->getError();
$message = $oModule->getMessage();
$redirect_url = $oModule->get('redirect_url');
$request_uri = Context::get('xeRequestURI');
$request_url = Context::get('xeVirtualRequestUrl');
if(substr($request_url,-1)!='/') $request_url .= '/';
if($error === 0) {
if($message != 'success') $output->message = $message;
if($redirect_url) $output->url = $redirect_url;
else $output->url = $request_uri;
} else {
if($message != 'fail') $output->message = $message;
}
$html = '<script type="text/javascript">'."\n";
if($output->message) $html .= 'alert("'.$output->message.'");'."\n";
if($output->url) {
$url = preg_replace('/#(.+)$/i','',$output->url);
$html .= 'self.location.href = "'.$request_url.'common/tpl/redirect.html?redirect_url='.urlencode($url).'";'."\n";
}
$html .= '</script>'."\n";
return $html;
}
}
?>

View file

@ -0,0 +1,44 @@
<?php
class XMLDisplayHandler {
/**
* @brief Produce XML compliant content given a module object.\n
* @param[in] $oModule the module object
**/
function toDoc(&$oModule)
{
$variables = $oModule->getVariables();
$xmlDoc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>\n";
$xmlDoc .= sprintf("<error>%s</error>\n",$oModule->getError());
$xmlDoc .= sprintf("<message>%s</message>\n",str_replace(array('<','>','&'),array('&lt;','&gt;','&amp;'),$oModule->getMessage()));
$xmlDoc .= $this->_makeXmlDoc($variables);
$xmlDoc .= "</response>";
return $xmlDoc;
}
/**
* @brief produce XML code given variable object\n
* @param[in] $oModule the module object
**/
function _makeXmlDoc($obj) {
if(!count($obj)) return;
$xmlDoc = '';
foreach($obj as $key => $val) {
if(is_numeric($key)) $key = 'item';
if(is_string($val)) $xmlDoc .= sprintf('<%s><![CDATA[%s]]></%s>%s', $key, $val, $key,"\n");
else if(!is_array($val) && !is_object($val)) $xmlDoc .= sprintf('<%s>%s</%s>%s', $key, $val, $key,"\n");
else $xmlDoc .= sprintf('<%s>%s%s</%s>%s',$key, "\n", $this->_makeXmlDoc($val), $key, "\n");
}
return $xmlDoc;
}
}
?>

View file

@ -141,9 +141,9 @@
$value = $this->_getTypeValue($this->type, $this->value);
switch($this->type) {
case 'homepage' :
return sprintf('<a href="%s" onclick="window.open(this.href); return false;">%s</a>', $value, $value);
return ($value)?sprintf('<a href="%s" onclick="window.open(this.href); return false;">%s</a>', $value, $value):"";
case 'email_address' :
return sprintf('<a href="mailto:%s">%s</a>', $value, $value);
return ($value)?sprintf('<a href="mailto:%s">%s</a>', $value, $value):"";
break;
case 'tel' :
return sprintf('%s - %s - %s', $value[0],$value[1],$value[2]);

View file

@ -332,11 +332,11 @@
* @remarks if the target is moved (when return code is 300~399), this function follows the location specified response header.
**/
function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array()) {
//set_include_path(_XE_PATH_."libs/PEAR");
requirePear();
require_once('HTTP/Request.php');
if(__PROXY_SERVER__!==null) {
$parsed_url = parse_url(__PROXY_SERVER__);
if($parsed_url["host"]) {
$oRequest = new HTTP_Request(__PROXY_SERVER__);
$oRequest->setMethod('POST');
$oRequest->_timeout = $timeout;

View file

@ -0,0 +1,55 @@
<?php
class Mobile {
var $ismobile = null;
function &getInstance() {
static $theInstance;
if(!isset($theInstance)) $theInstance = new Mobile();
return $theInstance;
}
function isFromMobilePhone() {
$oMobile =& Mobile::getInstance();
return $oMobile->_isFromMobilePhone();
}
function _isFromMobilePhone() {
if(isset($this->ismobile)) return $this->ismobile;
$db_info = Context::getDBInfo();
if($db_info->use_mobile_view != "Y" || Context::get('full_browse') || $_COOKIE["FullBrowse"])
{
$this->ismobile = false;
}
else
{
$m = Context::get('m');
if($m == "1") {
setcookie("mobile", true);
$this->ismobile = true;
}
else if($m === "0") {
setcookie("mobile", "");
$this->ismobile = false;
}
else if($_COOKIE["mobile"]) $this->ismobile = true;
else {
if(preg_match('/(iPod|iPhone|Android|BlackBerry|SCH\-M[0-9]+)/',$_SERVER['HTTP_USER_AGENT']))
{
setcookie("mobile", true);
$this->ismobile = true;
}
}
}
return $this->ismobile;
}
function setMobile($ismobile)
{
$oMobile =& Mobile::getInstance();
$oMobile->ismobile = $ismobile;
}
}
?>

View file

@ -61,7 +61,7 @@
// execute addon (before module initialization)
$called_position = 'before_module_init';
$oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath();
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file);
}
@ -203,13 +203,102 @@
$type = $xml_info->action->{$this->act}->type;
$kind = strpos(strtolower($this->act),'admin')!==false?'admin':'';
if(!$kind && $this->module == 'admin') $kind = 'admin';
if($this->module_info->use_mobile != "Y") Mobile::setMobile(false);
// create a module instance
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
if(!is_object($oModule)) {
$this->error = 'msg_module_is_not_exists';
return;
}
// if(type == view, and case for using mobilephone)
if($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled())
{
$orig_type = "view";
$type = "mobile";
// create a module instance
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
if(!is_object($oModule) || !method_exists($oModule, $this->act)) {
$type = $orig_type;
Mobile::setMobile(false);
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
}
}
else
{
// create a module instance
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
}
if(!is_object($oModule)) {
$this->error = 'msg_module_is_not_exists';
return;
}
// If there is no such action in the module object
if(!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act))
{
if(!Context::isInstalled())
{
$this->error = 'msg_invalid_request';
return;
}
$forward = null;
// 1. Look for the module with action name
if(preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches)) {
$module = strtolower($matches[2].$matches[3]);
$xml_info = $oModuleModel->getModuleActionXml($module);
if($xml_info->action->{$this->act}) {
$forward->module = $module;
$forward->type = $xml_info->action->{$this->act}->type;
$forward->act = $this->act;
}
}
if(!$forward)
{
$forward = $oModuleModel->getActionForward($this->act);
}
if($forward->module && $forward->type && $forward->act && $forward->act == $this->act) {
$kind = strpos(strtolower($forward->act),'admin')!==false?'admin':'';
$type = $forward->type;
$tpl_path = $oModule->getTemplatePath();
$orig_module = $oModule;
if($type == "view" && Mobile::isFromMobilePhone())
{
$orig_type = "view";
$type = "mobile";
// create a module instance
$oModule = &$this->getModuleInstance($forward->module, $type, $kind);
if(!is_object($oModule) || !method_exists($oModule, $this->act)) {
$type = $orig_type;
Mobile::setMobile(false);
$oModule = &$this->getModuleInstance($forward->module, $type, $kind);
}
}
else
{
$oModule = &$this->getModuleInstance($forward->module, $type, $kind);
}
$xml_info = $oModuleModel->getModuleActionXml($forward->module);
if($this->module == "admin" && $type == "view")
{
$oMemberModel = &getModel('member');
$logged_info = $oMemberModel->getLoggedInfo();
if($logged_info->is_admin=='Y') {
$orig_module->loadSideBar();
$oModule->setLayoutPath("./modules/admin/tpl");
$oModule->setLayoutFile("layout.html");
}
}
}
else if($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act))
{
$this->act = $xml_info->default_index_act;
}
else
{
$this->error = 'msg_invalid_request';
return;
}
}
$oModule->setAct($this->act);
@ -264,11 +353,20 @@
}
// Check if layout_srl exists for the module
if($oModule->module_info->layout_srl && !$oModule->getLayoutFile()) {
if(Mobile::isFromMobilePhone())
{
$layout_srl = $oModule->module_info->mlayout_srl;
}
else
{
$layout_srl = $oModule->module_info->layout_srl;
}
if($layout_srl && !$oModule->getLayoutFile()) {
// If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
$oLayoutModel = &getModel('layout');
$layout_info = $oLayoutModel->getLayout($oModule->module_info->layout_srl);
$layout_info = $oLayoutModel->getLayout($layout_srl);
if($layout_info) {
// Input extra_vars into $layout_info
@ -369,10 +467,10 @@
$instance_name = sprintf("%s%s",$module,"WAP");
$class_file = sprintf('%s%s%s.wap.php', _XE_PATH_, $class_path, $module);
break;
case 'smartphone' :
$instance_name = sprintf("%s%s",$module,"SPhone");
$class_file = sprintf('%s%s%s.smartphone.php', _XE_PATH_, $class_path, $module);
break;
case 'mobile' :
$instance_name = sprintf("%s%s",$module,"Mobile");
$class_file = sprintf("%s%s%s.mobile.php", _XE_PATH_, $class_path, $module);
break;
case 'class' :
$instance_name = $module;
$class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);

View file

@ -246,7 +246,7 @@
// addon 실행(called_position 를 before_module_proc로 하여 호출)
$called_position = 'before_module_proc';
$oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath();
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file);
if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) {
@ -261,75 +261,16 @@
// 실행
$output = $this->{$this->act}();
// act이 없으면 action_forward에서 해당하는 act가 있는지 찾아서 대신 실행
} else if(Context::isInstalled()) {
$oModuleModel = &getModel('module');
$forward = null;
// 현재 요청된 action의 대상 모듈을 찾음
// 1. action이름으로 검색 (DB검색 없이 하기 위함)
if(preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches)) {
$module = strtolower($matches[2].$matches[3]);
$xml_info = $oModuleModel->getModuleActionXml($module);
if($xml_info->action->{$this->act}) {
$forward->module = $module;
$forward->type = $xml_info->action->{$this->act}->type;
$forward->act = $this->act;
}
}
// 2. 1번에서 찾지 못하면 action forward를 검색
if(!$forward) $forward = $oModuleModel->getActionForward($this->act);
// 찾아진 forward 모듈이 있으면 실행
if($forward->module && $forward->type && $forward->act && $forward->act == $this->act) {
$kind = strpos(strtolower($forward->act),'admin')!==false?'admin':'';
$oModule = &getModule($forward->module, $forward->type, $kind);
$xml_info = $oModuleModel->getModuleActionXml($forward->module);
$oModule->setAct($forward->act);
$oModule->init();
if($oModule->stop_proc) return $this->stop($oModule->getMessage());
$oModule->setModuleInfo($this->module_info, $xml_info);
if(isset($xml_info->action->{$forward->act}) && method_exists($oModule, $forward->act)) {
$output = $oModule->{$forward->act}();
} else {
return $this->stop("msg_module_is_not_exists");
}
// forward 모듈의 실행 결과 검사
if($oModule->stop_proc) return $this->stop($oModule->getMessage());
$this->setTemplatePath($oModule->getTemplatePath());
$this->setTemplateFile($oModule->getTemplateFile());
if($oModule->getLayoutFile()) $this->setLayoutFile($oModule->getLayoutFile());
$this->adds($oModule->getVariables());
$this->setMessage($oModule->getMessage());
$this->setError($oModule->getError());
// forward 모듈을 찾지 못했다면 원 모듈의 default index action을 실행
} else if($this->xml_info->default_index_act && method_exists($this, $this->xml_info->default_index_act)) {
Context::set('act',$this->act = $this->xml_info->default_index_act);
$output = $this->{$this->xml_info->default_index_act}();
} else {
return false;
}
} else {
return false;
}
}
else {
return false;
}
// addon 실행(called_position 를 after_module_proc로 하여 호출)
$called_position = 'after_module_proc';
$oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath();
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file);
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {

View file

@ -43,7 +43,7 @@
**/
class XmlJsFilter extends XmlParser {
var $version = '0.2.3';
var $version = '0.2.4';
var $compiled_path = './files/cache/js_filter_compiled/'; ///< 컴파일된 캐시 파일이 놓일 위치
var $xml_file = NULL; ///< 대상 xml 파일
var $js_file = NULL; ///< 컴파일된 js 파일
@ -220,7 +220,8 @@
$name = trim($attrs->name);
$target = trim($attrs->target);
if($name && $target && ($name != $target)) $js_doc[] = "\t\tparams['{$name}'] = params['{$target}']; delete params['{$target}'];";
//if($name && $target && ($name != $target)) $js_doc[] = "\t\tparams['{$name}'] = params['{$target}']; delete params['{$target}'];";
if($name && $target && ($name != $target)) $js_doc[] = "\t\tif(params['{$target}']) { params['{$name}'] = params['{$target}']; delete params['{$target}']; }";
if($name && !in_array($name, $target_list)) $target_list[] = $name;
}