Cleanup OC::loadfile

This commit is contained in:
Bart Visscher 2012-08-10 00:40:16 +02:00
parent 667cd318fe
commit 0973969386
1 changed files with 21 additions and 11 deletions

View File

@ -257,25 +257,35 @@ class OC{
session_start(); session_start();
} }
public static function loadapp(){ public static function loadapp() {
if(file_exists(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/index.php')){ if(file_exists(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/index.php')) {
require_once(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/index.php'); require_once(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/index.php');
}else{ }
else {
trigger_error('The requested App was not found.', E_USER_ERROR);//load default app instead? trigger_error('The requested App was not found.', E_USER_ERROR);//load default app instead?
} }
} }
public static function loadfile(){ public static function loadfile() {
if(file_exists(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/' . OC::$REQUESTEDFILE)){ $app = OC::$REQUESTEDAPP;
if(substr(OC::$REQUESTEDFILE, -3) == 'css'){ $file = OC::$REQUESTEDFILE;
$file = OC_App::getAppWebPath(OC::$REQUESTEDAPP). '/' . OC::$REQUESTEDFILE; $app_path = OC_App::getAppPath($app);
if(file_exists($app_path . '/' . $file)) {
$file_ext = substr($file, -3);
if ($file_ext == 'css') {
$app_web_path = OC_App::getAppWebPath($app);
$filepath = $app_web_path . '/' . $file;
$minimizer = new OC_Minimizer_CSS(); $minimizer = new OC_Minimizer_CSS();
$minimizer->output(array(array(OC_App::getAppPath(OC::$REQUESTEDAPP), OC_App::getAppWebPath(OC::$REQUESTEDAPP), OC::$REQUESTEDFILE)),$file); $info = array($app_path, $app_web_path, $file);
$minimizer->output(array($info), $filepath);
exit; exit;
}elseif(substr(OC::$REQUESTEDFILE, -3) == 'php'){ } elseif($file_ext == 'php') {
require_once(OC_App::getAppPath(OC::$REQUESTEDAPP). '/' . OC::$REQUESTEDFILE); $file = $app_path . '/' . $file;
unset($app, $app_path, $app_web_path, $file_ext);
require_once($file);
} }
}else{ }
else {
die(); die();
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
exit; exit;