make the location of the 3rdparty folder flexible.

It´s automatically search in the owncloud folder and in the parent folder.
override with an option in config.php is also possible
This commit is contained in:
Frank Karlitschek 2012-02-23 15:37:38 +01:00
parent 196d619689
commit a62e109e8c
4 changed files with 54 additions and 5 deletions

View File

@ -7,7 +7,7 @@
*/ */
require_once ('../../../lib/base.php'); require_once ('../../../lib/base.php');
require_once('../../../3rdparty/when/When.php'); require_once('when/When.php');
function create_return_event($event, $vevent){ function create_return_event($event, $vevent){
$return_event = array(); $return_event = array();

View File

@ -13,6 +13,8 @@ $CONFIG = array(
"forcessl" => false, "forcessl" => false,
"enablebackup" => false, "enablebackup" => false,
"theme" => "", "theme" => "",
"3rdpartyroot" => "",
"3rdpartyurl" => "",
// "datadirectory" => "" // "datadirectory" => ""
); );
?> ?>

View File

@ -54,6 +54,14 @@ class OC{
* the folder that stores the data for the root filesystem (e.g. /srv/http/owncloud/data) * the folder that stores the data for the root filesystem (e.g. /srv/http/owncloud/data)
*/ */
public static $CONFIG_DATADIRECTORY_ROOT = ''; public static $CONFIG_DATADIRECTORY_ROOT = '';
/**
* The installation path of the 3rdparty folder on the server (e.g. /srv/http/owncloud/3rdparty)
*/
public static $THIRDPARTYROOT = '';
/**
* the root path of the 3rdparty folder for http requests (e.g. owncloud/3rdparty)
*/
public static $THIRDPARTYWEBROOT = '';
/** /**
* SPL autoload * SPL autoload
@ -138,12 +146,35 @@ class OC{
} }
OC::$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen(OC::$SUBURI)); OC::$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen(OC::$SUBURI));
if(OC::$WEBROOT!='' and OC::$WEBROOT[0]!=='/'){ if(OC::$WEBROOT!='' and OC::$WEBROOT[0]!=='/'){
OC::$WEBROOT='/'.OC::$WEBROOT; OC::$WEBROOT='/'.OC::$WEBROOT;
} }
// search the 3rdparty folder
if(OC_Config::getValue('3rdpartyroot', '')<>'' and OC_Config::getValue('3rdpartyurl', '')<>''){
OC::$THIRDPARTYROOT=OC_Config::getValue('3rdpartyroot', '');
OC::$THIRDPARTYWEBROOT=OC_Config::getValue('3rdpartyurl', '');
}elseif(file_exists(OC::$SERVERROOT.'/3rdparty')){
OC::$THIRDPARTYROOT=OC::$SERVERROOT;
OC::$THIRDPARTYWEBROOT=OC::$WEBROOT;
}elseif(file_exists(OC::$SERVERROOT.'/../3rdparty')){
$url_tmp=explode('/',OC::$WEBROOT);
$length=count($url_tmp);
unset($url_tmp[$length-1]);
OC::$THIRDPARTYWEBROOT=implode('/',$url_tmp);
$root_tmp=explode('/',OC::$SERVERROOT);
$length=count($root_tmp);
unset($root_tmp[$length-1]);
OC::$THIRDPARTYROOT=implode('/',$root_tmp);
}else{
echo("3rdparty directory not found! Please put the ownCloud 3rdparty folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
exit;
}
// set the right include path // set the right include path
set_include_path(OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.OC::$SERVERROOT.'/config'.PATH_SEPARATOR.OC::$SERVERROOT.'/3rdparty'.PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.OC::$SERVERROOT); set_include_path(OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.OC::$SERVERROOT.'/config'.PATH_SEPARATOR.OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.OC::$SERVERROOT);
// Redirect to installer if not installed // Redirect to installer if not installed
if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') { if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {

View File

@ -346,31 +346,41 @@ class OC_Template{
// Add the core js files or the js files provided by the selected theme // Add the core js files or the js files provided by the selected theme
foreach(OC_Util::$scripts as $script){ foreach(OC_Util::$scripts as $script){
if(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script$fext.js" )){ // Is it in 3rd party?
if(is_file(OC::$THIRDPARTYROOT."/$script.js" )){
$page->append( "jsfiles", OC::$THIRDPARTYWEBROOT."/$script.js" );
// Is it in apps and overwritten by the theme?
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script$fext.js" ); $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script.js" )){ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script.js" ); $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script.js" );
// Is it part of an app?
}elseif(is_file(OC::$SERVERROOT."/apps/$script$fext.js" )){ }elseif(is_file(OC::$SERVERROOT."/apps/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/apps/$script$fext.js" ); $page->append( "jsfiles", OC::$WEBROOT."/apps/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/apps/$script.js" )){ }elseif(is_file(OC::$SERVERROOT."/apps/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/apps/$script.js" ); $page->append( "jsfiles", OC::$WEBROOT."/apps/$script.js" );
// Is it in the owncloud root but overwritten by the theme?
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script$fext.js" )){ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script$fext.js" ); $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script.js" )){ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script.js" ); $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script.js" );
// Is it in the owncloud root ?
}elseif(is_file(OC::$SERVERROOT."/$script$fext.js" )){ }elseif(is_file(OC::$SERVERROOT."/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/$script$fext.js" ); $page->append( "jsfiles", OC::$WEBROOT."/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/$script.js" )){ }elseif(is_file(OC::$SERVERROOT."/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/$script.js" ); $page->append( "jsfiles", OC::$WEBROOT."/$script.js" );
// Is in core but overwritten by a theme?
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script$fext.js" )){ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script$fext.js" ); $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script.js" )){ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script.js" ); $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script.js" );
// Is it in core?
}elseif(is_file(OC::$SERVERROOT."/core/$script$fext.js" )){ }elseif(is_file(OC::$SERVERROOT."/core/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/core/$script$fext.js" ); $page->append( "jsfiles", OC::$WEBROOT."/core/$script$fext.js" );
}else{ }else{
@ -380,14 +390,20 @@ class OC_Template{
} }
// Add the css files // Add the css files
foreach(OC_Util::$styles as $style){ foreach(OC_Util::$styles as $style){
if(is_file(OC::$SERVERROOT."/apps/$style$fext.css" )){ // is it in 3rdparty?
if(is_file(OC::$THIRDPARTYROOT."/$style.css" )){
$page->append( "cssfiles", OC::$THIRDPARTYWEBROOT."/$style.css" );
// or in apps?
}elseif(is_file(OC::$SERVERROOT."/apps/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/apps/$style$fext.css" ); $page->append( "cssfiles", OC::$WEBROOT."/apps/$style$fext.css" );
}elseif(is_file(OC::$SERVERROOT."/apps/$style.css" )){ }elseif(is_file(OC::$SERVERROOT."/apps/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/apps/$style.css" ); $page->append( "cssfiles", OC::$WEBROOT."/apps/$style.css" );
// or in the owncloud root?
}elseif(is_file(OC::$SERVERROOT."/$style$fext.css" )){ }elseif(is_file(OC::$SERVERROOT."/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/$style$fext.css" ); $page->append( "cssfiles", OC::$WEBROOT."/$style$fext.css" );
}elseif(is_file(OC::$SERVERROOT."/$style.css" )){ }elseif(is_file(OC::$SERVERROOT."/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/$style.css" ); $page->append( "cssfiles", OC::$WEBROOT."/$style.css" );
// or in core ?
}elseif(is_file(OC::$SERVERROOT."/core/$style$fext.css" )){ }elseif(is_file(OC::$SERVERROOT."/core/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/core/$style$fext.css" ); $page->append( "cssfiles", OC::$WEBROOT."/core/$style$fext.css" );
}else{ }else{