mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 12:32:14 +09:00
issue 2662 display coding convention
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12217 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
d77d426c4f
commit
1b2d64a4d7
6 changed files with 381 additions and 321 deletions
|
|
@ -1,281 +1,309 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @class DisplayHandler
|
* @class DisplayHandler
|
||||||
* @author NHN (developers@xpressengine.com)
|
* @author NHN (developers@xpressengine.com)
|
||||||
* DisplayHandler is responsible for displaying the execution result. \n
|
* DisplayHandler is responsible for displaying the execution result. \n
|
||||||
* Depending on the request type, it can display either HTML or XML content.\n
|
* Depending on the request type, it can display either HTML or XML content.\n
|
||||||
* Xml content is simple xml presentation of variables in oModule while html content
|
* Xml content is simple xml presentation of variables in oModule while html content
|
||||||
* is the combination of the variables of oModue and template files/.
|
* is the combination of the variables of oModue and template files/.
|
||||||
**/
|
*/
|
||||||
|
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;
|
||||||
|
|
||||||
class DisplayHandler extends Handler {
|
/**
|
||||||
|
* print either html or xml content given oModule object
|
||||||
var $content_size = 0; // /< The size of displaying contents
|
* @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
|
||||||
|
* @param ModuleObject $oModule the module object
|
||||||
var $gz_enabled = false; // / <a flog variable whether to call contents after compressing by gzip
|
* @return void
|
||||||
var $handler = null;
|
*/
|
||||||
|
function printContent(&$oModule)
|
||||||
/**
|
{
|
||||||
* print either html or xml content given oModule object
|
// Check if the gzip encoding supported
|
||||||
* @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
|
if(
|
||||||
* @param ModuleObject $oModule the module object
|
(defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1) &&
|
||||||
* @return void
|
strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')!==false &&
|
||||||
**/
|
function_exists('ob_gzhandler') &&
|
||||||
function printContent(&$oModule) {
|
extension_loaded('zlib') &&
|
||||||
// Check if the gzip encoding supported
|
|
||||||
if(
|
|
||||||
(defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1) &&
|
|
||||||
strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')!==false &&
|
|
||||||
function_exists('ob_gzhandler') &&
|
|
||||||
extension_loaded('zlib') &&
|
|
||||||
$oModule->gzhandler_enable
|
$oModule->gzhandler_enable
|
||||||
) $this->gz_enabled = true;
|
) $this->gz_enabled = true;
|
||||||
// Extract contents to display by the request method
|
// 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();
|
require_once("./classes/display/VirtualXMLDisplayHandler.php");
|
||||||
}
|
$handler = new VirtualXMLDisplayHandler();
|
||||||
else if(Context::getRequestMethod() == 'XMLRPC') {
|
}
|
||||||
require_once("./classes/display/XMLDisplayHandler.php");
|
else if(Context::getRequestMethod() == 'XMLRPC')
|
||||||
$handler = new XMLDisplayHandler();
|
{
|
||||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) $this->gz_enabled = false;
|
require_once("./classes/display/XMLDisplayHandler.php");
|
||||||
}
|
$handler = new XMLDisplayHandler();
|
||||||
else if(Context::getRequestMethod() == 'JSON') {
|
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) $this->gz_enabled = false;
|
||||||
require_once("./classes/display/JSONDisplayHandler.php");
|
}
|
||||||
$handler = new JSONDisplayHandler();
|
else if(Context::getRequestMethod() == 'JSON')
|
||||||
}
|
{
|
||||||
else if(Context::getRequestMethod() == 'JS_CALLBACK')
|
require_once("./classes/display/JSONDisplayHandler.php");
|
||||||
|
$handler = new JSONDisplayHandler();
|
||||||
|
}
|
||||||
|
else if(Context::getRequestMethod() == 'JS_CALLBACK')
|
||||||
|
{
|
||||||
|
require_once("./classes/display/JSCallbackDisplayHandler.php");
|
||||||
|
$handler = new JSCallbackDisplayHandler();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
require_once("./classes/display/HTMLDisplayHandler.php");
|
||||||
|
$handler = new HTMLDisplayHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
$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");
|
||||||
|
@include($addon_file);
|
||||||
|
|
||||||
|
if(method_exists($handler, "prepareToPrint")) $handler->prepareToPrint($output);
|
||||||
|
// header output
|
||||||
|
if($this->gz_enabled) header("Content-Encoding: gzip");
|
||||||
|
|
||||||
|
$httpStatusCode = $oModule->getHttpStatusCode();
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
// 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.
|
||||||
|
* __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function _debugOutput()
|
||||||
|
{
|
||||||
|
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(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
|
||||||
{
|
{
|
||||||
require_once("./classes/display/JSCallbackDisplayHandler.php");
|
$firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
|
||||||
$handler = new JSCallbackDisplayHandler();
|
return;
|
||||||
}
|
}
|
||||||
else {
|
// display total execution time and Request/Response info
|
||||||
require_once("./classes/display/HTMLDisplayHandler.php");
|
if(__DEBUG__ & 2)
|
||||||
$handler = new HTMLDisplayHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
$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");
|
|
||||||
@include($addon_file);
|
|
||||||
|
|
||||||
if(method_exists($handler, "prepareToPrint")) $handler->prepareToPrint($output);
|
|
||||||
// header output
|
|
||||||
if($this->gz_enabled) header("Content-Encoding: gzip");
|
|
||||||
|
|
||||||
$httpStatusCode = $oModule->getHttpStatusCode();
|
|
||||||
if($httpStatusCode && $httpStatusCode != 200) $this->_printHttpStatusCode($httpStatusCode);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') $this->_printJSONHeader();
|
$firephp->fb(
|
||||||
else if(Context::getResponseMethod() != 'HTML') $this->_printXMLHeader();
|
array('Request / Response info >>> '.$_SERVER['REQUEST_METHOD'].' / '.Context::getResponseMethod(),
|
||||||
else $this->_printHTMLHeader();
|
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']),
|
||||||
|
$_SERVER['REQUEST_METHOD'],
|
||||||
|
Context::getResponseMethod(),
|
||||||
|
$this->content_size.' byte'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'TABLE'
|
||||||
|
);
|
||||||
|
$firephp->fb(
|
||||||
|
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', $GLOBALS['__widget_excute_elapsed__']),
|
||||||
|
sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'TABLE'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
// display DB query history
|
||||||
// debugOutput output
|
if((__DEBUG__ & 4) && $GLOBALS['__db_queries__'])
|
||||||
$this->content_size = strlen($output);
|
{
|
||||||
$output .= $this->_debugOutput();
|
$queries_output = array(array('Query', 'Elapsed time', 'Result'));
|
||||||
// results directly output
|
foreach($GLOBALS['__db_queries__'] as $query)
|
||||||
if($this->gz_enabled) print ob_gzhandler($output, 5);
|
{
|
||||||
else print $output;
|
array_push($queries_output, array($query['query'], sprintf('%0.5f', $query['elapsed_time']), $query['result']));
|
||||||
// call a trigger after display
|
}
|
||||||
ModuleHandler::triggerCall('display', 'after', $content);
|
$firephp->fb(
|
||||||
}
|
array(
|
||||||
|
'DB Queries >>> '.count($GLOBALS['__db_queries__']).' Queries, '.sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
|
||||||
|
$queries_output
|
||||||
/**
|
),
|
||||||
* Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
|
'TABLE'
|
||||||
* This method only functions when __DEBUG__ variable is set to 1.
|
);
|
||||||
* __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
|
}
|
||||||
* @return void
|
// dislpay the file and HTML comments
|
||||||
**/
|
|
||||||
function _debugOutput() {
|
|
||||||
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(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
|
|
||||||
$firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// display total execution time and Request/Response info
|
|
||||||
if(__DEBUG__ & 2) {
|
|
||||||
$firephp->fb(
|
|
||||||
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']),
|
|
||||||
$_SERVER['REQUEST_METHOD'],
|
|
||||||
Context::getResponseMethod(),
|
|
||||||
$this->content_size.' byte'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'TABLE'
|
|
||||||
);
|
|
||||||
$firephp->fb(
|
|
||||||
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', $GLOBALS['__widget_excute_elapsed__']),
|
|
||||||
sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'TABLE'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// display DB query history
|
|
||||||
if((__DEBUG__ & 4) && $GLOBALS['__db_queries__']) {
|
|
||||||
$queries_output = array(array('Query', 'Elapsed time', 'Result'));
|
|
||||||
foreach($GLOBALS['__db_queries__'] as $query) {
|
|
||||||
array_push($queries_output, array($query['query'], sprintf('%0.5f', $query['elapsed_time']), $query['result']));
|
|
||||||
}
|
|
||||||
$firephp->fb(
|
|
||||||
array(
|
|
||||||
'DB Queries >>> '.count($GLOBALS['__db_queries__']).' Queries, '.sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
|
|
||||||
$queries_output
|
|
||||||
),
|
|
||||||
'TABLE'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// dislpay the file and HTML comments
|
|
||||||
} else {
|
|
||||||
// display total execution time and Request/Response info
|
|
||||||
if(__DEBUG__ & 2) {
|
|
||||||
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
|
|
||||||
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 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("\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__']);
|
|
||||||
// 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__']);
|
|
||||||
}
|
|
||||||
// DB Logging
|
|
||||||
if(__DEBUG__ & 4) {
|
|
||||||
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($GLOBALS['__db_queries__']) {
|
|
||||||
$buff .= sprintf("\n- DB Queries : %d Queries. %0.5f sec\n", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
|
|
||||||
$num = 0;
|
|
||||||
|
|
||||||
foreach($GLOBALS['__db_queries__'] as $query) {
|
|
||||||
$buff .= sprintf("\t%02d. %s\n\t\t%0.6f sec. ", ++$num, $query['query'], $query['elapsed_time']);
|
|
||||||
if($query['result'] == 'Success') {
|
|
||||||
$buff .= "Query Success\n";
|
|
||||||
} else {
|
|
||||||
$buff .= sprintf("Query $s : %d\n\t\t\t %s\n", $query['result'], $query['errno'], $query['errstr']);
|
|
||||||
}
|
|
||||||
$buff .= sprintf("\t\tConnection: %s\n", $query['connection']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Output in HTML comments
|
|
||||||
if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') {
|
|
||||||
$buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
|
|
||||||
|
|
||||||
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
|
|
||||||
$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-->";
|
|
||||||
}
|
|
||||||
// Output to a file
|
|
||||||
if($buff && __DEBUG_OUTPUT__ == 0) {
|
|
||||||
$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";
|
|
||||||
|
|
||||||
if(@!$fp = fopen($debug_file, 'a')) return;
|
|
||||||
fwrite($fp, $buff);
|
|
||||||
fclose($fp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* print a HTTP HEADER for XML, which is encoded in UTF-8
|
|
||||||
* @return void
|
|
||||||
**/
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// display total execution time and Request/Response info
|
||||||
|
if(__DEBUG__ & 2)
|
||||||
|
{
|
||||||
|
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
|
||||||
|
{
|
||||||
|
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 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("\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__']);
|
||||||
|
// 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__']);
|
||||||
|
}
|
||||||
|
// DB Logging
|
||||||
|
if(__DEBUG__ & 4)
|
||||||
|
{
|
||||||
|
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
if($GLOBALS['__db_queries__'])
|
||||||
* print a HTTP HEADER for HTML, which is encoded in UTF-8
|
{
|
||||||
* @return void
|
$buff .= sprintf("\n- DB Queries : %d Queries. %0.5f sec\n", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
|
||||||
**/
|
$num = 0;
|
||||||
function _printHTMLHeader() {
|
|
||||||
header("Content-Type: text/html; charset=UTF-8");
|
foreach($GLOBALS['__db_queries__'] as $query)
|
||||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
{
|
||||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
$buff .= sprintf("\t%02d. %s\n\t\t%0.6f sec. ", ++$num, $query['query'], $query['elapsed_time']);
|
||||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
if($query['result'] == 'Success')
|
||||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
{
|
||||||
header("Pragma: no-cache");
|
$buff .= "Query Success\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$buff .= sprintf("Query $s : %d\n\t\t\t %s\n", $query['result'], $query['errno'], $query['errstr']);
|
||||||
|
}
|
||||||
|
$buff .= sprintf("\t\tConnection: %s\n", $query['connection']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Output in HTML comments
|
||||||
|
if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML')
|
||||||
|
{
|
||||||
|
$buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
|
||||||
|
|
||||||
|
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
|
||||||
|
{
|
||||||
|
$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-->";
|
||||||
|
}
|
||||||
|
// Output to a file
|
||||||
|
if($buff && __DEBUG_OUTPUT__ == 0)
|
||||||
|
{
|
||||||
|
$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";
|
||||||
|
|
||||||
|
if(@!$fp = fopen($debug_file, 'a')) return;
|
||||||
|
fwrite($fp, $buff);
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print a HTTP HEADER for XML, which is encoded in UTF-8
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print a HTTP HEADER for JSON, which is encoded in UTF-8
|
* print a HTTP HEADER for HTML, which is encoded in UTF-8
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
*/
|
||||||
function _printJSONHeader() {
|
function _printHTMLHeader()
|
||||||
header("Content-Type: text/html; charset=UTF-8");
|
{
|
||||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
header("Content-Type: text/html; charset=UTF-8");
|
||||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||||
header("Pragma: no-cache");
|
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||||
}
|
header("Pragma: no-cache");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print a HTTP HEADER for HTML, which is encoded in UTF-8
|
* print a HTTP HEADER for JSON, which is encoded in UTF-8
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
*/
|
||||||
function _printHttpStatusCode($code) {
|
function _printJSONHeader()
|
||||||
$statusMessage = Context::get('http_status_message');
|
{
|
||||||
header("HTTP/1.0 $code $statusMessage");
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print a HTTP HEADER for HTML, which is encoded in UTF-8
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function _printHttpStatusCode($code)
|
||||||
|
{
|
||||||
|
$statusMessage = Context::get('http_status_message');
|
||||||
|
header("HTTP/1.0 $code $statusMessage");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* End of file DisplayHandler.class.php */
|
||||||
|
/* Location: ./classes/display/DisplayHandler.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
class HTMLDisplayHandler
|
||||||
class HTMLDisplayHandler {
|
{
|
||||||
/**
|
/**
|
||||||
* Produce HTML compliant content given a module object.\n
|
* Produce HTML compliant content given a module object.\n
|
||||||
* @param ModuleObject $oModule the module object
|
* @param ModuleObject $oModule the module object
|
||||||
* @return string compiled template string
|
* @return string compiled template string
|
||||||
**/
|
*/
|
||||||
function toDoc(&$oModule)
|
function toDoc(&$oModule)
|
||||||
{
|
{
|
||||||
$oTemplate = &TemplateHandler::getInstance();
|
$oTemplate = &TemplateHandler::getInstance();
|
||||||
|
|
@ -28,7 +28,7 @@ class HTMLDisplayHandler {
|
||||||
{
|
{
|
||||||
$theme_skin = explode('|@|', $skin);
|
$theme_skin = explode('|@|', $skin);
|
||||||
$template_path = $oModule->getTemplatePath();
|
$template_path = $oModule->getTemplatePath();
|
||||||
if (count($theme_skin) == 2)
|
if(count($theme_skin) == 2)
|
||||||
{
|
{
|
||||||
$theme_path = sprintf('./themes/%s',$theme_skin[0]);
|
$theme_path = sprintf('./themes/%s',$theme_skin[0]);
|
||||||
if(substr($theme_path,0,strlen($theme_path)) != $theme_path)
|
if(substr($theme_path,0,strlen($theme_path)) != $theme_path)
|
||||||
|
|
@ -53,10 +53,12 @@ class HTMLDisplayHandler {
|
||||||
$output = $oTemplate->compile($template_path, $tpl_file);
|
$output = $oTemplate->compile($template_path, $tpl_file);
|
||||||
|
|
||||||
// add .x div for adminitration pages
|
// add .x div for adminitration pages
|
||||||
if(Context::getResponseMethod() == 'HTML') {
|
if(Context::getResponseMethod() == 'HTML')
|
||||||
|
{
|
||||||
if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin')>0) $output = '<div class="x">'.$output.'</div>';
|
if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin')>0) $output = '<div class="x">'.$output.'</div>';
|
||||||
|
|
||||||
if(Context::get('layout') != 'none') {
|
if(Context::get('layout') != 'none')
|
||||||
|
{
|
||||||
if(__DEBUG__==3) $start = getMicroTime();
|
if(__DEBUG__==3) $start = getMicroTime();
|
||||||
|
|
||||||
Context::set('content', $output, false);
|
Context::set('content', $output, false);
|
||||||
|
|
@ -72,10 +74,12 @@ class HTMLDisplayHandler {
|
||||||
$layout_srl = $layout_info->layout_srl;
|
$layout_srl = $layout_info->layout_srl;
|
||||||
|
|
||||||
// compile if connected to the layout
|
// compile if connected to the layout
|
||||||
if($layout_srl > 0){
|
if($layout_srl > 0)
|
||||||
|
{
|
||||||
|
|
||||||
// handle separately if the layout is faceoff
|
// handle separately if the layout is faceoff
|
||||||
if($layout_info && $layout_info->type == 'faceoff') {
|
if($layout_info && $layout_info->type == 'faceoff')
|
||||||
|
{
|
||||||
$oLayoutModel->doActivateFaceOff($layout_info);
|
$oLayoutModel->doActivateFaceOff($layout_info);
|
||||||
Context::set('layout_info', $layout_info);
|
Context::set('layout_info', $layout_info);
|
||||||
}
|
}
|
||||||
|
|
@ -91,7 +95,8 @@ class HTMLDisplayHandler {
|
||||||
|
|
||||||
if(__DEBUG__==3) $GLOBALS['__layout_compile_elapsed__'] = getMicroTime()-$start;
|
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')) {
|
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>');
|
Context::addHtmlFooter('<iframe id="xeTmpIframe" name="xeTmpIframe" style="width:1px;height:1px;position:absolute;top:-2px;left:-2px;"></iframe>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,8 +108,9 @@ class HTMLDisplayHandler {
|
||||||
* when display mode is HTML, prepare code before print.
|
* when display mode is HTML, prepare code before print.
|
||||||
* @param string $output compiled template string
|
* @param string $output compiled template string
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
*/
|
||||||
function prepareToPrint(&$output) {
|
function prepareToPrint(&$output)
|
||||||
|
{
|
||||||
if(Context::getResponseMethod() != 'HTML') return;
|
if(Context::getResponseMethod() != 'HTML') return;
|
||||||
|
|
||||||
if(__DEBUG__==3) $start = getMicroTime();
|
if(__DEBUG__==3) $start = getMicroTime();
|
||||||
|
|
@ -119,7 +125,8 @@ class HTMLDisplayHandler {
|
||||||
$output = preg_replace_callback('/<!--(#)?Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this,'_transMeta'), $output);
|
$output = preg_replace_callback('/<!--(#)?Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this,'_transMeta'), $output);
|
||||||
|
|
||||||
// handles a relative path generated by using the rewrite module
|
// handles a relative path generated by using the rewrite module
|
||||||
if(Context::isAllowRewrite()) {
|
if(Context::isAllowRewrite())
|
||||||
|
{
|
||||||
$url = parse_url(Context::getRequestUri());
|
$url = parse_url(Context::getRequestUri());
|
||||||
$real_path = $url['path'];
|
$real_path = $url['path'];
|
||||||
|
|
||||||
|
|
@ -129,7 +136,8 @@ class HTMLDisplayHandler {
|
||||||
$pattern = '/href=("|\'){1}(\?[^"\']+)/s';
|
$pattern = '/href=("|\'){1}(\?[^"\']+)/s';
|
||||||
$output = preg_replace($pattern, 'href=$1'.$real_path.'$2', $output);
|
$output = preg_replace($pattern, 'href=$1'.$real_path.'$2', $output);
|
||||||
|
|
||||||
if(Context::get('vid')) {
|
if(Context::get('vid'))
|
||||||
|
{
|
||||||
$pattern = '/\/'.Context::get('vid').'\?([^=]+)=/is';
|
$pattern = '/\/'.Context::get('vid').'\?([^=]+)=/is';
|
||||||
$output = preg_replace($pattern, '/?$1=', $output);
|
$output = preg_replace($pattern, '/?$1=', $output);
|
||||||
}
|
}
|
||||||
|
|
@ -164,7 +172,8 @@ class HTMLDisplayHandler {
|
||||||
// convert the final layout
|
// convert the final layout
|
||||||
Context::set('content', $output);
|
Context::set('content', $output);
|
||||||
$oTemplate = &TemplateHandler::getInstance();
|
$oTemplate = &TemplateHandler::getInstance();
|
||||||
if(Mobile::isFromMobilePhone()) {
|
if(Mobile::isFromMobilePhone())
|
||||||
|
{
|
||||||
$output = $oTemplate->compile('./common/tpl', 'mobile_layout');
|
$output = $oTemplate->compile('./common/tpl', 'mobile_layout');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -183,7 +192,7 @@ class HTMLDisplayHandler {
|
||||||
* when display mode is HTML, prepare code before print about <input> tag value.
|
* when display mode is HTML, prepare code before print about <input> tag value.
|
||||||
* @param array $match input value.
|
* @param array $match input value.
|
||||||
* @return string input value.
|
* @return string input value.
|
||||||
**/
|
*/
|
||||||
function _preserveValue($match)
|
function _preserveValue($match)
|
||||||
{
|
{
|
||||||
$INPUT_ERROR = Context::get('INPUT_ERROR');
|
$INPUT_ERROR = Context::get('INPUT_ERROR');
|
||||||
|
|
@ -194,7 +203,8 @@ class HTMLDisplayHandler {
|
||||||
$type = 'text';
|
$type = 'text';
|
||||||
if(preg_match('/\stype="([a-z]+)"/i', $str, $m)) $type = strtolower($m[1]);
|
if(preg_match('/\stype="([a-z]+)"/i', $str, $m)) $type = strtolower($m[1]);
|
||||||
|
|
||||||
switch($type){
|
switch($type)
|
||||||
|
{
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'hidden':
|
case 'hidden':
|
||||||
$str = preg_replace('@\svalue="[^"]*?"@', ' ', $str).' value="'.@htmlspecialchars($INPUT_ERROR[$match[3]]).'"';
|
$str = preg_replace('@\svalue="[^"]*?"@', ' ', $str).' value="'.@htmlspecialchars($INPUT_ERROR[$match[3]]).'"';
|
||||||
|
|
@ -205,7 +215,8 @@ class HTMLDisplayHandler {
|
||||||
case 'radio':
|
case 'radio':
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
$str = preg_replace('@\schecked(="[^"]*?")?@', ' ', $str);
|
$str = preg_replace('@\schecked(="[^"]*?")?@', ' ', $str);
|
||||||
if(@preg_match('@\s(?i:value)="'.$INPUT_ERROR[$match[3]].'"@', $str)) {
|
if(@preg_match('@\s(?i:value)="'.$INPUT_ERROR[$match[3]].'"@', $str))
|
||||||
|
{
|
||||||
$str .= ' checked="checked"';
|
$str .= ' checked="checked"';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -218,7 +229,7 @@ class HTMLDisplayHandler {
|
||||||
* when display mode is HTML, prepare code before print about <select> tag value.
|
* when display mode is HTML, prepare code before print about <select> tag value.
|
||||||
* @param array $matches select tag.
|
* @param array $matches select tag.
|
||||||
* @return string select tag.
|
* @return string select tag.
|
||||||
**/
|
*/
|
||||||
function _preserveSelectValue($matches)
|
function _preserveSelectValue($matches)
|
||||||
{
|
{
|
||||||
$INPUT_ERROR = Context::get('INPUT_ERROR');
|
$INPUT_ERROR = Context::get('INPUT_ERROR');
|
||||||
|
|
@ -232,7 +243,7 @@ class HTMLDisplayHandler {
|
||||||
{
|
{
|
||||||
return $matches[0];
|
return $matches[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$m[0][$key] = preg_replace('@(\svalue=".*?")@is', '$1 selected="selected"', $m[0][$key]);
|
$m[0][$key] = preg_replace('@(\svalue=".*?")@is', '$1 selected="selected"', $m[0][$key]);
|
||||||
|
|
||||||
return $mm[0].implode('', $m[0]).'</select>';
|
return $mm[0].implode('', $m[0]).'</select>';
|
||||||
|
|
@ -242,7 +253,7 @@ class HTMLDisplayHandler {
|
||||||
* when display mode is HTML, prepare code before print about <textarea> tag value.
|
* when display mode is HTML, prepare code before print about <textarea> tag value.
|
||||||
* @param array $matches textarea tag information.
|
* @param array $matches textarea tag information.
|
||||||
* @return string textarea tag
|
* @return string textarea tag
|
||||||
**/
|
*/
|
||||||
function _preserveTextAreaValue($matches)
|
function _preserveTextAreaValue($matches)
|
||||||
{
|
{
|
||||||
$INPUT_ERROR = Context::get('INPUT_ERROR');
|
$INPUT_ERROR = Context::get('INPUT_ERROR');
|
||||||
|
|
@ -255,8 +266,9 @@ class HTMLDisplayHandler {
|
||||||
* printed inside <header></header> later.
|
* printed inside <header></header> later.
|
||||||
* @param array $matches
|
* @param array $matches
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
*/
|
||||||
function _moveStyleToHeader($matches) {
|
function _moveStyleToHeader($matches)
|
||||||
|
{
|
||||||
Context::addHtmlHeader($matches[0]);
|
Context::addHtmlHeader($matches[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,8 +277,9 @@ class HTMLDisplayHandler {
|
||||||
* printed inside <header></header> later.
|
* printed inside <header></header> later.
|
||||||
* @param array $matches
|
* @param array $matches
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
*/
|
||||||
function _moveMetaToHeader($matches) {
|
function _moveMetaToHeader($matches)
|
||||||
|
{
|
||||||
Context::addHtmlHeader($matches[0]);
|
Context::addHtmlHeader($matches[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -274,8 +287,9 @@ class HTMLDisplayHandler {
|
||||||
* add given .css or .js file names in widget code to Context
|
* add given .css or .js file names in widget code to Context
|
||||||
* @param array $matches
|
* @param array $matches
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
*/
|
||||||
function _transMeta($matches) {
|
function _transMeta($matches)
|
||||||
|
{
|
||||||
if($matches[1]) return '';
|
if($matches[1]) return '';
|
||||||
Context::loadFile($matches[2]);
|
Context::loadFile($matches[2]);
|
||||||
}
|
}
|
||||||
|
|
@ -283,14 +297,15 @@ class HTMLDisplayHandler {
|
||||||
/**
|
/**
|
||||||
* import basic .js files.
|
* import basic .js files.
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
*/
|
||||||
function _loadJSCSS()
|
function _loadJSCSS()
|
||||||
{
|
{
|
||||||
$oContext =& Context::getInstance();
|
$oContext =& Context::getInstance();
|
||||||
$lang_type = Context::getLangType();
|
$lang_type = Context::getLangType();
|
||||||
|
|
||||||
// add common JS/CSS files
|
// add common JS/CSS files
|
||||||
if(__DEBUG__) {
|
if(__DEBUG__)
|
||||||
|
{
|
||||||
$oContext->loadFile(array('./common/js/jquery.js', 'head', '', -100000), true);
|
$oContext->loadFile(array('./common/js/jquery.js', 'head', '', -100000), true);
|
||||||
$oContext->loadFile(array('./common/js/x.js', 'head', '', -100000), true);
|
$oContext->loadFile(array('./common/js/x.js', 'head', '', -100000), true);
|
||||||
$oContext->loadFile(array('./common/js/common.js', 'head', '', -100000), true);
|
$oContext->loadFile(array('./common/js/common.js', 'head', '', -100000), true);
|
||||||
|
|
@ -298,7 +313,9 @@ class HTMLDisplayHandler {
|
||||||
$oContext->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000), true);
|
$oContext->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000), true);
|
||||||
$oContext->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000), true);
|
$oContext->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000), true);
|
||||||
$oContext->loadFile(array('./common/css/xe.css', '', '', -100000), true);
|
$oContext->loadFile(array('./common/css/xe.css', '', '', -100000), true);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$oContext->loadFile(array('./common/js/jquery.min.js', 'head', '', -100000), true);
|
$oContext->loadFile(array('./common/js/jquery.min.js', 'head', '', -100000), true);
|
||||||
$oContext->loadFile(array('./common/js/x.min.js', 'head', '', -100000), true);
|
$oContext->loadFile(array('./common/js/x.min.js', 'head', '', -100000), true);
|
||||||
$oContext->loadFile(array('./common/js/xe.min.js', 'head', '', -100000), true);
|
$oContext->loadFile(array('./common/js/xe.min.js', 'head', '', -100000), true);
|
||||||
|
|
@ -306,14 +323,18 @@ class HTMLDisplayHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for admin page, add admin css
|
// for admin page, add admin css
|
||||||
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0){
|
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0)
|
||||||
if(__DEBUG__) {
|
{
|
||||||
|
if(__DEBUG__)
|
||||||
|
{
|
||||||
$oContext->loadFile(array('./modules/admin/tpl/css/admin.css', '', '', 10), true);
|
$oContext->loadFile(array('./modules/admin/tpl/css/admin.css', '', '', 10), true);
|
||||||
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", '', '', 10), true);
|
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", '', '', 10), true);
|
||||||
$oContext->loadFile(array("./modules/admin/tpl/css/admin.iefix.css", '', 'ie', 10), true);
|
$oContext->loadFile(array("./modules/admin/tpl/css/admin.iefix.css", '', 'ie', 10), true);
|
||||||
$oContext->loadFile('./modules/admin/tpl/js/admin.js', true);
|
$oContext->loadFile('./modules/admin/tpl/js/admin.js', true);
|
||||||
$oContext->loadFile(array('./common/css/bootstrap.css', '', '', 1), true);
|
$oContext->loadFile(array('./common/css/bootstrap.css', '', '', 1), true);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$oContext->loadFile(array('./modules/admin/tpl/css/admin.min.css', '', '', 10), true);
|
$oContext->loadFile(array('./modules/admin/tpl/css/admin.min.css', '', '', 10), true);
|
||||||
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", '', '',10), true);
|
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", '', '',10), true);
|
||||||
$oContext->loadFile(array("./modules/admin/tpl/css/admin.iefix.min.css", '', 'ie', 10), true);
|
$oContext->loadFile(array("./modules/admin/tpl/css/admin.iefix.min.css", '', 'ie', 10), true);
|
||||||
|
|
@ -326,7 +347,7 @@ class HTMLDisplayHandler {
|
||||||
/**
|
/**
|
||||||
* add meta tag.
|
* add meta tag.
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
*/
|
||||||
function _addMetaTag()
|
function _addMetaTag()
|
||||||
{
|
{
|
||||||
$oContext =& Context::getInstance();
|
$oContext =& Context::getInstance();
|
||||||
|
|
@ -334,3 +355,5 @@ class HTMLDisplayHandler {
|
||||||
$oContext->addMetaTag('imagetoolbar', 'no');
|
$oContext->addMetaTag('imagetoolbar', 'no');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file HTMLDisplayHandler.class.php */
|
||||||
|
/* Location: ./classes/display/HTMLDisplayHandler.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
class JSCallbackDisplayHandler
|
||||||
class JSCallbackDisplayHandler{
|
{
|
||||||
/**
|
/**
|
||||||
* Produce JSCallback compliant content given a module object.\n
|
* Produce JSCallback compliant content given a module object.\n
|
||||||
* @param ModuleObject $oModule the module object
|
* @param ModuleObject $oModule the module object
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
*/
|
||||||
function toDoc(&$oModule)
|
function toDoc(&$oModule)
|
||||||
{
|
{
|
||||||
$variables = $oModule->getVariables();
|
$variables = $oModule->getVariables();
|
||||||
|
|
@ -16,3 +16,5 @@ class JSCallbackDisplayHandler{
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file JSCallback.class.php */
|
||||||
|
/* Location: ./classes/display/JSCallback.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
class JSONDisplayHandler
|
||||||
class JSONDisplayHandler {
|
{
|
||||||
/**
|
/**
|
||||||
* Produce JSON compliant content given a module object.\n
|
* Produce JSON compliant content given a module object.\n
|
||||||
* @param ModuleObject $oModule the module object
|
* @param ModuleObject $oModule the module object
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
*/
|
||||||
function toDoc(&$oModule)
|
function toDoc(&$oModule)
|
||||||
{
|
{
|
||||||
$variables = $oModule->getVariables();
|
$variables = $oModule->getVariables();
|
||||||
|
|
@ -15,3 +15,5 @@ class JSONDisplayHandler {
|
||||||
return $json;
|
return $json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file JSONDisplayHandler.class.php */
|
||||||
|
/* Location: ./classes/display/JSONDisplayHandler.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
class VirtualXMLDisplayHandler
|
||||||
class VirtualXMLDisplayHandler {
|
{
|
||||||
/**
|
/**
|
||||||
* Produce virtualXML compliant content given a module object.\n
|
* Produce virtualXML compliant content given a module object.\n
|
||||||
* @param ModuleObject $oModule the module object
|
* @param ModuleObject $oModule the module object
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
*/
|
||||||
|
|
||||||
function toDoc(&$oModule)
|
function toDoc(&$oModule)
|
||||||
{
|
{
|
||||||
|
|
@ -16,17 +16,21 @@ class VirtualXMLDisplayHandler {
|
||||||
$request_url = Context::get('xeVirtualRequestUrl');
|
$request_url = Context::get('xeVirtualRequestUrl');
|
||||||
if(substr($request_url,-1)!='/') $request_url .= '/';
|
if(substr($request_url,-1)!='/') $request_url .= '/';
|
||||||
|
|
||||||
if($error === 0) {
|
if($error === 0)
|
||||||
|
{
|
||||||
if($message != 'success') $output->message = $message;
|
if($message != 'success') $output->message = $message;
|
||||||
if($redirect_url) $output->url = $redirect_url;
|
if($redirect_url) $output->url = $redirect_url;
|
||||||
else $output->url = $request_uri;
|
else $output->url = $request_uri;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if($message != 'fail') $output->message = $message;
|
if($message != 'fail') $output->message = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = '<script>'."\n";
|
$html = '<script>'."\n";
|
||||||
if($output->message) $html .= 'alert("'.$output->message.'");'."\n";
|
if($output->message) $html .= 'alert("'.$output->message.'");'."\n";
|
||||||
if($output->url) {
|
if($output->url)
|
||||||
|
{
|
||||||
$url = preg_replace('/#(.+)$/i','',$output->url);
|
$url = preg_replace('/#(.+)$/i','',$output->url);
|
||||||
$html .= 'self.location.href = "'.$request_url.'common/tpl/redirect.html?redirect_url='.urlencode($url).'";'."\n";
|
$html .= 'self.location.href = "'.$request_url.'common/tpl/redirect.html?redirect_url='.urlencode($url).'";'."\n";
|
||||||
}
|
}
|
||||||
|
|
@ -34,5 +38,5 @@ class VirtualXMLDisplayHandler {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file VirtualXMLDisplayHandler.class.php */
|
||||||
?>
|
/* Location: ./classes/display/VirtualXMLDisplayHandler.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
class XMLDisplayHandler
|
||||||
class XMLDisplayHandler {
|
{
|
||||||
/**
|
/**
|
||||||
* Produce XML compliant content given a module object.\n
|
* Produce XML compliant content given a module object.\n
|
||||||
* @param ModuleObject $oModule the module object
|
* @param ModuleObject $oModule the module object
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
*/
|
||||||
function toDoc(&$oModule)
|
function toDoc(&$oModule)
|
||||||
{
|
{
|
||||||
$variables = $oModule->getVariables();
|
$variables = $oModule->getVariables();
|
||||||
|
|
@ -25,13 +25,14 @@ class XMLDisplayHandler {
|
||||||
* produce XML code given variable object\n
|
* produce XML code given variable object\n
|
||||||
* @param object $obj
|
* @param object $obj
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
*/
|
||||||
function _makeXmlDoc($obj) {
|
function _makeXmlDoc($obj) {
|
||||||
if(!count($obj)) return;
|
if(!count($obj)) return;
|
||||||
|
|
||||||
$xmlDoc = '';
|
$xmlDoc = '';
|
||||||
|
|
||||||
foreach($obj as $key => $val) {
|
foreach($obj as $key => $val)
|
||||||
|
{
|
||||||
if(is_numeric($key)) $key = 'item';
|
if(is_numeric($key)) $key = 'item';
|
||||||
|
|
||||||
if(is_string($val)) $xmlDoc .= sprintf('<%s><![CDATA[%s]]></%s>%s', $key, $val, $key,"\n");
|
if(is_string($val)) $xmlDoc .= sprintf('<%s><![CDATA[%s]]></%s>%s', $key, $val, $key,"\n");
|
||||||
|
|
@ -42,5 +43,5 @@ class XMLDisplayHandler {
|
||||||
return $xmlDoc;
|
return $xmlDoc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* End of file XMLDisplayHandler.class.php */
|
||||||
?>
|
/* Location: ./classes/display/XMLDisplayHandler.class.php */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue