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