Unit path and webpath, correct some more

remotes/origin/stable45
Brice Maron 13 years ago
parent 6832aec60f
commit cc494259d3
  1. 2
      apps/bookmarks/templates/list.php
  2. 3
      core/templates/layout.user.php
  3. 22
      lib/app.php
  4. 31
      lib/base.php
  5. 4
      lib/helper.php
  6. 8
      lib/template.php

@ -20,7 +20,7 @@
<div id="firstrun" style="display: none;"> <div id="firstrun" style="display: none;">
<?php <?php
echo $l->t('You have no bookmarks'); 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(); createBookmarklet();
?> ?>
</div> </div>

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

@ -328,11 +328,23 @@ class OC_App{
*/ */
public static function getAppPath($appid) { public static function getAppPath($appid) {
foreach(OC::$APPSROOTS as $dir) { foreach(OC::$APPSROOTS as $dir) {
if(file_exists($dir.'/'.$appid)) { if(file_exists($dir['path'].'/'.$appid)) {
return $dir.'/'.$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; return false;
} }
@ -477,9 +489,9 @@ class OC_App{
public static function getAllApps(){ public static function getAllApps(){
$apps=array(); $apps=array();
foreach(OC::$APPSROOTS as $apps_dir) { foreach(OC::$APPSROOTS as $apps_dir) {
$dh=opendir($apps_dir); $dh=opendir($apps_dir['path']);
while($file=readdir($dh)){ 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; $apps[]=$file;
} }
} }

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

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

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

Loading…
Cancel
Save