mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-26 05:42:13 +09:00
issue 2119. supporting php 5.4. display classes.
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12687 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
41fdaf00c3
commit
1de3e9cd17
6 changed files with 258 additions and 117 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @class DisplayHandler
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
|
|
@ -9,9 +10,10 @@
|
|||
*/
|
||||
class DisplayHandler extends Handler
|
||||
{
|
||||
|
||||
var $content_size = 0; // /< The size of displaying contents
|
||||
var $gz_enabled = false; // / <a flog variable whether to call contents after compressing by gzip
|
||||
var $handler = null;
|
||||
var $gz_enabled = FALSE; // / <a flog variable whether to call contents after compressing by gzip
|
||||
var $handler = NULL;
|
||||
|
||||
/**
|
||||
* print either html or xml content given oModule object
|
||||
|
|
@ -24,13 +26,17 @@ class DisplayHandler extends Handler
|
|||
// Check if the gzip encoding supported
|
||||
if(
|
||||
(defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1) &&
|
||||
strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')!==false &&
|
||||
strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE &&
|
||||
function_exists('ob_gzhandler') &&
|
||||
extension_loaded('zlib') &&
|
||||
$oModule->gzhandler_enable
|
||||
) $this->gz_enabled = true;
|
||||
)
|
||||
{
|
||||
$this->gz_enabled = TRUE;
|
||||
}
|
||||
|
||||
// Extract contents to display by the request method
|
||||
if(Context::get('xeVirtualRequestMethod')=='xml')
|
||||
if(Context::get('xeVirtualRequestMethod') == 'xml')
|
||||
{
|
||||
require_once("./classes/display/VirtualXMLDisplayHandler.php");
|
||||
$handler = new VirtualXMLDisplayHandler();
|
||||
|
|
@ -39,7 +45,10 @@ class DisplayHandler extends Handler
|
|||
{
|
||||
require_once("./classes/display/XMLDisplayHandler.php");
|
||||
$handler = new XMLDisplayHandler();
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) $this->gz_enabled = false;
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
|
||||
{
|
||||
$this->gz_enabled = FALSE;
|
||||
}
|
||||
}
|
||||
else if(Context::getRequestMethod() == 'JSON')
|
||||
{
|
||||
|
|
@ -58,38 +67,65 @@ class DisplayHandler extends Handler
|
|||
}
|
||||
|
||||
$output = $handler->toDoc($oModule);
|
||||
|
||||
// call a trigger before display
|
||||
ModuleHandler::triggerCall('display', 'before', $output);
|
||||
|
||||
// execute add-on
|
||||
$called_position = 'before_display_content';
|
||||
$oAddonController = &getController('addon');
|
||||
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
|
||||
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
|
||||
@include($addon_file);
|
||||
|
||||
if(method_exists($handler, "prepareToPrint")) $handler->prepareToPrint($output);
|
||||
if(method_exists($handler, "prepareToPrint"))
|
||||
{
|
||||
$handler->prepareToPrint($output);
|
||||
}
|
||||
// header output
|
||||
if($this->gz_enabled) header("Content-Encoding: gzip");
|
||||
if($this->gz_enabled)
|
||||
{
|
||||
header("Content-Encoding: gzip");
|
||||
}
|
||||
|
||||
$httpStatusCode = $oModule->getHttpStatusCode();
|
||||
if($httpStatusCode && $httpStatusCode != 200) $this->_printHttpStatusCode($httpStatusCode);
|
||||
if($httpStatusCode && $httpStatusCode != 200)
|
||||
{
|
||||
$this->_printHttpStatusCode($httpStatusCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') $this->_printJSONHeader();
|
||||
else if(Context::getResponseMethod() != 'HTML') $this->_printXMLHeader();
|
||||
else $this->_printHTMLHeader();
|
||||
if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK')
|
||||
{
|
||||
$this->_printJSONHeader();
|
||||
}
|
||||
else if(Context::getResponseMethod() != 'HTML')
|
||||
{
|
||||
$this->_printXMLHeader();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_printHTMLHeader();
|
||||
}
|
||||
}
|
||||
|
||||
// debugOutput output
|
||||
$this->content_size = strlen($output);
|
||||
$output .= $this->_debugOutput();
|
||||
|
||||
// results directly output
|
||||
if($this->gz_enabled) print ob_gzhandler($output, 5);
|
||||
else print $output;
|
||||
if($this->gz_enabled)
|
||||
{
|
||||
print ob_gzhandler($output, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $output;
|
||||
}
|
||||
|
||||
// call a trigger after display
|
||||
ModuleHandler::triggerCall('display', 'after', $content);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
|
||||
* This method only functions when __DEBUG__ variable is set to 1.
|
||||
|
|
@ -98,14 +134,21 @@ class DisplayHandler extends Handler
|
|||
*/
|
||||
function _debugOutput()
|
||||
{
|
||||
if(!__DEBUG__) return;
|
||||
if(!__DEBUG__)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$end = getMicroTime();
|
||||
|
||||
// Firebug console output
|
||||
if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1)
|
||||
{
|
||||
static $firephp;
|
||||
if(!isset($firephp)) $firephp = FirePHP::getInstance(true);
|
||||
if(!isset($firephp))
|
||||
{
|
||||
$firephp = FirePHP::getInstance(true);
|
||||
}
|
||||
|
||||
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
|
||||
{
|
||||
|
|
@ -116,36 +159,39 @@ class DisplayHandler extends Handler
|
|||
if(__DEBUG__ & 2)
|
||||
{
|
||||
$firephp->fb(
|
||||
array('Request / Response info >>> '.$_SERVER['REQUEST_METHOD'].' / '.Context::getResponseMethod(),
|
||||
array(
|
||||
'Request / Response info >>> ' . $_SERVER['REQUEST_METHOD'] . ' / ' . Context::getResponseMethod(),
|
||||
array(
|
||||
array('Request URI', 'Request method', 'Response method', 'Response contents size'),
|
||||
array(
|
||||
sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']),
|
||||
sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']),
|
||||
$_SERVER['REQUEST_METHOD'],
|
||||
Context::getResponseMethod(),
|
||||
$this->content_size.' byte'
|
||||
)
|
||||
$this->content_size . ' byte'
|
||||
)
|
||||
),
|
||||
)
|
||||
),
|
||||
'TABLE'
|
||||
);
|
||||
);
|
||||
$firephp->fb(
|
||||
array('Elapsed time >>> Total : '.sprintf('%0.5f sec', $end - __StartTime__),
|
||||
array(
|
||||
'Elapsed time >>> Total : ' . sprintf('%0.5f sec', $end - __StartTime__),
|
||||
array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'),
|
||||
array(
|
||||
sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
|
||||
sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']),
|
||||
sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']),
|
||||
sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']),
|
||||
sprintf('%0.5f sec', $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']),
|
||||
sprintf('%0.5f sec', $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']),
|
||||
sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']),
|
||||
sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
),
|
||||
'TABLE'
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
// display DB query history
|
||||
if((__DEBUG__ & 4) && $GLOBALS['__db_queries__'])
|
||||
{
|
||||
|
|
@ -156,11 +202,11 @@ class DisplayHandler extends Handler
|
|||
}
|
||||
$firephp->fb(
|
||||
array(
|
||||
'DB Queries >>> '.count($GLOBALS['__db_queries__']).' Queries, '.sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
|
||||
'DB Queries >>> ' . count($GLOBALS['__db_queries__']) . ' Queries, ' . sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
|
||||
$queries_output
|
||||
),
|
||||
),
|
||||
'TABLE'
|
||||
);
|
||||
);
|
||||
}
|
||||
// dislpay the file and HTML comments
|
||||
}
|
||||
|
|
@ -173,24 +219,29 @@ class DisplayHandler extends Handler
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Request/Response information
|
||||
$buff .= "\n- Request/ Response info\n";
|
||||
$buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']);
|
||||
$buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']);
|
||||
$buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']);
|
||||
$buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod());
|
||||
$buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->content_size);
|
||||
|
||||
// total execution time
|
||||
$buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end-__StartTime__);
|
||||
$buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end - __StartTime__);
|
||||
|
||||
$buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']);
|
||||
$buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
|
||||
$buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
|
||||
$buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']);
|
||||
$buff .= sprintf("\tDB class elapsed time \t\t: %0.5f sec\n", $GLOBALS['__dbclass_elapsed_time__'] -$GLOBALS['__db_elapsed_time__']);
|
||||
$buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']);
|
||||
$buff .= sprintf("\tDB class elapsed time \t\t: %0.5f sec\n", $GLOBALS['__dbclass_elapsed_time__'] - $GLOBALS['__db_elapsed_time__']);
|
||||
|
||||
// widget execution time
|
||||
$buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
|
||||
|
||||
// layout execution time
|
||||
$buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
|
||||
|
||||
// Widgets, the editor component replacement time
|
||||
$buff .= sprintf("\n\tTrans Content \t\t\t: %0.5f sec\n", $GLOBALS['__trans_content_elapsed__']);
|
||||
}
|
||||
|
|
@ -222,6 +273,7 @@ class DisplayHandler extends Handler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Output in HTML comments
|
||||
if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML')
|
||||
{
|
||||
|
|
@ -232,18 +284,23 @@ class DisplayHandler extends Handler
|
|||
$buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
|
||||
}
|
||||
|
||||
return "<!--\r\n".$buff."\r\n-->";
|
||||
return "<!--\r\n" . $buff . "\r\n-->";
|
||||
}
|
||||
|
||||
// Output to a file
|
||||
if($buff && __DEBUG_OUTPUT__ == 0)
|
||||
{
|
||||
$debug_file = _XE_PATH_.'files/_debug_message.php';
|
||||
$debug_file = _XE_PATH_ . 'files/_debug_message.php';
|
||||
$buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
|
||||
|
||||
$buff = str_repeat('=', 40)."\n".$buff.str_repeat('-', 40);
|
||||
$buff = "\n<?php\n/*".$buff."*/\n?>\n";
|
||||
$buff = str_repeat('=', 40) . "\n" . $buff . str_repeat('-', 40);
|
||||
$buff = "\n<?php\n/*" . $buff . "*/\n?>\n";
|
||||
|
||||
if(@!$fp = fopen($debug_file, 'a'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(@!$fp = fopen($debug_file, 'a')) return;
|
||||
fwrite($fp, $buff);
|
||||
fclose($fp);
|
||||
}
|
||||
|
|
@ -264,7 +321,6 @@ class DisplayHandler extends Handler
|
|||
header("Pragma: no-cache");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* print a HTTP HEADER for HTML, which is encoded in UTF-8
|
||||
* @return void
|
||||
|
|
@ -279,7 +335,6 @@ class DisplayHandler extends Handler
|
|||
header("Pragma: no-cache");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* print a HTTP HEADER for JSON, which is encoded in UTF-8
|
||||
* @return void
|
||||
|
|
@ -294,7 +349,6 @@ class DisplayHandler extends Handler
|
|||
header("Pragma: no-cache");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* print a HTTP HEADER for HTML, which is encoded in UTF-8
|
||||
* @return void
|
||||
|
|
@ -304,6 +358,7 @@ class DisplayHandler extends Handler
|
|||
$statusMessage = Context::get('http_status_message');
|
||||
header("HTTP/1.0 $code $statusMessage");
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file DisplayHandler.class.php */
|
||||
/* Location: ./classes/display/DisplayHandler.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue