Routing: Prepare load funtions to be called from OC_Router

This commit is contained in:
Bart Visscher 2012-08-12 16:16:22 +02:00
parent 1025e451a7
commit 8c02494744
1 changed files with 14 additions and 11 deletions

View File

@ -430,9 +430,12 @@ class OC{
OC_Response::setStatus(405); OC_Response::setStatus(405);
return; return;
} }
$app = OC::$REQUESTEDAPP;
$file = OC::$REQUESTEDFILE;
$param = array('app' => $app, 'file' => $file);
// Handle app css files // Handle app css files
if(substr(OC::$REQUESTEDFILE,-3) == 'css') { if(substr($file,-3) == 'css') {
self::loadCSSFile(); self::loadCSSFile($param);
return; return;
} }
// Someone is logged in : // Someone is logged in :
@ -442,14 +445,12 @@ class OC{
OC_User::logout(); OC_User::logout();
header("Location: ".OC::$WEBROOT.'/'); header("Location: ".OC::$WEBROOT.'/');
}else{ }else{
$app = OC::$REQUESTEDAPP;
$file = OC::$REQUESTEDFILE;
if(is_null($file)) { if(is_null($file)) {
$file = 'index.php'; $param['file'] = 'index.php';
} }
$file_ext = substr($file, -3); $file_ext = substr($param['file'], -3);
if ($file_ext != 'php' if ($file_ext != 'php'
|| !self::loadAppScriptFile($app, $file)) { || !self::loadAppScriptFile($param)) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
} }
} }
@ -459,7 +460,9 @@ class OC{
self::handleLogin(); self::handleLogin();
} }
protected static function loadAppScriptFile($app, $file) { public static function loadAppScriptFile($param) {
$app = $param['app'];
$file = $param['file'];
$app_path = OC_App::getAppPath($app); $app_path = OC_App::getAppPath($app);
$file = $app_path . '/' . $file; $file = $app_path . '/' . $file;
unset($app, $app_path); unset($app, $app_path);
@ -470,9 +473,9 @@ class OC{
return false; return false;
} }
protected static function loadCSSFile() { public static function loadCSSFile($param) {
$app = OC::$REQUESTEDAPP; $app = $param['app'];
$file = OC::$REQUESTEDFILE; $file = $param['file'];
$app_path = OC_App::getAppPath($app); $app_path = OC_App::getAppPath($app);
if (file_exists($app_path . '/' . $file)) { if (file_exists($app_path . '/' . $file)) {
$app_web_path = OC_App::getAppWebPath($app); $app_web_path = OC_App::getAppWebPath($app);