Unit path and webpath, correct some more

This commit is contained in:
Brice Maron 2012-06-03 21:13:30 +00:00
parent 6832aec60f
commit cc494259d3
6 changed files with 42 additions and 28 deletions

View File

@ -20,7 +20,7 @@
<div id="firstrun" style="display: none;">
<?php
echo $l->t('You have no bookmarks');
require_once(OC::$APPSROOT . '/apps/bookmarks/templates/bookmarklet.php');
require_once(OC_App::getAppPath('bookmarks') .'/templates/bookmarklet.php');
createBookmarklet();
?>
</div>

View File

@ -12,7 +12,8 @@
<?php endforeach; ?>
<script type="text/javascript">
var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
var oc_appswebroot = '<?php echo OC::$APPSWEBROOT; ?>';
var oc_appswebroot = '<?php //echo OC::$APPSWEBROOT; ?>';
// TODO: PATH
var oc_current_user = '<?php echo OC_User::getUser() ?>';
</script>
<?php if (!defined('DEBUG') || !DEBUG): ?>

View File

@ -328,11 +328,23 @@ class OC_App{
*/
public static function getAppPath($appid) {
foreach(OC::$APPSROOTS as $dir) {
if(file_exists($dir.'/'.$appid)) {
return $dir.'/'.$appid;
if(file_exists($dir['path'].'/'.$appid)) {
return $dir['path'].'/'.$appid;
}
}
return false;
}
/**
* Get the path for the given app on the access
* If the app is defined in multiple directory, the first one is taken. (false if not found)
*/
public static function getAppWebPath($appid) {
foreach(OC::$APPSROOTS as $dir) {
if(file_exists($dir['path'].'/'.$appid)) {
return $dir['web'].'/'.$appid;
}
}
// OC_Log::write('core','Unable to find app "'.$appid.'"',OC_Log::ERROR);
return false;
}
@ -477,9 +489,9 @@ class OC_App{
public static function getAllApps(){
$apps=array();
foreach(OC::$APPSROOTS as $apps_dir) {
$dh=opendir($apps_dir);
$dh=opendir($apps_dir['path']);
while($file=readdir($dh)){
if(substr($file,0,1)!='.' and is_file($apps_dir.'/'.$file.'/appinfo/app.php')){
if(substr($file,0,1)!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')){
$apps[]=$file;
}
}

View File

@ -55,13 +55,9 @@ class OC{
*/
public static $THIRDPARTYWEBROOT = '';
/**
* The installation path of the apps folder on the server (e.g. /srv/http/owncloud)
* The installation path array of the apps folder on the server (e.g. /srv/http/owncloud) 'real' and web path in 'web'
*/
public static $APPSROOTS = array();
/**
* the root path of the apps folder for http requests (e.g. owncloud)
*/
public static $APPSWEBROOT = '';
/*
* requested app
*/
@ -168,27 +164,31 @@ class OC{
// search the apps folder
if(OC_Config::getValue('appsroot', '')<>''){
OC::$APPSROOTS=explode(':',OC_Config::getValue('appsroot', ''));
OC::$APPSWEBROOT=OC_Config::getValue('appsurl', '');
}elseif(file_exists(OC::$SERVERROOT.'/apps')){
OC::$APPSROOTS= array(OC::$SERVERROOT.'/apps');
OC::$APPSWEBROOT=OC::$WEBROOT;
}
if(file_exists(OC::$SERVERROOT.'/../apps')){
OC::$APPSROOTS[] = rtrim(realpath(OC::$SERVERROOT.'/../apps'), '/');
// OC::$APPSWEBROOT=rtrim(dirname(OC::$WEBROOT), '/');
$real_a = explode(':',OC_Config::getValue('appsroot', ''));
$web_a = explode(':',OC_Config::getValue('appsurl', ''));
foreach($real_a as $k => $path) {
if(!isset($web_a[$k])){
echo("Apps root and appsurl not mathing. You need to have the same number of paths");
exit;
}
OC::$APPSROOTS[] = array('path'=> $path, 'web' => $web_a[$k]);
}
}
if(empty(OC::$APPSROOTS)){
echo("apps directory not found! Please put the ownCloud apps folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
exit;
}
$paths = array();
foreach( OC::$APPSROOTS as $path)
$paths[] = $path['path'];
// set the right include path
set_include_path(
OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.
OC::$SERVERROOT.'/config'.PATH_SEPARATOR.
OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR.
implode(OC::$APPSROOTS,PATH_SEPARATOR).PATH_SEPARATOR.
implode($paths,PATH_SEPARATOR).PATH_SEPARATOR.
get_include_path().PATH_SEPARATOR.
OC::$SERVERROOT
);
@ -292,6 +292,7 @@ class OC{
require_once(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE);
}
}else{
die();
header('HTTP/1.0 404 Not Found');
exit;
}

View File

@ -48,7 +48,7 @@ class OC_Helper {
$urlLinkTo = OC::$WEBROOT . '/?app=' . $app;
$urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):'';
}else{
$urlLinkTo = OC::$APPSWEBROOT . '/apps/' . $app . $file;
$urlLinkTo = OC_App::getAppWebPath($app) . $file;
}
}
else{
@ -151,7 +151,7 @@ class OC_Helper {
if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image" )){
return OC::$WEBROOT."/themes/$theme/apps/$app/img/$image";
}elseif( file_exists(OC_App::getAppPath($app)."/img/$image" )){
return OC::$APPSWEBROOT."/apps/$app/img/$image";
return OC_App::getAppWebPath($app)."/img/$image";
}elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/themes/$theme/$app/img/$image" )){
return OC::$WEBROOT."/themes/$theme/$app/img/$image";
}elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/$app/img/$image" )){

View File

@ -415,8 +415,8 @@ class OC_Template{
$append = false;
foreach( OC::$APPSROOTS as $apps_dir)
{
if($page->appendIfExist('jsfiles', $apps_dir, OC::$APPSWEBROOT.'/apps/', "$script$fext.js" , true)) { $append =true; break; }
elseif($page->appendIfExist('jsfiles', $apps_dir, OC::$APPSWEBROOT.'/apps/', "$script.js", true )) { $append =true; break; }
if($page->appendIfExist('jsfiles', $apps_dir['path'], $apps_dir['web'], "$script$fext.js" , true)) { $append =true; break; }
elseif($page->appendIfExist('jsfiles', $apps_dir['path'], $apps_dir['web'], "$script.js", true )) { $append =true; break; }
}
if(! $append) {
echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
@ -443,8 +443,8 @@ class OC_Template{
$append = false;
foreach( OC::$APPSROOTS as $apps_dir)
{
if($page->appendIfExist('cssfiles', $apps_dir, OC::$APPSWEBROOT, "$style$fext.css", true)) { $append =true; break; }
elseif($page->appendIfExist('cssfiles', $apps_dir, OC::$APPSWEBROOT, "$style.css", true )) { $append =true; break; }
if($page->appendIfExist('cssfiles', $apps_dir['path'], $apps_dir['web'], "$style$fext.css", true)) { $append =true; break; }
elseif($page->appendIfExist('cssfiles', $apps_dir['path'], $apps_dir['web'], "$style.css", true )) { $append =true; break; }
}
if(! $append) {
echo('css file not found: style:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);