$totaldirs = 0;
$totalsize = 0; ?>
<?php foreach($_['files'] as $file):
- $relativePath = substr($file['path'], 6); //strlen('files/') => 6
+ //strlen('files/') => 6
+ $relativePath = substr($file['path'], 6);
$totalsize += $file['size'];
if ($file['type'] === 'dir') {
$totaldirs++;
'preview_max_scale_factor' => 10,
/* custom path for libreoffice / openoffice binary */
'preview_libreoffice_path' => '/usr/bin/libreoffice',
+/* cl parameters for libreoffice / openoffice */
+'preview_office_cl_parameters' => '',
// date format to be used while writing to the owncloud logfile
'logdateformat' => 'F d, Y H:i:s',
);
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
if($file === '') {
- \OC_Response::setStatus(400); //400 Bad Request
+ //400 Bad Request
+ \OC_Response::setStatus(400);
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
exit;
}
if($maxX === 0 || $maxY === 0) {
- \OC_Response::setStatus(400); //400 Bad Request
+ //400 Bad Request
+ \OC_Response::setStatus(400);
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
exit;
}
$preview->show();
}catch(\Exception $e) {
\OC_Response::setStatus(500);
- \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
- exit;
+ \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
}
\ No newline at end of file
*/
namespace OC;
-require_once('preview/images.php');
-require_once('preview/movies.php');
-require_once('preview/mp3.php');
-require_once('preview/pdf.php');
-require_once('preview/svg.php');
-require_once('preview/txt.php');
-require_once('preview/unknown.php');
-require_once('preview/office.php');
+require_once 'preview/image.php';
+require_once 'preview/movies.php';
+require_once 'preview/mp3.php';
+require_once 'preview/pdf.php';
+require_once 'preview/svg.php';
+require_once 'preview/txt.php';
+require_once 'preview/unknown.php';
+require_once 'preview/office.php';
class Preview {
//the thumbnail folder
private $configMaxY;
//fileview object
- private $fileview = null;
- private $userview = null;
+ private $fileView = null;
+ private $userView = null;
//vars
private $file;
if($user === ''){
$user = \OC_User::getUser();
}
- $this->fileview = new \OC\Files\View('/' . $user . '/' . $root);
- $this->userview = new \OC\Files\View('/' . $user);
+ $this->fileView = new \OC\Files\View('/' . $user . '/' . $root);
+ $this->userView = new \OC\Files\View('/' . $user);
$this->preview = null;
public function isFileValid() {
$file = $this->getFile();
if($file === '') {
- \OC_Log::write('core', 'No filename passed', \OC_Log::ERROR);
+ \OC_Log::write('core', 'No filename passed', \OC_Log::DEBUG);
return false;
}
- if(!$this->fileview->file_exists($file)) {
- \OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::ERROR);
+ if(!$this->fileView->file_exists($file)) {
+ \OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::DEBUG);
return false;
}
public function deletePreview() {
$file = $this->getFile();
- $fileInfo = $this->fileview->getFileInfo($file);
+ $fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png';
- $this->userview->unlink($previewPath);
- return !$this->userview->file_exists($previewPath);
+ $this->userView->unlink($previewPath);
+ return !$this->userView->file_exists($previewPath);
}
/**
public function deleteAllPreviews() {
$file = $this->getFile();
- $fileInfo = $this->fileview->getFileInfo($file);
+ $fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
- $this->userview->deleteAll($previewPath);
- $this->userview->rmdir($previewPath);
- return !$this->userview->is_dir($previewPath);
+ $this->userView->deleteAll($previewPath);
+ $this->userView->rmdir($previewPath);
+ return !$this->userView->is_dir($previewPath);
}
/**
$maxX = $this->getMaxX();
$maxY = $this->getMaxY();
$scalingUp = $this->getScalingUp();
- $maxscalefactor = $this->getMaxScaleFactor();
+ $maxScaleFactor = $this->getMaxScaleFactor();
- $fileInfo = $this->fileview->getFileInfo($file);
+ $fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
if(is_null($fileId)) {
}
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
- if(!$this->userview->is_dir($previewPath)) {
+ if(!$this->userView->is_dir($previewPath)) {
return false;
}
//does a preview with the wanted height and width already exist?
- if($this->userview->file_exists($previewPath . $maxX . '-' . $maxY . '.png')) {
+ if($this->userView->file_exists($previewPath . $maxX . '-' . $maxY . '.png')) {
return $previewPath . $maxX . '-' . $maxY . '.png';
}
//array for usable cached thumbnails
$possibleThumbnails = array();
- $allThumbnails = $this->userview->getDirectoryContent($previewPath);
+ $allThumbnails = $this->userView->getDirectoryContent($previewPath);
foreach($allThumbnails as $thumbnail) {
$name = rtrim($thumbnail['name'], '.png');
$size = explode('-', $name);
if($x < $maxX || $y < $maxY) {
if($scalingUp) {
$scalefactor = $maxX / $x;
- if($scalefactor > $maxscalefactor) {
+ if($scalefactor > $maxScaleFactor) {
continue;
}
}else{
$maxY = $this->getMaxY();
$scalingUp = $this->getScalingUp();
- $fileInfo = $this->fileview->getFileInfo($file);
+ $fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
$cached = $this->isCached();
if($cached) {
- $image = new \OC_Image($this->userview->file_get_contents($cached, 'r'));
+ $image = new \OC_Image($this->userView->file_get_contents($cached, 'r'));
$this->preview = $image->valid() ? $image : null;
$this->resizeAndCrop();
}
if(is_null($this->preview)) {
- $mimetype = $this->fileview->getMimeType($file);
+ $mimetype = $this->fileView->getMimeType($file);
$preview = null;
foreach(self::$providers as $supportedMimetype => $provider) {
\OC_Log::write('core', 'Generating preview for "' . $file . '" with "' . get_class($provider) . '"', \OC_Log::DEBUG);
- $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileview);
+ $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileView);
if(!($preview instanceof \OC_Image)) {
continue;
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
$cachePath = $previewPath . $maxX . '-' . $maxY . '.png';
- if($this->userview->is_dir($this->getThumbnailsFolder() . '/') === false) {
- $this->userview->mkdir($this->getThumbnailsFolder() . '/');
+ if($this->userView->is_dir($this->getThumbnailsFolder() . '/') === false) {
+ $this->userView->mkdir($this->getThumbnailsFolder() . '/');
}
- if($this->userview->is_dir($previewPath) === false) {
- $this->userview->mkdir($previewPath);
+ if($this->userView->is_dir($previewPath) === false) {
+ $this->userView->mkdir($previewPath);
}
- $this->userview->file_put_contents($cachePath, $preview->data());
+ $this->userView->file_put_contents($cachePath, $preview->data());
break;
}
if($x === $realx && $y === $realy) {
$this->preview = $image;
- return true;
+ return;
}
$factorX = $x / $realx;
--- /dev/null
+<?php
+/**
+ * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org
+ * Copyright (c) 2013 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;
+
+class Image extends Provider {
+
+ public function getMimeType() {
+ return '/image\/.*/';
+ }
+
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ //get fileinfo
+ $fileInfo = $fileview->getFileInfo($path);
+ if(!$fileInfo) {
+ return false;
+ }
+
+ //check if file is encrypted
+ if($fileInfo['encrypted'] === true) {
+ $image = new \OC_Image(stream_get_contents($fileview->fopen($path, 'r')));
+ }else{
+ $image = new \OC_Image();
+ $image->loadFromFile($fileview->getLocalFile($path));
+ }
+
+ return $image->valid() ? $image : false;
+ }
+}
+
+\OC\Preview::registerProvider('OC\Preview\Image');
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org
- * Copyright (c) 2013 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;
-
-class Image extends Provider {
-
- public function getMimeType() {
- return '/image\/.*/';
- }
-
- public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
- //get fileinfo
- $fileInfo = $fileview->getFileInfo($path);
- if(!$fileInfo) {
- return false;
- }
-
- //check if file is encrypted
- if($fileInfo['encrypted'] === true) {
- $image = new \OC_Image(stream_get_contents($fileview->fopen($path, 'r')));
- }else{
- $image = new \OC_Image();
- $image->loadFromFile($fileview->getLocalFile($path));
- }
-
- return $image->valid() ? $image : false;
- }
-}
-
-\OC\Preview::registerProvider('OC\Preview\Image');
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Copyright (c) 2013 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;
-
-//we need imagick to convert
-class Office extends Provider {
-
- private $cmd;
-
- public function getMimeType() {
- return null;
- }
-
- public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
- $this->initCmd();
- if(is_null($this->cmd)) {
- return false;
- }
-
- $absPath = $fileview->toTmpFile($path);
-
- $tmpDir = get_temp_dir();
-
- $exec = $this->cmd . ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ' . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
- $export = 'export HOME=/' . $tmpDir;
-
- shell_exec($export . "\n" . $exec);
-
- //create imagick object from pdf
- try{
- $pdf = new \imagick($absPath . '.pdf' . '[0]');
- $pdf->setImageFormat('jpg');
- } catch (\Exception $e) {
- unlink($absPath);
- unlink($absPath . '.pdf');
- \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
- return false;
- }
-
- $image = new \OC_Image($pdf);
-
- unlink($absPath);
- unlink($absPath . '.pdf');
-
- return $image->valid() ? $image : false;
- }
-
- private function initCmd() {
- $cmd = '';
-
- if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) {
- $cmd = \OC_Config::getValue('preview_libreoffice_path', null);
- }
-
- $whichLibreOffice = shell_exec('which libreoffice');
- if($cmd === '' && !empty($whichLibreOffice)) {
- $cmd = 'libreoffice';
- }
-
- $whichOpenOffice = shell_exec('which openoffice');
- if($cmd === '' && !empty($whichOpenOffice)) {
- $cmd = 'openoffice';
- }
-
- if($cmd === '') {
- $cmd = null;
- }
-
- $this->cmd = $cmd;
- }
-}
-
-//.doc, .dot
-class MSOfficeDoc extends Office {
-
- public function getMimeType() {
- return '/application\/msword/';
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\MSOfficeDoc');
-
-//.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m)
-class MSOffice2003 extends Office {
-
- public function getMimeType() {
- return '/application\/vnd.ms-.*/';
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\MSOffice2003');
-
-//.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx
-class MSOffice2007 extends Office {
-
- public function getMimeType() {
- return '/application\/vnd.openxmlformats-officedocument.*/';
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\MSOffice2007');
-
-//.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt
-class OpenDocument extends Office {
-
- public function getMimeType() {
- return '/application\/vnd.oasis.opendocument.*/';
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\OpenDocument');
-
-//.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm
-class StarOffice extends Office {
-
- public function getMimeType() {
- return '/application\/vnd.sun.xml.*/';
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\StarOffice');
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Copyright (c) 2013 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;
-
-/* //There is no (good) php-only solution for converting 2003 word documents to pdfs / pngs ...
-class DOC extends Provider {
-
- public function getMimeType() {
- return '/application\/msword/';
- }
-
- public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
- require_once('');
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\DOC');
-*/
-
-class DOCX extends Provider {
-
- public function getMimeType() {
- return '/application\/vnd.openxmlformats-officedocument.wordprocessingml.document/';
- }
-
- public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
- require_once('phpdocx/classes/TransformDoc.inc');
-
- $tmpDoc = $fileview->toTmpFile($path);
-
- $transformdoc = new \TransformDoc();
- $transformdoc->setStrFile($tmpDoc);
- $transformdoc->generatePDF($tmpDoc);
-
- $pdf = new \imagick($tmpDoc . '[0]');
- $pdf->setImageFormat('jpg');
-
- unlink($tmpDoc);
-
- $image = new \OC_Image($pdf);
-
- return $image->valid() ? $image : false;
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\DOCX');
-
-class MSOfficeExcel extends Provider {
-
- public function getMimeType() {
- return null;
- }
-
- public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
- require_once('PHPExcel/Classes/PHPExcel.php');
- require_once('PHPExcel/Classes/PHPExcel/IOFactory.php');
-
- $absPath = $fileview->toTmpFile($path);
- $tmpPath = \OC_Helper::tmpFile();
-
- $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF;
- $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/3rdparty/dompdf';
-
- \PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
-
- $phpexcel = new \PHPExcel($absPath);
- $excel = \PHPExcel_IOFactory::createWriter($phpexcel, 'PDF');
- $excel->save($tmpPath);
-
- $pdf = new \imagick($tmpPath . '[0]');
- $pdf->setImageFormat('jpg');
-
- unlink($absPath);
- unlink($tmpPath);
-
- $image = new \OC_Image($pdf);
-
- return $image->valid() ? $image : false;
- }
-
-}
-
-class XLS extends MSOfficeExcel {
-
- public function getMimeType() {
- return '/application\/vnd.ms-excel/';
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\XLS');
-
-class XLSX extends MSOfficeExcel {
-
- public function getMimeType() {
- return '/application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet/';
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\XLSX');
-
-/* //There is no (good) php-only solution for converting powerpoint documents to pdfs / pngs ...
-class MSOfficePowerPoint extends Provider {
-
- public function getMimeType() {
- return null;
- }
-
- public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
- return false;
- }
-
-}
-
-class PPT extends MSOfficePowerPoint {
-
- public function getMimeType() {
- return '/application\/vnd.ms-powerpoint/';
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\PPT');
-
-class PPTX extends MSOfficePowerPoint {
-
- public function getMimeType() {
- return '/application\/vnd.openxmlformats-officedocument.presentationml.presentation/';
- }
-
-}
-
-\OC\Preview::registerProvider('OC\Preview\PPTX');
-*/
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Copyright (c) 2013 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;
+
+//we need imagick to convert
+class Office extends Provider {
+
+ private $cmd;
+
+ public function getMimeType() {
+ return null;
+ }
+
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ $this->initCmd();
+ if(is_null($this->cmd)) {
+ return false;
+ }
+
+ $absPath = $fileview->toTmpFile($path);
+
+ $tmpDir = get_temp_dir();
+
+ $defaultParameters = ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ';
+ $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
+
+ $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
+ $export = 'export HOME=/' . $tmpDir;
+
+ shell_exec($export . "\n" . $exec);
+
+ //create imagick object from pdf
+ try{
+ $pdf = new \imagick($absPath . '.pdf' . '[0]');
+ $pdf->setImageFormat('jpg');
+ } catch (\Exception $e) {
+ unlink($absPath);
+ unlink($absPath . '.pdf');
+ \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
+ return false;
+ }
+
+ $image = new \OC_Image($pdf);
+
+ unlink($absPath);
+ unlink($absPath . '.pdf');
+
+ return $image->valid() ? $image : false;
+ }
+
+ private function initCmd() {
+ $cmd = '';
+
+ if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) {
+ $cmd = \OC_Config::getValue('preview_libreoffice_path', null);
+ }
+
+ $whichLibreOffice = shell_exec('which libreoffice');
+ if($cmd === '' && !empty($whichLibreOffice)) {
+ $cmd = 'libreoffice';
+ }
+
+ $whichOpenOffice = shell_exec('which openoffice');
+ if($cmd === '' && !empty($whichOpenOffice)) {
+ $cmd = 'openoffice';
+ }
+
+ if($cmd === '') {
+ $cmd = null;
+ }
+
+ $this->cmd = $cmd;
+ }
+}
+
+//.doc, .dot
+class MSOfficeDoc extends Office {
+
+ public function getMimeType() {
+ return '/application\/msword/';
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\MSOfficeDoc');
+
+//.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m)
+class MSOffice2003 extends Office {
+
+ public function getMimeType() {
+ return '/application\/vnd.ms-.*/';
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\MSOffice2003');
+
+//.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx
+class MSOffice2007 extends Office {
+
+ public function getMimeType() {
+ return '/application\/vnd.openxmlformats-officedocument.*/';
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\MSOffice2007');
+
+//.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt
+class OpenDocument extends Office {
+
+ public function getMimeType() {
+ return '/application\/vnd.oasis.opendocument.*/';
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\OpenDocument');
+
+//.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm
+class StarOffice extends Office {
+
+ public function getMimeType() {
+ return '/application\/vnd.sun.xml.*/';
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\StarOffice');
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Copyright (c) 2013 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;
+
+/* //There is no (good) php-only solution for converting 2003 word documents to pdfs / pngs ...
+class DOC extends Provider {
+
+ public function getMimeType() {
+ return '/application\/msword/';
+ }
+
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ require_once('');
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\DOC');
+*/
+
+class DOCX extends Provider {
+
+ public function getMimeType() {
+ return '/application\/vnd.openxmlformats-officedocument.wordprocessingml.document/';
+ }
+
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ require_once('phpdocx/classes/TransformDoc.inc');
+
+ $tmpDoc = $fileview->toTmpFile($path);
+
+ $transformdoc = new \TransformDoc();
+ $transformdoc->setStrFile($tmpDoc);
+ $transformdoc->generatePDF($tmpDoc);
+
+ $pdf = new \imagick($tmpDoc . '[0]');
+ $pdf->setImageFormat('jpg');
+
+ unlink($tmpDoc);
+
+ $image = new \OC_Image($pdf);
+
+ return $image->valid() ? $image : false;
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\DOCX');
+
+class MSOfficeExcel extends Provider {
+
+ public function getMimeType() {
+ return null;
+ }
+
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ require_once('PHPExcel/Classes/PHPExcel.php');
+ require_once('PHPExcel/Classes/PHPExcel/IOFactory.php');
+
+ $absPath = $fileview->toTmpFile($path);
+ $tmpPath = \OC_Helper::tmpFile();
+
+ $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF;
+ $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/3rdparty/dompdf';
+
+ \PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
+
+ $phpexcel = new \PHPExcel($absPath);
+ $excel = \PHPExcel_IOFactory::createWriter($phpexcel, 'PDF');
+ $excel->save($tmpPath);
+
+ $pdf = new \imagick($tmpPath . '[0]');
+ $pdf->setImageFormat('jpg');
+
+ unlink($absPath);
+ unlink($tmpPath);
+
+ $image = new \OC_Image($pdf);
+
+ return $image->valid() ? $image : false;
+ }
+
+}
+
+class XLS extends MSOfficeExcel {
+
+ public function getMimeType() {
+ return '/application\/vnd.ms-excel/';
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\XLS');
+
+class XLSX extends MSOfficeExcel {
+
+ public function getMimeType() {
+ return '/application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet/';
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\XLSX');
+
+/* //There is no (good) php-only solution for converting powerpoint documents to pdfs / pngs ...
+class MSOfficePowerPoint extends Provider {
+
+ public function getMimeType() {
+ return null;
+ }
+
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ return false;
+ }
+
+}
+
+class PPT extends MSOfficePowerPoint {
+
+ public function getMimeType() {
+ return '/application\/vnd.ms-powerpoint/';
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\PPT');
+
+class PPTX extends MSOfficePowerPoint {
+
+ public function getMimeType() {
+ return '/application\/vnd.openxmlformats-officedocument.presentationml.presentation/';
+ }
+
+}
+
+\OC\Preview::registerProvider('OC\Preview\PPTX');
+*/
\ No newline at end of file
$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('libreoffice-cl.php');
+ require_once('office-cl.php');
}else{
//in case there isn't, use our fallback
- require_once('msoffice.php');
+ require_once('office-fallback.php');
}
}
\ No newline at end of file