move header printing to displayhandler, and print header according to response method

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7531 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2010-06-21 09:45:20 +00:00
parent c20bc9fef2
commit aa8fb9df1d
5 changed files with 45 additions and 50 deletions

View file

@ -65,7 +65,9 @@
// header 출력
if($this->gz_enabled) header("Content-Encoding: gzip");
$handler->printHeader();
if(Context::getResponseMethod() == 'JSON') $this->_printJSONHeader();
else if(Context::getResponseMethod() != 'HTML') $this->_printXMLHeader();
else $this->_printHTMLHeader();
// debugOutput 출력
$this->content_size = strlen($output);
@ -230,5 +232,47 @@
}
}
}
/**
* @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");
}
}
?>

View file

@ -15,7 +15,6 @@ class HTMLDisplayHandler {
$output = $oTemplate->compile($template_path, $tpl_file);
// add #xeAdmin div for adminitration pages
debugPrint(Context::getResponseMethod());
if(Context::getResponseMethod() == 'HTML') {
if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin')>0) $output = '<div id="xeAdmin">'.$output.'</div>';
@ -133,18 +132,6 @@ class HTMLDisplayHandler {
elseif(substr($matches[1],'-3')=='.js') Context::addJSFile($matches[1]);
}
/**
* @brief print a HTTP HEADER for HTML, which is encoded in UTF-8
**/
function printHeader() {
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");
}
function _loadJSCSS()
{
$oContext =& Context::getInstance();

View file

@ -9,16 +9,4 @@ class JSONDisplayHandler {
$json = preg_replace("(\r\n|\n)",'\n',json_encode2($variables));
return $json;
}
/**
* @brief print a HTTP HEADER for JSON, which is encoded in UTF-8
**/
function printHeader() {
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

@ -32,18 +32,6 @@ class VirtualXMLDisplayHandler {
$html .= '</script>'."\n";
return $html;
}
/**
* @brief print a HTTP HEADER for HTML, which is encoded in UTF-8
**/
function printHeader() {
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

@ -20,18 +20,6 @@ class XMLDisplayHandler {
return $xmlDoc;
}
/**
* @brief print a HTTP HEADER for XML, which is encoded in UTF-8
**/
function printHeader() {
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 produce XML code given variable object\n
* @param[in] $oModule the module object