add the option to only load apps of a specific type
This commit is contained in:
parent
a07c6b1a2e
commit
523fdda399
|
@ -7,4 +7,7 @@
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Robin Appelman</author>
|
<author>Robin Appelman</author>
|
||||||
<require>3</require>
|
<require>3</require>
|
||||||
|
<types>
|
||||||
|
<filesystem/>
|
||||||
|
</types>
|
||||||
</info>
|
</info>
|
||||||
|
|
|
@ -7,4 +7,7 @@
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Robin Appelman</author>
|
<author>Robin Appelman</author>
|
||||||
<require>3</require>
|
<require>3</require>
|
||||||
|
<types>
|
||||||
|
<filesystem/>
|
||||||
|
</types>
|
||||||
</info>
|
</info>
|
||||||
|
|
|
@ -7,4 +7,7 @@
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Robin Appelman</author>
|
<author>Robin Appelman</author>
|
||||||
<require>3</require>
|
<require>3</require>
|
||||||
|
<types>
|
||||||
|
<filesystem/>
|
||||||
|
</types>
|
||||||
</info>
|
</info>
|
||||||
|
|
|
@ -8,4 +8,7 @@
|
||||||
<author>Michael Gapczynski</author>
|
<author>Michael Gapczynski</author>
|
||||||
<require>2</require>
|
<require>2</require>
|
||||||
<default_enable/>
|
<default_enable/>
|
||||||
|
<types>
|
||||||
|
<filesystem/>
|
||||||
|
</types>
|
||||||
</info>
|
</info>
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// only need filesystem apps
|
||||||
|
$RUNTIME_APPTYPES=array('filesystem');
|
||||||
|
|
||||||
// Init owncloud
|
// Init owncloud
|
||||||
require_once('../../lib/base.php');
|
require_once('../../lib/base.php');
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// only need filesystem apps
|
||||||
|
$RUNTIME_APPTYPES=array('filesystem');
|
||||||
|
|
||||||
// Init owncloud
|
// Init owncloud
|
||||||
require_once('../../lib/base.php');
|
require_once('../../lib/base.php');
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// no need for apps
|
||||||
|
$RUNTIME_NOAPPS=false;
|
||||||
|
|
||||||
// Init owncloud
|
// Init owncloud
|
||||||
require_once('../../lib/base.php');
|
require_once('../../lib/base.php');
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
// Do not load FS ...
|
// Do not load FS ...
|
||||||
$RUNTIME_NOSETUPFS = true;
|
$RUNTIME_NOSETUPFS = true;
|
||||||
|
|
||||||
|
// only need filesystem apps
|
||||||
|
$RUNTIME_APPTYPES=array('filesystem');
|
||||||
|
|
||||||
require_once('../lib/base.php');
|
require_once('../lib/base.php');
|
||||||
|
|
||||||
// Backends
|
// Backends
|
||||||
|
|
43
lib/app.php
43
lib/app.php
|
@ -34,16 +34,20 @@ class OC_App{
|
||||||
static private $settingsForms = array();
|
static private $settingsForms = array();
|
||||||
static private $adminForms = array();
|
static private $adminForms = array();
|
||||||
static private $personalForms = array();
|
static private $personalForms = array();
|
||||||
|
static private $appInfo = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief loads all apps
|
* @brief loads all apps
|
||||||
|
* @param array $types
|
||||||
* @returns true/false
|
* @returns true/false
|
||||||
*
|
*
|
||||||
* This function walks through the owncloud directory and loads all apps
|
* This function walks through the owncloud directory and loads all apps
|
||||||
* it can find. A directory contains an app if the file /appinfo/app.php
|
* it can find. A directory contains an app if the file /appinfo/app.php
|
||||||
* exists.
|
* exists.
|
||||||
|
*
|
||||||
|
* if $types is set, only apps of those types will be loaded
|
||||||
*/
|
*/
|
||||||
public static function loadApps(){
|
public static function loadApps($types=null){
|
||||||
// Did we allready load everything?
|
// Did we allready load everything?
|
||||||
if( self::$init ){
|
if( self::$init ){
|
||||||
return true;
|
return true;
|
||||||
|
@ -51,16 +55,20 @@ class OC_App{
|
||||||
|
|
||||||
// Our very own core apps are hardcoded
|
// Our very own core apps are hardcoded
|
||||||
foreach( array('files', 'settings') as $app ){
|
foreach( array('files', 'settings') as $app ){
|
||||||
|
if(is_null($types) or self::isType($app,$types)){
|
||||||
require( $app.'/appinfo/app.php' );
|
require( $app.'/appinfo/app.php' );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The rest comes here
|
// The rest comes here
|
||||||
$apps = self::getEnabledApps();
|
$apps = self::getEnabledApps();
|
||||||
foreach( $apps as $app ){
|
foreach( $apps as $app ){
|
||||||
|
if(is_null($types) or self::isType($app,$types)){
|
||||||
if(is_file(OC::$APPSROOT.'/apps/'.$app.'/appinfo/app.php')){
|
if(is_file(OC::$APPSROOT.'/apps/'.$app.'/appinfo/app.php')){
|
||||||
require( $app.'/appinfo/app.php' );
|
require( $app.'/appinfo/app.php' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self::$init = true;
|
self::$init = true;
|
||||||
|
|
||||||
|
@ -68,6 +76,28 @@ class OC_App{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if an app is of a sepcific type
|
||||||
|
* @param string $app
|
||||||
|
* @param string/array $types
|
||||||
|
*/
|
||||||
|
public static function isType($app,$types){
|
||||||
|
if(is_string($types)){
|
||||||
|
$types=array($types);
|
||||||
|
}
|
||||||
|
$appData=self::getAppInfo($app);
|
||||||
|
if(!isset($appData['types'])){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$appTypes=$appData['types'];
|
||||||
|
foreach($types as $type){
|
||||||
|
if(array_search($type,$appTypes)!==false){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all enabled apps
|
* get all enabled apps
|
||||||
*/
|
*/
|
||||||
|
@ -283,6 +313,9 @@ class OC_App{
|
||||||
if($path){
|
if($path){
|
||||||
$file=$appid;
|
$file=$appid;
|
||||||
}else{
|
}else{
|
||||||
|
if(isset(self::$appInfo[$appid])){
|
||||||
|
return self::$appInfo[$appid];
|
||||||
|
}
|
||||||
$file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/info.xml';
|
$file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/info.xml';
|
||||||
}
|
}
|
||||||
$data=array();
|
$data=array();
|
||||||
|
@ -293,8 +326,16 @@ class OC_App{
|
||||||
$xml = new SimpleXMLElement($content);
|
$xml = new SimpleXMLElement($content);
|
||||||
$data['info']=array();
|
$data['info']=array();
|
||||||
foreach($xml->children() as $child){
|
foreach($xml->children() as $child){
|
||||||
|
if($child->getName()=='types'){
|
||||||
|
$data['types']=array();
|
||||||
|
foreach($child->children() as $type){
|
||||||
|
$data['types'][]=$type->getName();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
$data[$child->getName()]=(string)$child;
|
$data[$child->getName()]=(string)$child;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
self::$appInfo[$appid]=$data;
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,9 +333,14 @@ class OC{
|
||||||
// Load Apps
|
// Load Apps
|
||||||
// This includes plugins for users and filesystems as well
|
// This includes plugins for users and filesystems as well
|
||||||
global $RUNTIME_NOAPPS;
|
global $RUNTIME_NOAPPS;
|
||||||
|
global $RUNTIME_APPTYPES;
|
||||||
if(!$RUNTIME_NOAPPS ){
|
if(!$RUNTIME_NOAPPS ){
|
||||||
|
if($RUNTIME_APPTYPES){
|
||||||
|
OC_App::loadApps($RUNTIME_APPTYPES);
|
||||||
|
}else{
|
||||||
OC_App::loadApps();
|
OC_App::loadApps();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//make sure temporary files are cleaned up
|
//make sure temporary files are cleaned up
|
||||||
register_shutdown_function(array('OC_Helper','cleanTmp'));
|
register_shutdown_function(array('OC_Helper','cleanTmp'));
|
||||||
|
|
Loading…
Reference in New Issue