|
|
|
@ -24,7 +24,10 @@ Class FSC {
@@ -24,7 +24,10 @@ Class FSC {
|
|
|
|
|
$layoutName = !empty($config['error_layout']) ? $config['error_layout'] : 'error'; |
|
|
|
|
$error_layout = __DIR__ . "/../views/layout/{$layoutName}.php"; |
|
|
|
|
if (!empty($config['theme'])) { |
|
|
|
|
$error_layout = __DIR__ . "/../themes/{$config['theme']}/views/layout/{$layoutName}.php"; |
|
|
|
|
$theme_error_layout = __DIR__ . "/../themes/{$config['theme']}/views/layout/{$layoutName}.php"; |
|
|
|
|
if (file_exists($theme_error_layout)) { |
|
|
|
|
$error_layout = $theme_error_layout; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ob_start(); |
|
|
|
@ -63,6 +66,7 @@ Class FSC {
@@ -63,6 +66,7 @@ Class FSC {
|
|
|
|
|
return compact('controller', 'action'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//add themes support |
|
|
|
|
protected static function loadController($config) { |
|
|
|
|
//parse url to controller and action |
|
|
|
|
$requestUrl = $_SERVER['REQUEST_URI']; |
|
|
|
@ -78,16 +82,27 @@ Class FSC {
@@ -78,16 +82,27 @@ Class FSC {
|
|
|
|
|
$className = ucfirst($controller) . 'Controller'; |
|
|
|
|
$funName = 'action' . ucfirst($action); |
|
|
|
|
$controllerFile = __DIR__ . "/../controller/{$className}.php"; |
|
|
|
|
if (!empty($config['theme'])) { |
|
|
|
|
$controllerFile = __DIR__ . "/../themes/{$config['theme']}/controller/{$className}.php"; |
|
|
|
|
} |
|
|
|
|
if (file_exists($controllerFile)) { |
|
|
|
|
require_once $controllerFile; |
|
|
|
|
$cls = new $className(); |
|
|
|
|
if (method_exists($className, $funName)) { |
|
|
|
|
$cls->$funName(); |
|
|
|
|
}else { |
|
|
|
|
throw new Exception("Function {$funName} not exist in class {$className}.", 500); |
|
|
|
|
$error_message = "Function {$funName} not exist in class {$className}."; |
|
|
|
|
if (!empty($config['theme'])) { |
|
|
|
|
$error_message = "Function {$funName} not exist in class {$className} of theme {$config['theme']}."; |
|
|
|
|
} |
|
|
|
|
throw new Exception($error_message, 500); |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
throw new Exception("Controller {$className} not exist.", 500); |
|
|
|
|
$error_message = "Controller {$className} not exist."; |
|
|
|
|
if (!empty($config['theme'])) { |
|
|
|
|
$error_message = "Controller {$className} not exist in theme {$config['theme']}."; |
|
|
|
|
} |
|
|
|
|
throw new Exception($error_message, 500); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|