summaryrefslogtreecommitdiffstats
path: root/lib/private/preview.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-03-11 16:43:00 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-03-16 12:44:11 +0100
commitcae8529359ee4b0733cfbc958ab1405b45f0f2d2 (patch)
tree55443e59b817f2f3aa8967f2f0f1dcc91c2745a9 /lib/private/preview.php
parent4c4c0fa12066b9dace5d9689836fe4a70141a2d9 (diff)
downloadnextcloud-server-cae8529359ee4b0733cfbc958ab1405b45f0f2d2.tar.gz
nextcloud-server-cae8529359ee4b0733cfbc958ab1405b45f0f2d2.zip
Register preview providers on the preview manager instead of OC\Preview
Diffstat (limited to 'lib/private/preview.php')
-rw-r--r--lib/private/preview.php64
1 files changed, 9 insertions, 55 deletions
diff --git a/lib/private/preview.php b/lib/private/preview.php
index 6af1586293f..f55cf280b3e 100644
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -510,7 +510,7 @@ class Preview {
if (is_null($this->preview)) {
$preview = null;
- foreach (self::$providers as $supportedMimeType => $provider) {
+ foreach (self::getProviders() as $supportedMimeType => $provider) {
if (!preg_match($supportedMimeType, $this->mimeType)) {
continue;
}
@@ -757,6 +757,14 @@ class Preview {
array_multisort($keys, SORT_DESC, self::$providers);
}
+ protected static function getProviders() {
+ if (empty(self::$providers)) {
+ self::initProviders();
+ }
+
+ return self::$providers;
+ }
+
protected static function registerCoreProviders() {
self::registerProvider('OC\Preview\TXT');
self::registerProvider('OC\Preview\MarkDown');
@@ -915,60 +923,6 @@ class Preview {
}
/**
- * Check if a preview can be generated for a file
- *
- * @param \OC\Files\FileInfo $file
- * @return bool
- */
- public static function isAvailable(\OC\Files\FileInfo $file) {
- if (!\OC_Config::getValue('enable_previews', true)) {
- return false;
- }
-
- $mount = $file->getMountPoint();
- if ($mount and !$mount->getOption('previews', true)){
- return false;
- }
-
- //check if there are preview backends
- if (empty(self::$providers)) {
- self::initProviders();
- }
-
- foreach (self::$providers as $supportedMimeType => $provider) {
- /**
- * @var \OC\Preview\Provider $provider
- */
- if (preg_match($supportedMimeType, $file->getMimetype())) {
- return $provider->isAvailable($file);
- }
- }
- return false;
- }
-
- /**
- * @param string $mimeType
- * @return bool
- */
- public static function isMimeSupported($mimeType) {
- if (!\OC_Config::getValue('enable_previews', true)) {
- return false;
- }
-
- //check if there are preview backends
- if (empty(self::$providers)) {
- self::initProviders();
- }
-
- foreach(self::$providers as $supportedMimetype => $provider) {
- if(preg_match($supportedMimetype, $mimeType)) {
- return true;
- }
- }
- return false;
- }
-
- /**
* @param int $fileId
* @return string
*/