mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 11:11:39 +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,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
class HTMLDisplayHandler {
|
||||
class HTMLDisplayHandler
|
||||
{
|
||||
/**
|
||||
* Produce HTML compliant content given a module object.\n
|
||||
* @param ModuleObject $oModule the module object
|
||||
* @return string compiled template string
|
||||
**/
|
||||
*/
|
||||
function toDoc(&$oModule)
|
||||
{
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
|
|
@ -28,7 +28,7 @@ class HTMLDisplayHandler {
|
|||
{
|
||||
$theme_skin = explode('|@|', $skin);
|
||||
$template_path = $oModule->getTemplatePath();
|
||||
if (count($theme_skin) == 2)
|
||||
if(count($theme_skin) == 2)
|
||||
{
|
||||
$theme_path = sprintf('./themes/%s',$theme_skin[0]);
|
||||
if(substr($theme_path,0,strlen($theme_path)) != $theme_path)
|
||||
|
|
@ -53,10 +53,12 @@ class HTMLDisplayHandler {
|
|||
$output = $oTemplate->compile($template_path, $tpl_file);
|
||||
|
||||
// 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('layout') != 'none') {
|
||||
|
||||
if(Context::get('layout') != 'none')
|
||||
{
|
||||
if(__DEBUG__==3) $start = getMicroTime();
|
||||
|
||||
Context::set('content', $output, false);
|
||||
|
|
@ -72,10 +74,12 @@ class HTMLDisplayHandler {
|
|||
$layout_srl = $layout_info->layout_srl;
|
||||
|
||||
// compile if connected to the layout
|
||||
if($layout_srl > 0){
|
||||
if($layout_srl > 0)
|
||||
{
|
||||
|
||||
// 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);
|
||||
Context::set('layout_info', $layout_info);
|
||||
}
|
||||
|
|
@ -91,7 +95,8 @@ class HTMLDisplayHandler {
|
|||
|
||||
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>');
|
||||
}
|
||||
}
|
||||
|
|
@ -103,8 +108,9 @@ class HTMLDisplayHandler {
|
|||
* when display mode is HTML, prepare code before print.
|
||||
* @param string $output compiled template string
|
||||
* @return void
|
||||
**/
|
||||
function prepareToPrint(&$output) {
|
||||
*/
|
||||
function prepareToPrint(&$output)
|
||||
{
|
||||
if(Context::getResponseMethod() != 'HTML') return;
|
||||
|
||||
if(__DEBUG__==3) $start = getMicroTime();
|
||||
|
|
@ -119,7 +125,8 @@ class HTMLDisplayHandler {
|
|||
$output = preg_replace_callback('/<!--(#)?Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this,'_transMeta'), $output);
|
||||
|
||||
// handles a relative path generated by using the rewrite module
|
||||
if(Context::isAllowRewrite()) {
|
||||
if(Context::isAllowRewrite())
|
||||
{
|
||||
$url = parse_url(Context::getRequestUri());
|
||||
$real_path = $url['path'];
|
||||
|
||||
|
|
@ -129,7 +136,8 @@ class HTMLDisplayHandler {
|
|||
$pattern = '/href=("|\'){1}(\?[^"\']+)/s';
|
||||
$output = preg_replace($pattern, 'href=$1'.$real_path.'$2', $output);
|
||||
|
||||
if(Context::get('vid')) {
|
||||
if(Context::get('vid'))
|
||||
{
|
||||
$pattern = '/\/'.Context::get('vid').'\?([^=]+)=/is';
|
||||
$output = preg_replace($pattern, '/?$1=', $output);
|
||||
}
|
||||
|
|
@ -164,7 +172,8 @@ class HTMLDisplayHandler {
|
|||
// convert the final layout
|
||||
Context::set('content', $output);
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
if(Mobile::isFromMobilePhone()) {
|
||||
if(Mobile::isFromMobilePhone())
|
||||
{
|
||||
$output = $oTemplate->compile('./common/tpl', 'mobile_layout');
|
||||
}
|
||||
else
|
||||
|
|
@ -183,7 +192,7 @@ class HTMLDisplayHandler {
|
|||
* when display mode is HTML, prepare code before print about <input> tag value.
|
||||
* @param array $match input value.
|
||||
* @return string input value.
|
||||
**/
|
||||
*/
|
||||
function _preserveValue($match)
|
||||
{
|
||||
$INPUT_ERROR = Context::get('INPUT_ERROR');
|
||||
|
|
@ -194,7 +203,8 @@ class HTMLDisplayHandler {
|
|||
$type = 'text';
|
||||
if(preg_match('/\stype="([a-z]+)"/i', $str, $m)) $type = strtolower($m[1]);
|
||||
|
||||
switch($type){
|
||||
switch($type)
|
||||
{
|
||||
case 'text':
|
||||
case 'hidden':
|
||||
$str = preg_replace('@\svalue="[^"]*?"@', ' ', $str).' value="'.@htmlspecialchars($INPUT_ERROR[$match[3]]).'"';
|
||||
|
|
@ -205,7 +215,8 @@ class HTMLDisplayHandler {
|
|||
case 'radio':
|
||||
case 'checkbox':
|
||||
$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"';
|
||||
}
|
||||
break;
|
||||
|
|
@ -218,7 +229,7 @@ class HTMLDisplayHandler {
|
|||
* when display mode is HTML, prepare code before print about <select> tag value.
|
||||
* @param array $matches select tag.
|
||||
* @return string select tag.
|
||||
**/
|
||||
*/
|
||||
function _preserveSelectValue($matches)
|
||||
{
|
||||
$INPUT_ERROR = Context::get('INPUT_ERROR');
|
||||
|
|
@ -232,7 +243,7 @@ class HTMLDisplayHandler {
|
|||
{
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
|
||||
$m[0][$key] = preg_replace('@(\svalue=".*?")@is', '$1 selected="selected"', $m[0][$key]);
|
||||
|
||||
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.
|
||||
* @param array $matches textarea tag information.
|
||||
* @return string textarea tag
|
||||
**/
|
||||
*/
|
||||
function _preserveTextAreaValue($matches)
|
||||
{
|
||||
$INPUT_ERROR = Context::get('INPUT_ERROR');
|
||||
|
|
@ -255,8 +266,9 @@ class HTMLDisplayHandler {
|
|||
* printed inside <header></header> later.
|
||||
* @param array $matches
|
||||
* @return void
|
||||
**/
|
||||
function _moveStyleToHeader($matches) {
|
||||
*/
|
||||
function _moveStyleToHeader($matches)
|
||||
{
|
||||
Context::addHtmlHeader($matches[0]);
|
||||
}
|
||||
|
||||
|
|
@ -265,8 +277,9 @@ class HTMLDisplayHandler {
|
|||
* printed inside <header></header> later.
|
||||
* @param array $matches
|
||||
* @return void
|
||||
**/
|
||||
function _moveMetaToHeader($matches) {
|
||||
*/
|
||||
function _moveMetaToHeader($matches)
|
||||
{
|
||||
Context::addHtmlHeader($matches[0]);
|
||||
}
|
||||
|
||||
|
|
@ -274,8 +287,9 @@ class HTMLDisplayHandler {
|
|||
* add given .css or .js file names in widget code to Context
|
||||
* @param array $matches
|
||||
* @return void
|
||||
**/
|
||||
function _transMeta($matches) {
|
||||
*/
|
||||
function _transMeta($matches)
|
||||
{
|
||||
if($matches[1]) return '';
|
||||
Context::loadFile($matches[2]);
|
||||
}
|
||||
|
|
@ -283,14 +297,15 @@ class HTMLDisplayHandler {
|
|||
/**
|
||||
* import basic .js files.
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
function _loadJSCSS()
|
||||
{
|
||||
$oContext =& Context::getInstance();
|
||||
$lang_type = Context::getLangType();
|
||||
|
||||
// add common JS/CSS files
|
||||
if(__DEBUG__) {
|
||||
if(__DEBUG__)
|
||||
{
|
||||
$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/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_js_filter.js', 'head', '', -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/x.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
|
||||
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0){
|
||||
if(__DEBUG__) {
|
||||
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0)
|
||||
{
|
||||
if(__DEBUG__)
|
||||
{
|
||||
$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.iefix.css", '', 'ie', 10), true);
|
||||
$oContext->loadFile('./modules/admin/tpl/js/admin.js', 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_{$lang_type}.css", '', '',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.
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
function _addMetaTag()
|
||||
{
|
||||
$oContext =& Context::getInstance();
|
||||
|
|
@ -334,3 +355,5 @@ class HTMLDisplayHandler {
|
|||
$oContext->addMetaTag('imagetoolbar', 'no');
|
||||
}
|
||||
}
|
||||
/* End of file HTMLDisplayHandler.class.php */
|
||||
/* Location: ./classes/display/HTMLDisplayHandler.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue