aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-06-24 22:17:54 -0400
committerBart Visscher <bartv@thisnet.nl>2012-06-27 01:05:36 +0200
commit32f9901bcd8b767b93520de346e092147dbb205b (patch)
tree7f4e83c64ea64ba85d0e3b99dca235a805758b85
parent28b7793d5bc3e89dd1fd85fe0461e9c7b2dd4133 (diff)
downloadnextcloud-server-32f9901bcd8b767b93520de346e092147dbb205b.tar.gz
nextcloud-server-32f9901bcd8b767b93520de346e092147dbb205b.zip
Fix retrieving supported file extensions from backend and remove the dependsOn and supportedFileExtensions parameters from registerBackend()
-rw-r--r--apps/gallery/appinfo/app.php3
-rw-r--r--lib/public/share.php21
2 files changed, 12 insertions, 12 deletions
diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php
index df3b68ef736..9efb4346c3e 100644
--- a/apps/gallery/appinfo/app.php
+++ b/apps/gallery/appinfo/app.php
@@ -28,6 +28,9 @@ OC::$CLASSPATH['OC_Gallery_Sharing'] = 'gallery/lib/sharing.php';
OC::$CLASSPATH['OC_Gallery_Hooks_Handlers'] = 'gallery/lib/hooks_handlers.php';
OC::$CLASSPATH['Pictures_Managers'] = 'gallery/lib/managers.php';
OC::$CLASSPATH['Pictures_Tiles'] = 'gallery/lib/tiles.php';
+OC::$CLASSPATH['OC_Share_Backend_Photo'] = 'gallery/lib/share.php';
+
+OCP\Share::registerBackend('photo', new OC_Share_Backend_Photo());
$l = OC_L10N::get('gallery');
diff --git a/lib/public/share.php b/lib/public/share.php
index 3ceb9f590c2..1376eb4dedb 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -52,13 +52,13 @@ class Share {
* @param array (optional) List of supported file extensions if this item type depends on files
* @return Returns true if backend is registered or false if error
*/
- public static function registerBackend($itemType, $class, $dependsOn = null, $supportedFileExtensions = null) {
+ public static function registerBackend($itemType, $class) {
if (is_subclass_of($class, 'OCP\Share_Backend')) {
if (!isset(self::$backends[$itemType])) {
- self::$backends[$itemType] = array('class' => $class, 'dependsOn' => $dependsOn, 'supportedFileExtensions' => $supportedFileExtensions);
+ self::$backends[$itemType] = $class;
return true;
} else {
- \OC_Log::write('OCP\Share', 'Sharing backend '.get_class($class).' not registered, '.get_class(self::$backends[$itemType]['class']).' is already registered for '.$itemType, \OC_Log::WARN);
+ \OC_Log::write('OCP\Share', 'Sharing backend '.get_class($class).' not registered, '.get_class(self::$backends[$itemType]).' is already registered for '.$itemType, \OC_Log::WARN);
return false;
}
}
@@ -342,8 +342,8 @@ class Share {
* @return Sharing backend object
*/
private static function getBackend($itemType) {
- if (isset(self::$backends[$itemType]['class'])) {
- return self::$backends[$itemType]['class'];
+ if (isset(self::$backends[$itemType])) {
+ return self::$backends[$itemType];
}
\OC_Log::write('OCP\Share', 'Sharing backend for '.$itemType.' not found', \OC_Log::ERROR);
return false;
@@ -500,9 +500,8 @@ class Share {
// Check file extension for an equivalent item type to convert to
if ($itemType == 'file') {
$extension = strtolower(substr($item, strrpos($item, '.') + 1));
- $backendTypes = array_keys(self::$backends);
- foreach ($backendTypes as $type => $backend) {
- if (isset($backend['dependsOn']) && $backend['dependsOn'] == 'file' && isset($backend['supportedFileExtensions']) && in_array($extension, $backend['supportedFileExtensions'])) {
+ foreach (self::$backends as $type => $backend) {
+ if (isset($backend->dependsOn) && $backend->dependsOn == 'file' && isset($backend->supportedFileExtensions) && in_array($extension, $backend->supportedFileExtensions)) {
$itemType = $type;
break;
}
@@ -677,10 +676,8 @@ class Share {
*/
abstract class Share_Backend {
- public static $dependsOn;
- public static $supportedFileExtensions = array();
-
-
+ public $dependsOn;
+ public $supportedFileExtensions = array();
/**
* @brief Get the source of the item to be stored in the database