]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix issue with Non-static method Imagick ../..; @ doesn't seem to work in this case
authorGeorg Ehrke <developer@georgehrke.com>
Wed, 5 Mar 2014 14:53:12 +0000 (15:53 +0100)
committerGeorg Ehrke <developer@georgehrke.com>
Wed, 5 Mar 2014 14:57:45 +0000 (15:57 +0100)
lib/private/preview/office.php
lib/private/preview/pdf.php
lib/private/preview/svg.php

index 02bb22e9b9479b0f9816cd6c39aa51fd4f475295..269e1dad74efab0875d02425153e0cd0939d71f8 100644 (file)
@@ -6,24 +6,29 @@
  * See the COPYING-README file.
  */
 //both, libreoffice backend and php fallback, need imagick
-if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1) {
-       $isShellExecEnabled = \OC_Helper::is_function_enabled('shell_exec');
+if (extension_loaded('imagick')) {
 
-       // LibreOffice preview is currently not supported on Windows
-       if (!\OC_Util::runningOnWindows()) {
-               $whichLibreOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
-               $isLibreOfficeAvailable = !empty($whichLibreOffice);
-               $whichOpenOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
-               $isOpenOfficeAvailable = !empty($whichOpenOffice);
-               //let's see if there is libreoffice or openoffice on this machine
-               if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) {
-                       require_once('office-cl.php');
-               }else{
+       $checkImagick = new Imagick();
+
+       if(count($checkImagick->queryFormats('PDF')) === 1) {
+               $isShellExecEnabled = \OC_Helper::is_function_enabled('shell_exec');
+
+               // LibreOffice preview is currently not supported on Windows
+               if (!\OC_Util::runningOnWindows()) {
+                       $whichLibreOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
+                       $isLibreOfficeAvailable = !empty($whichLibreOffice);
+                       $whichOpenOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
+                       $isOpenOfficeAvailable = !empty($whichOpenOffice);
+                       //let's see if there is libreoffice or openoffice on this machine
+                       if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) {
+                               require_once('office-cl.php');
+                       }else{
+                               //in case there isn't, use our fallback
+                               require_once('office-fallback.php');
+                       }
+               } else {
                        //in case there isn't, use our fallback
                        require_once('office-fallback.php');
                }
-       } else {
-               //in case there isn't, use our fallback
-               require_once('office-fallback.php');
        }
 }
index d390b4fc6773402c15b444a794291e4d7d8b45cc..064a5a3b3d14b304184b46e1085ecb0aa114ff5d 100644 (file)
@@ -7,34 +7,41 @@
  */
 namespace OC\Preview;
 
-if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1) {
+use Imagick;
 
-       class PDF extends Provider {
+if (extension_loaded('imagick')) {
 
-               public function getMimeType() {
-                       return '/application\/pdf/';
-               }
+       $checkImagick = new Imagick();
+
+       if(count($checkImagick->queryFormats('PDF')) === 1) {
 
-               public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {      
-                       $tmpPath = $fileview->toTmpFile($path);
+               class PDF extends Provider {
 
-                       //create imagick object from pdf
-                       try{
-                               $pdf = new \imagick($tmpPath . '[0]');
-                               $pdf->setImageFormat('jpg');
-                       } catch (\Exception $e) {
-                               \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
-                               return false;
+                       public function getMimeType() {
+                               return '/application\/pdf/';
                        }
 
-                       unlink($tmpPath);
+                       public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+                               $tmpPath = $fileview->toTmpFile($path);
+
+                               //create imagick object from pdf
+                               try{
+                                       $pdf = new Imagick($tmpPath . '[0]');
+                                       $pdf->setImageFormat('jpg');
+                               } catch (\Exception $e) {
+                                       \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
+                                       return false;
+                               }
+
+                               unlink($tmpPath);
 
-                       //new image object
-                       $image = new \OC_Image($pdf);
-                       //check if image object is valid
-                       return $image->valid() ? $image : false;
+                               //new image object
+                               $image = new \OC_Image($pdf);
+                               //check if image object is valid
+                               return $image->valid() ? $image : false;
+                       }
                }
-       }
 
-       \OC\Preview::registerProvider('OC\Preview\PDF');
+               \OC\Preview::registerProvider('OC\Preview\PDF');
+       }
 }
index 9a73fff94675dc6205c8baf99a18a3647ee10ef2..505122fddbfb2eb837df110e83f47756fc8cfd6f 100644 (file)
@@ -7,40 +7,46 @@
  */
 namespace OC\Preview;
 
-if (extension_loaded('imagick') && count(@\Imagick::queryFormats("SVG")) === 1) {
+use Imagick;
 
-       class SVG extends Provider {
+if (extension_loaded('imagick')) {
 
-               public function getMimeType() {
-                       return '/image\/svg\+xml/';
-               }
+       $checkImagick = new Imagick();
 
-               public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) {
-                       try{
-                               $svg = new \Imagick();
-                               $svg->setBackgroundColor(new \ImagickPixel('transparent'));
+       if(count($checkImagick->queryFormats('SVG')) === 1) {
 
-                               $content = stream_get_contents($fileview->fopen($path, 'r'));
-                               if(substr($content, 0, 5) !== '<?xml') {
-                                       $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
-                               }
+               class SVG extends Provider {
 
-                               $svg->readImageBlob($content);
-                               $svg->setImageFormat('png32');
-                       } catch (\Exception $e) {
-                               \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
-                               return false;
+                       public function getMimeType() {
+                               return '/image\/svg\+xml/';
                        }
 
+                       public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) {
+                               try{
+                                       $svg = new Imagick();
+                                       $svg->setBackgroundColor(new \ImagickPixel('transparent'));
+
+                                       $content = stream_get_contents($fileview->fopen($path, 'r'));
+                                       if(substr($content, 0, 5) !== '<?xml') {
+                                               $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
+                                       }
+
+                                       $svg->readImageBlob($content);
+                                       $svg->setImageFormat('png32');
+                               } catch (\Exception $e) {
+                                       \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
+                                       return false;
+                               }
 
-                       //new image object
-                       $image = new \OC_Image();
-                       $image->loadFromData($svg);
-                       //check if image object is valid
-                       return $image->valid() ? $image : false;
-               }
-       }
 
-       \OC\Preview::registerProvider('OC\Preview\SVG');
+                               //new image object
+                               $image = new \OC_Image();
+                               $image->loadFromData($svg);
+                               //check if image object is valid
+                               return $image->valid() ? $image : false;
+                       }
+               }
 
+               \OC\Preview::registerProvider('OC\Preview\SVG');
+       }
 }
\ No newline at end of file