|
|
@ -24,25 +24,36 @@ Class Controller { |
|
|
|
|
|
|
|
|
|
|
|
//render view |
|
|
|
//render view |
|
|
|
protected function render($viewName, $viewData = array(), $pageTitle = '') { |
|
|
|
protected function render($viewName, $viewData = array(), $pageTitle = '') { |
|
|
|
$layoutFile = __DIR__ . '/../views/layout/' . $this->layout . '.php'; |
|
|
|
$baseLayoutFile = $themeLayoutFile = $layoutFile = ''; |
|
|
|
$viewFile = __DIR__ . '/../views/' . FSC::$app['controller'] . '/' . $viewName . '.php'; |
|
|
|
$baseViewFile = $themeViewFile = $viewFile = ''; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$baseLayoutFile = __DIR__ . '/../views/layout/' . $this->layout . '.php'; |
|
|
|
|
|
|
|
$baseViewFile = __DIR__ . '/../views/' . FSC::$app['controller'] . '/' . $viewName . '.php'; |
|
|
|
//双斜杠//开头的共享视图支持 |
|
|
|
//双斜杠//开头的共享视图支持 |
|
|
|
if (preg_match('/^\/\//', $viewName)) { |
|
|
|
if (preg_match('/^\/\//', $viewName)) { |
|
|
|
$viewFile = __DIR__ . '/../views/' . str_replace('//', '/', $viewName) . '.php'; |
|
|
|
$baseViewFile = __DIR__ . '/../views/' . str_replace('//', '/', $viewName) . '.php'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!empty(FSC::$app['config']['theme'])) { |
|
|
|
if (!empty(FSC::$app['config']['theme'])) { |
|
|
|
$layoutFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/layout/' . $this->layout . '.php'; |
|
|
|
$themeLayoutFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/layout/' . $this->layout . '.php'; |
|
|
|
$viewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' . FSC::$app['controller'] . '/' . $viewName . '.php'; |
|
|
|
$themeViewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' . FSC::$app['controller'] . '/' . $viewName . '.php'; |
|
|
|
//双斜杠//开头的共享视图支持 |
|
|
|
//双斜杠//开头的共享视图支持 |
|
|
|
if (preg_match('/^\/\//', $viewName)) { |
|
|
|
if (preg_match('/^\/\//', $viewName)) { |
|
|
|
$viewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' . |
|
|
|
$themeViewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' . |
|
|
|
str_replace('//', '/', $viewName) . '.php'; |
|
|
|
str_replace('//', '/', $viewName) . '.php'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($themeLayoutFile) && file_exists($themeLayoutFile)) { |
|
|
|
|
|
|
|
$layoutFile = $themeLayoutFile; |
|
|
|
|
|
|
|
$viewFile = $themeViewFile; |
|
|
|
|
|
|
|
}else if (file_exists($baseLayoutFile)) { |
|
|
|
|
|
|
|
$layoutFile = $baseLayoutFile; |
|
|
|
|
|
|
|
$viewFile = $baseViewFile; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//include layout and view |
|
|
|
//include layout and view |
|
|
|
if (file_exists($layoutFile)) { |
|
|
|
if (!empty($layoutFile)) { |
|
|
|
ob_start(); |
|
|
|
ob_start(); |
|
|
|
include_once $layoutFile; |
|
|
|
include_once $layoutFile; |
|
|
|
|
|
|
|
|
|
|
|