git-svn-id: http://xe-core.googlecode.com/svn/trunk@14 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-02-14 05:01:41 +00:00
parent 3d61ed75c1
commit cc287e7787
2 changed files with 155 additions and 139 deletions

View file

@ -2,7 +2,8 @@
/** /**
* @class DBMysql * @class DBMysql
* @author zero (zero@nzeo.com) * @author zero (zero@nzeo.com)
* @brief mysql handling class * @brief MySQL DBMS를 이용하기 위한 class
* mysql handling class
**/ **/
class DBMysql extends DB { class DBMysql extends DB {

View file

@ -1,21 +1,22 @@
<?php <?php
/** /**
* @file : classes/display/DisplayHandler.class.php * @class DisplayHandler
* @author : zero <zero@nzeo.com> * @author zero (zero@nzeo.com)
* @desc : display 객체 * @brief 데이터 출력을 위한 class (XML/HTML 데이터를 구분하여 출력)
* Request Method에 따라서 html or xml 출력방법을 결정한다
* xml : oModule의 variables를 simple xml 출력
* html : oModule의 template/variables로 html을 만들고 contents_html로 처리
* plugin이나 layout의 html과 연동하여 출력
* *
* Request Method에 따라서 html or xml 출력방법을 결정한다\n
* xml : oModule의 variables를 simple xml 출력\n
* html : oModule의 template/variables로 html을 만들고 contents_html로 처리\n
* plugin이나 layout의 html과 연동하여 출력\n
**/ **/
class DisplayHandler { class DisplayHandler {
// 출력하는 컨텐츠의 사이즈 var $content_size = 0; ///< 출력하는 컨텐츠의 사이즈
var $content_size = 0;
// public void printContent() /*{{{*/ /**
* @brief 모듈객체를 받아서 content 출력
**/
function printContent($oModule) { function printContent($oModule) {
// header 출력 // header 출력
$this->_printHeader(); $this->_printHeader();
@ -29,6 +30,7 @@
// content 래핑 (common/tpl/default.html) // content 래핑 (common/tpl/default.html)
require_once("./classes/template/TemplateHandler.class.php"); require_once("./classes/template/TemplateHandler.class.php");
$oTemplate = new TemplateHandler(); $oTemplate = new TemplateHandler();
$output = $oTemplate->compile($oModule->layout_path, $oModule->layout_tpl); $output = $oTemplate->compile($oModule->layout_path, $oModule->layout_tpl);
} else { } else {
@ -40,31 +42,34 @@
// 디버깅 데이터 출력 // 디버깅 데이터 출력
$this->_debugOutput(); $this->_debugOutput();
}/*}}}*/ }
// public void getContent() /*{{{*/
function getContent($oModule) {
// request method에 따른 처리
return $this->_toDoc($oModule);
}/*}}}*/
/** /**
* 문서 출력 * @brief 모듈 객체의 content return
**/
function getContent($oModule) {
return $this->_toDoc($oModule);
}
/**
* @brief 모듈 객체의 content return
**/ **/
// private string _toDoc($oModule) /*{{{*/
function _toDoc($oModule) { function _toDoc($oModule) {
if(Context::getRequestMethod() == 'XMLRPC') $content = $this->_toXmlDoc($oModule); if(Context::getRequestMethod() == 'XMLRPC') $content = $this->_toXmlDoc($oModule);
else $content = $this->_toHTMLDoc($oModule); else $content = $this->_toHTMLDoc($oModule);
return $content; return $content;
}/*}}}*/ }
// private string _toXmlDoc($oModule) /*{{{*/ /**
* @brief RequestMethod가 XML이면 XML 데이터로 컨텐츠 생성
**/
function _toXmlDoc($oModule) { function _toXmlDoc($oModule) {
$xmlDoc = "<response>\n"; $xmlDoc = "<response>\n";
$xmlDoc .= sprintf("<error>%s</error>\n",$oModule->getError()); $xmlDoc .= sprintf("<error>%s</error>\n",$oModule->getError());
$xmlDoc .= sprintf("<message>%s</message>\n",$oModule->getMessage()); $xmlDoc .= sprintf("<message>%s</message>\n",$oModule->getMessage());
$variables = $oModule->getVariables(); $variables = $oModule->getVariables();
if(count($variables)) { if(count($variables)) {
foreach($variables as $key => $val) { foreach($variables as $key => $val) {
if(is_string($val)) $val = '<![CDATA['.$val.']]>'; if(is_string($val)) $val = '<![CDATA['.$val.']]>';
@ -75,9 +80,11 @@
$xmlDoc .= "</response>"; $xmlDoc .= "</response>";
return $xmlDoc; return $xmlDoc;
}/*}}}*/ }
// private string _toHTMLDoc($oModule) /*{{{*/ /**
* @brief RequestMethod가 XML이 아니면 html 컨텐츠 생성
**/
function _toHTMLDoc($oModule) { function _toHTMLDoc($oModule) {
// template handler 객체 생성 // template handler 객체 생성
require_once("./classes/template/TemplateHandler.class.php"); require_once("./classes/template/TemplateHandler.class.php");
@ -87,17 +94,22 @@
$template_path = $oModule->getTemplatePath(); $template_path = $oModule->getTemplatePath();
$tpl_file = $oModule->getTemplateFile(); $tpl_file = $oModule->getTemplateFile();
return $oTemplate->compile($template_path, $tpl_file); return $oTemplate->compile($template_path, $tpl_file);
}/*}}}*/ }
// public int getContentSize() /*{{{*/ /**
* @brief content size return
**/
function getContentSize() { function getContentSize() {
return $this->content_size; return $this->content_size;
}/*}}}*/ }
// private void _debugOutput()/*{{{*/ /**
// __DEBUG__가 true일 경우 각 부분의 실행시간등을 debugPrint 함수를 이용해서 출력 * @brief 디버그 모드일 경우 디버기 메세지 출력
// 개발시나 테스트시에 config/config.inc.php의 __DEBUG__를 true로 세팅하고 *
// tail -f ./files/_debug_message.php로 하여 console로 확인하면 편리함 * __DEBUG__가 true일 경우 부분의 실행시간등을 debugPrint 함수를 이용해서 출력\n
* 개발시나 테스트시에 config/config.inc.php의 __DEBUG__를 true로 세팅하고\n
* tail -f ./files/_debug_message.php로 하여 console로 확인하면 편리함\n
**/
function _debugOutput() { function _debugOutput() {
if(!__DEBUG__) return; if(!__DEBUG__) return;
$end = getMicroTime(); $end = getMicroTime();
@ -120,18 +132,19 @@
$buff .= sprintf("\tTotal elapsed time \t\t: %0.5f sec", $end-__StartTime__); $buff .= sprintf("\tTotal elapsed time \t\t: %0.5f sec", $end-__StartTime__);
debugPrint($buff, false); debugPrint($buff, false);
}/*}}}*/ }
/** /**
* 헤더 출력 * @brief RequestMethod에 맞춰 헤더 출력
***/ ***/
// private void _printHeader()/*{{{*/
function _printHeader() { function _printHeader() {
if(Context::getRequestMethod() == 'XMLRPC') return $this->_printXMLHeader(); if(Context::getRequestMethod() == 'XMLRPC') return $this->_printXMLHeader();
else return $this->_printHTMLHeader(); else return $this->_printHTMLHeader();
}/*}}}*/ }
// private void _printXMLHeader()/*{{{*/ /**
* @brief xml header 출력 (utf8 고정)
**/
function _printXMLHeader() { function _printXMLHeader() {
header("Content-Type: text/xml; charset=UTF-8"); header("Content-Type: text/xml; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
@ -139,9 +152,11 @@
header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false); header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); header("Pragma: no-cache");
}/*}}}*/ }
// private void _printHTMLHeader()/*{{{*/ /**
* @brief html header 출력 (utf8 고정)
**/
function _printHTMLHeader() { function _printHTMLHeader() {
header("Content-Type: text/html; charset=UTF-8"); header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
@ -149,6 +164,6 @@
header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false); header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); header("Pragma: no-cache");
}/*}}}*/ }
} }
?> ?>