diff --git a/framework/helper.class.php b/framework/helper.class.php index ef0e5e1074..317ad9ccba 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -440,6 +440,50 @@ class helper if(substr($string, 0, 3) == pack('CCC', 239, 187, 191)) return substr($string, 3); return $string; } + + /** + * Set viewType. + * + * @static + * @access public + * @return void + */ + public static function setViewType() + { + global $config, $app; + if($config->requestType == 'PATH_INFO') + { + $pathInfo = $app->getPathInfo('PATH_INFO'); + if(empty($pathInfo)) $pathInfo = $app->getPathInfo('ORIG_PATH_INFO'); + if(!empty($pathInfo)) + { + $dotPos = strrpos($pathInfo, '.'); + if($dotPos) + { + $viewType = substr($pathInfo, $dotPos + 1); + } + else + { + $config->default->view = $config->default->view == 'mhtml' ? 'html' : $config->default->view; + } + } + } + elseif($config->requestType == 'GET') + { + if(isset($_GET[$config->viewVar])) + { + $viewType = $_GET[$config->viewVar]; + } + else + { + /* Set default view when url has not module name. such as only domain. */ + $config->default->view = ($config->default->view == 'mhtml' and isset($_GET[$config->moduleVar])) ? 'html' : $config->default->view; + } + } + + if(strpos($config->views, ',' . $viewType . ',') === false) $viewType = $config->default->view; + $app->viewType = isset($viewType) ? $viewType : $config->default->view; + } } /** diff --git a/framework/router.class.php b/framework/router.class.php index a5e477fe8c..755a89d0cf 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -854,10 +854,10 @@ class router * Mostly, the var name of PATH_INFO is PATH_INFO, but may be ORIG_PATH_INFO. * * @param string $varName PATH_INFO, ORIG_PATH_INFO - * @access private + * @access public * @return string the PATH_INFO */ - private function getPathInfo($varName) + public function getPathInfo($varName) { $value = @getenv($varName); if(isset($_SERVER[$varName])) $value = $_SERVER[$varName]; diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 14afed070c..400cfb0ab9 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -44,6 +44,7 @@ $lang->save = 'Save'; $lang->confirm = 'Confirm'; $lang->preview = 'View'; $lang->goback = 'Back'; +$lang->goPC = 'PC'; $lang->go = 'GO'; $lang->more = 'More'; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index a82e9233dc..3b9dc20596 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -44,6 +44,7 @@ $lang->save = '保存'; $lang->confirm = '确认'; $lang->preview = '查看'; $lang->goback = '返回'; +$lang->goPC = 'PC版'; $lang->go = 'GO'; $lang->more = '更多'; diff --git a/module/common/view/m.header.html.php b/module/common/view/m.header.html.php index 3516079bce..a9279e013e 100755 --- a/module/common/view/m.header.html.php +++ b/module/common/view/m.header.html.php @@ -3,7 +3,8 @@ if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper:: include 'm.header.lite.html.php'; ?>