]> source.dussan.org Git - nextcloud-server.git/commitdiff
Split bitmap providers into one per file
authorJoas Schilling <nickvergessen@gmx.de>
Fri, 28 Nov 2014 08:25:40 +0000 (09:25 +0100)
committerJoas Schilling <nickvergessen@gmx.de>
Fri, 28 Nov 2014 08:28:33 +0000 (09:28 +0100)
lib/private/preview.php
lib/private/preview/bitmap.php
lib/private/preview/illustrator.php [new file with mode: 0644]
lib/private/preview/pdf.php [new file with mode: 0644]
lib/private/preview/photoshop.php [new file with mode: 0644]
lib/private/preview/postscript.php [new file with mode: 0644]
lib/private/preview/tiff.php [new file with mode: 0644]

index 696895cd3ad9114f01aa3408cd54a47124e45898..f6c8c485d03d8e0375449e4f0ebea713924749f5 100644 (file)
@@ -16,8 +16,6 @@ namespace OC;
 use OC\Preview\Provider;
 use OCP\Files\NotFoundException;
 
-require_once 'preview/bitmap.php';
-
 class Preview {
        //the thumbnail folder
        const THUMBNAILS_FOLDER = 'thumbnails';
index 4632285348613f81cc608cb145b9b2ef4a6b63e5..25f65cf7fc9e3da3f91fb5a6aea6367854b2850f 100644 (file)
@@ -5,81 +5,33 @@
  * later.
  * See the COPYING-README file.
  */
-namespace OC\Preview;
-
-use Imagick;
 
-       class Bitmap extends Provider {
+namespace OC\Preview;
 
-               public function getMimeType() {
-                       return null;
+abstract class Bitmap extends Provider {
+       /**
+        * {@inheritDoc}
+        */
+       public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+               $tmpPath = $fileview->toTmpFile($path);
+
+               //create imagick object from bitmap or vector file
+               try {
+                       // Layer 0 contains either the bitmap or
+                       // a flat representation of all vector layers
+                       $bp = new \Imagick($tmpPath . '[0]');
+
+                       $bp->setImageFormat('png');
+               } catch (\Exception $e) {
+                       \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
+                       return false;
                }
 
-               public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
-                       $tmpPath = $fileview->toTmpFile($path);
-
-                       //create imagick object from bitmap or vector file
-                       try {
-                               // Layer 0 contains either the bitmap or
-                               // a flat representation of all vector layers
-                               $bp = new Imagick($tmpPath . '[0]');
+               unlink($tmpPath);
 
-                               $bp->setImageFormat('png');
-                       } catch (\Exception $e) {
-                               \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
-                               return false;
-                       }
-
-                       unlink($tmpPath);
-
-                       //new bitmap image object
-                       $image = new \OC_Image($bp);
-                       //check if image object is valid
-                       return $image->valid() ? $image : false;
-               }
+               //new bitmap image object
+               $image = new \OC_Image($bp);
+               //check if image object is valid
+               return $image->valid() ? $image : false;
        }
-
-               //.pdf
-               class PDF extends Bitmap {
-
-                       public function getMimeType() {
-                               return '/application\/pdf/';
-                       }
-
-               }
-
-               //.tiff
-               class TIFF extends Bitmap {
-
-                       public function getMimeType() {
-                               return '/image\/tiff/';
-                       }
-
-               }
-
-               //.ai
-               class Illustrator extends Bitmap {
-
-                       public function getMimeType() {
-                               return '/application\/illustrator/';
-                       }
-
-               }
-
-               //.eps
-               class Postscript extends Bitmap {
-
-                       public function getMimeType() {
-                               return '/application\/postscript/';
-                       }
-
-               }
-
-               //.psd
-               class Photoshop extends Bitmap {
-
-                       public function getMimeType() {
-                               return '/application\/x-photoshop/';
-                       }
-
-               }
+}
diff --git a/lib/private/preview/illustrator.php b/lib/private/preview/illustrator.php
new file mode 100644 (file)
index 0000000..e88c305
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Preview;
+
+//.ai
+class Illustrator extends Bitmap {
+       /**
+        * {@inheritDoc}
+        */
+       public function getMimeType() {
+               return '/application\/illustrator/';
+       }
+}
diff --git a/lib/private/preview/pdf.php b/lib/private/preview/pdf.php
new file mode 100644 (file)
index 0000000..cb13074
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Preview;
+
+//.pdf
+class PDF extends Bitmap {
+       /**
+        * {@inheritDoc}
+        */
+       public function getMimeType() {
+               return '/application\/pdf/';
+       }
+}
diff --git a/lib/private/preview/photoshop.php b/lib/private/preview/photoshop.php
new file mode 100644 (file)
index 0000000..f5f60ce
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Preview;
+
+//.psd
+class Photoshop extends Bitmap {
+       /**
+        * {@inheritDoc}
+        */
+       public function getMimeType() {
+               return '/application\/x-photoshop/';
+       }
+}
diff --git a/lib/private/preview/postscript.php b/lib/private/preview/postscript.php
new file mode 100644 (file)
index 0000000..7c8b089
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Preview;
+
+//.eps
+class Postscript extends Bitmap {
+       /**
+        * {@inheritDoc}
+        */
+       public function getMimeType() {
+               return '/application\/postscript/';
+       }
+}
diff --git a/lib/private/preview/tiff.php b/lib/private/preview/tiff.php
new file mode 100644 (file)
index 0000000..0a1e8e8
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Preview;
+
+//.tiff
+class TIFF extends Bitmap {
+       /**
+        * {@inheritDoc}
+        */
+       public function getMimeType() {
+               return '/image\/tiff/';
+       }
+}