From 5b44714f4cbd75138519789f55fd8b6f4b5d4241 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Tue, 13 Nov 2012 15:11:02 +0100 Subject: [PATCH 001/635] =?UTF-8?q?first=20version=20of=20the=20new=20prev?= =?UTF-8?q?iewer=20lib.=20It=20currently=20only=20created=20previews/thumb?= =?UTF-8?q?nails=20for=20images.=20It=20get=C2=B4s=20more=20interesting=20?= =?UTF-8?q?when=20we=20add=20PDFs,=20movies,=20mp3,=20text=20files=20and?= =?UTF-8?q?=20more...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/preview.php | 131 +++++++++++++++++++++++++++++++++++++++++ lib/public/preview.php | 50 ++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100755 lib/preview.php create mode 100644 lib/public/preview.php diff --git a/lib/preview.php b/lib/preview.php new file mode 100755 index 00000000000..8b1a42925a6 --- /dev/null +++ b/lib/preview.php @@ -0,0 +1,131 @@ +show(); + }else{ + header('Content-type: image/png'); + OC_PreviewUnknown::getThumbnail($maxX,$maxY); + } + } + + +} + + + +class OC_PreviewImage { + + // the thumbnail cache folder + const THUMBNAILS_FOLDER = 'thumbnails'; + + public static function getThumbnail($path,$maxX,$maxY,$scalingup) { + $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.self::THUMBNAILS_FOLDER); + + // is a preview already in the cache? + if ($thumbnails_view->file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { + return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); + } + + // does the sourcefile exist? + if (!\OC_Filesystem::file_exists($path)) { + \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); + return false; + } + + // open the source image + $image = new \OC_Image(); + $image->loadFromFile(\OC_Filesystem::getLocalFile($path)); + if (!$image->valid()) return false; + + // fix the orientation + $image->fixOrientation(); + + // calculate the right preview size + $Xsize=$image->width(); + $Ysize=$image->height(); + if (($Xsize/$Ysize)>($maxX/$maxY)) { + $factor=$maxX/$Xsize; + } else { + $factor=$maxY/$Ysize; + } + + // only scale up if requested + if($scalingup==false) { + if($factor>1) $factor=1; + } + $newXsize=$Xsize*$factor; + $newYsize=$Ysize*$factor; + + // resize + $ret = $image->preciseResize($newXsize, $newYsize); + if (!$ret) { + \OC_Log::write('Preview', 'Couldn\'t resize image', \OC_Log::ERROR); + unset($image); + return false; + } + + // store in cache + $l = $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); + $image->save($l); + + return $image; + } + + + +} + + +class OC_PreviewUnknown { + public static function getThumbnail($maxX,$maxY) { + + // check if GD is installed + if(!extension_loaded('gd') || !function_exists('gd_info')) { + OC_Log::write('preview', __METHOD__.'(): GD module not installed', OC_Log::ERROR); + return false; + } + + // create a white image + $image = imagecreatetruecolor($maxX, $maxY); + $color = imagecolorallocate($image, 255, 255, 255); + imagefill($image, 0, 0, $color); + + // output the image + imagepng($image); + imagedestroy($image); + } + +} + diff --git a/lib/public/preview.php b/lib/public/preview.php new file mode 100644 index 00000000000..a7487c485f1 --- /dev/null +++ b/lib/public/preview.php @@ -0,0 +1,50 @@ +. +* +*/ + +/** + * Public interface of ownCloud for apps to use. + * Preview Class. + * + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +/** + * This class provides functions to render and show thumbnails and previews of files + */ +class Preview { + + /** + * @brief return a preview of a file + * @param $file The path to the file where you want a thumbnail from + * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image + * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image + * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly + * @return image + */ + public static function show($file,$maxX=100,$maxY=75,$scaleup=false) { + return(\OC_Preview::show($file,$maxX,$maxY,$scaleup)); + } + +} -- GitLab From e484811e24f6332df49eb35c7e2adffca81d2005 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Tue, 13 Nov 2012 16:14:16 +0100 Subject: [PATCH 002/635] add some documentation, remove a debug hack, move folder name definition to main class --- lib/preview.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 8b1a42925a6..3fa494a2e03 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -19,21 +19,28 @@ TODO: class OC_Preview { - + + // the thumbnail cache folder + const THUMBNAILS_FOLDER = 'thumbnails'; /** * @brief return a preview of a file * @param $file The path to the file where you want a thumbnail from * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image + * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly * @return image */ - static public function show($file,$maxX,$maxY) { + static public function show($file,$maxX,$maxY,$scalingup) { + // get the mimetype of the file $mimetype=explode('/',OC_FileSystem::getMimeType($file)); - if($mimetype[0]=='imaage'){ + + // it´s an image + if($mimetype[0]=='image'){ OCP\Response::enableCaching(3600 * 24); // 24 hour - $image=OC_PreviewImage::getThumbnail($file,$maxX,$maxY,false); + $image=OC_PreviewImage::getThumbnail($file,$maxX,$maxY,$scalingup); $image->show(); + // it´s something else. Let´s create a dummy preview }else{ header('Content-type: image/png'); OC_PreviewUnknown::getThumbnail($maxX,$maxY); @@ -47,11 +54,8 @@ class OC_Preview { class OC_PreviewImage { - // the thumbnail cache folder - const THUMBNAILS_FOLDER = 'thumbnails'; - public static function getThumbnail($path,$maxX,$maxY,$scalingup) { - $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.self::THUMBNAILS_FOLDER); + $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); // is a preview already in the cache? if ($thumbnails_view->file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { -- GitLab From eb27c0b2a84da44f8e42f7e4aca0102c969eb195 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Mon, 14 Jan 2013 15:51:47 +0100 Subject: [PATCH 003/635] snapshor of the preview lib. movies are not yet working --- lib/preview.php | 94 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 26 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 3fa494a2e03..d49e9d3bde3 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -9,6 +9,7 @@ /* TODO: - delete thumbnails if files change. + - make it work with external filesystem files. - movies support - pdf support - mp3/id3 support @@ -34,12 +35,17 @@ class OC_Preview { static public function show($file,$maxX,$maxY,$scalingup) { // get the mimetype of the file $mimetype=explode('/',OC_FileSystem::getMimeType($file)); - // it´s an image if($mimetype[0]=='image'){ OCP\Response::enableCaching(3600 * 24); // 24 hour $image=OC_PreviewImage::getThumbnail($file,$maxX,$maxY,$scalingup); $image->show(); + + // it´s a video + }elseif($mimetype[0]=='video'){ + OCP\Response::enableCaching(3600 * 24); // 24 hour + OC_PreviewMovie::getThumbnail($file,$maxX,$maxY,$scalingup); + // it´s something else. Let´s create a dummy preview }else{ header('Content-type: image/png'); @@ -55,56 +61,59 @@ class OC_Preview { class OC_PreviewImage { public static function getThumbnail($path,$maxX,$maxY,$scalingup) { - $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); - // is a preview already in the cache? + $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); + + // is a preview already in the cache? if ($thumbnails_view->file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); } - - // does the sourcefile exist? + + // does the sourcefile exist? if (!\OC_Filesystem::file_exists($path)) { \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); return false; } - // open the source image + // open the source image $image = new \OC_Image(); $image->loadFromFile(\OC_Filesystem::getLocalFile($path)); if (!$image->valid()) return false; - // fix the orientation + // fix the orientation $image->fixOrientation(); - - // calculate the right preview size - $Xsize=$image->width(); - $Ysize=$image->height(); - if (($Xsize/$Ysize)>($maxX/$maxY)) { - $factor=$maxX/$Xsize; - } else { - $factor=$maxY/$Ysize; - } - - // only scale up if requested - if($scalingup==false) { - if($factor>1) $factor=1; - } - $newXsize=$Xsize*$factor; - $newYsize=$Ysize*$factor; - // resize + // calculate the right preview size + $Xsize=$image->width(); + $Ysize=$image->height(); + if (($Xsize/$Ysize)>($maxX/$maxY)) { + $factor=$maxX/$Xsize; + } else { + $factor=$maxY/$Ysize; + } + + // only scale up if requested + if($scalingup==false) { + if($factor>1) $factor=1; + } + $newXsize=$Xsize*$factor; + $newYsize=$Ysize*$factor; + + // resize $ret = $image->preciseResize($newXsize, $newYsize); if (!$ret) { \OC_Log::write('Preview', 'Couldn\'t resize image', \OC_Log::ERROR); unset($image); return false; } - - // store in cache + + // store in cache $l = $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); $image->save($l); return $image; + + } @@ -112,6 +121,39 @@ class OC_PreviewImage { } +class OC_PreviewMovie { + + public static function isAvailable() { + $check=shell_exec('ffmpeg'); + if($check==NULL) return(false); else return(true); + } + + public static function getThumbnail($path,$maxX,$maxY,$scalingup) { + $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); + + // is a preview already in the cache? + if ($thumbnails_view->file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { + return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); + } + + // does the sourcefile exist? + if (!\OC_Filesystem::file_exists($path)) { + \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); + return false; + } + + // call ffmpeg to do the screenshot + shell_exec('ffmpeg -y -i {'.escapeshellarg($path).'} -f mjpeg -vframes 1 -ss 1 -s {'.escapeshellarg($maxX).'}x{'.escapeshellarg($maxY).'} {.'.$thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup).'}'); + + // output the generated Preview + $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); + unset($thumbnails_view); + } + + +} + + class OC_PreviewUnknown { public static function getThumbnail($maxX,$maxY) { -- GitLab From 9ef449842a369c2517f5c34932b502b754393ce0 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 25 Apr 2013 11:18:45 +0200 Subject: [PATCH 004/635] save current work state of Preview Lib --- lib/preview.php | 378 +++++++++++++++++++++++++++++------------------- 1 file changed, 229 insertions(+), 149 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index d49e9d3bde3..c7047633212 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -1,28 +1,139 @@ getFileInfo($file); + $fileid = self::$fileinfo['fileid']; + + //echo self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid; + if(!self::$fileview->is_dir(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid)){ + return false; + } + + //does a preview with the wanted height and width already exist? + if(self::$fileview->file_exists(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid . PATH_SEPARATOR . $x . '-' . $y . '.png')){ + return self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid . PATH_SEPARATOR . $x . '-' . $y . '.png'; + } + + $wantedaspectratio = $maxX / $maxY; + + //array for usable cached thumbnails + $possiblethumbnails = array(); + + $allthumbnails = self::$fileview->getDirectoryContent(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid); + foreach($allthumbnails as $thumbnail){ + $size = explode('-', $thumbnail['name']); + $x = $size[0]; + $y = $size[1]; + + $aspectratio = $x / $y; + if($aspectratio != $wantedaspectratio){ + continue; + } + + if($x < $maxX || $y < $maxY){ + if($scalingup){ + $scalefactor = $maxX / $x; + if($scalefactor > self::MAX_SCALE_FACTOR){ + continue; + } + }else{ + continue; + } + } + + $possiblethumbnails[$x] = $thumbnail['path']; + } + + if(count($possiblethumbnails) === 0){ + return false; + } + + if(count($possiblethumbnails) === 1){ + return current($possiblethumbnails); + } + + ksort($possiblethumbnails); + + if(key(reset($possiblethumbnails)) > $maxX){ + return current(reset($possiblethumbnails)); + } + + if(key(end($possiblethumbnails)) < $maxX){ + return current(end($possiblethumbnails)); + } + + foreach($possiblethumbnails as $width => $path){ + if($width < $maxX){ + continue; + }else{ + return $path; + } + } + } - // the thumbnail cache folder - const THUMBNAILS_FOLDER = 'thumbnails'; + /** + * @brief delete a preview with a specfic height and width + * @param $file path to the file + * @param $x width of preview + * @param $y height of preview + * @return image + */ + public static function deletePreview($file, $x, $y){ + self::init(); + + $fileinfo = self::$fileview->getFileInfo($file); + $fileid = self::$fileinfo['fileid']; + + return self::$fileview->unlink(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid . PATH_SEPARATOR . $x . '-' . $y . '.png'); + } + + /** + * @brief deletes all previews of a file + * @param $file path of file + * @return bool + */ + public static function deleteAllPrevies($file){ + self::init(); + + $fileinfo = self::$fileview->getFileInfo($file); + $fileid = self::$fileinfo['fileid']; + + return self::$fielview->rmdir(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid); + } /** * @brief return a preview of a file @@ -32,146 +143,115 @@ class OC_Preview { * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly * @return image */ - static public function show($file,$maxX,$maxY,$scalingup) { - // get the mimetype of the file - $mimetype=explode('/',OC_FileSystem::getMimeType($file)); - // it´s an image - if($mimetype[0]=='image'){ - OCP\Response::enableCaching(3600 * 24); // 24 hour - $image=OC_PreviewImage::getThumbnail($file,$maxX,$maxY,$scalingup); - $image->show(); - - // it´s a video - }elseif($mimetype[0]=='video'){ - OCP\Response::enableCaching(3600 * 24); // 24 hour - OC_PreviewMovie::getThumbnail($file,$maxX,$maxY,$scalingup); - - // it´s something else. Let´s create a dummy preview - }else{ - header('Content-type: image/png'); - OC_PreviewUnknown::getThumbnail($maxX,$maxY); + public static function getPreview($file, $maxX, $maxY, $scalingup){ + self::init(); + + $cached = self::isCached($file, $maxX, $maxY); + if($cached){ + $image = new \OC_Image($cached); + if($image->width() != $maxX && $image->height != $maxY){ + $image->preciseResize($maxX, $maxY); + } + return $image; } + + $mimetype = self::$fileview->getMimeType($file); + + $preview; + + foreach(self::$providers as $supportedmimetype => $provider){ + if(!preg_match($supportedmimetype, $mimetype)){ + continue; + } + + $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingup); + + if(!$preview){ + continue; + } + + if(!($preview instanceof \OC_Image)){ + $preview = @new \OC_Image($preview); + } + + //cache thumbnail + $preview->save(self::$filesview->getAbsolutePath(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid . PATH_SEPARATOR . $x . '-' . $y . '.png')); + + break; + } + + return $preview; } + /** + * @brief return a preview of a file + * @param $file The path to the file where you want a thumbnail from + * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image + * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image + * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly + * @return image + */ + public static function showPreview($file, $maxX, $maxY, $scalingup = true, $fontsize = 12){ + OCP\Response::enableCaching(3600 * 24); // 24 hour + $preview = self::getPreview($file, $maxX, $maxY, $scalingup, $fontsize); + $preview->show(); + } + + /** + * @brief check whether or not providers and views are initialized and initialize if not + * @return void + */ + private static function init(){ + if(empty(self::$providers)){ + self::initProviders(); + } + if(is_null(self::$thumbnailsview) || is_null(self::$userlandview)){ + self::initViews(); + } + } -} - - - -class OC_PreviewImage { - - public static function getThumbnail($path,$maxX,$maxY,$scalingup) { - - $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); - - // is a preview already in the cache? - if ($thumbnails_view->file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { - return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); - } - - // does the sourcefile exist? - if (!\OC_Filesystem::file_exists($path)) { - \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); - return false; - } - - // open the source image - $image = new \OC_Image(); - $image->loadFromFile(\OC_Filesystem::getLocalFile($path)); - if (!$image->valid()) return false; - - // fix the orientation - $image->fixOrientation(); - - // calculate the right preview size - $Xsize=$image->width(); - $Ysize=$image->height(); - if (($Xsize/$Ysize)>($maxX/$maxY)) { - $factor=$maxX/$Xsize; - } else { - $factor=$maxY/$Ysize; - } - - // only scale up if requested - if($scalingup==false) { - if($factor>1) $factor=1; - } - $newXsize=$Xsize*$factor; - $newYsize=$Ysize*$factor; - - // resize - $ret = $image->preciseResize($newXsize, $newYsize); - if (!$ret) { - \OC_Log::write('Preview', 'Couldn\'t resize image', \OC_Log::ERROR); - unset($image); - return false; - } - - // store in cache - $l = $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); - $image->save($l); - - return $image; - - - } - - - -} - - -class OC_PreviewMovie { - - public static function isAvailable() { - $check=shell_exec('ffmpeg'); - if($check==NULL) return(false); else return(true); - } - - public static function getThumbnail($path,$maxX,$maxY,$scalingup) { - $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); - - // is a preview already in the cache? - if ($thumbnails_view->file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { - return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); - } - - // does the sourcefile exist? - if (!\OC_Filesystem::file_exists($path)) { - \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); - return false; - } - - // call ffmpeg to do the screenshot - shell_exec('ffmpeg -y -i {'.escapeshellarg($path).'} -f mjpeg -vframes 1 -ss 1 -s {'.escapeshellarg($maxX).'}x{'.escapeshellarg($maxY).'} {.'.$thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup).'}'); - - // output the generated Preview - $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); - unset($thumbnails_view); - } - - -} - + /** + * @brief register a new preview provider to be used + * @param string $provider class name of a OC_Preview_Provider + * @return void + */ + public static function registerProvider($class, $options=array()){ + self::$registeredProviders[]=array('class'=>$class, 'options'=>$options); + } -class OC_PreviewUnknown { - public static function getThumbnail($maxX,$maxY) { + /** + * @brief create instances of all the registered preview providers + * @return void + */ + private static function initProviders(){ + if(count(self::$providers)>0) { + return; + } + + foreach(self::$registeredProviders as $provider) { + $class=$provider['class']; + $options=$provider['options']; - // check if GD is installed - if(!extension_loaded('gd') || !function_exists('gd_info')) { - OC_Log::write('preview', __METHOD__.'(): GD module not installed', OC_Log::ERROR); - return false; + $object = new $class($options); + + self::$providers[$object->getMimeType()] = $object; } - - // create a white image - $image = imagecreatetruecolor($maxX, $maxY); - $color = imagecolorallocate($image, 255, 255, 255); - imagefill($image, 0, 0, $color); - - // output the image - imagepng($image); - imagedestroy($image); - } - -} - + + $keys = array_map('strlen', array_keys(self::$providers)); + array_multisort($keys, SORT_DESC, self::$providers); + } + + /** + * @brief initialize a new \OC\Files\View object + * @return void + */ + private static function initViews(){ + if(is_null(self::$fileview)){ + self::$fileview = new OC\Files\View(); + } + } + + public static function previewRouter($params){ + var_dump($params); + } +} \ No newline at end of file -- GitLab From f02aca3f6ee295485d5bb9bc99b85b5573716f17 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 25 Apr 2013 11:42:40 +0200 Subject: [PATCH 005/635] add route for previews --- core/routes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/routes.php b/core/routes.php index be19b66bf72..be5766cea9d 100644 --- a/core/routes.php +++ b/core/routes.php @@ -42,7 +42,8 @@ $this->create('js_config', '/core/js/config.js') // Routing $this->create('core_ajax_routes', '/core/routes.json') ->action('OC_Router', 'JSRoutes'); - +$this->create('core_ajax_preview', '/core/preview.png') + ->action('OC_Preview', 'previewRouter'); OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; $this->create('core_lostpassword_index', '/lostpassword/') ->get() -- GitLab From 8c1925425b26d9b2889632c724ec455ceeed4dd4 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 25 Apr 2013 12:51:44 +0200 Subject: [PATCH 006/635] save current work state --- lib/preview.php | 32 ++++++++++++++++-- lib/preview/images.php | 71 ++++++++++++++++++++++++++++++++++++++++ lib/preview/movies.php | 42 ++++++++++++++++++++++++ lib/preview/mp3.php | 1 + lib/preview/pdf.php | 0 lib/preview/provider.php | 20 +++++++++++ lib/preview/unknown.php | 34 +++++++++++++++++++ 7 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 lib/preview/images.php create mode 100644 lib/preview/movies.php create mode 100644 lib/preview/mp3.php create mode 100644 lib/preview/pdf.php create mode 100644 lib/preview/provider.php create mode 100644 lib/preview/unknown.php diff --git a/lib/preview.php b/lib/preview.php index c7047633212..de79b424077 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -205,7 +205,7 @@ class OC_Preview { if(empty(self::$providers)){ self::initProviders(); } - if(is_null(self::$thumbnailsview) || is_null(self::$userlandview)){ + if(is_null(self::$fileview)){ self::initViews(); } } @@ -247,11 +247,37 @@ class OC_Preview { */ private static function initViews(){ if(is_null(self::$fileview)){ - self::$fileview = new OC\Files\View(); + //does this work with LDAP? + self::$fileview = new OC\Files\View(OC_User::getUser()); } } public static function previewRouter($params){ - var_dump($params); + self::init(); + + $file = (string) urldecode($_GET['file']); + $maxX = (int) $_GET['x']; + $maxY = (int) $_GET['y']; + $scalingup = (bool) $_GET['scalingup']; + + $path = 'files/' . $file; + + if($maxX === 0 || $maxY === 0){ + OC_Log::write('core', 'Can not create preview with 0px width or 0px height', OC_Log::DEBUG); + exit; + } + + var_dump(self::$fileview->file_exists($path)); + var_dump(self::$fileview->getDirectoryContent()); + var_dump(self::$fileview->getDirectoryContent('files/')); + var_dump($path); + var_dump(self::$fileview->filesize($path)); + var_dump(self::$fileview->getAbsolutePath('/')); + + if(!self::$fileview->filesize($path)){ + OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND); + } + + self::showPreview($file, $maxX, $maxY, $scalingup); } } \ No newline at end of file diff --git a/lib/preview/images.php b/lib/preview/images.php new file mode 100644 index 00000000000..6b6e8e3599f --- /dev/null +++ b/lib/preview/images.php @@ -0,0 +1,71 @@ +file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { + return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); + } + + // does the sourcefile exist? + if (!\OC_Filesystem::file_exists($path)) { + \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); + return false; + } + + // open the source image + $image = new \OC_Image(); + $image->loadFromFile(\OC_Filesystem::getLocalFile($path)); + if (!$image->valid()) return false; + + // fix the orientation + $image->fixOrientation(); + + // calculate the right preview size + $Xsize=$image->width(); + $Ysize=$image->height(); + if (($Xsize/$Ysize)>($maxX/$maxY)) { + $factor=$maxX/$Xsize; + } else { + $factor=$maxY/$Ysize; + } + + // only scale up if requested + if($scalingup==false) { + if($factor>1) $factor=1; + } + $newXsize=$Xsize*$factor; + $newYsize=$Ysize*$factor; + + // resize + $ret = $image->preciseResize($newXsize, $newYsize); + if (!$ret) { + \OC_Log::write('Preview', 'Couldn\'t resize image', \OC_Log::ERROR); + unset($image); + return false; + } + + // store in cache + $l = $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); + $image->save($l); + + return $image; + } + +} + +OC_Preview::registerProvider('OC_Preview_Image'); \ No newline at end of file diff --git a/lib/preview/movies.php b/lib/preview/movies.php new file mode 100644 index 00000000000..afa27c0b143 --- /dev/null +++ b/lib/preview/movies.php @@ -0,0 +1,42 @@ +file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { + return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); + } + + // does the sourcefile exist? + if (!\OC_Filesystem::file_exists($path)) { + \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); + return false; + } + + // call ffmpeg to do the screenshot + shell_exec('ffmpeg -y -i {'.escapeshellarg($path).'} -f mjpeg -vframes 1 -ss 1 -s {'.escapeshellarg($maxX).'}x{'.escapeshellarg($maxY).'} {.'.$thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup).'}'); + + // output the generated Preview + $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); + unset($thumbnails_view); + } + + } + + OC_Preview::registerProvider('OC_Preview_Movie'); +} \ No newline at end of file diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php new file mode 100644 index 00000000000..645e6fa6232 --- /dev/null +++ b/lib/preview/mp3.php @@ -0,0 +1 @@ +///audio\/mpeg/ \ No newline at end of file diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lib/preview/provider.php b/lib/preview/provider.php new file mode 100644 index 00000000000..c45edbba44d --- /dev/null +++ b/lib/preview/provider.php @@ -0,0 +1,20 @@ +options=$options; + } + + abstract public function getMimeType(); + + /** + * search for $query + * @param string $query + * @return + */ + abstract public function getThumbnail($path, $maxX, $maxY, $scalingup); +} diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php new file mode 100644 index 00000000000..1cd270db687 --- /dev/null +++ b/lib/preview/unknown.php @@ -0,0 +1,34 @@ + Date: Thu, 9 May 2013 23:59:16 +0200 Subject: [PATCH 007/635] implement OC_Preview --- lib/preview.php | 517 +++++++++++++++++++++++++++++---------- lib/preview/images.php | 53 +--- lib/preview/movies.php | 4 +- lib/preview/mp3.php | 21 +- lib/preview/pdf.php | 29 +++ lib/preview/provider.php | 2 +- lib/preview/unknown.php | 2 +- 7 files changed, 446 insertions(+), 182 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index de79b424077..c062a068872 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -5,21 +5,38 @@ * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. - */ -/* + * * Thumbnails: * structure of filename: * /data/user/thumbnails/pathhash/x-y.png * */ +require_once('preview/images.php'); +require_once('preview/movies.php'); +require_once('preview/mp3.php'); +require_once('preview/pdf.php'); +require_once('preview/unknown.php'); class OC_Preview { //the thumbnail folder const THUMBNAILS_FOLDER = 'thumbnails'; - const MAX_SCALE_FACTOR = 2; + + //config + private $max_scale_factor; + private $max_x; + private $max_y; //fileview object - static private $fileview = null; + private $fileview = null; + private $userview = null; + + //vars + private $file; + private $maxX; + private $maxY; + private $scalingup; + + private $preview; //preview providers static private $providers = array(); @@ -27,6 +44,8 @@ class OC_Preview { /** * @brief check if thumbnail or bigger version of thumbnail of file is cached + * @param $user userid + * @param $root path of root * @param $file The path to the file where you want a thumbnail from * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image @@ -34,68 +53,223 @@ class OC_Preview { * false if thumbnail does not exist * path to thumbnail if thumbnail exists */ - private static function isCached($file, $maxX, $maxY, $scalingup){ - $fileinfo = self::$fileview->getFileInfo($file); - $fileid = self::$fileinfo['fileid']; + public function __construct($user = null, $root = '', $file = '', $maxX = 0, $maxY = 0, $scalingup = false){ + //set config + $this->max_x = OC_Config::getValue('preview_max_x', null); + $this->max_y = OC_Config::getValue('preview_max_y', null); + $this->max_scale_factor = OC_Config::getValue('preview_max_scale_factor', 10); - //echo self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid; - if(!self::$fileview->is_dir(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid)){ - return false; + //save parameters + $this->file = $file; + $this->maxX = $maxX; + $this->maxY = $maxY; + $this->scalingup = $scalingup; + + //init fileviews + $this->fileview = new \OC\Files\View('/' . $user . '/' . $root); + $this->userview = new \OC\Files\View('/' . $user); + + if(!is_null($this->max_x)){ + if($this->maxX > $this->max_x){ + OC_Log::write('core', 'maxX reduced from ' . $this->maxX . ' to ' . $this->max_x, OC_Log::DEBUG); + $this->maxX = $this->max_x; + } + } + + if(!is_null($this->max_y)){ + if($this->maxY > $this->max_y){ + OC_Log::write('core', 'maxY reduced from ' . $this->maxY . ' to ' . $this->max_y, OC_Log::DEBUG); + $this->maxY = $this->max_y; + } + } + + //init providers + if(empty(self::$providers)){ + self::initProviders(); + } + + //check if there are any providers at all + if(empty(self::$providers)){ + OC_Log::write('core', 'No preview providers exist', OC_Log::ERROR); + throw new Exception('No providers'); + } + + //validate parameters + if($file === ''){ + OC_Log::write('core', 'No filename passed', OC_Log::ERROR); + throw new Exception('File not found'); } + + //check if file exists + if(!$this->fileview->file_exists($file)){ + OC_Log::write('core', 'File:"' . $file . '" not found', OC_Log::ERROR); + throw new Exception('File not found'); + } + + //check if given size makes sense + if($maxX === 0 || $maxY === 0){ + OC_Log::write('core', 'Can not create preview with 0px width or 0px height', OC_Log::ERROR); + throw new Exception('Height and/or width set to 0'); + } + } + + /** + * @brief returns the path of the file you want a thumbnail from + * @return string + */ + public function getFile(){ + return $this->file; + } + + /** + * @brief returns the max width of the preview + * @return integer + */ + public function getMaxX(){ + return $this->maxX; + } + + /** + * @brief returns the max height of the preview + * @return integer + */ + public function getMaxY(){ + return $this->maxY; + } + + /** + * @brief returns whether or not scalingup is enabled + * @return bool + */ + public function getScalingup(){ + return $this->scalingup; + } + + /** + * @brief returns the name of the thumbnailfolder + * @return string + */ + public function getThumbnailsfolder(){ + return self::THUMBNAILS_FOLDER; + } + + /** + * @brief returns the max scale factor + * @return integer + */ + public function getMaxScaleFactor(){ + return $this->max_scale_factor; + } + + /** + * @brief returns the max width set in ownCloud's config + * @return integer + */ + public function getConfigMaxX(){ + return $this->max_x; + } + + /** + * @brief returns the max height set in ownCloud's config + * @return integer + */ + public function getConfigMaxY(){ + return $this->max_y; + } + + /** + * @brief deletes previews of a file with specific x and y + * @return bool + */ + public function deletePreview(){ + $fileinfo = $this->fileview->getFileInfo($this->file); + $fileid = $fileinfo['fileid']; + return $this->userview->unlink(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $this->maxX . '-' . $this->maxY . '.png'); + } + + /** + * @brief deletes all previews of a file + * @return bool + */ + public function deleteAllPrevies(){ + $fileinfo = $this->fileview->getFileInfo($this->file); + $fileid = $fileinfo['fileid']; + + return $this->userview->rmdir(self::THUMBNAILS_FOLDER . '/' . $fileid); + } + + /** + * @brief check if thumbnail or bigger version of thumbnail of file is cached + * @return mixed (bool / string) + * false if thumbnail does not exist + * path to thumbnail if thumbnail exists + */ + private function isCached(){ + $file = $this->file; + $maxX = $this->maxX; + $maxY = $this->maxY; + $scalingup = $this->scalingup; + + $fileinfo = $this->fileview->getFileInfo($file); + $fileid = $fileinfo['fileid']; + + if(!$this->userview->is_dir(self::THUMBNAILS_FOLDER . '/' . $fileid)){ + return false; + } + //does a preview with the wanted height and width already exist? - if(self::$fileview->file_exists(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid . PATH_SEPARATOR . $x . '-' . $y . '.png')){ - return self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid . PATH_SEPARATOR . $x . '-' . $y . '.png'; + if($this->userview->file_exists(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png')){ + return self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png'; } - + $wantedaspectratio = $maxX / $maxY; - + //array for usable cached thumbnails $possiblethumbnails = array(); - - $allthumbnails = self::$fileview->getDirectoryContent(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid); + + $allthumbnails = $this->userview->getDirectoryContent(self::THUMBNAILS_FOLDER . '/' . $fileid); foreach($allthumbnails as $thumbnail){ $size = explode('-', $thumbnail['name']); $x = $size[0]; $y = $size[1]; - + $aspectratio = $x / $y; if($aspectratio != $wantedaspectratio){ continue; } - + if($x < $maxX || $y < $maxY){ if($scalingup){ $scalefactor = $maxX / $x; - if($scalefactor > self::MAX_SCALE_FACTOR){ + if($scalefactor > $this->max_scale_factor){ continue; } }else{ continue; } } - $possiblethumbnails[$x] = $thumbnail['path']; } - + if(count($possiblethumbnails) === 0){ return false; } - + if(count($possiblethumbnails) === 1){ return current($possiblethumbnails); } - + ksort($possiblethumbnails); - + if(key(reset($possiblethumbnails)) > $maxX){ return current(reset($possiblethumbnails)); } - + if(key(end($possiblethumbnails)) < $maxX){ return current(end($possiblethumbnails)); } - + foreach($possiblethumbnails as $width => $path){ if($width < $maxX){ continue; @@ -106,33 +280,56 @@ class OC_Preview { } /** - * @brief delete a preview with a specfic height and width - * @param $file path to the file - * @param $x width of preview - * @param $y height of preview + * @brief return a preview of a file + * @param $file The path to the file where you want a thumbnail from + * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image + * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image + * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly * @return image */ - public static function deletePreview($file, $x, $y){ - self::init(); - - $fileinfo = self::$fileview->getFileInfo($file); - $fileid = self::$fileinfo['fileid']; - - return self::$fileview->unlink(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid . PATH_SEPARATOR . $x . '-' . $y . '.png'); - } + public function getPreview(){ + $file = $this->file; + $maxX = $this->maxX; + $maxY = $this->maxY; + $scalingup = $this->scalingup; - /** - * @brief deletes all previews of a file - * @param $file path of file - * @return bool - */ - public static function deleteAllPrevies($file){ - self::init(); - - $fileinfo = self::$fileview->getFileInfo($file); - $fileid = self::$fileinfo['fileid']; - - return self::$fielview->rmdir(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid); + $fileinfo = $this->fileview->getFileInfo($file); + $fileid = $fileinfo['fileid']; + + $cached = self::isCached(); + + if($cached){ + $image = new \OC_Image($this->userview->getLocalFile($cached)); + $this->preview = $image; + }else{ + $mimetype = $this->fileview->getMimeType($file); + + $preview; + + foreach(self::$providers as $supportedmimetype => $provider){ + if(!preg_match($supportedmimetype, $mimetype)){ + continue; + } + + $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingup, $this->fileview); + + if(!$preview){ + continue; + } + + if(!($preview instanceof \OC_Image)){ + $preview = @new \OC_Image($preview); + } + + //cache thumbnail + $preview->save($this->userview->getLocalFile(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png')); + + break; + } + $this->preview = $preview; + } + $this->resizeAndCrop(); + return $this->preview; } /** @@ -141,72 +338,109 @@ class OC_Preview { * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly + * @return void + */ + public function showPreview(){ + OCP\Response::enableCaching(3600 * 24); // 24 hour + $preview = $this->getPreview(); + if($preview){ + $preview->show(); + } + } + + /** + * @brief resize, crop and fix orientation * @return image */ - public static function getPreview($file, $maxX, $maxY, $scalingup){ - self::init(); + public function resizeAndCrop(){ + $image = $this->preview; + $x = $this->maxX; + $y = $this->maxY; + $scalingup = $this->scalingup; + + $image->fixOrientation(); + + if(!($image instanceof \OC_Image)){ + OC_Log::write('core', 'Object passed to resizeAndCrop is not an instance of OC_Image', OC_Log::DEBUG); + return; + } + + $realx = (int) $image->width(); + $realy = (int) $image->height(); + + if($x === $realx && $y === $realy){ + return $image; + } + + $factorX = $x / $realx; + $factorY = $y / $realy; - $cached = self::isCached($file, $maxX, $maxY); - if($cached){ - $image = new \OC_Image($cached); - if($image->width() != $maxX && $image->height != $maxY){ - $image->preciseResize($maxX, $maxY); + if($factorX >= $factorY){ + $factor = $factorX; + }else{ + $factor = $factorY; + } + + // only scale up if requested + if($scalingup === false) { + if($factor>1) $factor=1; + } + if(!is_null($this->max_scale_factor)){ + if($factor > $this->max_scale_factor){ + OC_Log::write('core', 'scalefactor reduced from ' . $factor . ' to ' . $this->max_scale_factor, OC_Log::DEBUG); + $factor = $this->max_scale_factor; } - return $image; } + $newXsize = $realx * $factor; + $newYsize = $realy * $factor; + + // resize + $image->preciseResize($newXsize, $newYsize); - $mimetype = self::$fileview->getMimeType($file); + if($newXsize === $x && $newYsize === $y){ + $this->preview = $image; + return; + } - $preview; + if($newXsize >= $x && $newYsize >= $y){ + $cropX = floor(abs($x - $newXsize) * 0.5); + $cropY = floor(abs($y - $newYsize) * 0.5); + + $image->crop($cropX, $cropY, $x, $y); + + $this->preview = $image; + return; + } - foreach(self::$providers as $supportedmimetype => $provider){ - if(!preg_match($supportedmimetype, $mimetype)){ - continue; + if($newXsize < $x || $newYsize < $y){ + if($newXsize > $x){ + $cropX = floor(($newXsize - $x) * 0.5); + $image->crop($cropX, 0, $x, $newYsize); } - $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingup); - - if(!$preview){ - continue; + if($newYsize > $y){ + $cropY = floor(($newYsize - $y) * 0.5); + $image->crop(0, $cropY, $newXsize, $y); } - if(!($preview instanceof \OC_Image)){ - $preview = @new \OC_Image($preview); - } + $newXsize = (int) $image->width(); + $newYsize = (int) $image->height(); - //cache thumbnail - $preview->save(self::$filesview->getAbsolutePath(self::THUMBNAILS_FOLDER . PATH_SEPARATOR . $fileid . PATH_SEPARATOR . $x . '-' . $y . '.png')); + //create transparent background layer + $transparentlayer = imagecreatetruecolor($x, $y); + $black = imagecolorallocate($transparentlayer, 0, 0, 0); + $image = $image->resource(); + imagecolortransparent($transparentlayer, $black); - break; - } - - return $preview; - } - - /** - * @brief return a preview of a file - * @param $file The path to the file where you want a thumbnail from - * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image - * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image - * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly - * @return image - */ - public static function showPreview($file, $maxX, $maxY, $scalingup = true, $fontsize = 12){ - OCP\Response::enableCaching(3600 * 24); // 24 hour - $preview = self::getPreview($file, $maxX, $maxY, $scalingup, $fontsize); - $preview->show(); - } - - /** - * @brief check whether or not providers and views are initialized and initialize if not - * @return void - */ - private static function init(){ - if(empty(self::$providers)){ - self::initProviders(); - } - if(is_null(self::$fileview)){ - self::initViews(); + $mergeX = floor(abs($x - $newXsize) * 0.5); + $mergeY = floor(abs($y - $newYsize) * 0.5); + + imagecopymerge($transparentlayer, $image, $mergeX, $mergeY, 0, 0, $newXsize, $newYsize, 100); + + $image = new \OC_Image($transparentlayer); + + $this->preview = $image; + return; } } @@ -236,48 +470,75 @@ class OC_Preview { self::$providers[$object->getMimeType()] = $object; } - + $keys = array_map('strlen', array_keys(self::$providers)); array_multisort($keys, SORT_DESC, self::$providers); } /** - * @brief initialize a new \OC\Files\View object + * @brief method that handles preview requests from users that are logged in * @return void */ - private static function initViews(){ - if(is_null(self::$fileview)){ - //does this work with LDAP? - self::$fileview = new OC\Files\View(OC_User::getUser()); - } - } - public static function previewRouter($params){ - self::init(); + OC_Util::checkLoggedIn(); - $file = (string) urldecode($_GET['file']); - $maxX = (int) $_GET['x']; - $maxY = (int) $_GET['y']; - $scalingup = (bool) $_GET['scalingup']; + $file = ''; + $maxX = 0; + $maxY = 0; + /* + * use: ?scalingup=0 / ?scalingup = 1 + * do not use ?scalingup=false / ?scalingup = true as these will always be true + */ + $scalingup = false; - $path = 'files/' . $file; + if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); + if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; + if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; + if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; - if($maxX === 0 || $maxY === 0){ - OC_Log::write('core', 'Can not create preview with 0px width or 0px height', OC_Log::DEBUG); + if($file !== '' && $maxX !== 0 && $maxY !== 0){ + $preview = new OC_Preview(OC_User::getUser(), 'files', $file, $maxX, $maxY, $scalingup); + $preview->showPreview(); + }else{ + OC_Response::setStatus(404); exit; } + } + + /** + * @brief method that handles preview requests from users that are not logged in / view shared folders that are public + * @return void + */ + public static function publicPreviewRouter($params){ + $file = ''; + $maxX = 0; + $maxY = 0; + $scalingup = false; + $token = ''; + + $user = null; + $path = null; - var_dump(self::$fileview->file_exists($path)); - var_dump(self::$fileview->getDirectoryContent()); - var_dump(self::$fileview->getDirectoryContent('files/')); - var_dump($path); - var_dump(self::$fileview->filesize($path)); - var_dump(self::$fileview->getAbsolutePath('/')); + if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); + if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; + if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; + if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; + if(array_key_exists('t', $_GET)) $token = (string) $_GET['t']; - if(!self::$fileview->filesize($path)){ - OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND); + $linkItem = OCP\Share::getShareByToken($token); + if (is_array($linkItem) && isset($linkItem['uid_owner']) && isset($linkItem['file_source'])) { + $userid = $linkItem['uid_owner']; + OC_Util::setupFS($fileOwner); + $path = $linkItem['file_source']; + } + + if($user !== null && $path !== null){ + $preview = new OC_Preview($userid, $path, $file, $maxX, $maxY, $scalingup); + $preview->showPreview(); + }else{ + OC_Response::setStatus(404); + exit; } - self::showPreview($file, $maxX, $maxY, $scalingup); } } \ No newline at end of file diff --git a/lib/preview/images.php b/lib/preview/images.php index 6b6e8e3599f..6766cdb2148 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -12,60 +12,15 @@ class OC_Preview_Image extends OC_Preview_Provider{ return '/image\/.*/'; } - public static function getThumbnail($path,$maxX,$maxY,$scalingup) { - - $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); - - // is a preview already in the cache? - if ($thumbnails_view->file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { - return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); - } - - // does the sourcefile exist? - if (!\OC_Filesystem::file_exists($path)) { - \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); - return false; - } - - // open the source image + public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { + //new image object $image = new \OC_Image(); - $image->loadFromFile(\OC_Filesystem::getLocalFile($path)); + $image->loadFromFile($fileview->getLocalFile($path)); + //check if image object is valid if (!$image->valid()) return false; - // fix the orientation - $image->fixOrientation(); - - // calculate the right preview size - $Xsize=$image->width(); - $Ysize=$image->height(); - if (($Xsize/$Ysize)>($maxX/$maxY)) { - $factor=$maxX/$Xsize; - } else { - $factor=$maxY/$Ysize; - } - - // only scale up if requested - if($scalingup==false) { - if($factor>1) $factor=1; - } - $newXsize=$Xsize*$factor; - $newYsize=$Ysize*$factor; - - // resize - $ret = $image->preciseResize($newXsize, $newYsize); - if (!$ret) { - \OC_Log::write('Preview', 'Couldn\'t resize image', \OC_Log::ERROR); - unset($image); - return false; - } - - // store in cache - $l = $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); - $image->save($l); - return $image; } - } OC_Preview::registerProvider('OC_Preview_Image'); \ No newline at end of file diff --git a/lib/preview/movies.php b/lib/preview/movies.php index afa27c0b143..c994240424c 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -6,7 +6,7 @@ * later. * See the COPYING-README file. */ -if(!is_null(shell_exec('ffmpeg'))){ +if(!is_null(shell_exec('ffmpeg -version'))){ class OC_Preview_Movie extends OC_Preview_Provider{ @@ -14,7 +14,7 @@ if(!is_null(shell_exec('ffmpeg'))){ return '/video\/.*/'; } - public static function getThumbnail($path,$maxX,$maxY,$scalingup) { + public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); // is a preview already in the cache? diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 645e6fa6232..2481e743783 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -1 +1,20 @@ -///audio\/mpeg/ \ No newline at end of file +getLocalFile($path) . '[0]'); + $pdf->setImageFormat('png'); + + //new image object + $image = new \OC_Image(); + $image->loadFromFile($fileview->getLocalFile($path)); + //check if image object is valid + if (!$image->valid()) return false; + + return $image; + } +} + +OC_Preview::registerProvider('OC_Preview_PDF'); \ No newline at end of file diff --git a/lib/preview/provider.php b/lib/preview/provider.php index c45edbba44d..e9264030144 100644 --- a/lib/preview/provider.php +++ b/lib/preview/provider.php @@ -16,5 +16,5 @@ abstract class OC_Preview_Provider{ * @param string $query * @return */ - abstract public function getThumbnail($path, $maxX, $maxY, $scalingup); + abstract public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview); } diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index 1cd270db687..5089a56d671 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -12,7 +12,7 @@ class OC_Preview_Unknown extends OC_Preview_Provider{ return '/.*/'; } - public static function getThumbnail($maxX,$maxY) { + public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) { // check if GD is installed if(!extension_loaded('gd') || !function_exists('gd_info')) { OC_Log::write('preview', __METHOD__.'(): GD module not installed', OC_Log::ERROR); -- GitLab From 837c6ed597f1c549cac5b0b439b257d81ea02b1d Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 17 May 2013 09:43:25 +0200 Subject: [PATCH 008/635] implement pdf preview backend --- lib/preview/pdf.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index d86ad643914..695f8569538 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -14,11 +14,10 @@ class OC_Preview_PDF extends OC_Preview_Provider{ public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) { //create imagick object from pdf $pdf = new imagick($fileview->getLocalFile($path) . '[0]'); - $pdf->setImageFormat('png'); - + $pdf->setImageFormat('jpg'); + //new image object - $image = new \OC_Image(); - $image->loadFromFile($fileview->getLocalFile($path)); + $image = new \OC_Image($pdf); //check if image object is valid if (!$image->valid()) return false; -- GitLab From 8dba46912d19bf976b24e0c097368f2e56ccb97b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 17 May 2013 11:28:49 +0200 Subject: [PATCH 009/635] Disable transparent backgrounds for now --- lib/preview.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index c062a068872..44b551006f1 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -427,17 +427,21 @@ class OC_Preview { $newYsize = (int) $image->height(); //create transparent background layer - $transparentlayer = imagecreatetruecolor($x, $y); - $black = imagecolorallocate($transparentlayer, 0, 0, 0); + $backgroundlayer = imagecreatetruecolor($x, $y); + $white = imagecolorallocate($backgroundlayer, 255, 255, 255); + imagefill($backgroundlayer, 0, 0, $white); + $image = $image->resource(); - imagecolortransparent($transparentlayer, $black); $mergeX = floor(abs($x - $newXsize) * 0.5); $mergeY = floor(abs($y - $newYsize) * 0.5); - imagecopymerge($transparentlayer, $image, $mergeX, $mergeY, 0, 0, $newXsize, $newYsize, 100); + imagecopy($backgroundlayer, $image, $mergeX, $mergeY, 0, 0, $newXsize, $newYsize); + + //$black = imagecolorallocate(0,0,0); + //imagecolortransparent($transparentlayer, $black); - $image = new \OC_Image($transparentlayer); + $image = new \OC_Image($backgroundlayer); $this->preview = $image; return; -- GitLab From f29b8cf68531844c23c45a210e280769a8cece73 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 17 May 2013 11:30:44 +0200 Subject: [PATCH 010/635] set default value of scalingup to true --- lib/preview.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 44b551006f1..3b6e0ae131e 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -53,7 +53,7 @@ class OC_Preview { * false if thumbnail does not exist * path to thumbnail if thumbnail exists */ - public function __construct($user = null, $root = '', $file = '', $maxX = 0, $maxY = 0, $scalingup = false){ + public function __construct($user = null, $root = '', $file = '', $maxX = 0, $maxY = 0, $scalingup = true){ //set config $this->max_x = OC_Config::getValue('preview_max_x', null); $this->max_y = OC_Config::getValue('preview_max_y', null); @@ -493,7 +493,7 @@ class OC_Preview { * use: ?scalingup=0 / ?scalingup = 1 * do not use ?scalingup=false / ?scalingup = true as these will always be true */ - $scalingup = false; + $scalingup = true; if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; @@ -517,7 +517,7 @@ class OC_Preview { $file = ''; $maxX = 0; $maxY = 0; - $scalingup = false; + $scalingup = true; $token = ''; $user = null; -- GitLab From 04a4234b9eba85dc1a2f690c12e6a59381a74a54 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 17 May 2013 11:32:42 +0200 Subject: [PATCH 011/635] implement mp3 preview backend --- lib/preview/mp3.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 2481e743783..f5fac0b8366 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -5,14 +5,30 @@ * later. * See the COPYING-README file. */ +require_once('getid3/getid3.php'); + class OC_Preview_MP3 extends OC_Preview_Provider{ public function getMimeType(){ return '/audio\/mpeg/'; } - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + $getID3 = new getID3(); + //Todo - add stream support + $tags = $getID3->analyze($fileview->getLocalFile($path)); + getid3_lib::CopyTagsToComments($tags); + $picture = @$tags['id3v2']['APIC'][0]['data']; + + $image = new \OC_Image($picture); + if (!$image->valid()) return $this->getNoCoverThumbnail($maxX, $maxY); + return $image; + } + + public function getNoCoverThumbnail($maxX, $maxY){ + $image = new \OC_Image(); + return $image; } } -- GitLab From 8b39a085121fae7823046f209eecc3484cf5c936 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 17 May 2013 12:00:32 +0200 Subject: [PATCH 012/635] fix typo --- lib/preview/images.php | 2 +- lib/preview/movies.php | 2 +- lib/preview/mp3.php | 2 +- lib/preview/pdf.php | 2 +- lib/preview/unknown.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/preview/images.php b/lib/preview/images.php index 6766cdb2148..589c7d829d5 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -1,7 +1,7 @@ Date: Fri, 17 May 2013 15:06:37 +0200 Subject: [PATCH 013/635] implement movie previews --- lib/preview/movies.php | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 1f0ceb3ace3..868755a1205 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -7,7 +7,6 @@ * See the COPYING-README file. */ if(!is_null(shell_exec('ffmpeg -version'))){ - class OC_Preview_Movie extends OC_Preview_Provider{ public function getMimeType(){ @@ -15,28 +14,18 @@ if(!is_null(shell_exec('ffmpeg -version'))){ } public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { - $thumbnails_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/'.OC_Preview::THUMBNAILS_FOLDER); - - // is a preview already in the cache? - if ($thumbnails_view->file_exists($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)) { - return new \OC_Image($thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup)); - } - - // does the sourcefile exist? - if (!\OC_Filesystem::file_exists($path)) { - \OC_Log::write('Preview', 'File '.$path.' don\'t exists', \OC_Log::WARN); - return false; - } - - // call ffmpeg to do the screenshot - shell_exec('ffmpeg -y -i {'.escapeshellarg($path).'} -f mjpeg -vframes 1 -ss 1 -s {'.escapeshellarg($maxX).'}x{'.escapeshellarg($maxY).'} {.'.$thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup).'}'); - - // output the generated Preview - $thumbnails_view->getLocalFile($path.'-'.$maxX.'-'.$maxY.'-'.$scalingup); - unset($thumbnails_view); + $abspath = $fileview->getLocalfile($path); + + $tmppath = OC_Helper::tmpFile(); + + $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; + shell_exec($cmd); + + $image = new \OC_Image($tmppath); + if (!$image->valid()) return false; + + return $image; } - } - OC_Preview::registerProvider('OC_Preview_Movie'); } \ No newline at end of file -- GitLab From dd06387a9c65dfaf8d95e6545586f7a042bfd44e Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 17 May 2013 19:08:16 +0200 Subject: [PATCH 014/635] remove whitespace --- lib/preview.php | 79 ++++++++++++++++++++-------------------- lib/preview/images.php | 2 +- lib/preview/movies.php | 10 ++--- lib/preview/mp3.php | 2 +- lib/preview/pdf.php | 2 +- lib/preview/provider.php | 2 +- lib/preview/unknown.php | 21 +++-------- 7 files changed, 53 insertions(+), 65 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 3b6e0ae131e..d6c72603524 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -20,7 +20,7 @@ require_once('preview/unknown.php'); class OC_Preview { //the thumbnail folder const THUMBNAILS_FOLDER = 'thumbnails'; - + //config private $max_scale_factor; private $max_x; @@ -35,7 +35,7 @@ class OC_Preview { private $maxX; private $maxY; private $scalingup; - + private $preview; //preview providers @@ -58,7 +58,7 @@ class OC_Preview { $this->max_x = OC_Config::getValue('preview_max_x', null); $this->max_y = OC_Config::getValue('preview_max_y', null); $this->max_scale_factor = OC_Config::getValue('preview_max_scale_factor', 10); - + //save parameters $this->file = $file; $this->maxX = $maxX; @@ -112,7 +112,7 @@ class OC_Preview { throw new Exception('Height and/or width set to 0'); } } - + /** * @brief returns the path of the file you want a thumbnail from * @return string @@ -120,7 +120,7 @@ class OC_Preview { public function getFile(){ return $this->file; } - + /** * @brief returns the max width of the preview * @return integer @@ -136,7 +136,7 @@ class OC_Preview { public function getMaxY(){ return $this->maxY; } - + /** * @brief returns whether or not scalingup is enabled * @return bool @@ -144,7 +144,7 @@ class OC_Preview { public function getScalingup(){ return $this->scalingup; } - + /** * @brief returns the name of the thumbnailfolder * @return string @@ -176,7 +176,7 @@ class OC_Preview { public function getConfigMaxY(){ return $this->max_y; } - + /** * @brief deletes previews of a file with specific x and y * @return bool @@ -303,27 +303,27 @@ class OC_Preview { $this->preview = $image; }else{ $mimetype = $this->fileview->getMimeType($file); - + $preview; - + foreach(self::$providers as $supportedmimetype => $provider){ if(!preg_match($supportedmimetype, $mimetype)){ continue; } - + $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingup, $this->fileview); if(!$preview){ continue; } - + if(!($preview instanceof \OC_Image)){ $preview = @new \OC_Image($preview); } - + //cache thumbnail $preview->save($this->userview->getLocalFile(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png')); - + break; } $this->preview = $preview; @@ -396,12 +396,12 @@ class OC_Preview { // resize $image->preciseResize($newXsize, $newYsize); - + if($newXsize === $x && $newYsize === $y){ $this->preview = $image; return; } - + if($newXsize >= $x && $newYsize >= $y){ $cropX = floor(abs($x - $newXsize) * 0.5); $cropY = floor(abs($y - $newYsize) * 0.5); @@ -411,38 +411,38 @@ class OC_Preview { $this->preview = $image; return; } - + if($newXsize < $x || $newYsize < $y){ if($newXsize > $x){ $cropX = floor(($newXsize - $x) * 0.5); $image->crop($cropX, 0, $x, $newYsize); } - + if($newYsize > $y){ $cropY = floor(($newYsize - $y) * 0.5); $image->crop(0, $cropY, $newXsize, $y); } - + $newXsize = (int) $image->width(); $newYsize = (int) $image->height(); - + //create transparent background layer $backgroundlayer = imagecreatetruecolor($x, $y); $white = imagecolorallocate($backgroundlayer, 255, 255, 255); imagefill($backgroundlayer, 0, 0, $white); - + $image = $image->resource(); - + $mergeX = floor(abs($x - $newXsize) * 0.5); $mergeY = floor(abs($y - $newYsize) * 0.5); - + imagecopy($backgroundlayer, $image, $mergeX, $mergeY, 0, 0, $newXsize, $newYsize); - + //$black = imagecolorallocate(0,0,0); //imagecolortransparent($transparentlayer, $black); - + $image = new \OC_Image($backgroundlayer); - + $this->preview = $image; return; } @@ -465,27 +465,27 @@ class OC_Preview { if(count(self::$providers)>0) { return; } - + foreach(self::$registeredProviders as $provider) { $class=$provider['class']; $options=$provider['options']; - + $object = new $class($options); - + self::$providers[$object->getMimeType()] = $object; } - + $keys = array_map('strlen', array_keys(self::$providers)); array_multisort($keys, SORT_DESC, self::$providers); } - + /** * @brief method that handles preview requests from users that are logged in * @return void */ public static function previewRouter($params){ OC_Util::checkLoggedIn(); - + $file = ''; $maxX = 0; $maxY = 0; @@ -494,12 +494,12 @@ class OC_Preview { * do not use ?scalingup=false / ?scalingup = true as these will always be true */ $scalingup = true; - + if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; - + if($file !== '' && $maxX !== 0 && $maxY !== 0){ $preview = new OC_Preview(OC_User::getUser(), 'files', $file, $maxX, $maxY, $scalingup); $preview->showPreview(); @@ -508,7 +508,7 @@ class OC_Preview { exit; } } - + /** * @brief method that handles preview requests from users that are not logged in / view shared folders that are public * @return void @@ -519,23 +519,23 @@ class OC_Preview { $maxY = 0; $scalingup = true; $token = ''; - + $user = null; $path = null; - + if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; if(array_key_exists('t', $_GET)) $token = (string) $_GET['t']; - + $linkItem = OCP\Share::getShareByToken($token); if (is_array($linkItem) && isset($linkItem['uid_owner']) && isset($linkItem['file_source'])) { $userid = $linkItem['uid_owner']; OC_Util::setupFS($fileOwner); $path = $linkItem['file_source']; } - + if($user !== null && $path !== null){ $preview = new OC_Preview($userid, $path, $file, $maxX, $maxY, $scalingup); $preview->showPreview(); @@ -543,6 +543,5 @@ class OC_Preview { OC_Response::setStatus(404); exit; } - } } \ No newline at end of file diff --git a/lib/preview/images.php b/lib/preview/images.php index 589c7d829d5..a0df337d58e 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -11,7 +11,7 @@ class OC_Preview_Image extends OC_Preview_Provider{ public function getMimeType(){ return '/image\/.*/'; } - + public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { //new image object $image = new \OC_Image(); diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 868755a1205..8144956c998 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -12,18 +12,18 @@ if(!is_null(shell_exec('ffmpeg -version'))){ public function getMimeType(){ return '/video\/.*/'; } - + public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { $abspath = $fileview->getLocalfile($path); - + $tmppath = OC_Helper::tmpFile(); - + $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; shell_exec($cmd); - + $image = new \OC_Image($tmppath); if (!$image->valid()) return false; - + return $image; } } diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 5194e165818..6fb4b051f41 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -25,7 +25,7 @@ class OC_Preview_MP3 extends OC_Preview_Provider{ return $image; } - + public function getNoCoverThumbnail($maxX, $maxY){ $image = new \OC_Image(); return $image; diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index f1b7f3eee73..bf1d8b2b3b5 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -15,7 +15,7 @@ class OC_Preview_PDF extends OC_Preview_Provider{ //create imagick object from pdf $pdf = new imagick($fileview->getLocalFile($path) . '[0]'); $pdf->setImageFormat('jpg'); - + //new image object $image = new \OC_Image($pdf); //check if image object is valid diff --git a/lib/preview/provider.php b/lib/preview/provider.php index e9264030144..2f2a0e68486 100644 --- a/lib/preview/provider.php +++ b/lib/preview/provider.php @@ -8,7 +8,7 @@ abstract class OC_Preview_Provider{ public function __construct($options) { $this->options=$options; } - + abstract public function getMimeType(); /** diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index 746b0ebb47a..290c18a72d7 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -12,23 +12,12 @@ class OC_Preview_Unknown extends OC_Preview_Provider{ return '/.*/'; } - public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) { - // check if GD is installed - if(!extension_loaded('gd') || !function_exists('gd_info')) { - OC_Log::write('preview', __METHOD__.'(): GD module not installed', OC_Log::ERROR); - return false; - } - - // create a white image - $image = imagecreatetruecolor($maxX, $maxY); - $color = imagecolorallocate($image, 255, 255, 255); - imagefill($image, 0, 0, $color); - - // output the image - imagepng($image); - imagedestroy($image); - } + public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) { + + $mimetype = $this->fileview->getMimeType($file); + return new \OC_Image(); + } } OC_Preview::registerProvider('OC_Preview_Unknown'); \ No newline at end of file -- GitLab From 13c6ef1ba9c3f857150679d164852d8724ab946f Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 21 May 2013 12:23:31 +0200 Subject: [PATCH 015/635] add svg backend --- lib/preview.php | 1 + lib/preview/svg.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 lib/preview/svg.php diff --git a/lib/preview.php b/lib/preview.php index d6c72603524..572c85057be 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -15,6 +15,7 @@ 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/unknown.php'); class OC_Preview { diff --git a/lib/preview/svg.php b/lib/preview/svg.php new file mode 100644 index 00000000000..12b93f696ea --- /dev/null +++ b/lib/preview/svg.php @@ -0,0 +1,28 @@ +readImageBlob($fileview->file_get_contents($path)); + $svg->setImageFormat('jpg'); + + //new image object + $image = new \OC_Image($svg); + //check if image object is valid + if (!$image->valid()) return false; + + return $image; + } +} + +OC_Preview::registerProvider('OC_Preview_SVG'); \ No newline at end of file -- GitLab From 00985068ca249f4087f9f5b634e628afb8e8f7b1 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 22 May 2013 15:12:25 +0200 Subject: [PATCH 016/635] add previews for public files --- core/routes.php | 2 ++ lib/preview.php | 24 +++++++++++++++++++----- lib/preview/unknown.php | 10 ++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/core/routes.php b/core/routes.php index be5766cea9d..c45ffee26fd 100644 --- a/core/routes.php +++ b/core/routes.php @@ -44,6 +44,8 @@ $this->create('core_ajax_routes', '/core/routes.json') ->action('OC_Router', 'JSRoutes'); $this->create('core_ajax_preview', '/core/preview.png') ->action('OC_Preview', 'previewRouter'); +$this->create('core_ajax_public_preview', '/core/publicpreview.png') + ->action('OC_Preview', 'publicPreviewRouter'); OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; $this->create('core_lostpassword_index', '/lostpassword/') ->get() diff --git a/lib/preview.php b/lib/preview.php index 572c85057be..39a87ed5396 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -529,16 +529,30 @@ class OC_Preview { if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; if(array_key_exists('t', $_GET)) $token = (string) $_GET['t']; - + $linkItem = OCP\Share::getShareByToken($token); + if (is_array($linkItem) && isset($linkItem['uid_owner']) && isset($linkItem['file_source'])) { $userid = $linkItem['uid_owner']; - OC_Util::setupFS($fileOwner); - $path = $linkItem['file_source']; + OC_Util::setupFS($userid); + $pathid = $linkItem['file_source']; + $path = \OC\Files\Filesystem::getPath($pathid); + } + + //clean up file parameter + $file = \OC\Files\Filesystem::normalizePath($file); + if(!\OC\Files\Filesystem::isValidPath($file)){ + OC_Response::setStatus(403); + exit; + } + + $path = \OC\Files\Filesystem::normalizePath($path, false); + if(substr($path, 0, 1) == '/'){ + $path = substr($path, 1); } - if($user !== null && $path !== null){ - $preview = new OC_Preview($userid, $path, $file, $maxX, $maxY, $scalingup); + if($userid !== null && $path !== null){ + $preview = new OC_Preview($userid, 'files/' . $path, $file, $maxX, $maxY, $scalingup); $preview->showPreview(); }else{ OC_Response::setStatus(404); diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index 290c18a72d7..5bbdcf847f1 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -13,11 +13,13 @@ class OC_Preview_Unknown extends OC_Preview_Provider{ } public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) { - - - $mimetype = $this->fileview->getMimeType($file); + /*$mimetype = $fileview->getMimeType($path); + $info = $fileview->getFileInfo($path); + $name = array_key_exists('name', $info) ? $info['name'] : ''; + $size = array_key_exists('size', $info) ? $info['size'] : 0; + $isencrypted = array_key_exists('encrypted', $info) ? $info['encrypted'] : false;*/ // show little lock return new \OC_Image(); } } -OC_Preview::registerProvider('OC_Preview_Unknown'); \ No newline at end of file +OC_Preview::registerProvider('OC_Preview_Unknown'); -- GitLab From 1bed3253abfc627a6dd698fc62a617285c1d7c84 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 25 May 2013 11:05:37 +0200 Subject: [PATCH 017/635] add sample config for previews --- config/config.sample.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/config.sample.php b/config/config.sample.php index 72834009201..db6eaf852af 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -183,4 +183,12 @@ $CONFIG = array( 'customclient_desktop' => '', //http://owncloud.org/sync-clients/ 'customclient_android' => '', //https://play.google.com/store/apps/details?id=com.owncloud.android 'customclient_ios' => '' //https://itunes.apple.com/us/app/owncloud/id543672169?mt=8 + +// PREVIEW +/* the max width of a generated preview, if value is null, there is no limit */ +'preview_max_x' => null, +/* the max height of a generated preview, if value is null, there is no limit */ +'preview_max_y' => null, +/* the max factor to scale a preview, default is set to 10 */ +'preview_max_scale_factor' => 10, ); -- GitLab From f78e00209692d28253b91a432eb02d432c96a695 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 27 May 2013 10:45:21 +0200 Subject: [PATCH 018/635] make image preview backend work with encryption --- lib/preview/images.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/preview/images.php b/lib/preview/images.php index a0df337d58e..52aad67ca8b 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -14,11 +14,10 @@ class OC_Preview_Image extends OC_Preview_Provider{ public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { //new image object - $image = new \OC_Image(); - $image->loadFromFile($fileview->getLocalFile($path)); + $image = new \OC_Image($fileview->fopen($path, 'r')); //check if image object is valid if (!$image->valid()) return false; - + return $image; } } -- GitLab From 62411965f9ccfbe66584e91bc325d156e08196d2 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 27 May 2013 11:09:55 +0200 Subject: [PATCH 019/635] make svg preview backend work with encryption --- lib/preview/svg.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/preview/svg.php b/lib/preview/svg.php index 12b93f696ea..8f4697dce04 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -13,7 +13,8 @@ class OC_Preview_SVG extends OC_Preview_Provider{ public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { $svg = new Imagick(); - $svg->readImageBlob($fileview->file_get_contents($path)); + $svg->setResolution($maxX, $maxY); + $svg->readImageBlob('' . $fileview->file_get_contents($path)); $svg->setImageFormat('jpg'); //new image object -- GitLab From 005d8e98706fc98d8dc5aa4927bb3ab0e6b00ac2 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 28 May 2013 10:21:02 +0200 Subject: [PATCH 020/635] update images.php --- lib/preview/images.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/preview/images.php b/lib/preview/images.php index 52aad67ca8b..a8f203528c5 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -13,11 +13,20 @@ class OC_Preview_Image extends OC_Preview_Provider{ } public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { - //new image object - $image = new \OC_Image($fileview->fopen($path, 'r')); + //get fileinfo + $fileinfo = $fileview->getFileInfo($path); + + //check if file is encrypted + if($fileinfo['encrypted'] === true){ + $image = new \OC_Image($fileview->fopen($path, 'r')); + }else{ + $image = new \OC_Image(); + $image->loadFromFile($fileview->getLocalFile($path)); + } + //check if image object is valid if (!$image->valid()) return false; - + return $image; } } -- GitLab From 707f52f1dbb063595541331f94b3796f0f96ce9a Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 28 May 2013 10:23:40 +0200 Subject: [PATCH 021/635] check if the imagick extension is loaded --- lib/preview/svg.php | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/preview/svg.php b/lib/preview/svg.php index 8f4697dce04..415b7751c2b 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -5,25 +5,29 @@ * later. * See the COPYING-README file. */ -class OC_Preview_SVG extends OC_Preview_Provider{ +if (extension_loaded('imagick')){ - public function getMimeType(){ - return '/image\/svg\+xml/'; - } + class OC_Preview_SVG extends OC_Preview_Provider{ + + public function getMimeType(){ + return '/image\/svg\+xml/'; + } - public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { - $svg = new Imagick(); - $svg->setResolution($maxX, $maxY); - $svg->readImageBlob('' . $fileview->file_get_contents($path)); - $svg->setImageFormat('jpg'); + public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { + $svg = new Imagick(); + $svg->setResolution($maxX, $maxY); + $svg->readImageBlob('' . $fileview->file_get_contents($path)); + $svg->setImageFormat('jpg'); - //new image object - $image = new \OC_Image($svg); - //check if image object is valid - if (!$image->valid()) return false; + //new image object + $image = new \OC_Image($svg); + //check if image object is valid + if (!$image->valid()) return false; - return $image; + return $image; + } } -} -OC_Preview::registerProvider('OC_Preview_SVG'); \ No newline at end of file + OC_Preview::registerProvider('OC_Preview_SVG'); + +} \ No newline at end of file -- GitLab From 5ae1333c76fd1331e21fff0fc7343888c473c8d4 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 28 May 2013 11:29:01 +0200 Subject: [PATCH 022/635] add preview backend for text based files --- lib/preview/txt.php | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 lib/preview/txt.php diff --git a/lib/preview/txt.php b/lib/preview/txt.php new file mode 100644 index 00000000000..2b5d8edb893 --- /dev/null +++ b/lib/preview/txt.php @@ -0,0 +1,49 @@ +fopen($path, 'r'); + $content = stream_get_contents($content); + + $lines = preg_split("/\r\n|\n|\r/", $content); + $numoflines = count($lines); + + $fontsize = 5; //5px + $linesize = ceil($fontsize * 1.25); + + $image = imagecreate($maxX, $maxY); + $imagecolor = imagecolorallocate($image, 255, 255, 255); + $textcolor = imagecolorallocate($image, 0, 0, 0); + + foreach($lines as $index => $line){ + $index = $index + 1; + + $x = (int) 1; + $y = (int) ($index * $linesize) - $fontsize; + + imagestring($image, 1, $x, $y, $line, $textcolor); + + if(($index * $linesize) >= $maxY){ + break; + } + } + + $image = new \OC_Image($image); + + if (!$image->valid()) return false; + + return $image; + } +} + +OC_Preview::registerProvider('OC_Preview_TXT'); \ No newline at end of file -- GitLab From 7555332d58c6e684cfbde72d5676e8e1902ae4f3 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 28 May 2013 11:31:48 +0200 Subject: [PATCH 023/635] remove whitespace --- lib/preview/txt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview/txt.php b/lib/preview/txt.php index 2b5d8edb893..1e88aec69fd 100644 --- a/lib/preview/txt.php +++ b/lib/preview/txt.php @@ -39,7 +39,7 @@ class OC_Preview_TXT extends OC_Preview_Provider{ } $image = new \OC_Image($image); - + if (!$image->valid()) return false; return $image; -- GitLab From 4d52dfb0a0517a7fd52d20572085aba2ec0e4ad0 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 28 May 2013 11:48:02 +0200 Subject: [PATCH 024/635] make movie backend work with encryption --- lib/preview/movies.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 8144956c998..1e517b38182 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -14,18 +14,25 @@ if(!is_null(shell_exec('ffmpeg -version'))){ } public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { - $abspath = $fileview->getLocalfile($path); + //get fileinfo + $fileinfo = $fileview->getFileInfo($path); + $abspath = $fileview->toTmpFile($path); $tmppath = OC_Helper::tmpFile(); $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; shell_exec($cmd); + unlink($abspath); + $image = new \OC_Image($tmppath); if (!$image->valid()) return false; + unlink($tmppath); + return $image; } } + OC_Preview::registerProvider('OC_Preview_Movie'); } \ No newline at end of file -- GitLab From 738cc48a85f48f8dca2b42d5667d6662810a688b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 28 May 2013 11:49:18 +0200 Subject: [PATCH 025/635] make mp3 backend work with encryption --- lib/preview/mp3.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 6fb4b051f41..18f5cfde375 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -14,15 +14,20 @@ class OC_Preview_MP3 extends OC_Preview_Provider{ } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $getID3 = new getID3(); + $getID3 = new getID3(); + + $tmppath = $fileview->toTmpFile($path); + //Todo - add stream support - $tags = $getID3->analyze($fileview->getLocalFile($path)); + $tags = $getID3->analyze($tmppath); getid3_lib::CopyTagsToComments($tags); $picture = @$tags['id3v2']['APIC'][0]['data']; - + + unlink($tmppath); + $image = new \OC_Image($picture); if (!$image->valid()) return $this->getNoCoverThumbnail($maxX, $maxY); - + return $image; } -- GitLab From 55b00fe819079d78224989eee91d5886233738ab Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 28 May 2013 11:59:20 +0200 Subject: [PATCH 026/635] make pdf backend work with encryption --- lib/preview/pdf.php | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index bf1d8b2b3b5..de5263f91d8 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -5,24 +5,31 @@ * later. * See the COPYING-README file. */ -class OC_Preview_PDF extends OC_Preview_Provider{ +if (extension_loaded('imagick')){ - public function getMimeType(){ - return '/application\/pdf/'; - } + class OC_Preview_PDF extends OC_Preview_Provider{ + + public function getMimeType(){ + return '/application\/pdf/'; + } + + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + $tmppath = $fileview->toTmpFile($path); - public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) { - //create imagick object from pdf - $pdf = new imagick($fileview->getLocalFile($path) . '[0]'); - $pdf->setImageFormat('jpg'); + //create imagick object from pdf + $pdf = new imagick($tmppath . '[0]'); + $pdf->setImageFormat('jpg'); - //new image object - $image = new \OC_Image($pdf); - //check if image object is valid - if (!$image->valid()) return false; + unlink($tmppath); - return $image; + //new image object + $image = new \OC_Image($pdf); + //check if image object is valid + if (!$image->valid()) return false; + + return $image; + } } -} -OC_Preview::registerProvider('OC_Preview_PDF'); \ No newline at end of file + OC_Preview::registerProvider('OC_Preview_PDF'); +} -- GitLab From 08a022aaa48a6bae95ff75204a763a7c16a8253e Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 28 May 2013 12:09:46 +0200 Subject: [PATCH 027/635] don't give ffmpeg wanted size, cause it doesn't care about aspect ratio --- lib/preview/movies.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 1e517b38182..d2aaf730d67 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -20,7 +20,8 @@ if(!is_null(shell_exec('ffmpeg -version'))){ $abspath = $fileview->toTmpFile($path); $tmppath = OC_Helper::tmpFile(); - $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; + //$cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; + $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . $tmppath; shell_exec($cmd); unlink($abspath); -- GitLab From a03787bc422563d129359d34673eb361b0173f51 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 28 May 2013 16:04:39 +0200 Subject: [PATCH 028/635] make preview cache work with encryption and improve error handling --- lib/preview.php | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 39a87ed5396..6fc166b9c70 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -16,6 +16,7 @@ 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'); class OC_Preview { @@ -300,7 +301,7 @@ class OC_Preview { $cached = self::isCached(); if($cached){ - $image = new \OC_Image($this->userview->getLocalFile($cached)); + $image = new \OC_Image($this->userview->file_get_contents($cached, 'r')); $this->preview = $image; }else{ $mimetype = $this->fileview->getMimeType($file); @@ -313,17 +314,22 @@ class OC_Preview { } $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingup, $this->fileview); - + if(!$preview){ continue; } - if(!($preview instanceof \OC_Image)){ - $preview = @new \OC_Image($preview); + //are there any cached thumbnails yet + if($this->userview->is_dir(self::THUMBNAILS_FOLDER . '/') === false){ + $this->userview->mkdir(self::THUMBNAILS_FOLDER . '/'); } //cache thumbnail - $preview->save($this->userview->getLocalFile(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png')); + $cachepath = self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png'; + if($this->userview->is_dir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/') === false){ + $this->userview->mkdir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/'); + } + $this->userview->file_put_contents($cachepath, $preview->data()); break; } @@ -354,13 +360,13 @@ class OC_Preview { * @return image */ public function resizeAndCrop(){ + $this->preview->fixOrientation(); + $image = $this->preview; $x = $this->maxX; $y = $this->maxY; $scalingup = $this->scalingup; - $image->fixOrientation(); - if(!($image instanceof \OC_Image)){ OC_Log::write('core', 'Object passed to resizeAndCrop is not an instance of OC_Image', OC_Log::DEBUG); return; @@ -502,8 +508,14 @@ class OC_Preview { if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; if($file !== '' && $maxX !== 0 && $maxY !== 0){ - $preview = new OC_Preview(OC_User::getUser(), 'files', $file, $maxX, $maxY, $scalingup); - $preview->showPreview(); + try{ + $preview = new OC_Preview(OC_User::getUser(), 'files', $file, $maxX, $maxY, $scalingup); + $preview->showPreview(); + }catch(Exception $e){ + OC_Response::setStatus(404); + OC_Log::write('core', $e->getmessage(), OC_Log::ERROR); + exit; + } }else{ OC_Response::setStatus(404); exit; @@ -552,8 +564,14 @@ class OC_Preview { } if($userid !== null && $path !== null){ - $preview = new OC_Preview($userid, 'files/' . $path, $file, $maxX, $maxY, $scalingup); - $preview->showPreview(); + try{ + $preview = new OC_Preview($userid, 'files/' . $path, $file, $maxX, $maxY, $scalingup); + $preview->showPreview(); + }catch(Exception $e){ + OC_Response::setStatus(404); + OC_Log::write('core', $e->getmessage(), OC_Log::ERROR); + exit; + } }else{ OC_Response::setStatus(404); exit; -- GitLab From eebc15dce0da88dff91dc5249938341cd50b8a85 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 29 May 2013 12:01:43 +0200 Subject: [PATCH 029/635] connect preview lib to filesystem hooks --- lib/base.php | 9 ++++ lib/preview.php | 106 ++++++++++++++++++++++++++++-------------------- 2 files changed, 71 insertions(+), 44 deletions(-) diff --git a/lib/base.php b/lib/base.php index 724bd250a5c..ae384225bed 100644 --- a/lib/base.php +++ b/lib/base.php @@ -474,6 +474,7 @@ class OC { self::registerCacheHooks(); self::registerFilesystemHooks(); + self::registerPreviewHooks(); self::registerShareHooks(); //make sure temporary files are cleaned up @@ -539,6 +540,14 @@ class OC { OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted'); } + /** + * register hooks for previews + */ + public static function registerPreviewHooks() { + OC_Hook::connect('OC_Filesystem', 'post_write', 'OC_Preview', 'post_write'); + OC_Hook::connect('OC_Filesystem', 'delete', 'OC_Preview', 'post_delete'); + } + /** * register hooks for sharing */ diff --git a/lib/preview.php b/lib/preview.php index 6fc166b9c70..7c4db971dfb 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -55,7 +55,7 @@ class OC_Preview { * false if thumbnail does not exist * path to thumbnail if thumbnail exists */ - public function __construct($user = null, $root = '', $file = '', $maxX = 0, $maxY = 0, $scalingup = true){ + public function __construct($user = null, $root = '', $file = '', $maxX = 0, $maxY = 0, $scalingup = true, $force = false){ //set config $this->max_x = OC_Config::getValue('preview_max_x', null); $this->max_y = OC_Config::getValue('preview_max_y', null); @@ -71,47 +71,49 @@ class OC_Preview { $this->fileview = new \OC\Files\View('/' . $user . '/' . $root); $this->userview = new \OC\Files\View('/' . $user); - if(!is_null($this->max_x)){ - if($this->maxX > $this->max_x){ - OC_Log::write('core', 'maxX reduced from ' . $this->maxX . ' to ' . $this->max_x, OC_Log::DEBUG); - $this->maxX = $this->max_x; + if($force !== true){ + if(!is_null($this->max_x)){ + if($this->maxX > $this->max_x){ + OC_Log::write('core', 'maxX reduced from ' . $this->maxX . ' to ' . $this->max_x, OC_Log::DEBUG); + $this->maxX = $this->max_x; + } } - } - - if(!is_null($this->max_y)){ - if($this->maxY > $this->max_y){ - OC_Log::write('core', 'maxY reduced from ' . $this->maxY . ' to ' . $this->max_y, OC_Log::DEBUG); - $this->maxY = $this->max_y; + + if(!is_null($this->max_y)){ + if($this->maxY > $this->max_y){ + OC_Log::write('core', 'maxY reduced from ' . $this->maxY . ' to ' . $this->max_y, OC_Log::DEBUG); + $this->maxY = $this->max_y; + } + } + + //init providers + if(empty(self::$providers)){ + self::initProviders(); + } + + //check if there are any providers at all + if(empty(self::$providers)){ + OC_Log::write('core', 'No preview providers exist', OC_Log::ERROR); + throw new Exception('No providers'); + } + + //validate parameters + if($file === ''){ + OC_Log::write('core', 'No filename passed', OC_Log::ERROR); + throw new Exception('File not found'); + } + + //check if file exists + if(!$this->fileview->file_exists($file)){ + OC_Log::write('core', 'File:"' . $file . '" not found', OC_Log::ERROR); + throw new Exception('File not found'); + } + + //check if given size makes sense + if($maxX === 0 || $maxY === 0){ + OC_Log::write('core', 'Can not create preview with 0px width or 0px height', OC_Log::ERROR); + throw new Exception('Height and/or width set to 0'); } - } - - //init providers - if(empty(self::$providers)){ - self::initProviders(); - } - - //check if there are any providers at all - if(empty(self::$providers)){ - OC_Log::write('core', 'No preview providers exist', OC_Log::ERROR); - throw new Exception('No providers'); - } - - //validate parameters - if($file === ''){ - OC_Log::write('core', 'No filename passed', OC_Log::ERROR); - throw new Exception('File not found'); - } - - //check if file exists - if(!$this->fileview->file_exists($file)){ - OC_Log::write('core', 'File:"' . $file . '" not found', OC_Log::ERROR); - throw new Exception('File not found'); - } - - //check if given size makes sense - if($maxX === 0 || $maxY === 0){ - OC_Log::write('core', 'Can not create preview with 0px width or 0px height', OC_Log::ERROR); - throw new Exception('Height and/or width set to 0'); } } @@ -186,19 +188,22 @@ class OC_Preview { public function deletePreview(){ $fileinfo = $this->fileview->getFileInfo($this->file); $fileid = $fileinfo['fileid']; - - return $this->userview->unlink(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $this->maxX . '-' . $this->maxY . '.png'); + + $this->userview->unlink(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $this->maxX . '-' . $this->maxY . '.png'); + return; } /** * @brief deletes all previews of a file * @return bool */ - public function deleteAllPrevies(){ + public function deleteAllPreviews(){ $fileinfo = $this->fileview->getFileInfo($this->file); $fileid = $fileinfo['fileid']; - return $this->userview->rmdir(self::THUMBNAILS_FOLDER . '/' . $fileid); + $this->userview->deleteAll(self::THUMBNAILS_FOLDER . '/' . $fileid . '/'); + $this->userview->rmdir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/'); + return; } /** @@ -577,4 +582,17 @@ class OC_Preview { exit; } } + + public static function post_write($args){ + self::post_delete($args); + } + + public static function post_delete($args){ + $path = $args['path']; + if(substr($path, 0, 1) == '/'){ + $path = substr($path, 1); + } + $preview = new OC_Preview(OC_User::getUser(), 'files/', $path, 0, 0, false, true); + $preview->deleteAllPreviews(); + } } \ No newline at end of file -- GitLab From fa6b96090abc341da4f9320af02ee75b29a204e6 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 29 May 2013 12:33:24 +0200 Subject: [PATCH 030/635] move to OC namespace --- core/routes.php | 4 +-- lib/base.php | 4 +-- lib/preview.php | 64 +++++++++++++++++++++------------------- lib/preview/images.php | 6 ++-- lib/preview/movies.php | 8 +++-- lib/preview/mp3.php | 10 ++++--- lib/preview/pdf.php | 8 +++-- lib/preview/provider.php | 4 ++- lib/preview/svg.php | 16 +++++++--- lib/preview/txt.php | 6 ++-- lib/preview/unknown.php | 6 ++-- 11 files changed, 80 insertions(+), 56 deletions(-) diff --git a/core/routes.php b/core/routes.php index c45ffee26fd..4b3ad53da01 100644 --- a/core/routes.php +++ b/core/routes.php @@ -43,9 +43,9 @@ $this->create('js_config', '/core/js/config.js') $this->create('core_ajax_routes', '/core/routes.json') ->action('OC_Router', 'JSRoutes'); $this->create('core_ajax_preview', '/core/preview.png') - ->action('OC_Preview', 'previewRouter'); + ->action('OC\Preview', 'previewRouter'); $this->create('core_ajax_public_preview', '/core/publicpreview.png') - ->action('OC_Preview', 'publicPreviewRouter'); + ->action('OC\Preview', 'publicPreviewRouter'); OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; $this->create('core_lostpassword_index', '/lostpassword/') ->get() diff --git a/lib/base.php b/lib/base.php index ae384225bed..525b259f673 100644 --- a/lib/base.php +++ b/lib/base.php @@ -544,8 +544,8 @@ class OC { * register hooks for previews */ public static function registerPreviewHooks() { - OC_Hook::connect('OC_Filesystem', 'post_write', 'OC_Preview', 'post_write'); - OC_Hook::connect('OC_Filesystem', 'delete', 'OC_Preview', 'post_delete'); + OC_Hook::connect('OC_Filesystem', 'post_write', 'OC\Preview', 'post_write'); + OC_Hook::connect('OC_Filesystem', 'delete', 'OC\Preview', 'post_delete'); } /** diff --git a/lib/preview.php b/lib/preview.php index 7c4db971dfb..31812035c49 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -11,6 +11,8 @@ * /data/user/thumbnails/pathhash/x-y.png * */ +namespace OC; + require_once('preview/images.php'); require_once('preview/movies.php'); require_once('preview/mp3.php'); @@ -19,7 +21,7 @@ require_once('preview/svg.php'); require_once('preview/txt.php'); require_once('preview/unknown.php'); -class OC_Preview { +class Preview { //the thumbnail folder const THUMBNAILS_FOLDER = 'thumbnails'; @@ -57,9 +59,9 @@ class OC_Preview { */ public function __construct($user = null, $root = '', $file = '', $maxX = 0, $maxY = 0, $scalingup = true, $force = false){ //set config - $this->max_x = OC_Config::getValue('preview_max_x', null); - $this->max_y = OC_Config::getValue('preview_max_y', null); - $this->max_scale_factor = OC_Config::getValue('preview_max_scale_factor', 10); + $this->max_x = \OC_Config::getValue('preview_max_x', null); + $this->max_y = \OC_Config::getValue('preview_max_y', null); + $this->max_scale_factor = \OC_Config::getValue('preview_max_scale_factor', 10); //save parameters $this->file = $file; @@ -74,14 +76,14 @@ class OC_Preview { if($force !== true){ if(!is_null($this->max_x)){ if($this->maxX > $this->max_x){ - OC_Log::write('core', 'maxX reduced from ' . $this->maxX . ' to ' . $this->max_x, OC_Log::DEBUG); + \OC_Log::write('core', 'maxX reduced from ' . $this->maxX . ' to ' . $this->max_x, \OC_Log::DEBUG); $this->maxX = $this->max_x; } } if(!is_null($this->max_y)){ if($this->maxY > $this->max_y){ - OC_Log::write('core', 'maxY reduced from ' . $this->maxY . ' to ' . $this->max_y, OC_Log::DEBUG); + \OC_Log::write('core', 'maxY reduced from ' . $this->maxY . ' to ' . $this->max_y, \OC_Log::DEBUG); $this->maxY = $this->max_y; } } @@ -93,26 +95,26 @@ class OC_Preview { //check if there are any providers at all if(empty(self::$providers)){ - OC_Log::write('core', 'No preview providers exist', OC_Log::ERROR); - throw new Exception('No providers'); + \OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR); + throw new \Exception('No providers'); } //validate parameters if($file === ''){ - OC_Log::write('core', 'No filename passed', OC_Log::ERROR); - throw new Exception('File not found'); + \OC_Log::write('core', 'No filename passed', \OC_Log::ERROR); + throw new \Exception('File not found'); } //check if file exists if(!$this->fileview->file_exists($file)){ - OC_Log::write('core', 'File:"' . $file . '" not found', OC_Log::ERROR); - throw new Exception('File not found'); + \OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::ERROR); + throw new \Exception('File not found'); } //check if given size makes sense if($maxX === 0 || $maxY === 0){ - OC_Log::write('core', 'Can not create preview with 0px width or 0px height', OC_Log::ERROR); - throw new Exception('Height and/or width set to 0'); + \OC_Log::write('core', 'Can not create preview with 0px width or 0px height', \OC_Log::ERROR); + throw new \Exception('Height and/or width set to 0'); } } } @@ -353,7 +355,7 @@ class OC_Preview { * @return void */ public function showPreview(){ - OCP\Response::enableCaching(3600 * 24); // 24 hour + \OCP\Response::enableCaching(3600 * 24); // 24 hour $preview = $this->getPreview(); if($preview){ $preview->show(); @@ -373,7 +375,7 @@ class OC_Preview { $scalingup = $this->scalingup; if(!($image instanceof \OC_Image)){ - OC_Log::write('core', 'Object passed to resizeAndCrop is not an instance of OC_Image', OC_Log::DEBUG); + OC_Log::write('core', 'Object passed to resizeAndCrop is not an instance of OC_Image', \OC_Log::DEBUG); return; } @@ -399,7 +401,7 @@ class OC_Preview { } if(!is_null($this->max_scale_factor)){ if($factor > $this->max_scale_factor){ - OC_Log::write('core', 'scalefactor reduced from ' . $factor . ' to ' . $this->max_scale_factor, OC_Log::DEBUG); + \OC_Log::write('core', 'scalefactor reduced from ' . $factor . ' to ' . $this->max_scale_factor, \OC_Log::DEBUG); $factor = $this->max_scale_factor; } } @@ -462,7 +464,7 @@ class OC_Preview { /** * @brief register a new preview provider to be used - * @param string $provider class name of a OC_Preview_Provider + * @param string $provider class name of a Preview_Provider * @return void */ public static function registerProvider($class, $options=array()){ @@ -496,7 +498,7 @@ class OC_Preview { * @return void */ public static function previewRouter($params){ - OC_Util::checkLoggedIn(); + \OC_Util::checkLoggedIn(); $file = ''; $maxX = 0; @@ -514,15 +516,15 @@ class OC_Preview { if($file !== '' && $maxX !== 0 && $maxY !== 0){ try{ - $preview = new OC_Preview(OC_User::getUser(), 'files', $file, $maxX, $maxY, $scalingup); + $preview = new Preview(\OC_User::getUser(), 'files', $file, $maxX, $maxY, $scalingup); $preview->showPreview(); }catch(Exception $e){ - OC_Response::setStatus(404); - OC_Log::write('core', $e->getmessage(), OC_Log::ERROR); + \OC_Response::setStatus(404); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); exit; } }else{ - OC_Response::setStatus(404); + \OC_Response::setStatus(404); exit; } } @@ -547,11 +549,11 @@ class OC_Preview { if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; if(array_key_exists('t', $_GET)) $token = (string) $_GET['t']; - $linkItem = OCP\Share::getShareByToken($token); + $linkItem = \OCP\Share::getShareByToken($token); if (is_array($linkItem) && isset($linkItem['uid_owner']) && isset($linkItem['file_source'])) { $userid = $linkItem['uid_owner']; - OC_Util::setupFS($userid); + \OC_Util::setupFS($userid); $pathid = $linkItem['file_source']; $path = \OC\Files\Filesystem::getPath($pathid); } @@ -559,7 +561,7 @@ class OC_Preview { //clean up file parameter $file = \OC\Files\Filesystem::normalizePath($file); if(!\OC\Files\Filesystem::isValidPath($file)){ - OC_Response::setStatus(403); + \OC_Response::setStatus(403); exit; } @@ -570,15 +572,15 @@ class OC_Preview { if($userid !== null && $path !== null){ try{ - $preview = new OC_Preview($userid, 'files/' . $path, $file, $maxX, $maxY, $scalingup); + $preview = new Preview($userid, 'files/' . $path, $file, $maxX, $maxY, $scalingup); $preview->showPreview(); }catch(Exception $e){ - OC_Response::setStatus(404); - OC_Log::write('core', $e->getmessage(), OC_Log::ERROR); + \OC_Response::setStatus(404); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); exit; } }else{ - OC_Response::setStatus(404); + \OC_Response::setStatus(404); exit; } } @@ -592,7 +594,7 @@ class OC_Preview { if(substr($path, 0, 1) == '/'){ $path = substr($path, 1); } - $preview = new OC_Preview(OC_User::getUser(), 'files/', $path, 0, 0, false, true); + $preview = new Preview(\OC_User::getUser(), 'files/', $path, 0, 0, false, true); $preview->deleteAllPreviews(); } } \ No newline at end of file diff --git a/lib/preview/images.php b/lib/preview/images.php index a8f203528c5..c62fc5397e5 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -6,7 +6,9 @@ * later. * See the COPYING-README file. */ -class OC_Preview_Image extends OC_Preview_Provider{ +namespace OC\Preview; + +class Image extends Provider{ public function getMimeType(){ return '/image\/.*/'; @@ -31,4 +33,4 @@ class OC_Preview_Image extends OC_Preview_Provider{ } } -OC_Preview::registerProvider('OC_Preview_Image'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\Image'); \ No newline at end of file diff --git a/lib/preview/movies.php b/lib/preview/movies.php index d2aaf730d67..14ac97b552d 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -6,8 +6,10 @@ * later. * See the COPYING-README file. */ +namespace OC\Preview; + if(!is_null(shell_exec('ffmpeg -version'))){ - class OC_Preview_Movie extends OC_Preview_Provider{ + class Movie extends Provider{ public function getMimeType(){ return '/video\/.*/'; @@ -18,7 +20,7 @@ if(!is_null(shell_exec('ffmpeg -version'))){ $fileinfo = $fileview->getFileInfo($path); $abspath = $fileview->toTmpFile($path); - $tmppath = OC_Helper::tmpFile(); + $tmppath = \OC_Helper::tmpFile(); //$cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . $tmppath; @@ -35,5 +37,5 @@ if(!is_null(shell_exec('ffmpeg -version'))){ } } - OC_Preview::registerProvider('OC_Preview_Movie'); + \OC\Preview::registerProvider('OC\Preview\Movie'); } \ No newline at end of file diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 18f5cfde375..d62c7230788 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -5,22 +5,24 @@ * later. * See the COPYING-README file. */ +namespace OC\Preview; + require_once('getid3/getid3.php'); -class OC_Preview_MP3 extends OC_Preview_Provider{ +class MP3 extends Provider{ public function getMimeType(){ return '/audio\/mpeg/'; } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $getID3 = new getID3(); + $getID3 = new \getID3(); $tmppath = $fileview->toTmpFile($path); //Todo - add stream support $tags = $getID3->analyze($tmppath); - getid3_lib::CopyTagsToComments($tags); + \getid3_lib::CopyTagsToComments($tags); $picture = @$tags['id3v2']['APIC'][0]['data']; unlink($tmppath); @@ -38,4 +40,4 @@ class OC_Preview_MP3 extends OC_Preview_Provider{ } -OC_Preview::registerProvider('OC_Preview_MP3'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\MP3'); \ No newline at end of file diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index de5263f91d8..4dd4538545c 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -5,9 +5,11 @@ * later. * See the COPYING-README file. */ +namespace OC\Preview; + if (extension_loaded('imagick')){ - class OC_Preview_PDF extends OC_Preview_Provider{ + class PDF extends Provider{ public function getMimeType(){ return '/application\/pdf/'; @@ -17,7 +19,7 @@ if (extension_loaded('imagick')){ $tmppath = $fileview->toTmpFile($path); //create imagick object from pdf - $pdf = new imagick($tmppath . '[0]'); + $pdf = new \imagick($tmppath . '[0]'); $pdf->setImageFormat('jpg'); unlink($tmppath); @@ -31,5 +33,5 @@ if (extension_loaded('imagick')){ } } - OC_Preview::registerProvider('OC_Preview_PDF'); + \OC\Preview::registerProvider('OC\Preview\PDF'); } diff --git a/lib/preview/provider.php b/lib/preview/provider.php index 2f2a0e68486..1e8d537adc8 100644 --- a/lib/preview/provider.php +++ b/lib/preview/provider.php @@ -2,7 +2,9 @@ /** * provides search functionalty */ -abstract class OC_Preview_Provider{ +namespace OC\Preview; + +abstract class Provider{ private $options; public function __construct($options) { diff --git a/lib/preview/svg.php b/lib/preview/svg.php index 415b7751c2b..70be263189d 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -5,18 +5,26 @@ * later. * See the COPYING-README file. */ +namespace OC\Preview; + if (extension_loaded('imagick')){ - class OC_Preview_SVG extends OC_Preview_Provider{ + class SVG extends Provider{ public function getMimeType(){ return '/image\/svg\+xml/'; } public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { - $svg = new Imagick(); + $svg = new \Imagick(); $svg->setResolution($maxX, $maxY); - $svg->readImageBlob('' . $fileview->file_get_contents($path)); + + $content = stream_get_contents($fileview->fopen($path, 'r')); + if(substr($content, 0, 5) !== '' . $content; + } + + $svg->readImageBlob($content); $svg->setImageFormat('jpg'); //new image object @@ -28,6 +36,6 @@ if (extension_loaded('imagick')){ } } - OC_Preview::registerProvider('OC_Preview_SVG'); + \OC\Preview::registerProvider('OC\Preview\SVG'); } \ No newline at end of file diff --git a/lib/preview/txt.php b/lib/preview/txt.php index 1e88aec69fd..4004ecd3fce 100644 --- a/lib/preview/txt.php +++ b/lib/preview/txt.php @@ -5,7 +5,9 @@ * later. * See the COPYING-README file. */ -class OC_Preview_TXT extends OC_Preview_Provider{ +namespace OC\Preview; + +class TXT extends Provider{ public function getMimeType(){ return '/text\/.*/'; @@ -46,4 +48,4 @@ class OC_Preview_TXT extends OC_Preview_Provider{ } } -OC_Preview::registerProvider('OC_Preview_TXT'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\TXT'); \ No newline at end of file diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index 5bbdcf847f1..6a8d2fbb75c 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -6,7 +6,9 @@ * later. * See the COPYING-README file. */ -class OC_Preview_Unknown extends OC_Preview_Provider{ +namespace OC\Preview; + +class Unknown extends Provider{ public function getMimeType(){ return '/.*/'; @@ -22,4 +24,4 @@ class OC_Preview_Unknown extends OC_Preview_Provider{ } } -OC_Preview::registerProvider('OC_Preview_Unknown'); +\OC\Preview::registerProvider('OC\Preview\Unknown'); -- GitLab From 268246fac833837d7b9e7a6a2a4559cfadc0a7ab Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 29 May 2013 12:48:21 +0200 Subject: [PATCH 031/635] namespace fix --- lib/preview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview.php b/lib/preview.php index 31812035c49..855d5a9da04 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -375,7 +375,7 @@ class Preview { $scalingup = $this->scalingup; if(!($image instanceof \OC_Image)){ - OC_Log::write('core', 'Object passed to resizeAndCrop is not an instance of OC_Image', \OC_Log::DEBUG); + \OC_Log::write('core', 'Object passed to resizeAndCrop is not an instance of OC_Image', \OC_Log::DEBUG); return; } -- GitLab From 7408ab660af2c681ca6abfb15d6230382f35dd7c Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 29 May 2013 13:03:33 +0200 Subject: [PATCH 032/635] respect coding style guidelines --- lib/preview.php | 136 +++++++++++++++++++-------------------- lib/preview/images.php | 6 +- lib/preview/movies.php | 6 +- lib/preview/mp3.php | 4 +- lib/preview/pdf.php | 4 +- lib/preview/provider.php | 2 +- lib/preview/svg.php | 6 +- lib/preview/txt.php | 8 +-- lib/preview/unknown.php | 4 +- 9 files changed, 88 insertions(+), 88 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 855d5a9da04..1150681e64f 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -57,7 +57,7 @@ class Preview { * false if thumbnail does not exist * path to thumbnail if thumbnail exists */ - public function __construct($user = null, $root = '', $file = '', $maxX = 0, $maxY = 0, $scalingup = true, $force = false){ + public function __construct($user=null, $root='', $file='', $maxX=0, $maxY=0, $scalingup=true, $force=false) { //set config $this->max_x = \OC_Config::getValue('preview_max_x', null); $this->max_y = \OC_Config::getValue('preview_max_y', null); @@ -73,46 +73,46 @@ class Preview { $this->fileview = new \OC\Files\View('/' . $user . '/' . $root); $this->userview = new \OC\Files\View('/' . $user); - if($force !== true){ - if(!is_null($this->max_x)){ - if($this->maxX > $this->max_x){ + if($force !== true) { + if(!is_null($this->max_x)) { + if($this->maxX > $this->max_x) { \OC_Log::write('core', 'maxX reduced from ' . $this->maxX . ' to ' . $this->max_x, \OC_Log::DEBUG); $this->maxX = $this->max_x; } } - if(!is_null($this->max_y)){ - if($this->maxY > $this->max_y){ + if(!is_null($this->max_y)) { + if($this->maxY > $this->max_y) { \OC_Log::write('core', 'maxY reduced from ' . $this->maxY . ' to ' . $this->max_y, \OC_Log::DEBUG); $this->maxY = $this->max_y; } } //init providers - if(empty(self::$providers)){ + if(empty(self::$providers)) { self::initProviders(); } //check if there are any providers at all - if(empty(self::$providers)){ + if(empty(self::$providers)) { \OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR); throw new \Exception('No providers'); } //validate parameters - if($file === ''){ + if($file === '') { \OC_Log::write('core', 'No filename passed', \OC_Log::ERROR); throw new \Exception('File not found'); } //check if file exists - if(!$this->fileview->file_exists($file)){ + if(!$this->fileview->file_exists($file)) { \OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::ERROR); throw new \Exception('File not found'); } //check if given size makes sense - if($maxX === 0 || $maxY === 0){ + if($maxX === 0 || $maxY === 0) { \OC_Log::write('core', 'Can not create preview with 0px width or 0px height', \OC_Log::ERROR); throw new \Exception('Height and/or width set to 0'); } @@ -123,7 +123,7 @@ class Preview { * @brief returns the path of the file you want a thumbnail from * @return string */ - public function getFile(){ + public function getFile() { return $this->file; } @@ -131,7 +131,7 @@ class Preview { * @brief returns the max width of the preview * @return integer */ - public function getMaxX(){ + public function getMaxX() { return $this->maxX; } @@ -139,7 +139,7 @@ class Preview { * @brief returns the max height of the preview * @return integer */ - public function getMaxY(){ + public function getMaxY() { return $this->maxY; } @@ -147,7 +147,7 @@ class Preview { * @brief returns whether or not scalingup is enabled * @return bool */ - public function getScalingup(){ + public function getScalingup() { return $this->scalingup; } @@ -155,7 +155,7 @@ class Preview { * @brief returns the name of the thumbnailfolder * @return string */ - public function getThumbnailsfolder(){ + public function getThumbnailsfolder() { return self::THUMBNAILS_FOLDER; } @@ -163,7 +163,7 @@ class Preview { * @brief returns the max scale factor * @return integer */ - public function getMaxScaleFactor(){ + public function getMaxScaleFactor() { return $this->max_scale_factor; } @@ -171,7 +171,7 @@ class Preview { * @brief returns the max width set in ownCloud's config * @return integer */ - public function getConfigMaxX(){ + public function getConfigMaxX() { return $this->max_x; } @@ -179,7 +179,7 @@ class Preview { * @brief returns the max height set in ownCloud's config * @return integer */ - public function getConfigMaxY(){ + public function getConfigMaxY() { return $this->max_y; } @@ -187,7 +187,7 @@ class Preview { * @brief deletes previews of a file with specific x and y * @return bool */ - public function deletePreview(){ + public function deletePreview() { $fileinfo = $this->fileview->getFileInfo($this->file); $fileid = $fileinfo['fileid']; @@ -199,7 +199,7 @@ class Preview { * @brief deletes all previews of a file * @return bool */ - public function deleteAllPreviews(){ + public function deleteAllPreviews() { $fileinfo = $this->fileview->getFileInfo($this->file); $fileid = $fileinfo['fileid']; @@ -214,7 +214,7 @@ class Preview { * false if thumbnail does not exist * path to thumbnail if thumbnail exists */ - private function isCached(){ + private function isCached() { $file = $this->file; $maxX = $this->maxX; $maxY = $this->maxY; @@ -223,12 +223,12 @@ class Preview { $fileinfo = $this->fileview->getFileInfo($file); $fileid = $fileinfo['fileid']; - if(!$this->userview->is_dir(self::THUMBNAILS_FOLDER . '/' . $fileid)){ + if(!$this->userview->is_dir(self::THUMBNAILS_FOLDER . '/' . $fileid)) { return false; } //does a preview with the wanted height and width already exist? - if($this->userview->file_exists(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png')){ + if($this->userview->file_exists(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png')) { return self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png'; } @@ -238,20 +238,20 @@ class Preview { $possiblethumbnails = array(); $allthumbnails = $this->userview->getDirectoryContent(self::THUMBNAILS_FOLDER . '/' . $fileid); - foreach($allthumbnails as $thumbnail){ + foreach($allthumbnails as $thumbnail) { $size = explode('-', $thumbnail['name']); $x = $size[0]; $y = $size[1]; $aspectratio = $x / $y; - if($aspectratio != $wantedaspectratio){ + if($aspectratio != $wantedaspectratio) { continue; } - if($x < $maxX || $y < $maxY){ - if($scalingup){ + if($x < $maxX || $y < $maxY) { + if($scalingup) { $scalefactor = $maxX / $x; - if($scalefactor > $this->max_scale_factor){ + if($scalefactor > $this->max_scale_factor) { continue; } }else{ @@ -261,26 +261,26 @@ class Preview { $possiblethumbnails[$x] = $thumbnail['path']; } - if(count($possiblethumbnails) === 0){ + if(count($possiblethumbnails) === 0) { return false; } - if(count($possiblethumbnails) === 1){ + if(count($possiblethumbnails) === 1) { return current($possiblethumbnails); } ksort($possiblethumbnails); - if(key(reset($possiblethumbnails)) > $maxX){ + if(key(reset($possiblethumbnails)) > $maxX) { return current(reset($possiblethumbnails)); } - if(key(end($possiblethumbnails)) < $maxX){ + if(key(end($possiblethumbnails)) < $maxX) { return current(end($possiblethumbnails)); } - foreach($possiblethumbnails as $width => $path){ - if($width < $maxX){ + foreach($possiblethumbnails as $width => $path) { + if($width < $maxX) { continue; }else{ return $path; @@ -296,7 +296,7 @@ class Preview { * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly * @return image */ - public function getPreview(){ + public function getPreview() { $file = $this->file; $maxX = $this->maxX; $maxY = $this->maxY; @@ -307,7 +307,7 @@ class Preview { $cached = self::isCached(); - if($cached){ + if($cached) { $image = new \OC_Image($this->userview->file_get_contents($cached, 'r')); $this->preview = $image; }else{ @@ -315,25 +315,25 @@ class Preview { $preview; - foreach(self::$providers as $supportedmimetype => $provider){ - if(!preg_match($supportedmimetype, $mimetype)){ + foreach(self::$providers as $supportedmimetype => $provider) { + if(!preg_match($supportedmimetype, $mimetype)) { continue; } $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingup, $this->fileview); - if(!$preview){ + if(!$preview) { continue; } //are there any cached thumbnails yet - if($this->userview->is_dir(self::THUMBNAILS_FOLDER . '/') === false){ + if($this->userview->is_dir(self::THUMBNAILS_FOLDER . '/') === false) { $this->userview->mkdir(self::THUMBNAILS_FOLDER . '/'); } //cache thumbnail $cachepath = self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png'; - if($this->userview->is_dir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/') === false){ + if($this->userview->is_dir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/') === false) { $this->userview->mkdir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/'); } $this->userview->file_put_contents($cachepath, $preview->data()); @@ -354,10 +354,10 @@ class Preview { * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly * @return void */ - public function showPreview(){ + public function showPreview() { \OCP\Response::enableCaching(3600 * 24); // 24 hour $preview = $this->getPreview(); - if($preview){ + if($preview) { $preview->show(); } } @@ -366,7 +366,7 @@ class Preview { * @brief resize, crop and fix orientation * @return image */ - public function resizeAndCrop(){ + public function resizeAndCrop() { $this->preview->fixOrientation(); $image = $this->preview; @@ -374,7 +374,7 @@ class Preview { $y = $this->maxY; $scalingup = $this->scalingup; - if(!($image instanceof \OC_Image)){ + if(!($image instanceof \OC_Image)) { \OC_Log::write('core', 'Object passed to resizeAndCrop is not an instance of OC_Image', \OC_Log::DEBUG); return; } @@ -382,14 +382,14 @@ class Preview { $realx = (int) $image->width(); $realy = (int) $image->height(); - if($x === $realx && $y === $realy){ + if($x === $realx && $y === $realy) { return $image; } $factorX = $x / $realx; $factorY = $y / $realy; - if($factorX >= $factorY){ + if($factorX >= $factorY) { $factor = $factorX; }else{ $factor = $factorY; @@ -399,8 +399,8 @@ class Preview { if($scalingup === false) { if($factor>1) $factor=1; } - if(!is_null($this->max_scale_factor)){ - if($factor > $this->max_scale_factor){ + if(!is_null($this->max_scale_factor)) { + if($factor > $this->max_scale_factor) { \OC_Log::write('core', 'scalefactor reduced from ' . $factor . ' to ' . $this->max_scale_factor, \OC_Log::DEBUG); $factor = $this->max_scale_factor; } @@ -411,12 +411,12 @@ class Preview { // resize $image->preciseResize($newXsize, $newYsize); - if($newXsize === $x && $newYsize === $y){ + if($newXsize === $x && $newYsize === $y) { $this->preview = $image; return; } - if($newXsize >= $x && $newYsize >= $y){ + if($newXsize >= $x && $newYsize >= $y) { $cropX = floor(abs($x - $newXsize) * 0.5); $cropY = floor(abs($y - $newYsize) * 0.5); @@ -426,13 +426,13 @@ class Preview { return; } - if($newXsize < $x || $newYsize < $y){ - if($newXsize > $x){ + if($newXsize < $x || $newYsize < $y) { + if($newXsize > $x) { $cropX = floor(($newXsize - $x) * 0.5); $image->crop($cropX, 0, $x, $newYsize); } - if($newYsize > $y){ + if($newYsize > $y) { $cropY = floor(($newYsize - $y) * 0.5); $image->crop(0, $cropY, $newXsize, $y); } @@ -467,7 +467,7 @@ class Preview { * @param string $provider class name of a Preview_Provider * @return void */ - public static function registerProvider($class, $options=array()){ + public static function registerProvider($class, $options=array()) { self::$registeredProviders[]=array('class'=>$class, 'options'=>$options); } @@ -475,7 +475,7 @@ class Preview { * @brief create instances of all the registered preview providers * @return void */ - private static function initProviders(){ + private static function initProviders() { if(count(self::$providers)>0) { return; } @@ -497,7 +497,7 @@ class Preview { * @brief method that handles preview requests from users that are logged in * @return void */ - public static function previewRouter($params){ + public static function previewRouter($params) { \OC_Util::checkLoggedIn(); $file = ''; @@ -514,11 +514,11 @@ class Preview { if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; - if($file !== '' && $maxX !== 0 && $maxY !== 0){ + if($file !== '' && $maxX !== 0 && $maxY !== 0) { try{ $preview = new Preview(\OC_User::getUser(), 'files', $file, $maxX, $maxY, $scalingup); $preview->showPreview(); - }catch(Exception $e){ + }catch(Exception $e) { \OC_Response::setStatus(404); \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); exit; @@ -533,7 +533,7 @@ class Preview { * @brief method that handles preview requests from users that are not logged in / view shared folders that are public * @return void */ - public static function publicPreviewRouter($params){ + public static function publicPreviewRouter($params) { $file = ''; $maxX = 0; $maxY = 0; @@ -560,21 +560,21 @@ class Preview { //clean up file parameter $file = \OC\Files\Filesystem::normalizePath($file); - if(!\OC\Files\Filesystem::isValidPath($file)){ + if(!\OC\Files\Filesystem::isValidPath($file)) { \OC_Response::setStatus(403); exit; } $path = \OC\Files\Filesystem::normalizePath($path, false); - if(substr($path, 0, 1) == '/'){ + if(substr($path, 0, 1) == '/') { $path = substr($path, 1); } - if($userid !== null && $path !== null){ + if($userid !== null && $path !== null) { try{ $preview = new Preview($userid, 'files/' . $path, $file, $maxX, $maxY, $scalingup); $preview->showPreview(); - }catch(Exception $e){ + }catch(Exception $e) { \OC_Response::setStatus(404); \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); exit; @@ -585,13 +585,13 @@ class Preview { } } - public static function post_write($args){ + public static function post_write($args) { self::post_delete($args); } - public static function post_delete($args){ + public static function post_delete($args) { $path = $args['path']; - if(substr($path, 0, 1) == '/'){ + if(substr($path, 0, 1) == '/') { $path = substr($path, 1); } $preview = new Preview(\OC_User::getUser(), 'files/', $path, 0, 0, false, true); diff --git a/lib/preview/images.php b/lib/preview/images.php index c62fc5397e5..933d65ec59e 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -10,16 +10,16 @@ namespace OC\Preview; class Image extends Provider{ - public function getMimeType(){ + public function getMimeType() { return '/image\/.*/'; } - public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { //get fileinfo $fileinfo = $fileview->getFileInfo($path); //check if file is encrypted - if($fileinfo['encrypted'] === true){ + if($fileinfo['encrypted'] === true) { $image = new \OC_Image($fileview->fopen($path, 'r')); }else{ $image = new \OC_Image(); diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 14ac97b552d..aa97c3f43fc 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -8,14 +8,14 @@ */ namespace OC\Preview; -if(!is_null(shell_exec('ffmpeg -version'))){ +if(!is_null(shell_exec('ffmpeg -version'))) { class Movie extends Provider{ - public function getMimeType(){ + public function getMimeType() { return '/video\/.*/'; } - public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { //get fileinfo $fileinfo = $fileview->getFileInfo($path); diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index d62c7230788..cfe78f32727 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -11,7 +11,7 @@ require_once('getid3/getid3.php'); class MP3 extends Provider{ - public function getMimeType(){ + public function getMimeType() { return '/audio\/mpeg/'; } @@ -33,7 +33,7 @@ class MP3 extends Provider{ return $image; } - public function getNoCoverThumbnail($maxX, $maxY){ + public function getNoCoverThumbnail($maxX, $maxY) { $image = new \OC_Image(); return $image; } diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index 4dd4538545c..66570b05aa4 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -7,11 +7,11 @@ */ namespace OC\Preview; -if (extension_loaded('imagick')){ +if (extension_loaded('imagick')) { class PDF extends Provider{ - public function getMimeType(){ + public function getMimeType() { return '/application\/pdf/'; } diff --git a/lib/preview/provider.php b/lib/preview/provider.php index 1e8d537adc8..58e7ad7f453 100644 --- a/lib/preview/provider.php +++ b/lib/preview/provider.php @@ -18,5 +18,5 @@ abstract class Provider{ * @param string $query * @return */ - abstract public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview); + abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); } diff --git a/lib/preview/svg.php b/lib/preview/svg.php index 70be263189d..746315d6e6a 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -7,11 +7,11 @@ */ namespace OC\Preview; -if (extension_loaded('imagick')){ +if (extension_loaded('imagick')) { class SVG extends Provider{ - public function getMimeType(){ + public function getMimeType() { return '/image\/svg\+xml/'; } @@ -20,7 +20,7 @@ if (extension_loaded('imagick')){ $svg->setResolution($maxX, $maxY); $content = stream_get_contents($fileview->fopen($path, 'r')); - if(substr($content, 0, 5) !== '' . $content; } diff --git a/lib/preview/txt.php b/lib/preview/txt.php index 4004ecd3fce..5961761aaa4 100644 --- a/lib/preview/txt.php +++ b/lib/preview/txt.php @@ -9,11 +9,11 @@ namespace OC\Preview; class TXT extends Provider{ - public function getMimeType(){ + public function getMimeType() { return '/text\/.*/'; } - public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { $content = $fileview->fopen($path, 'r'); $content = stream_get_contents($content); @@ -27,7 +27,7 @@ class TXT extends Provider{ $imagecolor = imagecolorallocate($image, 255, 255, 255); $textcolor = imagecolorallocate($image, 0, 0, 0); - foreach($lines as $index => $line){ + foreach($lines as $index => $line) { $index = $index + 1; $x = (int) 1; @@ -35,7 +35,7 @@ class TXT extends Provider{ imagestring($image, 1, $x, $y, $line, $textcolor); - if(($index * $linesize) >= $maxY){ + if(($index * $linesize) >= $maxY) { break; } } diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index 6a8d2fbb75c..2977cd68923 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -10,11 +10,11 @@ namespace OC\Preview; class Unknown extends Provider{ - public function getMimeType(){ + public function getMimeType() { return '/.*/'; } - public function getThumbnail($path, $maxX, $maxY, $scalingup,$fileview) { + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { /*$mimetype = $fileview->getMimeType($path); $info = $fileview->getFileInfo($path); $name = array_key_exists('name', $info) ? $info['name'] : ''; -- GitLab From 6b90416891e9e0943a7b19f29017bf7d8140eb0a Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 29 May 2013 13:09:38 +0200 Subject: [PATCH 033/635] add php preview backend --- lib/preview/txt.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/preview/txt.php b/lib/preview/txt.php index 5961761aaa4..def6806860b 100644 --- a/lib/preview/txt.php +++ b/lib/preview/txt.php @@ -48,4 +48,14 @@ class TXT extends Provider{ } } -\OC\Preview::registerProvider('OC\Preview\TXT'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\TXT'); + +class PHP extends TXT { + + public function getMimeType() { + return '/application\/x-php/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\PHP'); \ No newline at end of file -- GitLab From 1e252b67635aeed7fa8180a0868abd6442a3c42c Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 29 May 2013 13:11:43 +0200 Subject: [PATCH 034/635] more style fixes --- lib/preview/images.php | 2 +- lib/preview/movies.php | 3 ++- lib/preview/mp3.php | 4 ++-- lib/preview/pdf.php | 2 +- lib/preview/provider.php | 2 +- lib/preview/svg.php | 2 +- lib/preview/txt.php | 2 +- lib/preview/unknown.php | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/preview/images.php b/lib/preview/images.php index 933d65ec59e..080e424e5bd 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -8,7 +8,7 @@ */ namespace OC\Preview; -class Image extends Provider{ +class Image extends Provider { public function getMimeType() { return '/image\/.*/'; diff --git a/lib/preview/movies.php b/lib/preview/movies.php index aa97c3f43fc..18e9d4f778c 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -9,7 +9,8 @@ namespace OC\Preview; if(!is_null(shell_exec('ffmpeg -version'))) { - class Movie extends Provider{ + + class Movie extends Provider { public function getMimeType() { return '/video\/.*/'; diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index cfe78f32727..303626e022e 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -1,4 +1,4 @@ - Date: Wed, 29 May 2013 13:13:47 +0200 Subject: [PATCH 035/635] fix c&p fail --- lib/preview/mp3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 303626e022e..3c6be5c9226 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -1,4 +1,4 @@ -Provider{ Date: Thu, 30 May 2013 10:44:23 +0200 Subject: [PATCH 036/635] validate size of file --- lib/preview.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 1150681e64f..be3abc2cd47 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -87,7 +87,15 @@ class Preview { $this->maxY = $this->max_y; } } - + + $fileinfo = $this->fileview->getFileInfo($this->file); + if(array_key_exists('size', $fileinfo)){ + if((int) $fileinfo['size'] === 0){ + \OC_Log::write('core', 'You can\'t generate a preview of a 0 byte file (' . $this->file . ')', \OC_Log::ERROR); + throw new \Exception('0 byte file given'); + } + } + //init providers if(empty(self::$providers)) { self::initProviders(); @@ -518,7 +526,7 @@ class Preview { try{ $preview = new Preview(\OC_User::getUser(), 'files', $file, $maxX, $maxY, $scalingup); $preview->showPreview(); - }catch(Exception $e) { + }catch(\Exception $e) { \OC_Response::setStatus(404); \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); exit; @@ -574,7 +582,7 @@ class Preview { try{ $preview = new Preview($userid, 'files/' . $path, $file, $maxX, $maxY, $scalingup); $preview->showPreview(); - }catch(Exception $e) { + }catch(\Exception $e) { \OC_Response::setStatus(404); \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); exit; -- GitLab From a014662c52f5295a7e86cd43b7dd62b89e3f1085 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 30 May 2013 11:06:52 +0200 Subject: [PATCH 037/635] improve imagick error handling --- lib/preview/pdf.php | 9 +++++++-- lib/preview/svg.php | 23 ++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index 85878a122a8..f1d0a33dc63 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -19,8 +19,13 @@ if (extension_loaded('imagick')) { $tmppath = $fileview->toTmpFile($path); //create imagick object from pdf - $pdf = new \imagick($tmppath . '[0]'); - $pdf->setImageFormat('jpg'); + 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); diff --git a/lib/preview/svg.php b/lib/preview/svg.php index 8bceeaf60d1..76d81589bac 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -16,17 +16,22 @@ if (extension_loaded('imagick')) { } public function getThumbnail($path,$maxX,$maxY,$scalingup,$fileview) { - $svg = new \Imagick(); - $svg->setResolution($maxX, $maxY); - - $content = stream_get_contents($fileview->fopen($path, 'r')); - if(substr($content, 0, 5) !== '' . $content; + try{ + $svg = new \Imagick(); + $svg->setResolution($maxX, $maxY); + + $content = stream_get_contents($fileview->fopen($path, 'r')); + if(substr($content, 0, 5) !== '' . $content; + } + + $svg->readImageBlob($content); + $svg->setImageFormat('jpg'); + }catch(\Exception $e){ + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; } - $svg->readImageBlob($content); - $svg->setImageFormat('jpg'); - //new image object $image = new \OC_Image($svg); //check if image object is valid -- GitLab From b944b1c5d29393e1b6f0bc51cf50db6eba356e64 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 30 May 2013 11:12:12 +0200 Subject: [PATCH 038/635] add javascript preview backend --- lib/preview/txt.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/preview/txt.php b/lib/preview/txt.php index 4eb0e820406..f18da66c3b8 100644 --- a/lib/preview/txt.php +++ b/lib/preview/txt.php @@ -58,4 +58,14 @@ class PHP extends TXT { } -\OC\Preview::registerProvider('OC\Preview\PHP'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\PHP'); + +class JavaScript extends TXT { + + public function getMimeType() { + return '/application\/javascript/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\JavaScript'); \ No newline at end of file -- GitLab From f7c80a391d192a15d594c3eaf7909a3d78df1a29 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 30 May 2013 15:29:38 +0200 Subject: [PATCH 039/635] load getID3 only if needed --- lib/preview/mp3.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 3c6be5c9226..660e9fc3ce4 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -7,8 +7,6 @@ */ namespace OC\Preview; -require_once('getid3/getid3.php'); - class MP3 extends Provider { public function getMimeType() { @@ -16,6 +14,8 @@ class MP3 extends Provider { } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + require_once('getid3/getid3.php'); + $getID3 = new \getID3(); $tmppath = $fileview->toTmpFile($path); -- GitLab From a11a40d9a96685d41e5acae096752f16785b16b5 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 31 May 2013 12:23:51 +0200 Subject: [PATCH 040/635] add backend for microsoft office 2007 documents --- lib/preview.php | 2 + lib/preview/msoffice.php | 109 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 lib/preview/msoffice.php diff --git a/lib/preview.php b/lib/preview.php index be3abc2cd47..a73f4cb1ac0 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -20,6 +20,8 @@ require_once('preview/pdf.php'); require_once('preview/svg.php'); require_once('preview/txt.php'); require_once('preview/unknown.php'); +require_once('preview/msoffice.php'); +//require_once('preview/opendocument.php'); class Preview { //the thumbnail folder diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php new file mode 100644 index 00000000000..c99ca313c72 --- /dev/null +++ b/lib/preview/msoffice.php @@ -0,0 +1,109 @@ +toTmpFile($path); + + $transformdoc = new \TransformDoc(); + $transformdoc->setStrFile($tmpdoc); + $transformdoc->generatePDF($tmpdoc); + + $pdf = new \imagick($tmpdoc . '[0]'); + $pdf->setImageFormat('jpg'); + + unlink($tmpdoc); + + //new image object + $image = new \OC_Image($pdf); + //check if image object is valid + if (!$image->valid()) return false; + + return $image; + } +} + +class DOC extends MSOffice2003 { + + public function getMimeType() { + return '/application\/msword/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\DOC'); + +class DOCX extends MSOffice2007 { + + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.wordprocessingml.document/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\DOCX'); + +class XLS extends MSOffice2003 { + + public function getMimeType() { + return '/application\/vnd.ms-excel/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\XLS'); + +class XLSX extends MSOffice2007 { + + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\XLSX'); + +class PPT extends MSOffice2003 { + + public function getMimeType() { + return '/application\/vnd.ms-powerpoint/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\PPT'); + +class PPTX extends MSOffice2007 { + + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.presentationml.presentation/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\PPTX'); \ No newline at end of file -- GitLab From 34decf357697a81c23e844ef606c04a20a08c597 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 3 Jun 2013 11:24:31 +0200 Subject: [PATCH 041/635] save current work state --- lib/preview.php | 2 +- lib/preview/libreoffice-cl.php | 0 lib/preview/office.php | 13 +++++++++++++ lib/preview/opendocument.php | 0 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lib/preview/libreoffice-cl.php create mode 100644 lib/preview/office.php create mode 100644 lib/preview/opendocument.php diff --git a/lib/preview.php b/lib/preview.php index a73f4cb1ac0..4705efe2107 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -20,7 +20,7 @@ require_once('preview/pdf.php'); require_once('preview/svg.php'); require_once('preview/txt.php'); require_once('preview/unknown.php'); -require_once('preview/msoffice.php'); +//require_once('preview/msoffice.php'); //require_once('preview/opendocument.php'); class Preview { diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lib/preview/office.php b/lib/preview/office.php new file mode 100644 index 00000000000..c66f5584f07 --- /dev/null +++ b/lib/preview/office.php @@ -0,0 +1,13 @@ + Date: Wed, 5 Jun 2013 10:50:20 +0200 Subject: [PATCH 042/635] save current work state of libreoffice preview backend --- lib/preview/libreoffice-cl.php | 129 +++++++++++++++++++++++++++++++++ lib/preview/office.php | 4 +- 2 files changed, 132 insertions(+), 1 deletion(-) diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index e69de29bb2d..1408e69e8cf 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -0,0 +1,129 @@ +initCmd(); + if(is_null($this->cmd)) { + return false; + } + + $abspath = $fileview->toTmpFile($path); + + chdir(get_temp_dir()); + + $exec = 'libreoffice --headless -convert-to pdf ' . escapeshellarg($abspath); + exec($exec) + + //create imagick object from pdf + try{ + $pdf = new \imagick($abspath . '.pdf' . '[0]'); + $pdf->setImageFormat('jpg'); + }catch(\Exception $e){ + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; + } + + $image = new \OC_Image($pdf); + + unlink($abspath); + unlink($tmppath); + if (!$image->valid()) return false; + + return $image; + } + + private function initCmd() { + $cmd = ''; + + if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { + $cmd = \OC_Config::getValue('preview_libreoffice_path', null); + } + + if($cmd === '' && shell_exec('libreoffice --headless --version')) { + $cmd = 'libreoffice'; + } + + if($cmd === '' && shell_exec('openoffice --headless --version')) { + $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 diff --git a/lib/preview/office.php b/lib/preview/office.php index c66f5584f07..cc1addf3996 100644 --- a/lib/preview/office.php +++ b/lib/preview/office.php @@ -5,9 +5,11 @@ * later. * See the COPYING-README file. */ -if(shell_exec('libreoffice') || shell_exec('openoffice')) { +//let's see if there is libreoffice or openoffice on this machine +if(shell_exec('libreoffice --headless --version') || shell_exec('openoffice --headless --version') || is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { require_once('libreoffice-cl.php'); }else{ + //in case there isn't, use our fallback require_once('msoffice.php'); require_once('opendocument.php'); } \ No newline at end of file -- GitLab From 749c33f39d9452e2c1fdca718e3abcdb7c4a9dd0 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 5 Jun 2013 10:53:16 +0200 Subject: [PATCH 043/635] escape tmppath shell arg --- lib/preview/movies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 18e9d4f778c..8cd50263e2a 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -24,7 +24,7 @@ if(!is_null(shell_exec('ffmpeg -version'))) { $tmppath = \OC_Helper::tmpFile(); //$cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; - $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . $tmppath; + $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmppath); shell_exec($cmd); unlink($abspath); -- GitLab From f437673f1a03ba5b2eeb3e79d24bf6ad3265aa0b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 5 Jun 2013 10:55:57 +0200 Subject: [PATCH 044/635] update require_once block in preview.php --- lib/preview.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 4705efe2107..f9f1288cb98 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -20,8 +20,7 @@ require_once('preview/pdf.php'); require_once('preview/svg.php'); require_once('preview/txt.php'); require_once('preview/unknown.php'); -//require_once('preview/msoffice.php'); -//require_once('preview/opendocument.php'); +require_once('preview/office.php'); class Preview { //the thumbnail folder -- GitLab From bab8b20cbdc65888d92477f9a5810ea4b114ada1 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 5 Jun 2013 11:06:36 +0200 Subject: [PATCH 045/635] use ->cmd instead of hardcoded libreoffice --- lib/preview/libreoffice-cl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index 1408e69e8cf..49c574c9521 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -28,7 +28,7 @@ if (extension_loaded('imagick')) { chdir(get_temp_dir()); - $exec = 'libreoffice --headless -convert-to pdf ' . escapeshellarg($abspath); + $exec = $this->cmd . ' --headless -convert-to pdf ' . escapeshellarg($abspath); exec($exec) //create imagick object from pdf -- GitLab From 8c5fceba296ae76a0f22f3ed0324dec46ef16019 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 5 Jun 2013 11:13:13 +0200 Subject: [PATCH 046/635] fix syntax error --- lib/preview/libreoffice-cl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index 49c574c9521..1b8e482fb23 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -29,7 +29,7 @@ if (extension_loaded('imagick')) { chdir(get_temp_dir()); $exec = $this->cmd . ' --headless -convert-to pdf ' . escapeshellarg($abspath); - exec($exec) + exec($exec); //create imagick object from pdf try{ -- GitLab From 78e8712366e2a198973f9a887c771894bef9a905 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 5 Jun 2013 11:17:29 +0200 Subject: [PATCH 047/635] update config.sample.php --- config/config.sample.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/config.sample.php b/config/config.sample.php index db6eaf852af..2f437771f2b 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -191,4 +191,6 @@ $CONFIG = array( 'preview_max_y' => null, /* the max factor to scale a preview, default is set to 10 */ 'preview_max_scale_factor' => 10, +/* custom path for libreoffice / openoffice binary */ +'preview_libreoffice_path' => '/usr/bin/libreoffice'; ); -- GitLab From 5c1d4fc186b692508f718c06218621bddcfd8f22 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 5 Jun 2013 11:18:57 +0200 Subject: [PATCH 048/635] yet another update for config.sample.php --- config/config.sample.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.sample.php b/config/config.sample.php index 2f437771f2b..2812d848133 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -192,5 +192,5 @@ $CONFIG = array( /* the max factor to scale a preview, default is set to 10 */ 'preview_max_scale_factor' => 10, /* custom path for libreoffice / openoffice binary */ -'preview_libreoffice_path' => '/usr/bin/libreoffice'; +'preview_libreoffice_path' => '/usr/bin/libreoffice', ); -- GitLab From 21cc4f6960618c41e81ca7e785a6d9e21c21ecf9 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 5 Jun 2013 12:44:31 +0200 Subject: [PATCH 049/635] make libreoffice preview backend work :D --- lib/preview/libreoffice-cl.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index 1b8e482fb23..5121a4c5a08 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -26,11 +26,13 @@ if (extension_loaded('imagick')) { $abspath = $fileview->toTmpFile($path); - chdir(get_temp_dir()); + $tmpdir = get_temp_dir(); + + $exec = $this->cmd . ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ' . escapeshellarg($tmpdir) . ' ' . escapeshellarg($abspath); + $export = 'export HOME=/tmp'; + + shell_exec($export . "\n" . $exec); - $exec = $this->cmd . ' --headless -convert-to pdf ' . escapeshellarg($abspath); - exec($exec); - //create imagick object from pdf try{ $pdf = new \imagick($abspath . '.pdf' . '[0]'); @@ -43,7 +45,8 @@ if (extension_loaded('imagick')) { $image = new \OC_Image($pdf); unlink($abspath); - unlink($tmppath); + unlink($abspath . '.pdf'); + if (!$image->valid()) return false; return $image; -- GitLab From f80aba48935e7325effaa65f899922927157028a Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 5 Jun 2013 12:58:39 +0200 Subject: [PATCH 050/635] use tmpdir var instead of hardcoded /tmp --- lib/preview/libreoffice-cl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index 5121a4c5a08..33fa7a04e5d 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -29,7 +29,7 @@ if (extension_loaded('imagick')) { $tmpdir = get_temp_dir(); $exec = $this->cmd . ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ' . escapeshellarg($tmpdir) . ' ' . escapeshellarg($abspath); - $export = 'export HOME=/tmp'; + $export = 'export HOME=/' . $tmpdir; shell_exec($export . "\n" . $exec); -- GitLab From 25e8ac1c2f51e7f3f35eaec013aa1b3f8356f17b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 10 Jun 2013 11:01:12 +0200 Subject: [PATCH 051/635] implement previews for single shared files --- lib/preview.php | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index f9f1288cb98..904689bc4e1 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -557,31 +557,40 @@ class Preview { if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; if(array_key_exists('t', $_GET)) $token = (string) $_GET['t']; - + $linkItem = \OCP\Share::getShareByToken($token); - + if (is_array($linkItem) && isset($linkItem['uid_owner']) && isset($linkItem['file_source'])) { $userid = $linkItem['uid_owner']; \OC_Util::setupFS($userid); + $pathid = $linkItem['file_source']; $path = \OC\Files\Filesystem::getPath($pathid); - } - - //clean up file parameter - $file = \OC\Files\Filesystem::normalizePath($file); - if(!\OC\Files\Filesystem::isValidPath($file)) { - \OC_Response::setStatus(403); - exit; - } + $pathinfo = \OC\Files\Filesystem::getFileInfo($path); + + $sharedfile = null; + if($linkItem['item_type'] === 'folder') { + //clean up file parameter + $sharedfile = \OC\Files\Filesystem::normalizePath($file); + if(!\OC\Files\Filesystem::isValidPath($file)) { + \OC_Response::setStatus(403); + exit; + } + } else if($linkItem['item_type'] === 'file') { + $parent = $pathinfo['parent']; + $path = \OC\Files\Filesystem::getPath($parent); + $sharedfile = $pathinfo['name']; + } - $path = \OC\Files\Filesystem::normalizePath($path, false); - if(substr($path, 0, 1) == '/') { - $path = substr($path, 1); + $path = \OC\Files\Filesystem::normalizePath($path, false); + if(substr($path, 0, 1) == '/') { + $path = substr($path, 1); + } } - if($userid !== null && $path !== null) { + if($userid !== null && $path !== null && $sharedfile !== null) { try{ - $preview = new Preview($userid, 'files/' . $path, $file, $maxX, $maxY, $scalingup); + $preview = new Preview($userid, 'files/' . $path, $sharedfile, $maxX, $maxY, $scalingup); $preview->showPreview(); }catch(\Exception $e) { \OC_Response::setStatus(404); -- GitLab From 0e4f5001d5143f55a9d051b501fe32de900917c5 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 11 Jun 2013 10:45:50 +0200 Subject: [PATCH 052/635] don't crop Y axis --- lib/preview.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/preview.php b/lib/preview.php index 904689bc4e1..ed33e7b09dc 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -427,7 +427,8 @@ class Preview { if($newXsize >= $x && $newYsize >= $y) { $cropX = floor(abs($x - $newXsize) * 0.5); - $cropY = floor(abs($y - $newYsize) * 0.5); + //$cropY = floor(abs($y - $newYsize) * 0.5); + $cropY = 0; $image->crop($cropX, $cropY, $x, $y); -- GitLab From 2ff97917e9e72b674de07ca05dc04dd3bea14f07 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 11 Jun 2013 10:56:16 +0200 Subject: [PATCH 053/635] code optimization --- lib/preview/images.php | 5 +---- lib/preview/movies.php | 5 ++--- lib/preview/mp3.php | 4 +--- lib/preview/pdf.php | 4 +--- lib/preview/svg.php | 4 +--- lib/preview/txt.php | 4 +--- 6 files changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/preview/images.php b/lib/preview/images.php index 080e424e5bd..e4041538e92 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -26,10 +26,7 @@ class Image extends Provider { $image->loadFromFile($fileview->getLocalFile($path)); } - //check if image object is valid - if (!$image->valid()) return false; - - return $image; + return $image->valid() ? $image : false; } } diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 8cd50263e2a..cb959a962a7 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -27,14 +27,13 @@ if(!is_null(shell_exec('ffmpeg -version'))) { $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmppath); shell_exec($cmd); - unlink($abspath); $image = new \OC_Image($tmppath); - if (!$image->valid()) return false; + unlink($abspath); unlink($tmppath); - return $image; + return $image->valid() ? $image : false; } } diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 660e9fc3ce4..60dfb5ff461 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -28,9 +28,7 @@ class MP3 extends Provider { unlink($tmppath); $image = new \OC_Image($picture); - if (!$image->valid()) return $this->getNoCoverThumbnail($maxX, $maxY); - - return $image; + return $image->valid() ? $image : $this->getNoCoverThumbnail($maxX, $maxY); } public function getNoCoverThumbnail($maxX, $maxY) { diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index f1d0a33dc63..3eabd201156 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -32,9 +32,7 @@ if (extension_loaded('imagick')) { //new image object $image = new \OC_Image($pdf); //check if image object is valid - if (!$image->valid()) return false; - - return $image; + return $image->valid() ? $image : false; } } diff --git a/lib/preview/svg.php b/lib/preview/svg.php index 76d81589bac..bafaf71b15a 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -35,9 +35,7 @@ if (extension_loaded('imagick')) { //new image object $image = new \OC_Image($svg); //check if image object is valid - if (!$image->valid()) return false; - - return $image; + return $image->valid() ? $image : false; } } diff --git a/lib/preview/txt.php b/lib/preview/txt.php index f18da66c3b8..c7b8fabc6b0 100644 --- a/lib/preview/txt.php +++ b/lib/preview/txt.php @@ -42,9 +42,7 @@ class TXT extends Provider { $image = new \OC_Image($image); - if (!$image->valid()) return false; - - return $image; + return $image->valid() ? $image : false; } } -- GitLab From 28cf63d37d6a2b90ae32a2b5b7193a5f5c69830d Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 11 Jun 2013 11:00:44 +0200 Subject: [PATCH 054/635] check if imagick is loaded in office.php, not in libreoffice-cl.php --- lib/preview/libreoffice-cl.php | 87 ++++++++++++++++------------------ lib/preview/office.php | 17 ++++--- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index 33fa7a04e5d..2749c4867e9 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -8,71 +8,66 @@ namespace OC\Preview; //we need imagick to convert -if (extension_loaded('imagick')) { +class Office extends Provider { - class Office extends Provider { + private $cmd; - private $cmd; + public function getMimeType() { + return null; + } - public function getMimeType() { - return null; + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + $this->initCmd(); + if(is_null($this->cmd)) { + return false; } - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $this->initCmd(); - if(is_null($this->cmd)) { - return false; - } + $abspath = $fileview->toTmpFile($path); - $abspath = $fileview->toTmpFile($path); + $tmpdir = get_temp_dir(); - $tmpdir = get_temp_dir(); + $exec = $this->cmd . ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ' . escapeshellarg($tmpdir) . ' ' . escapeshellarg($abspath); + $export = 'export HOME=/' . $tmpdir; - $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); - shell_exec($export . "\n" . $exec); + //create imagick object from pdf + try{ + $pdf = new \imagick($abspath . '.pdf' . '[0]'); + $pdf->setImageFormat('jpg'); + }catch(\Exception $e){ + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; + } - //create imagick object from pdf - try{ - $pdf = new \imagick($abspath . '.pdf' . '[0]'); - $pdf->setImageFormat('jpg'); - }catch(\Exception $e){ - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); - return false; - } + $image = new \OC_Image($pdf); - $image = new \OC_Image($pdf); + unlink($abspath); + unlink($abspath . '.pdf'); - unlink($abspath); - unlink($abspath . '.pdf'); + return $image->valid() ? $image : false; + } - if (!$image->valid()) return false; + private function initCmd() { + $cmd = ''; - return $image; + if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { + $cmd = \OC_Config::getValue('preview_libreoffice_path', null); } - private function initCmd() { - $cmd = ''; - - if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { - $cmd = \OC_Config::getValue('preview_libreoffice_path', null); - } - - if($cmd === '' && shell_exec('libreoffice --headless --version')) { - $cmd = 'libreoffice'; - } - - if($cmd === '' && shell_exec('openoffice --headless --version')) { - $cmd = 'openoffice'; - } + if($cmd === '' && shell_exec('libreoffice --headless --version')) { + $cmd = 'libreoffice'; + } - if($cmd === '') { - $cmd = null; - } + if($cmd === '' && shell_exec('openoffice --headless --version')) { + $cmd = 'openoffice'; + } - $this->cmd = $cmd; + if($cmd === '') { + $cmd = null; } + + $this->cmd = $cmd; } } diff --git a/lib/preview/office.php b/lib/preview/office.php index cc1addf3996..20f545ef337 100644 --- a/lib/preview/office.php +++ b/lib/preview/office.php @@ -5,11 +5,14 @@ * later. * See the COPYING-README file. */ -//let's see if there is libreoffice or openoffice on this machine -if(shell_exec('libreoffice --headless --version') || shell_exec('openoffice --headless --version') || is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { - require_once('libreoffice-cl.php'); -}else{ - //in case there isn't, use our fallback - require_once('msoffice.php'); - require_once('opendocument.php'); +//both, libreoffice backend and php fallback, need imagick +if (extension_loaded('imagick')) { + //let's see if there is libreoffice or openoffice on this machine + if(shell_exec('libreoffice --headless --version') || shell_exec('openoffice --headless --version') || is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { + require_once('libreoffice-cl.php'); + }else{ + //in case there isn't, use our fallback + require_once('msoffice.php'); + require_once('opendocument.php'); + } } \ No newline at end of file -- GitLab From 67816da0bfe16ecb58d3a3bdb70c1fb9a79cff75 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 11 Jun 2013 13:15:24 +0200 Subject: [PATCH 055/635] save current work state of office fallback --- lib/preview/msoffice.php | 95 ++++++++++++++++++++++++++---------- lib/preview/opendocument.php | 12 +++++ 2 files changed, 81 insertions(+), 26 deletions(-) diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php index c99ca313c72..4fedb735c95 100644 --- a/lib/preview/msoffice.php +++ b/lib/preview/msoffice.php @@ -7,22 +7,24 @@ */ namespace OC\Preview; -class MSOffice2003 extends Provider { +class DOC extends Provider { - public function getMimeType(){ - return null; + public function getMimeType() { + return '/application\/msword/'; } - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview){ - return false; + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + } + } +\OC\Preview::registerProvider('OC\Preview\DOC'); -class MSOffice2007 extends Provider { +class DOCX extends Provider { - public function getMimeType(){ - return null; + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.wordprocessingml.document/'; } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { @@ -39,36 +41,50 @@ class MSOffice2007 extends Provider { unlink($tmpdoc); - //new image object $image = new \OC_Image($pdf); - //check if image object is valid - if (!$image->valid()) return false; - - return $image; + + return $image->valid() ? $image : false; } + } -class DOC extends MSOffice2003 { +\OC\Preview::registerProvider('OC\Preview\DOCX'); + +class MSOfficeExcel extends Provider { public function getMimeType() { - return '/application\/msword/'; + return null; } -} + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + require_once('PHPExcel/Classes/PHPExcel.php'); + require_once('PHPExcel/Classes/PHPExcel/IOFactory.php'); + //require_once('mpdf/mpdf.php'); -\OC\Preview::registerProvider('OC\Preview\DOC'); + $abspath = $fileview->toTmpFile($path); + $tmppath = \OC_Helper::tmpFile(); -class DOCX extends MSOffice2007 { + $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF; + $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/dompdf'; - public function getMimeType() { - return '/application\/vnd.openxmlformats-officedocument.wordprocessingml.document/'; + \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); + + return $image->valid() ? $image : false; } } -\OC\Preview::registerProvider('OC\Preview\DOCX'); - -class XLS extends MSOffice2003 { +class XLS extends MSOfficeExcel { public function getMimeType() { return '/application\/vnd.ms-excel/'; @@ -78,7 +94,7 @@ class XLS extends MSOffice2003 { \OC\Preview::registerProvider('OC\Preview\XLS'); -class XLSX extends MSOffice2007 { +class XLSX extends MSOfficeExcel { public function getMimeType() { return '/application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet/'; @@ -88,7 +104,34 @@ class XLSX extends MSOffice2007 { \OC\Preview::registerProvider('OC\Preview\XLSX'); -class PPT extends MSOffice2003 { +class MSOfficePowerPoint extends Provider { + + public function getMimeType() { + return null; + } + + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + //require_once(''); + //require_once(''); + + $abspath = $fileview->toTmpFile($path); + $tmppath = \OC_Helper::tmpFile(); + + $excel = PHPPowerPoint_IOFactory::createWriter($abspath, 'PDF'); + $excel->save($tmppath); + + $pdf = new \imagick($tmppath . '[0]'); + $pdf->setImageFormat('jpg'); + + unlink($abspath); + unlink($tmppath); + + return $image->valid() ? $image : false; + } + +} + +class PPT extends MSOfficePowerPoint { public function getMimeType() { return '/application\/vnd.ms-powerpoint/'; @@ -98,7 +141,7 @@ class PPT extends MSOffice2003 { \OC\Preview::registerProvider('OC\Preview\PPT'); -class PPTX extends MSOffice2007 { +class PPTX extends MSOfficePowerPoint { public function getMimeType() { return '/application\/vnd.openxmlformats-officedocument.presentationml.presentation/'; diff --git a/lib/preview/opendocument.php b/lib/preview/opendocument.php index e69de29bb2d..786a038ff82 100644 --- a/lib/preview/opendocument.php +++ b/lib/preview/opendocument.php @@ -0,0 +1,12 @@ + Date: Wed, 12 Jun 2013 11:40:01 +0200 Subject: [PATCH 056/635] finish implementation of Excel preview fallback --- lib/preview/msoffice.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php index 4fedb735c95..c2e39d00d94 100644 --- a/lib/preview/msoffice.php +++ b/lib/preview/msoffice.php @@ -42,7 +42,7 @@ class DOCX extends Provider { unlink($tmpdoc); $image = new \OC_Image($pdf); - + return $image->valid() ? $image : false; } @@ -65,7 +65,7 @@ class MSOfficeExcel extends Provider { $tmppath = \OC_Helper::tmpFile(); $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF; - $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/dompdf'; + $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/3rdparty/dompdf'; \PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath); @@ -79,6 +79,8 @@ class MSOfficeExcel extends Provider { unlink($abspath); unlink($tmppath); + $image = new \OC_Image($pdf); + return $image->valid() ? $image : false; } -- GitLab From 1f52ad0363e2cff05e2058d31317b580c27e2c31 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 12 Jun 2013 13:20:59 +0200 Subject: [PATCH 057/635] work on powerpoint fallback --- lib/preview/msoffice.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php index c2e39d00d94..65886169e9a 100644 --- a/lib/preview/msoffice.php +++ b/lib/preview/msoffice.php @@ -59,7 +59,6 @@ class MSOfficeExcel extends Provider { public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { require_once('PHPExcel/Classes/PHPExcel.php'); require_once('PHPExcel/Classes/PHPExcel/IOFactory.php'); - //require_once('mpdf/mpdf.php'); $abspath = $fileview->toTmpFile($path); $tmppath = \OC_Helper::tmpFile(); @@ -113,14 +112,12 @@ class MSOfficePowerPoint extends Provider { } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - //require_once(''); - //require_once(''); + return false; $abspath = $fileview->toTmpFile($path); $tmppath = \OC_Helper::tmpFile(); - $excel = PHPPowerPoint_IOFactory::createWriter($abspath, 'PDF'); - $excel->save($tmppath); + null; $pdf = new \imagick($tmppath . '[0]'); $pdf->setImageFormat('jpg'); @@ -128,6 +125,8 @@ class MSOfficePowerPoint extends Provider { unlink($abspath); unlink($tmppath); + $image = new \OC_Image($pdf); + return $image->valid() ? $image : false; } -- GitLab From f89a23b463884e1a9b89c84fdcb1c34afba62645 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 12 Jun 2013 16:18:16 +0200 Subject: [PATCH 058/635] implement unknown preview backend --- lib/preview/unknown.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index 6b161424917..6e1dc06c1bc 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -15,12 +15,24 @@ class Unknown extends Provider { } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - /*$mimetype = $fileview->getMimeType($path); - $info = $fileview->getFileInfo($path); - $name = array_key_exists('name', $info) ? $info['name'] : ''; - $size = array_key_exists('size', $info) ? $info['size'] : 0; - $isencrypted = array_key_exists('encrypted', $info) ? $info['encrypted'] : false;*/ // show little lock - return new \OC_Image(); + $mimetype = $fileview->getMimeType($path); + if(substr_count($mimetype, '/')) { + list($type, $subtype) = explode('/', $mimetype); + } + + $iconsroot = \OC::$SERVERROOT . '/core/img/filetypes/'; + + $icons = array($mimetype, $type, 'text'); + foreach($icons as $icon) { + $icon = str_replace('/', '-', $icon); + + $iconpath = $iconsroot . $icon . '.png'; + + if(file_exists($iconpath)) { + return new \OC_Image($iconpath); + } + } + return false; } } -- GitLab From 25981a079a185080ad3ca2d2a23dd827efbd9d05 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 13 Jun 2013 09:52:39 +0200 Subject: [PATCH 059/635] some whitespace fixes --- lib/preview.php | 11 ++++++----- lib/preview/unknown.php | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index ed33e7b09dc..3564fe3df44 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -41,6 +41,7 @@ class Preview { private $maxY; private $scalingup; + //preview images object private $preview; //preview providers @@ -81,7 +82,7 @@ class Preview { $this->maxX = $this->max_x; } } - + if(!is_null($this->max_y)) { if($this->maxY > $this->max_y) { \OC_Log::write('core', 'maxY reduced from ' . $this->maxY . ' to ' . $this->max_y, \OC_Log::DEBUG); @@ -101,25 +102,25 @@ class Preview { if(empty(self::$providers)) { self::initProviders(); } - + //check if there are any providers at all if(empty(self::$providers)) { \OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR); throw new \Exception('No providers'); } - + //validate parameters if($file === '') { \OC_Log::write('core', 'No filename passed', \OC_Log::ERROR); throw new \Exception('File not found'); } - + //check if file exists if(!$this->fileview->file_exists($file)) { \OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::ERROR); throw new \Exception('File not found'); } - + //check if given size makes sense if($maxX === 0 || $maxY === 0) { \OC_Log::write('core', 'Can not create preview with 0px width or 0px height', \OC_Log::ERROR); diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index 6e1dc06c1bc..4e1ca7de741 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -36,4 +36,4 @@ class Unknown extends Provider { } } -\OC\Preview::registerProvider('OC\Preview\Unknown'); +\OC\Preview::registerProvider('OC\Preview\Unknown'); \ No newline at end of file -- GitLab From 6082a0649cefd356370d4ca8034041c1af3875ff Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 17 Jun 2013 12:27:26 +0200 Subject: [PATCH 060/635] stream first mb of movie to create preview --- lib/preview/movies.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/preview/movies.php b/lib/preview/movies.php index cb959a962a7..8531050d112 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -17,17 +17,19 @@ if(!is_null(shell_exec('ffmpeg -version'))) { } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - //get fileinfo - $fileinfo = $fileview->getFileInfo($path); - - $abspath = $fileview->toTmpFile($path); + $abspath = \OC_Helper::tmpFile(); $tmppath = \OC_Helper::tmpFile(); + $handle = $fileview->fopen($path, 'rb'); + + $firstmb = stream_get_contents($handle, 1048576); //1024 * 1024 = 1048576 + file_put_contents($abspath, $firstmb); + //$cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; - $cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmppath); + $cmd = 'ffmpeg -an -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmppath); + shell_exec($cmd); - $image = new \OC_Image($tmppath); unlink($abspath); -- GitLab From bea4376fd48e714b121e1abb54f9bd786e89c877 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 18 Jun 2013 11:04:08 +0200 Subject: [PATCH 061/635] remove opendocument.php --- lib/preview/office.php | 1 - lib/preview/opendocument.php | 12 ------------ 2 files changed, 13 deletions(-) delete mode 100644 lib/preview/opendocument.php diff --git a/lib/preview/office.php b/lib/preview/office.php index 20f545ef337..b6783bc5798 100644 --- a/lib/preview/office.php +++ b/lib/preview/office.php @@ -13,6 +13,5 @@ if (extension_loaded('imagick')) { }else{ //in case there isn't, use our fallback require_once('msoffice.php'); - require_once('opendocument.php'); } } \ No newline at end of file diff --git a/lib/preview/opendocument.php b/lib/preview/opendocument.php deleted file mode 100644 index 786a038ff82..00000000000 --- a/lib/preview/opendocument.php +++ /dev/null @@ -1,12 +0,0 @@ - Date: Tue, 18 Jun 2013 13:53:02 +0200 Subject: [PATCH 062/635] use ppt icon instead of preview --- lib/preview/msoffice.php | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php index 65886169e9a..262582f0216 100644 --- a/lib/preview/msoffice.php +++ b/lib/preview/msoffice.php @@ -14,7 +14,7 @@ class DOC extends Provider { } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - + require_once(); } } @@ -105,6 +105,7 @@ class XLSX extends MSOfficeExcel { \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() { @@ -113,21 +114,6 @@ class MSOfficePowerPoint extends Provider { public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { return false; - - $abspath = $fileview->toTmpFile($path); - $tmppath = \OC_Helper::tmpFile(); - - null; - - $pdf = new \imagick($tmppath . '[0]'); - $pdf->setImageFormat('jpg'); - - unlink($abspath); - unlink($tmppath); - - $image = new \OC_Image($pdf); - - return $image->valid() ? $image : false; } } @@ -150,4 +136,5 @@ class PPTX extends MSOfficePowerPoint { } -\OC\Preview::registerProvider('OC\Preview\PPTX'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\PPTX'); +*/ \ No newline at end of file -- GitLab From 1fcbf8dd7ac69bfce888cc61084a72919503fd05 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 19 Jun 2013 10:21:55 +0200 Subject: [PATCH 063/635] implemenet getNoCoverThumbnail --- lib/preview/mp3.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 60dfb5ff461..835ff529000 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -20,7 +20,6 @@ class MP3 extends Provider { $tmppath = $fileview->toTmpFile($path); - //Todo - add stream support $tags = $getID3->analyze($tmppath); \getid3_lib::CopyTagsToComments($tags); $picture = @$tags['id3v2']['APIC'][0]['data']; @@ -32,8 +31,14 @@ class MP3 extends Provider { } public function getNoCoverThumbnail($maxX, $maxY) { - $image = new \OC_Image(); - return $image; + $icon = \OC::$SERVERROOT . '/core/img/filetypes/audio.png'; + + if(!file_exists($icon)) { + return false; + } + + $image = new \OC_Image($icon); + return $image->valid() ? $image : false; } } -- GitLab From fb67b458412241cb91c01bdb339d1a4317aeacab Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 19 Jun 2013 13:40:57 +0200 Subject: [PATCH 064/635] comment out old code --- lib/preview/msoffice.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php index 262582f0216..ccf1d674c7a 100644 --- a/lib/preview/msoffice.php +++ b/lib/preview/msoffice.php @@ -7,6 +7,7 @@ */ 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() { @@ -14,12 +15,13 @@ class DOC extends Provider { } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - require_once(); + require_once(''); } } \OC\Preview::registerProvider('OC\Preview\DOC'); +*/ class DOCX extends Provider { -- GitLab From efe4bfc693ce98fc45e6a003f9bedd0d9da1d1af Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 19 Jun 2013 13:43:11 +0200 Subject: [PATCH 065/635] update 3rdparty submodule --- 3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty b/3rdparty index 3ef9f738a91..0a8f54ed446 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit 3ef9f738a9107879dddc7d97842cf4d2198fae4c +Subproject commit 0a8f54ed446d9c0d56f8abff3bdb18fcaa6f561b -- GitLab From 1a8e4399b0084a2769bbf43f0ba417c547ac931c Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Tue, 25 Jun 2013 15:08:51 +0200 Subject: [PATCH 066/635] increase Files row height to tappable 44px, more breathing space --- apps/files/css/files.css | 56 +++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/apps/files/css/files.css b/apps/files/css/files.css index 108dcd741c6..be29186cbb7 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -62,7 +62,10 @@ color:#888; text-shadow:#fff 0 1px 0; } #filestable { position: relative; top:37px; width:100%; } -tbody tr { background-color:#fff; height:2.5em; } +tbody tr { + background-color: #fff; + height: 44px; +} tbody tr:hover, tbody tr:active { background-color: rgb(240,240,240); } @@ -75,12 +78,25 @@ span.extension { text-transform:lowercase; -ms-filter:"progid:DXImageTransform.M tr:hover span.extension { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; color:#777; } table tr.mouseOver td { background-color:#eee; } table th { height:2em; padding:0 .5em; color:#999; } -table th .name { float:left; margin-left:.5em; } +table th .name { + float: left; + margin-left: 17px; +} table th, table td { border-bottom:1px solid #ddd; text-align:left; font-weight:normal; } -table td { border-bottom:1px solid #eee; font-style:normal; background-position:1em .5em; background-repeat:no-repeat; } +table td { + border-bottom: 1px solid #eee; + font-style: normal; + background-position: 8px center; + background-repeat: no-repeat; +} table th#headerName { width:100em; /* not really sure why this works better than 100% … table styling */ } table th#headerSize, table td.filesize { min-width:3em; padding:0 1em; text-align:right; } -table th#headerDate, table td.date { min-width:11em; padding:0 .1em 0 1em; text-align:left; } +table th#headerDate, table td.date { + position: relative; + min-width: 11em; + padding:0 .1em 0 1em; + text-align:left; +} /* Multiselect bar */ #filestable.multiselect { top:63px; } @@ -93,13 +109,29 @@ table.multiselect thead th { } table.multiselect #headerName { width: 100%; } table td.selection, table th.selection, table td.fileaction { width:2em; text-align:center; } -table td.filename a.name { display:block; height:1.5em; vertical-align:middle; margin-left:3em; } +table td.filename a.name { + box-sizing: border-box; + display: block; + height: 44px; + vertical-align: middle; + margin-left: 50px; +} table tr[data-type="dir"] td.filename a.name span.nametext {font-weight:bold; } table td.filename input.filename { width:100%; cursor:text; } table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:.2em .5em .5em 0; } table td.filename .nametext, .uploadtext, .modified { float:left; padding:.3em 0; } +.modified { + position: absolute; + top: 10px; +} /* TODO fix usability bug (accidental file/folder selection) */ -table td.filename .nametext { overflow:hidden; text-overflow:ellipsis; max-width:800px; } +table td.filename .nametext { + position: absolute; + top: 10px; + overflow: hidden; + text-overflow: ellipsis; + max-width: 800px; +} table td.filename .uploadtext { font-weight:normal; margin-left:.5em; } table td.filename form { font-size:.85em; margin-left:3em; margin-right:3em; } @@ -119,8 +151,10 @@ table td.filename form { font-size:.85em; margin-left:3em; margin-right:3em; } /* File actions */ .fileactions { - position:absolute; top:.6em; right:0; - font-size:.8em; + position: absolute; + top: 13px; + right: 0; + font-size: 11px; } #fileList .name { position:relative; /* Firefox needs to explicitly have this default set … */ } #fileList tr:hover .fileactions { /* background to distinguish when overlaying with file names */ @@ -132,7 +166,11 @@ table td.filename form { font-size:.85em; margin-left:3em; margin-right:3em; } box-shadow: -5px 0 7px rgba(230,230,230,.9); } #fileList .fileactions a.action img { position:relative; top:.2em; } -#fileList a.action { display:inline; margin:-.5em 0; padding:1em .5em 1em .5em !important; } +#fileList a.action { + display: inline; + margin: -.5em 0; + padding: 16px 8px !important; +} #fileList img.move2trash { display:inline; margin:-.5em 0; padding:1em .5em 1em .5em !important; float:right; } a.action.delete { float:right; } a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; } -- GitLab From dc65482d50ae274b0db12cadce25f6fff0c86671 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Tue, 25 Jun 2013 17:57:38 +0200 Subject: [PATCH 067/635] first round of replacing small filetype icons with proper ones, from Elementary --- core/img/filetypes/application-pdf.png | Bin 591 -> 1759 bytes core/img/filetypes/application-pdf.svg | 277 +++++++ core/img/filetypes/application-rss+xml.png | Bin 691 -> 1098 bytes core/img/filetypes/application-rss+xml.svg | 914 +++++++++++++++++++++ core/img/filetypes/application.png | Bin 464 -> 1235 bytes core/img/filetypes/application.svg | 320 ++++++++ core/img/filetypes/audio.png | Bin 385 -> 858 bytes core/img/filetypes/audio.svg | 274 ++++++ core/img/filetypes/code.png | Bin 603 -> 908 bytes core/img/filetypes/code.svg | 359 ++++++++ core/img/filetypes/file.png | Bin 294 -> 374 bytes core/img/filetypes/file.svg | 197 +++++ core/img/filetypes/flash.png | Bin 580 -> 954 bytes core/img/filetypes/flash.svg | 310 +++++++ core/img/filetypes/folder.png | Bin 537 -> 709 bytes core/img/filetypes/folder.svg | 329 ++++++++ core/img/filetypes/font.png | Bin 813 -> 1793 bytes core/img/filetypes/font.svg | 338 ++++++++ core/img/filetypes/image-svg+xml.png | Bin 481 -> 959 bytes core/img/filetypes/image-svg+xml.svg | 666 +++++++++++++++ core/img/filetypes/image.png | Bin 606 -> 978 bytes core/img/filetypes/image.svg | 321 ++++++++ core/img/filetypes/text-html.png | Bin 578 -> 741 bytes core/img/filetypes/text-html.svg | 280 +++++++ core/img/filetypes/text.png | Bin 342 -> 757 bytes core/img/filetypes/text.svg | 228 +++++ 26 files changed, 4813 insertions(+) create mode 100644 core/img/filetypes/application-pdf.svg create mode 100644 core/img/filetypes/application-rss+xml.svg create mode 100644 core/img/filetypes/application.svg create mode 100644 core/img/filetypes/audio.svg create mode 100644 core/img/filetypes/code.svg create mode 100644 core/img/filetypes/file.svg create mode 100644 core/img/filetypes/flash.svg create mode 100644 core/img/filetypes/folder.svg create mode 100644 core/img/filetypes/font.svg create mode 100644 core/img/filetypes/image-svg+xml.svg create mode 100644 core/img/filetypes/image.svg create mode 100644 core/img/filetypes/text-html.svg create mode 100644 core/img/filetypes/text.svg diff --git a/core/img/filetypes/application-pdf.png b/core/img/filetypes/application-pdf.png index 8f8095e46fa4965700afe1f9d065d8a37b101676..2cbcb741d84a8e1303608089a33e22180a0e4510 100644 GIT binary patch literal 1759 zcmV<51|a!~P)6y0bI$p6Bu6%zn&%#0xKS<6+L6nR(B9p8xxQ{?GrMF{;XqZ1#pm|33gATKwgs z#^mqmS+{FoZDmj7TmcKl7_b&hbCNa9p%uHRpo(EmQv#@;2)(;|HsMqT>8W{l9OP8^=S#UY1*NHHNRW*QsctO2@ zDyX7rFrugp=}>Eso(*(;;mgDwolK97@#pV+o6^iQao+&%Uwgl0$?35%EQB>OAGEO= z08v3j!bEFPtIZTBh`}cbxsN|g=O-S)ILE~kf8ebj{ebqwkpZT&!ct#rOitpO!BqrV zf}oWF2mnMuB`8c3v4&{JPP!la3{iVKS*^y|AHKrn-~NV5xj-p$%+xdD&Q8Kj3(Z<}bW;-~er!QOYM2qX;94_zY7l zh4Ne)!`MJ(Grdc5)B>Q^@X6Z!FM@LmKZF>w?{cmIqzbt(%3^d&rRVZ%0 zgT8OQNbZx5B3?iRBVaTb3#zRwSl4p@;+}50jj4Jg%v}O*nFvoj^DONH{jAx(o%Q$K z%laoi$Mn{_`1i{%W2YwP8E66S72~26Oei$B;a2LICtbk_muLVA@4d^FW5+qOe?Pzb z;?rCi8lwDxEeyQ$eHgr>sRL>0;w78|R(Sl`YL()~jbxb+>2f!00T3BeZ;NBP(wOcv zCB66#C!cwiH(xq{Nm2&B{sQLCElt`(UC-4xa||r%^;+1Lla5aEy|>`zuB`?@2^(LG zrQ{rKE@n-dFmdcSukYQ5iZHNmA9m~Ah{$|b5v+?^o?N`AR;z(3k#nrM{{b4AUzVj7 z0Mab4K&uiPD7%REIHrE~EGM7ai)5Znd%s5fq3sI{hy?py^z^gUSF5FoQACu2agKcD9C! zVvQw@la{oUw{4^0rM5U`iw}%eXMXX{)b!(hy}fZ1g-d2}$s0%%5})zcgNNAhjThMP z)Kgp=8zbrLB+Ie@#u(BxZP_vFv$MQ$_=t?oR$p5j)67k(R4Q#{Yd77VWshu0bGtC6 zqa`&jNvF?Te`&m(yX;U%d)z2?&|pX`25k?+~~jO{{au3n480DmkIy?002ovPDHLkV1k

~O9lw>B8WRlD)Gm}Jrz31u-X&&gn2lvjs=i{7nIaL6v2==uw+8Lcs(8j27 z;|c`rmSv@Lx!heopGP^^Ieb3f=R!%Lpp$}iMS-&P3EJ)s48wrJ_Ni0~k|c47D2nj= z{jS6bt|kFpFf|p5cM`_&0Zh|`rfEp0(}=}lT#(6RpzAsUfxv^LSYX>WlAaN$>)*J5 z0#sE+JRUD8iT9*fz{)_^7@6P&!sEjTcD+I9Z4YjT1`wH@fV{cEvneYGFU%maIEU2s55&K(LixD|{p-uiS@?KNj zk-Go8G$hH6g002ovPDHLkV1hVj1#|!a diff --git a/core/img/filetypes/application-pdf.svg b/core/img/filetypes/application-pdf.svg new file mode 100644 index 00000000000..3f9ad528afb --- /dev/null +++ b/core/img/filetypes/application-pdf.svg @@ -0,0 +1,277 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/application-rss+xml.png b/core/img/filetypes/application-rss+xml.png index 315c4f4fa62cb720326ba3f54259666ba3999e42..e5bb322c5733e7d2961fd27e049e4249a0d2a5c1 100644 GIT binary patch literal 1098 zcmV-Q1hxB#P)a7G#|~(yYCzq z@9WOI*UT(}ap8kI_ua?4_y0Tpb3fjQnX#Fd+f?=c0sadB_3j7fp1*$%XG0(xEM=gw zcH28AcdQFw=+M|xQw>4D2}oM9Hd(t$!&0HNwzQ~W80U{1DRn6WsA6Ylu&WE;93l=} zT0)p^2n$42^V&?4_SWr~YHxs84ZH^*fjG=L5SP0lJpe3-noQgjyidmN1%N8%74bfe zI1^7CuuQlTfWmgu0>TXQDNHW_GfUFo4G{ye)OAVbWnTbEZDFlS)vj9tP*w1W3kcu@ zgT(sO{cEp~Oq?_o1%P->#_s8W8s=lnD<*=tgxXR7sfs>u!BURQ5!3YE$5=mez$~%f zVof4-X~be66mC@NXKA1_4H$S!RzxoVRYQG}21Ky9Y`aT>k1 zAZjUG52Md+!*Mg~v&b_yV#VUVQjpM^SDLS%Krj4^{&|}C!YuJG-yjt>cK6Sr0vPdq zuYx!SkdYgxjZ9M8J;?x|f6TJ>(QD|XbL$ZV03_)$z$>b89}Z~Yz|!|H*e{0)YNjfoeVpZT=EEKST864DR!H8GQT|wmdk+ z;1jQ6s3xxGex_dd2h`3A!;e~4_mk@l%$w2prO z1A{c4Ie^B3MyYTYjD^qQejNzrz`_gnv9SLEqMyE^e*0dU&mP2LSpE2I^snEk-MWYR zT@#(6QI~kwu9yR52duEp%%NBQX7Q~l+CO|r{f@m1J~V}{EYmvqDFC%y;}ua`DGlbe zawn`vLE*sY^ii%q^exid!SZ|401VvoFzS`)>?r{1V|zMsUzLWu^s@?76^mjtQlj&x zk)dI9WeJx(!D!<{m4x#cW&R-(B;K^tCj2s z?)N)2U4Hq{25xwiGYdbpQb1=l6TxbDZwj&S={?7%qx-u`rsG(Zp`-rh=e^=%((1yvsuf5d=&62Zj)Y zH&JviNS_F4_Hj|T(1j4$p-!}kixP9&dB4uv^MveG?dGf%sUCoc2!IFxD6wHRA2^dX zXRVk!-qSfk(jcaUKn#RP48(whfPlJUpApdrA!TQi_4D+fVoM;3I0gZ8{=Xv~Po;geVA+Em9@0Wq2 zr>OTZEGR05L=gf1T;ucCxq6Q6EgJiH@@-lVaAlQyw`jIF^c=&IVnj|95hHbE_cnt| zTzZQ?F4Ne@(bH(~&3nM%m)I@ID{@jJ2qZPjr)jhpe9hViOwH5k&|T#EmmL3(vHeUQ zq^!t^Al6JD;=mHq^Bg?J-8-zG2Od7gZbknG;K9czYjPqG*xjPo0k(c4%lPXTpw(qq z@aGMnxtFS(np+2kC} z7P02O874ZkJH$v#nCUVx$({yDN`IX@o2wyvTD#e`qN`_w5<}$3F+_ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/core/img/filetypes/application.png b/core/img/filetypes/application.png index 1dee9e366094e87db68c606d0522d72d4b939818..3518d3116d2a6d0fadd6b09b3b592a2cb322bdce 100644 GIT binary patch literal 1235 zcmV;^1T6cBP)zpC!G631~st$=$LjuDnvM`SqpI###sn8@8#)w6&qwSNGIL1Hskx^mf7_ukXz+^#B% zs;c;vCVy%5{{aAg{mYXlPksx6;AvG=4_4=Xf+-=y-(^|;_4x7Q(MABC=RJ+0=wY|p zmA>yIr9?`J=Xo2)Qhp}T7~@=Py>YCR@`uCW!?Uw9fIl|^P)a@UJWsxU{n{1tecydr z_dL%5u>iEzXsuC7Ik(>}kY=+fl~NDtHJ1PwV|=?<2tid<7-Nu9y0O+8fU2t27_hNb zRk`)`@t1l3s{mFLtOg4q+*G zL9f>%iX!qnUn_ns2CQXSMzh(Zsw&rrM@L8W`+Wcgg8?5td_V|+F@~L;9kMK2(tj%k z>L_j3W?6<(is^I;Kv|abdOiC6K3SFl(C_!rTJ!$>dxQ`S1_So@_X&c4cDw!GBse=e zLrRGd0x2a*DQ?}m#p&s(TQi@}IXpaMFc=U70Yy=8adCk$W~~pllAzAOYC{@h$n)Io z4e+^7R`p)poVI4b2H3>+@84%WpEDc|xw^VSYt3jhqSNUtC5q$N?UuW{yL7u<_V)J3 z^Lz=+wHUBZ8HOQ25b)x~3#61JNkUN+gkcE4cswS{GJM}hDaGBpcWJlVEEWrw>sk!h zASoqjnj(Z?GMPA8q?C-uW70GQKuU@4`)>a9^pt~xgC!ZaW?=Oo5khczc}bEaNGU1H z()EPz`%WsQlw&N8W2&m6)oLxBigkIdt(^sRq}HP-A`C;c)*KxjadL7(v)Od>&1RF6 zlM}k#E?R5CFm#(&-LEBqy$=W>$n%`z<71}NDZ9J7eERf>D2m)^7)2362ztF9w{PF3 z-EK1&43_k_3~VLADga{)uU@_4#*G_%{P^*6;1|s;aC2p|l@cDLJoc6D_XCQ0%;;BBn(0WbcEP)8e6`gpm!y1M!N^ZV(=IC*t) z{^;nqJv-tM$9J1L2QJ2DN!#51=1_l@G`2=6e0lehL%sic%`_4--LFM}IF!KzJCseW zq1I3__Z40|e?qyK1__gzP(qrBf-G7SQbQ`#Lw94WVe(o`qg+f4hy;Qju)q#I(9{`% zQmAGomzhQ!b|gq>KqL@IkO~$=Koi}a$u6d07kiS}NoYVMJjAeZpaB*;wwcDdEbK@K zNP;B7RzhQ|H9AlUO<`J>m1(5R)Pb-iLBb@7Jp)}LHdAb-VVgYxVoTzGoqu{~a>6uj zeqCRFI9pC#h09bGwy9;oHcp6(RB%jeY^F=Ll!S+9JkVe4nDG7tJMQiP0000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/audio.png b/core/img/filetypes/audio.png index a8b3ede3df956f8d505543b190bc8d1b5b4dce75..cd9821ec047ff066ac222f7434fd318f1968a6c6 100644 GIT binary patch literal 858 zcmV-g1Eu_lP)NI9*~1SCT_Gs%VjNDv0ZoG^URyES=V*=%*HvDbeh9Q z)6-KtJw1^GhEh7vfK7xk*1OF%Vtb_Px}Fs09BG^)&#sMb)+~*6VeDx!8uy>8ZGn)_~baRl~(% zfvTz;axnt-mducRgsSs|35u?Clbynh-6_%cfPW9< zc^(*;&*y{HlS*N~1!))yL7JvGIXOXDmPnEW^Z6WUnmVs2$_uef7^MMImZg+9I5@!B z*%`FfsO#Fv7z&&s5+&g0zTY;R4K|z2;O{X4V;&^DC<@GGGXQkq`J3i>z|kEuKNdxi zuU4xcLWmgv&KMIPg8oiI0nkdR-+7*YUoMv`hX4Q^9UV=TQeToJ$+XrVN`P~&+P0NK kh^j2hK87q7?|;$$0M}CEus3`j`~Uy|07*qoM6N<$f-drfxBvhE literal 385 zcmV-{0e=38P)klCE>?a@fNhGaV ftv%qM$TQzJ6;XjO8erVL00000NkvXXu0mjfw}q7O diff --git a/core/img/filetypes/audio.svg b/core/img/filetypes/audio.svg new file mode 100644 index 00000000000..f742383d632 --- /dev/null +++ b/core/img/filetypes/audio.svg @@ -0,0 +1,274 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/code.png b/core/img/filetypes/code.png index 0c76bd1297751b66230f74719504b2adb02b1615..753d151f538842c2636a94e0f9231fc4ef1c301f 100644 GIT binary patch literal 908 zcmV;719SX|P)calP19IDZ2()FQp&u6e`_n%%{zg$fG7#T{5*f}IRMSI>v=OdjnCu4>voZt znPW?hPD@=iTLOB~5Jdr)Y0pJEa=yN{%|#bpscy*t7w(Ved`-dieEc?x&*Netogt`u z`S@*?pkB$>*%X8OwmT1SwzsWdcjjEj0WLm#Y4L9j=)9Ynv78NbHd0sREeKcA68^C> zJ*~E+NNfG7Vyi(E1@O;bLv!$xOH(;t*NGbD#y*gGov;-O4DNOg!2ArKuCe%iyBhKB zYRoH8$jX|)*yXP|U;EK&7G8WJ^=i_RQ`r{6+qJ2ncu@d`VOWB@PHnIzgg4<0+rW7=;1;izPJMweME|Xz{et{60wL$2{xyZsozNH~rfs{rgt?xf;zwoCoU4ghY9O#pDX zJO3q>uWrcz2lZoFhfgA-hNZKCj*YfX9S68OdlSE+qkeHS`E&}8$3uUAe>PbWYY))p zJ%B(!y+nqVVoJ5L0d8Nv4S?V8Cz(vLzrK@7;U*JLqK5or;z_iIDvbF>+^s@ zb}6InA?}RFIn+^y$ED^4$XC0l2{1H7jjA&6+pnrBQc4c*sI%l9@2+1_#9X&@fQkxR z;F>R?rfIm{?vh1Tvp<*IssKU=Wn^R|F*-ULbX0w*enJSLNGWsIqA*hlAq1c=2XoNU iz>GABigJEWC+!!w&Od^wnO&v;0000^~*-1fljz_B$LUvK}k?BNXe#Y!m=zM!!V#}8bncK5m;8VP zw86G*RI63?Cd%b9bX|ueNlZ|wR6rj|r_)VIP@r2imh3?SN+^{|kY%~8B{maJ@F*OK z&VH9LwOeGt#DRjj0~v~8`>iO7!Ybi;zE$va`A^T#yW`y44;k^#O~K5*jD=qcUhPSc zvyy~q;5H_1WT1l~cqje9yfa+l!hu6xjdOJ8s;8E^+=QQ$tw p?%p!Hy#YapB=@+^9(46X{{RQg%9y;OKjr`c002ovPDHLkV1g7l326WT diff --git a/core/img/filetypes/code.svg b/core/img/filetypes/code.svg new file mode 100644 index 00000000000..1dee047b11f --- /dev/null +++ b/core/img/filetypes/code.svg @@ -0,0 +1,359 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/file.png b/core/img/filetypes/file.png index 8b8b1ca0000bc8fa8d0379926736029f8fabe364..c20f13c2e13af5bccf96b77dd66a6a0df0508c90 100644 GIT binary patch literal 374 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmSQK*5Dp-y;YjHK@;M7UB8!3Q zuY)k7lg8`{prB-lYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt-QDT^vIq zTHj9H&D(4s(Dq)Z+eliWEkR@z&jFT~D>P5CyqVw|WW>-jq3h5tZ(${F>&}jI2ZR1h zzjpKc-ODG=B&=TdIyg{7mF0p(-}Qa(&wra4C;hZC&dj$s#H-UvT`A-CHOq3KHP0&9 zl6y27uEm8v;4O|7c5LGF}$;v{gPaVutPR)C#5QQ<|d}62BjvZR2H60wE-&H;pyTSqH(@-Vl>|&1p(LP>kg~E zYiz5X^`c$+%8#zC{u)yfe-5 zmgid={Z3k(ERKCKrE7DF;=x4^O+ pzO8rLO8p|Ip=x)jHOtWj`bJBmKdh_V<`47(gQu&X%Q~loCIFbEay|e6 diff --git a/core/img/filetypes/file.svg b/core/img/filetypes/file.svg new file mode 100644 index 00000000000..f0c0f1daf7e --- /dev/null +++ b/core/img/filetypes/file.svg @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/core/img/filetypes/flash.png b/core/img/filetypes/flash.png index 9f5db634a4fb42ad33c7a78f5488f03308d3317c..bcde641da3ca196a8212a5b6d91a62013f1430ab 100644 GIT binary patch literal 954 zcmV;r14aCaP)8=ZhVsRlE5JVI@Zd?wX?nDHR%jISl z78YJM3?tIyQc9MVmICVm007r@>2x}g0$7$d71}a;+Y*Hii>bv@N<|LQ7r^ZtqE-N) zTm7Bb0bR^UTd=dfPH}aW(%KrPWYo~BGOXL$NVhG%J2g4u$pwpp47*;x^eo#2uS*qfY+W6C@s) z#dX~S!`w}-8^VEF;Cmj$<@d>rXNWsCrfu?9+oQO0j!$N1_~MzTwSGDcbP<(5{g~mQ z7{enYIJQYgDss6=rY0xw+djYl_DjG&x{F9Du77lvsm$HP9TU?uF%{UBf$T`!RvW_* zS^%B;K882HynxwmkxWlw$75W+{434M%>y>avf0q_`r3h88%3_Yy-05A9)^xNRCX&2 zP2S5>pM4YXuhnXSwZQ?DqVfGY*WP-AiLp`A;~5Oc;zntknRm`otyXVeWd_~#ADG7TyifoGzXkqYh3VzF*APPBc^<7+i)zn=hXn{d1HB3}<%8<~`B(g(16Y!Kav9LZ#I-!JhChA6D-Iv8UfilU%gE+d!ANl7-FMJko@B=v9?3Fv}pny_sf z=E*mhpTB_ZBv7eTkk99(z%UF@k#stJCutT?*giObx$qWlViRogHB?nap-^ZUi83t$ z=kGt5(=*`f%P^*A!PYjsQHsT)>?D)PJRsm4)^;3x^8<|7M{rS<(>t*|l29kKk5Z}B zUcfJY! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/folder.png b/core/img/filetypes/folder.png index 784e8fa48234f4f64b6922a6758f254ee0ca08ec..b7be63d58369d5da485f12ead9ca6982c8e8e563 100644 GIT binary patch literal 709 zcmV;$0y_PPP)M_{T#OD zL*!f7*x1-vsEwk95U>jf7J?W|NZj3IbMMS~T9|!>kgRdc^k2sZ#MOqsjx?%!t$0I=ZhpQcF+A>0EnJ3t8GHUPLgnEA-0vMdKV zcTc!(*WK49003Gd^3lwW%{DWL$W)a&EQ+GIKl~n_==FLaqLco2s%W)Z6XW3Sc+g&Y ze0g#4>783Q+p5|qAkTArUj6c}^LyjPn^!NN7XWbe+Vw}v%g@?Ho;SMqARaC~X|JrT ztONK9NGknr8$F26=UQmx0GmZ%{|u;jO(d|qMAMIB2!N|X#p)q|g=1m?P|O7&Dqz!U z2oTjeu_Dg^Ygmwl0Aqo$j8%Z8A{G>-%>|$&P~j1P64#Lh=ggtjEFjMSVnJjZZ2?oP z6Du-p9$*e6QBaB_K%`WW2ugLx900_MNNEH}v8qTEEo&a&07wK>)g!>}PQOYdIByQt z=DXxXf>`y&D$v{9BN4DVSdV`V|1UBSGxj>&y&+(G^Jm4Z5N*B!0S*#Hck9OpK>a>P zCML6z{;2}TU=N*kL}KlCIy3|TK&n$B;xfqrz^pGO%aCFn2g3otV~Ug#Bgw&j;0VA; zY?h<0V*+5~fS|FqOBZqglRZHbC*oI%!!i#5J8K_azx}%U{)&6EO+g63l;ReEKCs`C r?N1Z{F5+MbW*-V**WG0Ta9Z&Pj@y0dwwZ6q00000NkvXXu0mjfO6e%^ literal 537 zcmV+!0_OdRP)x(K@^6+>g^d@v4;gkbWsEoXE%32*i1tcpTNXd5CcIl)ECgqz|2rE6EW}s7R?kl za1q`0GCkMruC6-2LANtwVlsgzsp4?{@7$`KBv!G66>Vie3h?3OmEEkjwdLG0PgLVi z`!N((f$A@n17Ldj#`};0I3@iHJ5M{#IZz|UIYRm4(!uV7eYIYIwQf&}_2J~}>pQ^n z6o8--^T(=hkBNQ_k{-_GWE;FMW7!p}f{NG3nHZ{D5<3d8&tLh%a4AqqnjMkr3m&fkMdECD3N5}Unig5wy40;>lo4j~k+e}v)` zR6)J8Mk*u=SpB`p6o)7j?S0T@9?bz#m@l>gc*zk__|*!FMcHwP!gwLJvS~9c0px8E zW + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/font.png b/core/img/filetypes/font.png index 81e41de7d3a9bcc50267b34d0005487d5c7cc7c0..df44a7fc47db6c6edce188fa5e00ead07456bf97 100644 GIT binary patch literal 1793 zcmV+c2mbhpP)kn#o@63d#~SKd+oK^#LT#!OYK22X zLr*dD$ihD}KYHN6f#6 zT>yCNt~>4(zWzFd`lNsB&FuB{1f&&6NstsM=i=ek{$mdx{luLkw~rlp0l2~zG@H#q z0DYe4Ax%>U;FXDqiPr&~$@3gx7!rVoMw-pu$-CFR#8L2ycT4{RvbV>j({tJU@zNhLykMF8XxI?P9+5%Q%XkxcAQ|vW0o}e{A3;Ewr_1 z3APT|TpG42?R|?|{C)tw?{85`IUxkv?RE~}Y3|%y6B83>r4VCTmcjEpoGu(4Ki8gY z?mPTgw{rk+N{&R!Z>+hbK>E-3U`QVC*1Ru(5MoCV1a;>evMggE#812XKVyr;wcBvc zL1~RAt=UL(xs>xpqtVCAo3z%*^Be#s_wL<$ zVsYa2>o?y8Y-V<_)BFi`kLlQz&RLQV~kHkJDGVW01!Yw)LtNF=E2NxLO9R&rPjLYoLj63FW<5L9^aFz07N&rBuR?`6Vr9eAPGBdQ+l;`0wYaWU1{?%2lssu2Vl&zyeZr>BypE>6s zgn$5jv?YacNf}#4khe>v1tHCBRxqY63qV9Wq?C2%9E>q3Gw&K7AAhS`^ZeSu_yd`# z`T{Uc=qNXjjs@~}Wm#@jN(m{2dP6yC=6H!f_Y|4AnFNp+pfnc)EY^WWqtORolMv#3 zb~{I9S^j$I0ArElg+-Yg+yD~@rn|Sa@Srf3m>G}~2Nlr_lkfX9d^VrE!t<2=uwCn8Nms`J%Eq|X-o z#8l4hvnAnO1Dq`xbJk&P#$e~b%pgG#fUnKwMS8|K%o@OB@_U7liG?+melU9S;LjHU z8jZ%s0rYi34`$X=Q&X=2hycirDFFK0({CJ`w#AQ*6=nOhahNfT6S*ye`8;>l7M_la?YV+yIZYR3qW@<;Evg! z%p7_0tSP=VUAiNuOZ)eCO!13D|C;%n1I{hXK}6nUudid{etWXC#p%Mnea01E{?5#s z-vq$ixwvTIZAe5OfUvVt2OtAbEF6%fxzK@ET@liqi0KY!4j=_!K2_-pk0xj4-v&wm jmb)IL^#8}{^#=GivXWu0)28I700000NkvXXu0mjfbU9WX literal 813 zcmV+|1JeA7P)%S8Yz4}?d^ZEOv#Sc!)mtIgHXaEQ+_ullV zJO1Y8v8UhuAAS7ozvIlitK{;}YszGvVI*jPQs)gu{RuZGF1qsJqxF>Ai*mOY zeUVJ^Xn04=g+vNN2-6q_7DHe6!8fa@! z^ZEB_2Vebf-umoI@{HTtK!PIfdyIp7Zk$|p=*|D=N%#IIE_w1_EaGe}ST5wWclgx% z|Fx4ZY{8likTKA?G12oM|4&}@o+);3yYs=L?ao)At-(S*$63Le zJ&q^>ZEbL?y!O>L=h9<7rvvdA2Do?L{p8zs_rGt?o&P=^cm5ltT|5S~l@laqmU8i; rSIv!oK>XjU`o@3v@@qdCD9z3Q7_5=EFk?|V00000NkvXXu0mjffa;^e diff --git a/core/img/filetypes/font.svg b/core/img/filetypes/font.svg new file mode 100644 index 00000000000..404f622ea7b --- /dev/null +++ b/core/img/filetypes/font.svg @@ -0,0 +1,338 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/image-svg+xml.png b/core/img/filetypes/image-svg+xml.png index a1291c2dfad75b289f88ab762a3a32ccb436c1ed..e3dd52489d3772962e22cdf47569b53616fe73eb 100644 GIT binary patch literal 959 zcmV;w13>(VP)z_|7@MbH1CXD&v&%^iqNC6zjp|aZmRb{Gb&4rJudU0!ZU@;&b3ZQ(98X^?H zWA8xK;(sR4OFtmbu7hREXXnht<1ls^P5+Io>_&Q$$hxv%*pp~*1m@GVjosx1A1$O!tmFaOWz|qKZPajp#bXMf;k|@K;T0$j~atHdzARr z_ld3V#cuD!YK-ALwUXxEw}?NHK>H8Yj1wB5QnK$etYym~pM|T#hz8iJo=5y_$qF+_ zJ_Gq_63=zR#3=gt{;D_&KLbmYBQi07i&EL={_ zi4n~^uyGr5{a5tH6~s#;K@KU*fR{!*_bxyNEBPuW(Gd!u?iSSCL%{6#7y_T%i4X54 zpT_d0kemyCj_ICv@n1iT*|NK;m}uUCL< zy_+D`9LhHoKqxh}Vy)hU?`Du+E{1Yh@IzF~nkI&6ac)8^jy>29H?Bn2f%&Xu{2N;T zIEUC4Xh8AJKAh8su)jME?w`>E*n|D0DosG!*q1bq4+2n_%%CftCRnwm6m0w&v6BZL z3Lw-qbiO?WKvQ;vvf;J@<<+Oz~z@wR`0ef1}Tm-j^vP}s1o%CXF$G_-YMUg(`O7a2elivAr~AVj4e zdk6lX0FL7jkH;egxcA9D5I{t%fq{X^p`oFUNVDIMKPe)Xs?L6kQcfiz0<>0wMJON0 hXjxKO%u^pm{{i;%Y;-~x&NBc2002ovPDHLkV1mQAx^@5n literal 481 zcmV<70UrK|P)SXcnW4?r|Fc?Kd3cm$;%kZi#G`Sa_VnwmC}YZ26Y zhXbnt^XAQKXm4+SUQ}H6r(?sz`|0x@O--EjU}EI72kk(5e$=!F(*t|%| zOO`#}*s$)|C0u^?YPrGY(Rf4Gt^S&sOU+enjCclWzS^+v`E5dh=Tv=F*rDQzDn?3c zT=(o=$L8ms2^j#wwxyStFa(R1K0Y&H$BX|!zZw%`2!=rX%m*7M?R@p$v*kt(Sq6Bw z+-#h< + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/image.png b/core/img/filetypes/image.png index 4a158fef7e0da8fd19525f574f2c4966443866cf..83d20fdb7762d4b52b398c80e4ecc3fb6f2d5470 100644 GIT binary patch literal 978 zcmV;@11@dUJ z_uS{qnOPyFq@AX;75#q#fES=pD6}OJy1KfA7r;tHA;ez+wkLj-fDnSEr6o$GQgxDj zqP<^l%)PLEj%k_>Us+kHjyV*_<#JU5KVcT2l(O1d-wp*#(?keSv$IClY>pko4Q_88 z1gr%O!*C2XGs7_OcsveZx73Y@*f*fqS-0vP9UV+gPU7)+&~=?krGlnuXqrZ)QfcbC zt~*Gyq=1wX!!S@31w~O98yjP2Xoy@c$I;PI(;d6}R;cTSz?$r~P$g4gS< z0*sE1GBGhhAP``Gf1ka*y_#LyO;MD_1neQOFY@s4!13`h!^6V_gF$p%C!J0ckH_in z?+2huhgt6OBgc>FHs4d6}oDC!*0Pi;Ig$DOp`z zKw=y@8NH9A)i>j*R^LcJ>ZvnW!zvuh=8&y?VSXf|ZXNQA> zgQg|jt$^bgetv$E&1QLjf9LJ(jjyjSd_Es@b91Pw3V^DrOifKWS^&S_PcoULv$M0N z9@I<5nqw%Xq*yGX>$-#S$Hxb$RElsoOg^6{nM_vQvaPKxUSD5%d3m8wDExT{8r6aG z^K(qoWO{mq=bD-72)CKr9v`7z}c9a>C)^Ar}`HWHK2tnGAP#cNB}omhX^%J%(-x1AzcD zGc%-8DWsIFudh4CudlCL0=BGa4!GF?%+JrWySs~F7{3MdBLsSTdkKX?+}zy!2zWh= znh;n;Ls#OM)^b%<9R!4wl5{%VmRE5+9v6xbLiybX$xpcu zLJ@!fV!%H@$6wlf8OQ-oqLoMJe`#(1HETP8UxCcTx6i@D5&!@I07*qoM6N<$f_;y! A`2YX_ literal 606 zcmV-k0-^nhP)Q2rnAt>LM%-F zK|rtwgcU)}7x~z1Hrcs5bH*ZO$!>xO8K#?==bZPQ_ecnV>#P`H`QzGaRhd62G_&rC zTLU$c7_x*nFP_dW#Q+*);mMHE?j)HexK784D4x9l_tfpz2$@1y}9rkF+ zI+J5NMWeZyObc!d+rUc=>D+uOdAOg#%+Ej6h+wn5^xPmVVH*Eu446Y0A_@ zo$rlds-+sL10Db + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text-html.png b/core/img/filetypes/text-html.png index 55d1072eafda48abb0a5fcecb98b114d866077b9..de11613f25f41a5918b041f358a66cd38366eaaf 100644 GIT binary patch literal 741 zcmVba;AtS^`X`Q)aW-{s5~WK@i}19;H%=YPFh5sFb4L?{j~Dk1>X7wMwZ} z!t*?WAV?J6*#V^#gTa7eu}HmMCyJsJz{|@E7Z(>?UtcfhNWEUCSS&Ia3{Xn#=783E z89W}30cbXx#BrP|uC=Dy?Q(m2i>lnJOi{m&v4B?hm;gCY1K&@6I48y~YVI0Ra8jWR7EcUzIE;lzf zsU};*G#ZV}zFF5_U&S9EAK11{rBX@Q`0((6lrr^b%H>~QU6y4fzN!wI1yV|`uCCBp z^Zx!0fbaXMWB`|!msplX7>1d7_W}S2f*`Zty0V%z7l1?cWdTk;j!*8u*95R_oAdMY zTmcrd<*hNZ(J00000NkvXXu0mjf_EbrX literal 578 zcmV-I0=@l-P)dis)>+`f+#3Rv=dSV4I&~|Vk?LiBG~#L1X~NSQGbAyogj#ie_$n8 z*oYwUieR#5zw>=_v)By?+NE%sVPM|5yzfjE5$wfk_Go)9(A<0e{hvFiJ0eb2MFf%t zDJxl&RDw>Nl#~WweRba-&_F#fn|ifCG!S=00#QfIDe64k{5mZFusu=CnSq>Qvt$j5 zI$4b(K~|@Tvozn3#yaJ|Be;BKfh@+AwFR!7UF7D*61OfavvGQ!VN-Ga+zO*%#qEoS z8E0dX4NpRyRS|XCrXq{e4r(61{zg^7gBPDUwmjg}k(Q%NLkD6fm6*tZ=)6^ARRw9CNHr!!-b)EovamKwdDMpr>=!|-tf?S+boQE&JP}G_9P5@nR zSOjlBPI$jHA&U_KsTjQko(uJ_ROpKn!K^ckXTHmZd+_Mh7C&~BUYvvb=Xi2w6%i+L zP+hwJF0QUE^66)$h?CXHvdjEbu3a_69GS^`e5Gac*$0~K9VHcGVKhe>RE(rT+Ca5J zv_?D-3(OpKFrQAl`$E;pyKkaTN=V?@iK2u!kqwFy=F?aM-2b}R>c4;EZ`t2+*gqpJ QK>z>%07*qoM6N<$f@8}2CIA2c diff --git a/core/img/filetypes/text-html.svg b/core/img/filetypes/text-html.svg new file mode 100644 index 00000000000..bf29fbcbbf2 --- /dev/null +++ b/core/img/filetypes/text-html.svg @@ -0,0 +1,280 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text.png b/core/img/filetypes/text.png index 813f712f726c935f9adf8d2f2dd0d7683791ef11..2b96638d16c9af6b5f98350c4ec102d4975c1b64 100644 GIT binary patch literal 757 zcmVr^#nd|{2jDfVx`$1`XC^PkIDD5WqlpU;1cMx#5v z0GrL`_v7Q^Pt#^)7x}(_cYlBXz0qjYdbpI5#bS}O=Li5qQN(VytCfId6&^)lnAx<{ zfqgy;X(^>@CsB!jxnaFt5C9}=0364m-|y3Iw@ZoT2>D-+VUx9;AS|c(qyqq@vaT9mgSxB0SGSN=Y2YD5X+rbh}*!gTdh` zkW!`yOeT}Uja8uiNh!+-m>U3IUS0rbwOS~plJ@jG41fDgB+erKo`na zOv9s!aJgIp`8Ev05Zkti;~2+rk`~nOKR!MfkH;yWMJOFarxal=gGei2+cr|l%56BE zPETvYo12@mC3}%A+=B_23OqkQ1JG`_iQ^d8b=hvWxULI)DxmAb{Jpxm%H17D5jaJG zYz-VlAbS_og`@8Ror0pfK=q#u5CgH zf*`=MESk+G7Z(@wdcDMF5lU;|R0Xu3N;P2O>FEh5&U+99oS&c5Y&HqQkju-(g(B`YhYXo=00000NkvXXu0mjfEhtiT literal 342 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-%6;pyTSA|c6o&@eC9QG)Hj&ExYL zO&oVL^)+cM^qd@ApywS>pwx0H@RDN}hq;7mU-SKczYQ-hnrr=;iDAQMZQ+*g=YOM= z!QlMQEn7FbaD->uKAYgo_j9)W&$$zS*W9}m(ey0q$&7l-XEWO0Y(9M=SnhLbwy;d>@~SY$Ku*0xPvIOQeV1x7u_z-2-X>_74(yfh7C znXL|3GZ+d2`3re2hs?MK + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + -- GitLab From c7fdf00e8497af9804b0cfd4fa081940bf53bc96 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 21 Jun 2013 14:24:52 +0200 Subject: [PATCH 068/635] add unit tests for preview lib to make @DeepDiver1975 happy --- tests/lib/preview.php | 108 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 tests/lib/preview.php diff --git a/tests/lib/preview.php b/tests/lib/preview.php new file mode 100644 index 00000000000..2599da400c8 --- /dev/null +++ b/tests/lib/preview.php @@ -0,0 +1,108 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test; + +class Preview extends \PHPUnit_Framework_TestCase { + + public function testIsPreviewDeleted() { + $user = $this->initFS(); + + $rootView = new \OC\Files\View(''); + $rootView->mkdir('/'.$user); + $rootView->mkdir('/'.$user.'/files'); + + $samplefile = '/'.$user.'/files/test.txt'; + + $rootView->file_put_contents($samplefile, 'dummy file data'); + + $x = 50; + $y = 50; + + $preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y); + $preview->getPreview(); + + $fileinfo = $rootView->getFileInfo($samplefile); + $fileid = $fileinfo['fileid']; + + $thumbcachefile = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $x . '-' . $y . '.png'; + + $this->assertEquals($rootView->file_exists($thumbcachefile), true); + + $preview->deletePreview(); + + $this->assertEquals($rootView->file_exists($thumbcachefile), false); + } + + public function testAreAllPreviewsDeleted() { + $user = $this->initFS(); + + $rootView = new \OC\Files\View(''); + $rootView->mkdir('/'.$user); + $rootView->mkdir('/'.$user.'/files'); + + $samplefile = '/'.$user.'/files/test.txt'; + + $rootView->file_put_contents($samplefile, 'dummy file data'); + + $x = 50; + $y = 50; + + $preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y); + $preview->getPreview(); + + $fileinfo = $rootView->getFileInfo($samplefile); + $fileid = $fileinfo['fileid']; + + $thumbcachefolder = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileid . '/'; + + $this->assertEquals($rootView->is_dir($thumbcachefolder), true); + + $preview->deleteAllPreviews(); + + $this->assertEquals($rootView->is_dir($thumbcachefolder), false); + } + + public function testIsMaxSizeWorking() { + $user = $this->initFS(); + + $maxX = 250; + $maxY = 250; + + \OC_Config::getValue('preview_max_x', $maxX); + \OC_Config::getValue('preview_max_y', $maxY); + + $rootView = new \OC\Files\View(''); + $rootView->mkdir('/'.$user); + $rootView->mkdir('/'.$user.'/files'); + + $samplefile = '/'.$user.'/files/test.txt'; + + $rootView->file_put_contents($samplefile, 'dummy file data'); + + $preview = new \OC\Preview($user, 'files/', 'test.txt', 1000, 1000); + $image = $preview->getPreview(); + + $this->assertEquals($image->width(), $maxX); + $this->assertEquals($image->height(), $maxY); + } + + private function initFS() { + if(\OC\Files\Filesystem::getView()){ + $user = \OC_User::getUser(); + }else{ + $user=uniqid(); + \OC_User::setUserId($user); + \OC\Files\Filesystem::init($user, '/'.$user.'/files'); + } + + \OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', array(), '/'); + + return $user; + } +} \ No newline at end of file -- GitLab From a98391b976ba7dd544af6a0d16b324efb2fc7a3c Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 26 Jun 2013 10:57:37 +0200 Subject: [PATCH 069/635] some minor improvements to preview lib --- lib/preview.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/preview.php b/lib/preview.php index 3564fe3df44..87e2e78d1d8 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -323,7 +323,7 @@ class Preview { }else{ $mimetype = $this->fileview->getMimeType($file); - $preview; + $preview = null; foreach(self::$providers as $supportedmimetype => $provider) { if(!preg_match($supportedmimetype, $mimetype)) { @@ -350,6 +350,11 @@ class Preview { break; } + + if(is_null($preview) || $preview === false) { + $preview = new \OC_Image(); + } + $this->preview = $preview; } $this->resizeAndCrop(); -- GitLab From 9b7efef39d3f7eae45741f0adf0bc0d52945d842 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 26 Jun 2013 14:28:40 +0200 Subject: [PATCH 070/635] improve Image Provider --- lib/preview/images.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview/images.php b/lib/preview/images.php index e4041538e92..987aa9aef0a 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -20,7 +20,7 @@ class Image extends Provider { //check if file is encrypted if($fileinfo['encrypted'] === true) { - $image = new \OC_Image($fileview->fopen($path, 'r')); + $image = new \OC_Image(stream_get_contents($fileview->fopen($path, 'r'))); }else{ $image = new \OC_Image(); $image->loadFromFile($fileview->getLocalFile($path)); -- GitLab From 39c387eed4e5da7bddb6f7cd48a8f8b607f3b8dd Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 26 Jun 2013 18:04:18 +0200 Subject: [PATCH 071/635] implement server side use of previews --- apps/files/templates/part.list.php | 3 ++- lib/helper.php | 11 +++++++++++ lib/public/template.php | 9 +++++++++ lib/template.php | 12 ++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 1e94275dcba..6dabd7d6970 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -1,6 +1,7 @@ style="background-image:url()" - style="background-image:url()" + style="background-image:url()" > diff --git a/lib/helper.php b/lib/helper.php index a315c640d1a..e8cc81774dd 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -223,6 +223,17 @@ class OC_Helper { } } + /** + * @brief get path to preview of file + * @param string $path path + * @return string the url + * + * Returns the path to the preview of the file. + */ + public static function previewIcon($path) { + return self::linkToRoute( 'core_ajax_preview', array('x' => 32, 'y' => 32, 'file' => $path)); + } + /** * @brief Make a human file size * @param int $bytes file size in bytes diff --git a/lib/public/template.php b/lib/public/template.php index ccf19cf052c..5f9888f9f28 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -54,6 +54,15 @@ function mimetype_icon( $mimetype ) { return(\mimetype_icon( $mimetype )); } +/** + * @brief make preview_icon available as a simple function + * Returns the path to the preview of the image. + * @param $path path of file + * @returns link to the preview + */ +function preview_icon( $path ) { + return(\preview_icon( $path )); +} /** * @brief make OC_Helper::humanFileSize available as a simple function diff --git a/lib/template.php b/lib/template.php index ae9ea187445..048d172f1c9 100644 --- a/lib/template.php +++ b/lib/template.php @@ -62,6 +62,18 @@ function image_path( $app, $image ) { return OC_Helper::imagePath( $app, $image ); } +/** + * @brief make preview_icon available as a simple function + * Returns the path to the preview of the image. + * @param $path path of file + * @returns link to the preview + * + * For further information have a look at OC_Helper::previewIcon + */ +function preview_icon( $path ) { + return OC_Helper::previewIcon( $path ); +} + /** * @brief make OC_Helper::mimetypeIcon available as a simple function * @param string $mimetype mimetype -- GitLab From 806f3bddecbd8182f1da90ec91e2a03a1a6e2c3b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 26 Jun 2013 18:19:10 +0200 Subject: [PATCH 072/635] increase size of preview to size of row --- apps/files/css/files.css | 2 +- lib/helper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files/css/files.css b/apps/files/css/files.css index be29186cbb7..222cc9c83ef 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -118,7 +118,7 @@ table td.filename a.name { } table tr[data-type="dir"] td.filename a.name span.nametext {font-weight:bold; } table td.filename input.filename { width:100%; cursor:text; } -table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:.2em .5em .5em 0; } +table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:.2em .5em .5em .3em; } table td.filename .nametext, .uploadtext, .modified { float:left; padding:.3em 0; } .modified { position: absolute; diff --git a/lib/helper.php b/lib/helper.php index e8cc81774dd..0a8962a5312 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -231,7 +231,7 @@ class OC_Helper { * Returns the path to the preview of the file. */ public static function previewIcon($path) { - return self::linkToRoute( 'core_ajax_preview', array('x' => 32, 'y' => 32, 'file' => $path)); + return self::linkToRoute( 'core_ajax_preview', array('x' => 44, 'y' => 44, 'file' => $path)); } /** -- GitLab From 57370353ad1b21156094adc3d1e735582bbd2bb0 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 28 Jun 2013 19:22:51 +0200 Subject: [PATCH 073/635] Check if the app is enabled and the app path is found before trying to load the script file --- lib/base.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/base.php b/lib/base.php index fd4870974fe..af0a30ea173 100644 --- a/lib/base.php +++ b/lib/base.php @@ -661,12 +661,15 @@ class OC { $app = $param['app']; $file = $param['file']; $app_path = OC_App::getAppPath($app); - $file = $app_path . '/' . $file; - unset($app, $app_path); - if (file_exists($file)) { - require_once $file; - return true; + if (OC_App::isEnabled($app) && $app_path !== false) { + $file = $app_path . '/' . $file; + unset($app, $app_path); + if (file_exists($file)) { + require_once $file; + return true; + } } + header('HTTP/1.0 404 Not Found'); return false; } -- GitLab From d332b1d4a2e9382aaa8e8a11b6200efaadb18768 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 2 Jul 2013 11:13:22 +0200 Subject: [PATCH 074/635] implement preview loading after upload --- apps/files/js/filelist.js | 5 +++-- apps/files/js/files.js | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index e19a35bbc5b..11bf028d93a 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -172,8 +172,9 @@ var FileList={ if (id != null) { tr.attr('data-id', id); } - getMimeIcon(mime,function(path){ - tr.find('td.filename').attr('style','background-image:url('+path+')'); + var path = $('#dir').val()+'/'+name; + getPreviewIcon(path, function(previewpath){ + tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); }); tr.find('td.filename').draggable(dragOptions); }, diff --git a/apps/files/js/files.js b/apps/files/js/files.js index a79d34c9b23..224167b99c1 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -513,8 +513,9 @@ $(document).ready(function() { var tr=$('tr').filterAttr('data-file',name); tr.attr('data-mime',result.data.mime); tr.attr('data-id', result.data.id); - getMimeIcon(result.data.mime,function(path){ - tr.find('td.filename').attr('style','background-image:url('+path+')'); + var path = $('#dir').val()+'/'+name; + getPreviewIcon(path, function(previewpath){ + tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); }); } else { OC.dialogs.alert(result.data.message, t('core', 'Error')); @@ -577,8 +578,9 @@ $(document).ready(function() { var tr=$('tr').filterAttr('data-file',localName); tr.data('mime',mime).data('id',id); tr.attr('data-id', id); - getMimeIcon(mime,function(path){ - tr.find('td.filename').attr('style','background-image:url('+path+')'); + var path = $('#dir').val()+'/'+localName; + getPreviewIcon(path, function(previewpath){ + tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); }); }); eventSource.listen('error',function(error){ @@ -769,8 +771,9 @@ var createDragShadow = function(event){ if (elem.type === 'dir') { newtr.find('td.filename').attr('style','background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')'); } else { - getMimeIcon(elem.mime,function(path){ - newtr.find('td.filename').attr('style','background-image:url('+path+')'); + var path = $('#dir').val()+'/'+elem.name; + getPreviewIcon(path, function(previewpath){ + newtr.find('td.filename').attr('style','background-image:url('+previewpath+')'); }); } }); @@ -956,6 +959,10 @@ function getMimeIcon(mime, ready){ } getMimeIcon.cache={}; +function getPreviewIcon(path, ready){ + ready(OC.Router.generate('core_ajax_preview', {file:path, x:44, y:44})); +} + function getUniqueName(name){ if($('tr').filterAttr('data-file',name).length>0){ var parts=name.split('.'); -- GitLab From 6e864e6599602609b5808ae4d043b273a9fe5071 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 2 Jul 2013 16:30:58 +0200 Subject: [PATCH 075/635] fix size of icons in 'new' dropdown menu - I hope @jancborchardt knows a better solution coz this won't work in most IE versions ... --- apps/files/templates/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index b576253f4f0..c4a15c5fa61 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -6,9 +6,9 @@

t('New'));?>
    -
  • t('Text file'));?>

  • -
  • t('Folder'));?>

  • t('From link'));?>

  • -- GitLab From 04292ff16c56d85216ddbd6f644e8055413c0170 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 8 Jul 2013 10:53:53 +0200 Subject: [PATCH 076/635] implement use of preview icons in thrashbin app --- apps/files_trashbin/lib/trash.php | 4 +++ apps/files_trashbin/templates/part.list.php | 2 +- core/routes.php | 2 ++ lib/preview.php | 35 ++++++++++++++++++--- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 7b8d3cb4252..e82a597c61e 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -850,4 +850,8 @@ class Trashbin { //Listen to delete user signal \OCP\Util::connectHook('OC_User', 'pre_deleteUser', "OCA\Files_Trashbin\Hooks", "deleteUser_hook"); } + + public static function preview_icon($path) { + return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 44, 'y' => 44, 'file' => $path)); + } } diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php index 92a38bd2635..d53e38549d1 100644 --- a/apps/files_trashbin/templates/part.list.php +++ b/apps/files_trashbin/templates/part.list.php @@ -27,7 +27,7 @@ style="background-image:url()" - style="background-image:url()" + style="background-image:url()" > diff --git a/core/routes.php b/core/routes.php index 4b3ad53da01..41e82f8a73d 100644 --- a/core/routes.php +++ b/core/routes.php @@ -44,6 +44,8 @@ $this->create('core_ajax_routes', '/core/routes.json') ->action('OC_Router', 'JSRoutes'); $this->create('core_ajax_preview', '/core/preview.png') ->action('OC\Preview', 'previewRouter'); +$this->create('core_ajax_trashbin_preview', '/core/trashbinpreview.png') + ->action('OC\Preview', 'trashbinPreviewRouter'); $this->create('core_ajax_public_preview', '/core/publicpreview.png') ->action('OC\Preview', 'publicPreviewRouter'); OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; diff --git a/lib/preview.php b/lib/preview.php index 87e2e78d1d8..f12107c9f57 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -519,10 +519,6 @@ class Preview { $file = ''; $maxX = 0; $maxY = 0; - /* - * use: ?scalingup=0 / ?scalingup = 1 - * do not use ?scalingup=false / ?scalingup = true as these will always be true - */ $scalingup = true; if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); @@ -610,6 +606,37 @@ class Preview { } } + public static function trashbinPreviewRouter() { + if(!\OC_App::isEnabled('files_trashbin')){ + exit; + } + \OC_Util::checkLoggedIn(); + + $file = ''; + $maxX = 0; + $maxY = 0; + $scalingup = true; + + if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); + if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; + if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; + if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; + + if($file !== '' && $maxX !== 0 && $maxY !== 0) { + try{ + $preview = new Preview(\OC_User::getUser(), 'files_trashbin/files', $file, $maxX, $maxY, $scalingup); + $preview->showPreview(); + }catch(\Exception $e) { + \OC_Response::setStatus(404); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + exit; + } + }else{ + \OC_Response::setStatus(404); + exit; + } + } + public static function post_write($args) { self::post_delete($args); } -- GitLab From d699135c5e9cc56b7c3bcbb2263ffa5946b0b8b6 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 8 Jul 2013 15:14:25 +0200 Subject: [PATCH 077/635] fix for previews in trashbin app --- apps/files_trashbin/templates/part.list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php index d53e38549d1..3f260867582 100644 --- a/apps/files_trashbin/templates/part.list.php +++ b/apps/files_trashbin/templates/part.list.php @@ -27,7 +27,7 @@ style="background-image:url()" - style="background-image:url()" + style="background-image:url()" > -- GitLab From 8eefaba719160eb92dcb6747b5e70b7e04736cea Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 9 Jul 2013 11:40:09 +0200 Subject: [PATCH 078/635] some style adjustments --- apps/files/css/files.css | 4 ++-- apps/files/templates/index.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/files/css/files.css b/apps/files/css/files.css index 222cc9c83ef..d7843ab3535 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -19,9 +19,9 @@ background:#f8f8f8; border:1px solid #ddd; border-radius:10px; border-top-left-radius:0; box-shadow:0 2px 7px rgba(170,170,170,.4); } -#new>ul>li { height:20px; margin:.3em; padding-left:2em; padding-bottom:0.1em; +#new>ul>li { height:36px; margin:.3em; padding-left:3em; padding-bottom:0.1em; background-repeat:no-repeat; cursor:pointer; } -#new>ul>li>p { cursor:pointer; } +#new>ul>li>p { cursor:pointer; padding-top: 7px; padding-bottom: 7px;} #new>ul>li>form>input { padding:0.3em; margin:-0.3em; } #trash { height:17px; margin: 0 1em; z-index:1010; float: right; } diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index c4a15c5fa61..89e270fd146 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -6,11 +6,11 @@
    t('New'));?>
      -
    • t('Text file'));?>

    • -
    • t('Folder'));?>

    • -
    • t('From link'));?>

    -- GitLab From cf449d42e87b21dff0de35c394031c5fa28b56aa Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 10 Jul 2013 11:25:28 +0200 Subject: [PATCH 079/635] properly encode path --- apps/files/js/files.js | 2 +- apps/files_trashbin/lib/trash.php | 2 +- lib/helper.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 224167b99c1..06d193bf8f3 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -960,7 +960,7 @@ function getMimeIcon(mime, ready){ getMimeIcon.cache={}; function getPreviewIcon(path, ready){ - ready(OC.Router.generate('core_ajax_preview', {file:path, x:44, y:44})); + ready(OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:44, y:44})); } function getUniqueName(name){ diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index e82a597c61e..fb99fca5b3f 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -852,6 +852,6 @@ class Trashbin { } public static function preview_icon($path) { - return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 44, 'y' => 44, 'file' => $path)); + return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 44, 'y' => 44, 'file' => urlencode($path) )); } } diff --git a/lib/helper.php b/lib/helper.php index 0a8962a5312..326f2567f99 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -231,7 +231,7 @@ class OC_Helper { * Returns the path to the preview of the file. */ public static function previewIcon($path) { - return self::linkToRoute( 'core_ajax_preview', array('x' => 44, 'y' => 44, 'file' => $path)); + return self::linkToRoute( 'core_ajax_preview', array('x' => 44, 'y' => 44, 'file' => urlencode($path) )); } /** -- GitLab From 832779804d36d27c47325d1dcce09e566c8cee60 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 10 Jul 2013 12:18:17 +0200 Subject: [PATCH 080/635] add two new icons - for copyright see filetypes/readme-2.txt --- core/img/web.png | Bin 0 -> 4472 bytes core/img/web.svg | 183 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 core/img/web.png create mode 100644 core/img/web.svg diff --git a/core/img/web.png b/core/img/web.png new file mode 100644 index 0000000000000000000000000000000000000000..bdc2f4a84a53f20d2501f8addd72d299b6f098fc GIT binary patch literal 4472 zcmai12Q-}P)*iy>y|-YrQAdk1h7lQz&gen}VWN$}V3ZLPAzCC#5{clDq8(jCZxJne z2_b5PIC>4yF6W+m?z!i#`~Tls@Atjm-p{-Dv!AusUh9oDHP)r0=B5S!0Cajt1nT@N zaK0{60?*$@)V$&V0GY7+wQHt&*RBbe`uVuId$|GtDojz9Gd`0RtQxUCs8{T80UO=> zaUV)7&9B$+a2K@$^-^B1>9fCH9+wbafGWr4^H5AKR~49q5|x3+B$}TuF(6@rbU^3O z&-=}ldgk{f3iObn-`f}jMc2qJ=jsBT#mw96_kMmlcPo?4JwQbkd+lVATFArN*zmT^qlUHA3Xdy6h?~YH`~omCg7%*bR8XwSf_#0jGSeR;cLYMnm|fa=G+$rsm1(AYYFmSj5==zC^Ip{Zk4|zRlOblWsbJNIUpww4lyfvl z=a{`#>nOoCb(Pt`%|DYI^E+3p%JQIDUX?13r>{~Pv_MMIA<-6ir$*0E&D=o2Y0harCeJaCV`N6n;~tmV8)1S3LGlDl5FhHM#8Fpx7`+XZ-Xh~vWDo&n0LR)bKHMwBvD;2&rMy8Yb+(W1 z3grgczxehf4iC+Y6GO&s#GABr%qx(-%d9`RaUfdy=F;A23X3chI_oWEDAK7gp8@r? z(%z-Ur4RHvgac>jbMy)WKPh#yS${4mC=sU$>#mk}7}dSc)~m?Y{|&4ZRNc@T|5CUy z5|sG;>hw{gcHk7P_xg3j{j*lJ6|39V^H>OLjC)Po6VaQ-VT%em@f3Tt4f9Jckqf{i zb7<+z5#O@G{1oopAU@)UWxp6gjbEAjtXP>_%@K6QKIpmww*~m(y?7*9&c_B77HR8$ zK2OFj7Ks)(9S;DI2Dw|<;B1Txp)Nk&GETRAoLyz`-q>?A006^7&$r&LI41$Tw-?4A zidP5yj)0!;FU$~-!0!;8r#i^S$W-8(kDsf+6&X1hd5{LRfPetZ@0J@Bh0yuq`1zkY z=r#_Ag+d@fK|wM>3Nk)^Xo#GuswzZQ9wIL#2f;gGA#yUZkUt}zAB3IP2)*X# z>V)(0v+(ip(zu}Jj`8$&al*P@5QIVgj`$-b406HaFT8#)`Xc1t?EfEMoV(kWJv4Bme+)kRIZy1(GhnIyAvzl<#zE=}XPdmuC+9 zvA@#9d<0FBJLZYdFv-2)o}`S{${8ig8?9{g_Uy*E2v2bG6uD2dRW9@2&VK9eO-YU# z$dfJyzNK-nxiv^=?puciqSrHyG*0@a_^w@7#r|mQQ=bWHoCykVQXq9nkQw`Vbo9ZY zE|C2AB>I$KJ+QhEkZnr znIC(5B=g$>t=0`JWXzQH2WNdgC*V-arDR=D0oDD+bDVM{~s7i{8C4xV68 z3~QN@#FD5O+P?;#siu5T!P4}ZaM?i*z@!9c3curi1Sci^*?&I3_9Gp?Ja+dan7Qqj zKl6)nLx_}G8l`b_3v`r`jg^U4{qoo@q^T>%BSEnr?QYAs=MgKx(IFO}QgeC&!JLUu z)bqxkftu0uWvyvmVXJS&QmEEc#ixEreA?3-H<}dDqWvsyx62GwVXKeZe)wV)p z6ny7p>i+$!rg%a{q9lg_lir)-0}jYi(fIJCrit}%HY(a6J(_H$4c!~zib?wQD(3k^ zl`e<+wO5CR-IGyzeh*09rPnNirtDBFJYcN7pTDZ}Cn?)3h9u<>{ag9$(EVw%CYL!a z@pNOj#G@|V@E7;5YSxXgIMZeFL>n}PFRiOtScYi8gOmI`JQ?*q8GIm~SZF9Ci4W3N z^tyLl!Il!2W&Pm&af7cV$R$$9u#UiFaI zvhO7QORM6~e$&~XY4k!Jfp@iwq@ATQW%WOF)A6q#E_d~&D;tFVSl6b=F(n$ME8SnZ zg}T#8alo;pOR93Ue8TSVMk$T$7j&>cc%36FeF6(8T%0Oh7$ zQpu#SX?Vn{z$hkTznf9O7VpuT!dnTv%sksZ%V6al{E9qn=9xHam!fp1s1tyg^B`Wl zW+4RSY@00Xefi7FWLQCiu}qqQrG zMetK@ip6R{qLG-1^Eaktsi8I1PbeJiBQnHH71BuA++*2DSnQ?}ym^%`tuM>Gr8OWg z!X)|E$eYn&6%0Of)zWHttd&sy8vdx7t)WN1WSwsHjER;LUG1~8c|)%A!tWw zr(B_MD?L)f4M?r~SiHkw&9Vy-$CW}Jkkec{_blkW1~0_uOa(u>Ev3kZ-rutKQV z<5;@16H6u7;_?z0^mP+gw-4edjjAzI(3)i1fVRqU>BMQ?+t1uOznTjV(~1)#u`yq; z^2||`mq^nhBU|@+)J*B6pX90bS-&%5x79z1V9* zXqXe@Gu*yzW%uGqe$Rrbi)wN!8Aw1bF)BZW)yG5WLD=)c=J))};FD!bGmBv=RI&v$ zAf~6w$yviuC+4!ULNh5xbmUhqvF3jKBDd={V-P;W;+QWDJk*e`JXkT)@D!(J;uZ{~ z>TZ_kc7_=u^ll=h*Ct2F#G0=oXInY7#Fs6LvT2GPuikjA+2@s6P{UOIMt5#e0;su` zPEnF^SW%;*7L%rX5Aoq^!&VjDZnpx1X*$MS@D35dD&63#+BFE=_8NY~+Cn|JC1&`+ zHf&v`Q|TsGzGufoU$QwT1<_oVMW`s;>^4$7r(gUMBZ(l>Yw&Wf15&f&QJNz29vSmP zBjhdIWHjBY0txjWJ2OLF_Rs9tuP7|m+(q-KewKNvLL@ji3~+i!$UO~i&kcX8so^Hs zEth7f^F>_>6e|Um3*F~jP|^}v)S7=;@<3|@(e=Sod~hqk!^=UBqz4^|AWv-iwwRv3 zu|@Iyr?#AYoA9+m#AWde$y|-3OntA1A@%2MUs|fo#hbd{s z5Shf(OjkWtRJiMXvzBAEZ~?ZC_dbaGaFgD;nMg#V(fPS(HuaND_TN7Bn^U=flg~=# zPI?xr>%mdfSW-|hKZTWyNur?qq;n@M`%8~5BO^BkS%P}C-FbhZ$MF3<8^0^&&h7RO z2J(@;?l;=ZMGY!i$5-%aE5dE{~9|c%-(RHRaLTUP}2ayUNmpp#wN@N zTztP~vym-vS3?*JPDKn5uEDB;9 zEdT;e9k&&`--8sDm5xD z3{})2Z{BulG_b3Uymf_yv|=uVLGNbRWl9n<8{|!6l164w66FXDa#)d@hsS^Cu$~ka zD`{?RJyz%Ut^278I4eFzldAScN!p^~Hw_+qabx6sa{X*z^k=dvCU6M5VRp3bJT|-j z0Mkfbon;$)p; zibBdL*`6e^$>K(TdsHMv*TeWE8%Zh+FRP+^-xEw+8hb|(u~gu>;-ws&E?QAmdR`bp z**-|xwZgW_`2%(E$0yRgq5G@B@AmoN@i9zib3_<4$ReJl>WQ&|#nlWh{1G{%lt0yc z>yB(Tx9m)6n)L_yE94_q3&9GS#poU-vc+dP-)wV)yTS@ZcvUvvm7O}kmwC9j#C^$= zyMzORf@T<|3lER@)B?d_{7|1(#$yAKUs18zFS*`!8!D;d4+K6e+qfJRt$afsvlB;* ziK+C+%PiXDEP$Y6{jG-CU!@HDIoVu#TOuinrs}fJ1S6(3!jJJ|L$3{#NygV!S9>s1 zwE;YtcSeSW=64(&1WEFmTMmKQZ=z8}?7VRuqqmg`Ep`sM7=u{|;aOgF1rA16uIP=k zzsECi4w#Y7Tt3>(${qU=ID_BK2>O(en7GZiIe9J$4Lu)pw{Eo1`p%^>GmJjx2K{V3 zS!bC6o8}!(CmCLPbo}*u*&s_vHm)a+Su$l598%mm`e=v8p9$74-BR_925CZI!e*L+!zc%?$%C>xgzR>~l^kZ0ITNBOoYN3KD`*m8ax2e*m)=v>S zk>m5J+A~3Awy5!YdF6qstvWi1_gtT#s|iQ@zIVe=UTYI?KZb^cOb-M!9Ja->Fz~Bj fZ$jD^##iAE!=tD$;plG{cO5-#V??pm&Aa~qFUaxB literal 0 HcmV?d00001 diff --git a/core/img/web.svg b/core/img/web.svg new file mode 100644 index 00000000000..bc6c6bde650 --- /dev/null +++ b/core/img/web.svg @@ -0,0 +1,183 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- GitLab From 45d16916718ea103b371da9c7bef0385717d8cef Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 10 Jul 2013 13:38:42 +0200 Subject: [PATCH 081/635] fix orientation before caching preview --- lib/preview.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index f12107c9f57..6173fc8aa6b 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -332,7 +332,7 @@ class Preview { $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingup, $this->fileview); - if(!$preview) { + if(!($preview instanceof \OC_Image)) { continue; } @@ -346,6 +346,8 @@ class Preview { if($this->userview->is_dir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/') === false) { $this->userview->mkdir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/'); } + + $preview->fixOrientation(); $this->userview->file_put_contents($cachepath, $preview->data()); break; @@ -382,8 +384,6 @@ class Preview { * @return image */ public function resizeAndCrop() { - $this->preview->fixOrientation(); - $image = $this->preview; $x = $this->maxX; $y = $this->maxY; -- GitLab From 7091d7a6d2c495901383d89aaa0030366bf61d02 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 10 Jul 2013 17:57:04 +0200 Subject: [PATCH 082/635] clean up oc\preview --- lib/preview.php | 301 +++++++++++++++++++++++++++++------------------- 1 file changed, 181 insertions(+), 120 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 6173fc8aa6b..8ecad159157 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -23,7 +23,7 @@ require_once('preview/unknown.php'); require_once('preview/office.php'); class Preview { - //the thumbnail folder + //the thumbnail folder const THUMBNAILS_FOLDER = 'thumbnails'; //config @@ -50,7 +50,7 @@ class Preview { /** * @brief check if thumbnail or bigger version of thumbnail of file is cached - * @param $user userid + * @param $user userid - if no user is given, OC_User::getUser will be used * @param $root path of root * @param $file The path to the file where you want a thumbnail from * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image @@ -59,73 +59,35 @@ class Preview { * false if thumbnail does not exist * path to thumbnail if thumbnail exists */ - public function __construct($user=null, $root='', $file='', $maxX=0, $maxY=0, $scalingup=true, $force=false) { + public function __construct($user='', $root='/', $file='', $maxX=1, $maxY=1, $scalingup=true) { //set config $this->max_x = \OC_Config::getValue('preview_max_x', null); $this->max_y = \OC_Config::getValue('preview_max_y', null); $this->max_scale_factor = \OC_Config::getValue('preview_max_scale_factor', 10); //save parameters - $this->file = $file; - $this->maxX = $maxX; - $this->maxY = $maxY; - $this->scalingup = $scalingup; + $this->setFile($file); + $this->setMaxX($maxX); + $this->setMaxY($maxY); + $this->setScalingUp($scalingup); //init fileviews + if($user === ''){ + $user = OC_User::getUser(); + } $this->fileview = new \OC\Files\View('/' . $user . '/' . $root); $this->userview = new \OC\Files\View('/' . $user); + + $this->preview = null; - if($force !== true) { - if(!is_null($this->max_x)) { - if($this->maxX > $this->max_x) { - \OC_Log::write('core', 'maxX reduced from ' . $this->maxX . ' to ' . $this->max_x, \OC_Log::DEBUG); - $this->maxX = $this->max_x; - } - } - - if(!is_null($this->max_y)) { - if($this->maxY > $this->max_y) { - \OC_Log::write('core', 'maxY reduced from ' . $this->maxY . ' to ' . $this->max_y, \OC_Log::DEBUG); - $this->maxY = $this->max_y; - } - } - - $fileinfo = $this->fileview->getFileInfo($this->file); - if(array_key_exists('size', $fileinfo)){ - if((int) $fileinfo['size'] === 0){ - \OC_Log::write('core', 'You can\'t generate a preview of a 0 byte file (' . $this->file . ')', \OC_Log::ERROR); - throw new \Exception('0 byte file given'); - } - } - - //init providers - if(empty(self::$providers)) { - self::initProviders(); - } - - //check if there are any providers at all - if(empty(self::$providers)) { - \OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR); - throw new \Exception('No providers'); - } - - //validate parameters - if($file === '') { - \OC_Log::write('core', 'No filename passed', \OC_Log::ERROR); - throw new \Exception('File not found'); - } - - //check if file exists - if(!$this->fileview->file_exists($file)) { - \OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::ERROR); - throw new \Exception('File not found'); - } + //check if there are preview backends + if(empty(self::$providers)) { + self::initProviders(); + } - //check if given size makes sense - if($maxX === 0 || $maxY === 0) { - \OC_Log::write('core', 'Can not create preview with 0px width or 0px height', \OC_Log::ERROR); - throw new \Exception('Height and/or width set to 0'); - } + if(empty(self::$providers)) { + \OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR); + throw new \Exception('No preview providers'); } } @@ -165,7 +127,7 @@ class Preview { * @brief returns the name of the thumbnailfolder * @return string */ - public function getThumbnailsfolder() { + public function getThumbnailsFolder() { return self::THUMBNAILS_FOLDER; } @@ -193,16 +155,97 @@ class Preview { return $this->max_y; } + /** + * @brief set the path of the file you want a thumbnail from + * @return $this + */ + public function setFile($file) { + $this->file = $file; + return $this; + } + + /** + * @brief set the the max width of the preview + * @return $this + */ + public function setMaxX($maxX=1) { + if($maxX === 0) { + throw new \Exception('Cannot set width of 0!'); + } + $configMaxX = $this->getConfigMaxX(); + if(!is_null($configMaxX)) { + if($maxX > $configMaxX) { + \OC_Log::write('core', 'maxX reduced from ' . $maxX . ' to ' . $configMaxX, \OC_Log::DEBUG); + $maxX = $configMaxX; + } + } + $this->maxX = $maxX; + return $this; + } + + /** + * @brief set the the max height of the preview + * @return $this + */ + public function setMaxY($maxY=1) { + if($maxY === 0) { + throw new \Exception('Cannot set height of 0!'); + } + $configMaxY = $this->getConfigMaxY(); + if(!is_null($configMaxY)) { + if($maxY > $configMaxY) { + \OC_Log::write('core', 'maxX reduced from ' . $maxY . ' to ' . $configMaxY, \OC_Log::DEBUG); + $maxY = $configMaxY; + } + } + $this->maxY = $maxY; + return $this; + } + + /** + * @brief set whether or not scalingup is enabled + * @return $this + */ + public function setScalingup($scalingup) { + if($this->getMaxScaleFactor() === 1) { + $scalingup = false; + } + $this->scalingup = $scalingup; + return $this; + } + + /** + * @brief check if all parameters are valid + * @return integer + */ + public function isFileValid() { + $file = $this->getFile(); + if($file === '') { + \OC_Log::write('core', 'No filename passed', \OC_Log::ERROR); + return false; + } + + if(!$this->fileview->file_exists($file)) { + \OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::ERROR); + return false; + } + + return true; + } + /** * @brief deletes previews of a file with specific x and y * @return bool */ public function deletePreview() { - $fileinfo = $this->fileview->getFileInfo($this->file); + $file = $this->getFile(); + + $fileinfo = $this->fileview->getFileInfo($file); $fileid = $fileinfo['fileid']; - $this->userview->unlink(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $this->maxX . '-' . $this->maxY . '.png'); - return; + $previepath = $this->getThumbnailsFolder() . '/' . $fileid . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png'; + $this->userview->unlink($previepath); + return $this->userview->file_exists($previepath); } /** @@ -210,12 +253,15 @@ class Preview { * @return bool */ public function deleteAllPreviews() { - $fileinfo = $this->fileview->getFileInfo($this->file); - $fileid = $fileinfo['fileid']; + $file = $this->getFile(); - $this->userview->deleteAll(self::THUMBNAILS_FOLDER . '/' . $fileid . '/'); - $this->userview->rmdir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/'); - return; + $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($previepath); } /** @@ -225,21 +271,23 @@ class Preview { * path to thumbnail if thumbnail exists */ private function isCached() { - $file = $this->file; - $maxX = $this->maxX; - $maxY = $this->maxY; - $scalingup = $this->scalingup; + $file = $this->getFile(); + $maxX = $this->getMaxX(); + $maxY = $this->getMaxY(); + $scalingup = $this->getScalingup(); + $maxscalefactor = $this->getMaxScaleFactor(); $fileinfo = $this->fileview->getFileInfo($file); $fileid = $fileinfo['fileid']; - if(!$this->userview->is_dir(self::THUMBNAILS_FOLDER . '/' . $fileid)) { + $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/'; + if(!$this->userview->is_dir($previewpath)) { return false; } //does a preview with the wanted height and width already exist? - if($this->userview->file_exists(self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png')) { - return self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png'; + if($this->userview->file_exists($previewpath . $maxX . '-' . $maxY . '.png')) { + return $previewpath . $maxX . '-' . $maxY . '.png'; } $wantedaspectratio = $maxX / $maxY; @@ -247,7 +295,7 @@ class Preview { //array for usable cached thumbnails $possiblethumbnails = array(); - $allthumbnails = $this->userview->getDirectoryContent(self::THUMBNAILS_FOLDER . '/' . $fileid); + $allthumbnails = $this->userview->getDirectoryContent($previewpath); foreach($allthumbnails as $thumbnail) { $size = explode('-', $thumbnail['name']); $x = $size[0]; @@ -261,7 +309,7 @@ class Preview { if($x < $maxX || $y < $maxY) { if($scalingup) { $scalefactor = $maxX / $x; - if($scalefactor > $this->max_scale_factor) { + if($scalefactor > $maxscalefactor) { continue; } }else{ @@ -307,22 +355,28 @@ class Preview { * @return image */ public function getPreview() { - $file = $this->file; - $maxX = $this->maxX; - $maxY = $this->maxY; - $scalingup = $this->scalingup; + if(!is_null($this->preview) && $this->preview->valid()){ + return $this->preview; + } + + $this->preview = null; + $file = $this->getFile(); + $maxX = $this->getMaxX(); + $maxY = $this->getMaxY(); + $scalingup = $this->getScalingup(); $fileinfo = $this->fileview->getFileInfo($file); $fileid = $fileinfo['fileid']; - $cached = self::isCached(); + $cached = $this->isCached(); if($cached) { $image = new \OC_Image($this->userview->file_get_contents($cached, 'r')); - $this->preview = $image; - }else{ - $mimetype = $this->fileview->getMimeType($file); + $this->preview = $image->valid() ? $image : null; + } + if(is_null($this->preview)) { + $mimetype = $this->fileview->getMimeType($file); $preview = null; foreach(self::$providers as $supportedmimetype => $provider) { @@ -336,35 +390,35 @@ class Preview { continue; } - //are there any cached thumbnails yet - if($this->userview->is_dir(self::THUMBNAILS_FOLDER . '/') === false) { - $this->userview->mkdir(self::THUMBNAILS_FOLDER . '/'); + $this->preview = $preview; + $this->resizeAndCrop(); + + $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/'; + $cachepath = $previewpath . $maxX . '-' . $maxY . '.png'; + + if($this->userview->is_dir($this->getThumbnailsFolder() . '/') === false) { + $this->userview->mkdir($this->getThumbnailsFolder() . '/'); } - //cache thumbnail - $cachepath = self::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $maxX . '-' . $maxY . '.png'; - if($this->userview->is_dir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/') === false) { - $this->userview->mkdir(self::THUMBNAILS_FOLDER . '/' . $fileid . '/'); + if($this->userview->is_dir($previewpath) === false) { + $this->userview->mkdir($previewpath); } - $preview->fixOrientation(); $this->userview->file_put_contents($cachepath, $preview->data()); break; } + } - if(is_null($preview) || $preview === false) { - $preview = new \OC_Image(); - } - - $this->preview = $preview; + if(is_null($this->preview)) { + $this->preview = new \OC_Image(); } - $this->resizeAndCrop(); + return $this->preview; } /** - * @brief return a preview of a file + * @brief show preview * @param $file The path to the file where you want a thumbnail from * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image @@ -372,67 +426,74 @@ class Preview { * @return void */ public function showPreview() { - \OCP\Response::enableCaching(3600 * 24); // 24 hour - $preview = $this->getPreview(); - if($preview) { - $preview->show(); + \OCP\Response::enableCaching(3600 * 24); // 24 hours + if(is_null($this->preview)) { + $this->getPreview(); } + $this->preview->show(); } /** * @brief resize, crop and fix orientation * @return image */ - public function resizeAndCrop() { + private function resizeAndCrop() { $image = $this->preview; - $x = $this->maxX; - $y = $this->maxY; - $scalingup = $this->scalingup; + $x = $this->getMaxX(); + $y = $this->getMaxY(); + $scalingup = $this->getScalingup(); + $maxscalefactor = $this->getMaxScaleFactor(); if(!($image instanceof \OC_Image)) { - \OC_Log::write('core', 'Object passed to resizeAndCrop is not an instance of OC_Image', \OC_Log::DEBUG); + \OC_Log::write('core', '$this->preview is not an instance of OC_Image', \OC_Log::DEBUG); return; } + $image->fixOrientation(); + $realx = (int) $image->width(); $realy = (int) $image->height(); if($x === $realx && $y === $realy) { - return $image; + $this->preview = $image; + return true; } $factorX = $x / $realx; $factorY = $y / $realy; - + if($factorX >= $factorY) { $factor = $factorX; }else{ $factor = $factorY; } - - // only scale up if requested + if($scalingup === false) { - if($factor>1) $factor=1; + if($factor > 1) { + $factor = 1; + } } - if(!is_null($this->max_scale_factor)) { - if($factor > $this->max_scale_factor) { - \OC_Log::write('core', 'scalefactor reduced from ' . $factor . ' to ' . $this->max_scale_factor, \OC_Log::DEBUG); - $factor = $this->max_scale_factor; + + if(!is_null($maxscalefactor)) { + if($factor > $maxscalefactor) { + \OC_Log::write('core', 'scalefactor reduced from ' . $factor . ' to ' . $maxscalefactor, \OC_Log::DEBUG); + $factor = $maxscalefactor; } } - $newXsize = $realx * $factor; - $newYsize = $realy * $factor; - // resize + $newXsize = (int) ($realx * $factor); + $newYsize = (int) ($realy * $factor); + $image->preciseResize($newXsize, $newYsize); - if($newXsize === $x && $newYsize === $y) { + if($newXsize == $x && $newYsize === $y) { $this->preview = $image; return; } if($newXsize >= $x && $newYsize >= $y) { $cropX = floor(abs($x - $newXsize) * 0.5); + //don't crop previews on the Y axis, this sucks if it's a document. //$cropY = floor(abs($y - $newYsize) * 0.5); $cropY = 0; -- GitLab From f14b0fa6e0dfad28f2f6573ec517019ac12342cf Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 10 Jul 2013 18:01:04 +0200 Subject: [PATCH 083/635] update some comments in preview lib --- lib/preview.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 8ecad159157..0a8ab438367 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -348,10 +348,6 @@ class Preview { /** * @brief return a preview of a file - * @param $file The path to the file where you want a thumbnail from - * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image - * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image - * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly * @return image */ public function getPreview() { @@ -419,10 +415,6 @@ class Preview { /** * @brief show preview - * @param $file The path to the file where you want a thumbnail from - * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image - * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image - * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly * @return void */ public function showPreview() { @@ -431,6 +423,7 @@ class Preview { $this->getPreview(); } $this->preview->show(); + return; } /** @@ -486,7 +479,7 @@ class Preview { $image->preciseResize($newXsize, $newYsize); - if($newXsize == $x && $newYsize === $y) { + if($newXsize === $x && $newYsize === $y) { $this->preview = $image; return; } -- GitLab From 5c31b843fc62b2be43d85ca680eeffa3e6f292dd Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 10 Jul 2013 18:04:13 +0200 Subject: [PATCH 084/635] fix typo --- lib/preview.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 0a8ab438367..f018fa38850 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -243,9 +243,9 @@ class Preview { $fileinfo = $this->fileview->getFileInfo($file); $fileid = $fileinfo['fileid']; - $previepath = $this->getThumbnailsFolder() . '/' . $fileid . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png'; - $this->userview->unlink($previepath); - return $this->userview->file_exists($previepath); + $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png'; + $this->userview->unlink($previewpath); + return $this->userview->file_exists($previewpath); } /** @@ -261,7 +261,7 @@ class Preview { $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/'; $this->userview->deleteAll($previewpath); $this->userview->rmdir($previewpath); - return $this->userview->is_dir($previepath); + return $this->userview->is_dir($previewpath); } /** -- GitLab From 7f71ae60b0fefe697aa9da2cda40853736df0580 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 10:10:07 +0200 Subject: [PATCH 085/635] improve validation of oc\preview and implement preview of error icon if something went wrong --- lib/preview.php | 255 ++++++++++++++++++++++++++++++------------------ 1 file changed, 159 insertions(+), 96 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index f018fa38850..94e0cd96e7c 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -426,6 +426,14 @@ class Preview { return; } + /** + * @brief show preview + * @return void + */ + public function show() { + return $this->showPreview(); + } + /** * @brief resize, crop and fix orientation * @return image @@ -567,30 +575,40 @@ class Preview { * @brief method that handles preview requests from users that are logged in * @return void */ - public static function previewRouter($params) { + public static function previewRouter() { \OC_Util::checkLoggedIn(); - $file = ''; - $maxX = 0; - $maxY = 0; - $scalingup = true; - - if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); - if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; - if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; - if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; - - if($file !== '' && $maxX !== 0 && $maxY !== 0) { - try{ - $preview = new Preview(\OC_User::getUser(), 'files', $file, $maxX, $maxY, $scalingup); - $preview->showPreview(); - }catch(\Exception $e) { - \OC_Response::setStatus(404); - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); - exit; - } - }else{ - \OC_Response::setStatus(404); + $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; + $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44'; + $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44'; + $scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; + + if($file === '') { + \OC_Response::setStatus(400); //400 Bad Request + \OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG); + self::showErrorPreview(); + exit; + } + + if($maxX === 0 || $maxY === 0) { + \OC_Response::setStatus(400); //400 Bad Request + \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG); + self::showErrorPreview(); + exit; + } + + try{ + $preview = new Preview(\OC_User::getUser(), 'files'); + $preview->setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingup); + + $preview->show(); + }catch(\Exception $e) { + \OC_Response::setStatus(500); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + self::showErrorPreview(); exit; } } @@ -599,94 +617,132 @@ class Preview { * @brief method that handles preview requests from users that are not logged in / view shared folders that are public * @return void */ - public static function publicPreviewRouter($params) { - $file = ''; - $maxX = 0; - $maxY = 0; - $scalingup = true; - $token = ''; - - $user = null; - $path = null; - - if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); - if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; - if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; - if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; - if(array_key_exists('t', $_GET)) $token = (string) $_GET['t']; - - $linkItem = \OCP\Share::getShareByToken($token); - - if (is_array($linkItem) && isset($linkItem['uid_owner']) && isset($linkItem['file_source'])) { - $userid = $linkItem['uid_owner']; - \OC_Util::setupFS($userid); - - $pathid = $linkItem['file_source']; - $path = \OC\Files\Filesystem::getPath($pathid); - $pathinfo = \OC\Files\Filesystem::getFileInfo($path); - - $sharedfile = null; - if($linkItem['item_type'] === 'folder') { - //clean up file parameter - $sharedfile = \OC\Files\Filesystem::normalizePath($file); - if(!\OC\Files\Filesystem::isValidPath($file)) { - \OC_Response::setStatus(403); - exit; - } - } else if($linkItem['item_type'] === 'file') { - $parent = $pathinfo['parent']; - $path = \OC\Files\Filesystem::getPath($parent); - $sharedfile = $pathinfo['name']; - } + public static function publicPreviewRouter() { + if(!\OC_App::isEnabled('files_sharing')){ + exit; + } - $path = \OC\Files\Filesystem::normalizePath($path, false); - if(substr($path, 0, 1) == '/') { - $path = substr($path, 1); - } + $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; + $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44'; + $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44'; + $scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; + $token = array_key_exists('t', $_GET) ? (string) $_GET['t'] : ''; + + if($token === ''){ + \OC_Response::setStatus(400); //400 Bad Request + \OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG); + self::showErrorPreview(); + exit; } - if($userid !== null && $path !== null && $sharedfile !== null) { - try{ - $preview = new Preview($userid, 'files/' . $path, $sharedfile, $maxX, $maxY, $scalingup); - $preview->showPreview(); - }catch(\Exception $e) { - \OC_Response::setStatus(404); - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + $linkedItem = \OCP\Share::getShareByToken($token); + if($linkedItem === false || ($linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder')) { + \OC_Response::setStatus(404); + \OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG); + self::showErrorPreview(); + exit; + } + + if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) { + \OC_Response::setStatus(500); + \OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")'); + self::showErrorPreview(); + exit; + } + + $userid = $linkedItem['uid_owner']; + \OC_Util::setupFS($userid); + + $pathid = $linkedItem['file_source']; + $path = \OC\Files\Filesystem::getPath($pathid); + $pathinfo = \OC\Files\Filesystem::getFileInfo($path); + $sharedfile = null; + + if($linkedItem['item_type'] === 'folder') { + $isvalid = \OC\File\Filesystem::isValidPath($file); + if(!$isvalid) { + \OC_Response::setStatus(400); //400 Bad Request + \OC_Log::write('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . $_SERVER['REMOTE_ADDR'] . '")', \OC_Log::WARN); + self::showErrorPreview(); exit; } - }else{ - \OC_Response::setStatus(404); + $sharedfile = \OC\Files\Filesystem::normalizePath($file); + } + + if($linkedItem['item_type'] === 'file') { + $parent = $pathinfo['parent']; + $path = \OC\Files\Filesystem::getPath($parent); + $sharedfile = $pathinfo['name']; + } + + $path = \OC\Files\Filesystem::normalizePath($path, false); + if(substr($path, 0, 1) == '/') { + $path = substr($path, 1); + } + + if($maxX === 0 || $maxY === 0) { + \OC_Response::setStatus(400); //400 Bad Request + \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG); + self::showErrorPreview(); + exit; + } + + $root = 'files/' . $path; + + try{ + $preview = new Preview($userid, $path); + $preview->setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingup); + + $preview->show(); + }catch(\Exception $e) { + \OC_Response::setStatus(500); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + self::showErrorPreview(); exit; } } public static function trashbinPreviewRouter() { + \OC_Util::checkLoggedIn(); + if(!\OC_App::isEnabled('files_trashbin')){ exit; } - \OC_Util::checkLoggedIn(); - $file = ''; - $maxX = 0; - $maxY = 0; - $scalingup = true; - - if(array_key_exists('file', $_GET)) $file = (string) urldecode($_GET['file']); - if(array_key_exists('x', $_GET)) $maxX = (int) $_GET['x']; - if(array_key_exists('y', $_GET)) $maxY = (int) $_GET['y']; - if(array_key_exists('scalingup', $_GET)) $scalingup = (bool) $_GET['scalingup']; - - if($file !== '' && $maxX !== 0 && $maxY !== 0) { - try{ - $preview = new Preview(\OC_User::getUser(), 'files_trashbin/files', $file, $maxX, $maxY, $scalingup); - $preview->showPreview(); - }catch(\Exception $e) { - \OC_Response::setStatus(404); - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); - exit; - } - }else{ - \OC_Response::setStatus(404); + $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; + $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44'; + $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44'; + $scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; + + if($file === '') { + \OC_Response::setStatus(400); //400 Bad Request + \OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG); + self::showErrorPreview(); + exit; + } + + if($maxX === 0 || $maxY === 0) { + \OC_Response::setStatus(400); //400 Bad Request + \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG); + self::showErrorPreview(); + exit; + } + + try{ + $preview = new Preview(\OC_User::getUser(), 'files_trashbin/files'); + $preview->setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingup); + + $preview->showPreview(); + }catch(\Exception $e) { + \OC_Response::setStatus(500); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + self::showErrorPreview(); exit; } } @@ -703,4 +759,11 @@ class Preview { $preview = new Preview(\OC_User::getUser(), 'files/', $path, 0, 0, false, true); $preview->deleteAllPreviews(); } + + private static function showErrorPreview() { + $path = \OC::$SERVERROOT . '/core/img/actions/delete.png'; + $preview = new \OC_Image($path); + $preview->preciseResize(44, 44); + $preview->show(); + } } \ No newline at end of file -- GitLab From 4bbbba1dc8288462881d9bfdf979b3f207572d2e Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 11:43:53 +0200 Subject: [PATCH 086/635] fix typo --- lib/preview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview.php b/lib/preview.php index 94e0cd96e7c..5b2ee2cddd4 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -659,7 +659,7 @@ class Preview { $sharedfile = null; if($linkedItem['item_type'] === 'folder') { - $isvalid = \OC\File\Filesystem::isValidPath($file); + $isvalid = \OC\Files\Filesystem::isValidPath($file); if(!$isvalid) { \OC_Response::setStatus(400); //400 Bad Request \OC_Log::write('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . $_SERVER['REMOTE_ADDR'] . '")', \OC_Log::WARN); -- GitLab From 06eca985ce493bba65293003bd52aed10566c6d6 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 11:57:19 +0200 Subject: [PATCH 087/635] use $root instead of $path --- lib/preview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview.php b/lib/preview.php index 5b2ee2cddd4..62bcf4873b5 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -690,7 +690,7 @@ class Preview { $root = 'files/' . $path; try{ - $preview = new Preview($userid, $path); + $preview = new Preview($userid, $root); $preview->setFile($file); $preview->setMaxX($maxX); $preview->setMaxY($maxY); -- GitLab From 53830f2f751151d2d326b253471e63d9b1cf8eb1 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 11:58:52 +0200 Subject: [PATCH 088/635] implement use of previews in sharing app --- apps/files/index.php | 1 + apps/files/templates/part.list.php | 9 ++++++++- apps/files_sharing/public.php | 3 +++ lib/helper.php | 4 ++++ lib/public/template.php | 10 ++++++++++ lib/template.php | 4 ++++ 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/apps/files/index.php b/apps/files/index.php index 2338cf439e4..156febd87f4 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -95,6 +95,7 @@ $list->assign('files', $files); $list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir='); $list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/'))); $list->assign('disableSharing', false); +$list->assign('isPublic', false); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir='); diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 38d1314392b..9e62c991975 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -30,7 +30,14 @@ $totalsize = 0; ?> style="background-image:url()" - style="background-image:url()" + + + style="background-image:url()" + + style="background-image:url()" + > diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 9462844a82b..0c4150f74d2 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -191,6 +191,9 @@ if (isset($path)) { $list->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); $list->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path='); + $list->assign('isPublic', true); + $list->assign('sharingtoken', $token); + $list->assign('sharingroot', ($path)); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); diff --git a/lib/helper.php b/lib/helper.php index 856dba625b3..6153f318723 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -234,6 +234,10 @@ class OC_Helper { return self::linkToRoute( 'core_ajax_preview', array('x' => 44, 'y' => 44, 'file' => urlencode($path) )); } + public static function publicPreview_icon( $path, $token ) { + return self::linkToRoute( 'core_ajax_public_preview', array('x' => 44, 'y' => 44, 'file' => urlencode($path), 't' => $token)); + } + /** * @brief Make a human file size * @param int $bytes file size in bytes diff --git a/lib/public/template.php b/lib/public/template.php index 5f9888f9f28..69997ad42b6 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -64,6 +64,16 @@ function preview_icon( $path ) { return(\preview_icon( $path )); } +/** + * @brief make publicpreview_icon available as a simple function + * Returns the path to the preview of the image. + * @param $path path of file + * @returns link to the preview + */ +function publicPreview_icon ( $path, $token ) { + return(\publicPreview_icon( $path, $token )); +} + /** * @brief make OC_Helper::humanFileSize available as a simple function * Makes 2048 to 2 kB. diff --git a/lib/template.php b/lib/template.php index 048d172f1c9..842c3325357 100644 --- a/lib/template.php +++ b/lib/template.php @@ -74,6 +74,10 @@ function preview_icon( $path ) { return OC_Helper::previewIcon( $path ); } +function publicPreview_icon ( $path, $token ) { + return OC_Helper::publicPreview_icon( $path, $token ); +} + /** * @brief make OC_Helper::mimetypeIcon available as a simple function * @param string $mimetype mimetype -- GitLab From ec75e1904d9d4c77d1a6c1c656e7deeae07a8804 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 12:28:41 +0200 Subject: [PATCH 089/635] make jenkins happy --- lib/preview/unknown.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index 4e1ca7de741..a31b365722e 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -22,7 +22,11 @@ class Unknown extends Provider { $iconsroot = \OC::$SERVERROOT . '/core/img/filetypes/'; - $icons = array($mimetype, $type, 'text'); + if(isset($type)){ + $icons = array($mimetype, $type, 'text'); + }else{ + $icons = array($mimetype, 'text'); + } foreach($icons as $icon) { $icon = str_replace('/', '-', $icon); -- GitLab From 89554bd917f9cbc7d16cc31b754a47d9f942b0b1 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 13:39:10 +0200 Subject: [PATCH 090/635] it's setValue not getValue, damn type --- tests/lib/preview.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/lib/preview.php b/tests/lib/preview.php index 2599da400c8..c4894f848f6 100644 --- a/tests/lib/preview.php +++ b/tests/lib/preview.php @@ -74,8 +74,8 @@ class Preview extends \PHPUnit_Framework_TestCase { $maxX = 250; $maxY = 250; - \OC_Config::getValue('preview_max_x', $maxX); - \OC_Config::getValue('preview_max_y', $maxY); + \OC_Config::setValue('preview_max_x', $maxX); + \OC_Config::setValue('preview_max_y', $maxY); $rootView = new \OC\Files\View(''); $rootView->mkdir('/'.$user); @@ -87,7 +87,10 @@ class Preview extends \PHPUnit_Framework_TestCase { $preview = new \OC\Preview($user, 'files/', 'test.txt', 1000, 1000); $image = $preview->getPreview(); - + + var_dump($image->width()); + var_dump($image->height()); + $this->assertEquals($image->width(), $maxX); $this->assertEquals($image->height(), $maxY); } -- GitLab From 7f3dbb6936cded830cbbf135f887a84ebd50b77c Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 13:41:09 +0200 Subject: [PATCH 091/635] remove debug code ... --- tests/lib/preview.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/lib/preview.php b/tests/lib/preview.php index c4894f848f6..bebdc12b500 100644 --- a/tests/lib/preview.php +++ b/tests/lib/preview.php @@ -87,10 +87,7 @@ class Preview extends \PHPUnit_Framework_TestCase { $preview = new \OC\Preview($user, 'files/', 'test.txt', 1000, 1000); $image = $preview->getPreview(); - - var_dump($image->width()); - var_dump($image->height()); - + $this->assertEquals($image->width(), $maxX); $this->assertEquals($image->height(), $maxY); } -- GitLab From 7b2aa5d830efeea7e68a71ddc33bc6e9add1409d Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 19:03:21 +0200 Subject: [PATCH 092/635] OC\Preview - use camelCase --- lib/preview.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 62bcf4873b5..327a45d8d13 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -27,9 +27,9 @@ class Preview { const THUMBNAILS_FOLDER = 'thumbnails'; //config - private $max_scale_factor; - private $max_x; - private $max_y; + private $maxScaleFactor; + private $configMaxX; + private $configMaxY; //fileview object private $fileview = null; @@ -61,9 +61,9 @@ class Preview { */ public function __construct($user='', $root='/', $file='', $maxX=1, $maxY=1, $scalingup=true) { //set config - $this->max_x = \OC_Config::getValue('preview_max_x', null); - $this->max_y = \OC_Config::getValue('preview_max_y', null); - $this->max_scale_factor = \OC_Config::getValue('preview_max_scale_factor', 10); + $this->configMaxX = \OC_Config::getValue('preview_max_x', null); + $this->configMaxY = \OC_Config::getValue('preview_max_y', null); + $this->maxScaleFactor = \OC_Config::getValue('preview_max_scale_factor', 10); //save parameters $this->setFile($file); @@ -136,7 +136,7 @@ class Preview { * @return integer */ public function getMaxScaleFactor() { - return $this->max_scale_factor; + return $this->maxScaleFactor; } /** @@ -144,7 +144,7 @@ class Preview { * @return integer */ public function getConfigMaxX() { - return $this->max_x; + return $this->configMaxX; } /** @@ -152,7 +152,7 @@ class Preview { * @return integer */ public function getConfigMaxY() { - return $this->max_y; + return $this->configMaxY; } /** -- GitLab From 1e8a646f51428d19f565fa702cbb935ca8267adb Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 19:21:37 +0200 Subject: [PATCH 093/635] OC\Preview - improve documentation --- lib/preview.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 327a45d8d13..fba1d893e08 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -50,11 +50,12 @@ class Preview { /** * @brief check if thumbnail or bigger version of thumbnail of file is cached - * @param $user userid - if no user is given, OC_User::getUser will be used - * @param $root path of root - * @param $file The path to the file where you want a thumbnail from - * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image - * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image + * @param string $user userid - if no user is given, OC_User::getUser will be used + * @param string $root path of root + * @param string $file The path to the file where you want a thumbnail from + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image + * @param bool $scalingup Disable/Enable upscaling of previews * @return mixed (bool / string) * false if thumbnail does not exist * path to thumbnail if thumbnail exists @@ -157,6 +158,7 @@ class Preview { /** * @brief set the path of the file you want a thumbnail from + * @param string $file * @return $this */ public function setFile($file) { @@ -166,6 +168,7 @@ class Preview { /** * @brief set the the max width of the preview + * @param int $maxX * @return $this */ public function setMaxX($maxX=1) { @@ -185,6 +188,7 @@ class Preview { /** * @brief set the the max height of the preview + * @param int $maxY * @return $this */ public function setMaxY($maxY=1) { @@ -204,6 +208,7 @@ class Preview { /** * @brief set whether or not scalingup is enabled + * @param bool $scalingup * @return $this */ public function setScalingup($scalingup) { @@ -216,7 +221,7 @@ class Preview { /** * @brief check if all parameters are valid - * @return integer + * @return bool */ public function isFileValid() { $file = $this->getFile(); @@ -543,6 +548,7 @@ class Preview { /** * @brief register a new preview provider to be used * @param string $provider class name of a Preview_Provider + * @param array $options * @return void */ public static function registerProvider($class, $options=array()) { -- GitLab From c6849bed9da49b488497eb44c81059630bade2e0 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 20:02:59 +0200 Subject: [PATCH 094/635] OC\Preview - remove unneeded comment --- lib/preview/provider.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/preview/provider.php b/lib/preview/provider.php index 44e1d11ba06..e4a730bafc8 100644 --- a/lib/preview/provider.php +++ b/lib/preview/provider.php @@ -1,7 +1,4 @@ Date: Thu, 11 Jul 2013 20:15:30 +0200 Subject: [PATCH 095/635] OC\Preview - fix logic of two return values --- lib/preview.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index fba1d893e08..cc287595f40 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -250,7 +250,7 @@ class Preview { $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png'; $this->userview->unlink($previewpath); - return $this->userview->file_exists($previewpath); + return !$this->userview->file_exists($previewpath); } /** @@ -266,7 +266,7 @@ class Preview { $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/'; $this->userview->deleteAll($previewpath); $this->userview->rmdir($previewpath); - return $this->userview->is_dir($previewpath); + return !$this->userview->is_dir($previewpath); } /** -- GitLab From 14a35267c15115a1e7d2901ddd9b8c5c7e1b9a31 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 11 Jul 2013 20:35:55 +0200 Subject: [PATCH 096/635] OC\Preview - outsource static methods --- core/routes.php | 7 ++++--- lib/preview.php | 29 +++++++++++++++++++---------- lib/preview/images.php | 2 +- lib/preview/libreoffice-cl.php | 10 +++++----- lib/preview/movies.php | 2 +- lib/preview/mp3.php | 2 +- lib/preview/msoffice.php | 12 ++++++------ lib/preview/pdf.php | 2 +- lib/preview/svg.php | 2 +- lib/preview/txt.php | 6 +++--- lib/preview/unknown.php | 2 +- 11 files changed, 43 insertions(+), 33 deletions(-) diff --git a/core/routes.php b/core/routes.php index 41e82f8a73d..c0e658b26dc 100644 --- a/core/routes.php +++ b/core/routes.php @@ -42,12 +42,13 @@ $this->create('js_config', '/core/js/config.js') // Routing $this->create('core_ajax_routes', '/core/routes.json') ->action('OC_Router', 'JSRoutes'); +OC::$CLASSPATH['OC\PreviewManager'] = 'lib/preview.php'; $this->create('core_ajax_preview', '/core/preview.png') - ->action('OC\Preview', 'previewRouter'); + ->action('OC\PreviewManager', 'previewRouter'); $this->create('core_ajax_trashbin_preview', '/core/trashbinpreview.png') - ->action('OC\Preview', 'trashbinPreviewRouter'); + ->action('OC\PreviewManager', 'trashbinPreviewRouter'); $this->create('core_ajax_public_preview', '/core/publicpreview.png') - ->action('OC\Preview', 'publicPreviewRouter'); + ->action('OC\PreviewManager', 'publicPreviewRouter'); OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; $this->create('core_lostpassword_index', '/lostpassword/') ->get() diff --git a/lib/preview.php b/lib/preview.php index cc287595f40..73e01a9e552 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -44,10 +44,6 @@ class Preview { //preview images object private $preview; - //preview providers - static private $providers = array(); - static private $registeredProviders = array(); - /** * @brief check if thumbnail or bigger version of thumbnail of file is cached * @param string $user userid - if no user is given, OC_User::getUser will be used @@ -82,11 +78,13 @@ class Preview { $this->preview = null; //check if there are preview backends - if(empty(self::$providers)) { - self::initProviders(); + $providers = PreviewManager::getProviders(); + if(empty($providers)) { + PreviewManager::initProviders(); } - if(empty(self::$providers)) { + $providers = PreviewManager::getProviders(); + if(empty($providers)) { \OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR); throw new \Exception('No preview providers'); } @@ -380,7 +378,8 @@ class Preview { $mimetype = $this->fileview->getMimeType($file); $preview = null; - foreach(self::$providers as $supportedmimetype => $provider) { + $providers = PreviewManager::getProviders(); + foreach($providers as $supportedmimetype => $provider) { if(!preg_match($supportedmimetype, $mimetype)) { continue; } @@ -544,6 +543,16 @@ class Preview { return; } } +} + +class PreviewManager { + //preview providers + static private $providers = array(); + static private $registeredProviders = array(); + + public static function getProviders() { + return self::$providers; + } /** * @brief register a new preview provider to be used @@ -559,7 +568,7 @@ class Preview { * @brief create instances of all the registered preview providers * @return void */ - private static function initProviders() { + public static function initProviders() { if(count(self::$providers)>0) { return; } @@ -766,7 +775,7 @@ class Preview { $preview->deleteAllPreviews(); } - private static function showErrorPreview() { + public static function showErrorPreview() { $path = \OC::$SERVERROOT . '/core/img/actions/delete.png'; $preview = new \OC_Image($path); $preview->preciseResize(44, 44); diff --git a/lib/preview/images.php b/lib/preview/images.php index 987aa9aef0a..84ab9f1ae43 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -30,4 +30,4 @@ class Image extends Provider { } } -\OC\Preview::registerProvider('OC\Preview\Image'); \ No newline at end of file +\OC\PreviewManager::registerProvider('OC\Preview\Image'); \ No newline at end of file diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index 2749c4867e9..ffe8de505f7 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -80,7 +80,7 @@ class MSOfficeDoc extends Office { } -\OC\Preview::registerProvider('OC\Preview\MSOfficeDoc'); +\OC\PreviewManager::registerProvider('OC\Preview\MSOfficeDoc'); //.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m) class MSOffice2003 extends Office { @@ -91,7 +91,7 @@ class MSOffice2003 extends Office { } -\OC\Preview::registerProvider('OC\Preview\MSOffice2003'); +\OC\PreviewManager::registerProvider('OC\Preview\MSOffice2003'); //.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx class MSOffice2007 extends Office { @@ -102,7 +102,7 @@ class MSOffice2007 extends Office { } -\OC\Preview::registerProvider('OC\Preview\MSOffice2007'); +\OC\PreviewManager::registerProvider('OC\Preview\MSOffice2007'); //.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt class OpenDocument extends Office { @@ -113,7 +113,7 @@ class OpenDocument extends Office { } -\OC\Preview::registerProvider('OC\Preview\OpenDocument'); +\OC\PreviewManager::registerProvider('OC\Preview\OpenDocument'); //.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm class StarOffice extends Office { @@ -124,4 +124,4 @@ class StarOffice extends Office { } -\OC\Preview::registerProvider('OC\Preview\StarOffice'); \ No newline at end of file +\OC\PreviewManager::registerProvider('OC\Preview\StarOffice'); \ No newline at end of file diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 8531050d112..f4452e02fc2 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -39,5 +39,5 @@ if(!is_null(shell_exec('ffmpeg -version'))) { } } - \OC\Preview::registerProvider('OC\Preview\Movie'); + \OC\PreviewManager::registerProvider('OC\Preview\Movie'); } \ No newline at end of file diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 835ff529000..baa24ad129e 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -43,4 +43,4 @@ class MP3 extends Provider { } -\OC\Preview::registerProvider('OC\Preview\MP3'); \ No newline at end of file +\OC\PreviewManager::registerProvider('OC\Preview\MP3'); \ No newline at end of file diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php index ccf1d674c7a..9f6ea7f74cf 100644 --- a/lib/preview/msoffice.php +++ b/lib/preview/msoffice.php @@ -20,7 +20,7 @@ class DOC extends Provider { } -\OC\Preview::registerProvider('OC\Preview\DOC'); +\OC\PreviewManager::registerProvider('OC\Preview\DOC'); */ class DOCX extends Provider { @@ -50,7 +50,7 @@ class DOCX extends Provider { } -\OC\Preview::registerProvider('OC\Preview\DOCX'); +\OC\PreviewManager::registerProvider('OC\Preview\DOCX'); class MSOfficeExcel extends Provider { @@ -95,7 +95,7 @@ class XLS extends MSOfficeExcel { } -\OC\Preview::registerProvider('OC\Preview\XLS'); +\OC\PreviewManager::registerProvider('OC\Preview\XLS'); class XLSX extends MSOfficeExcel { @@ -105,7 +105,7 @@ class XLSX extends MSOfficeExcel { } -\OC\Preview::registerProvider('OC\Preview\XLSX'); +\OC\PreviewManager::registerProvider('OC\Preview\XLSX'); /* //There is no (good) php-only solution for converting powerpoint documents to pdfs / pngs ... class MSOfficePowerPoint extends Provider { @@ -128,7 +128,7 @@ class PPT extends MSOfficePowerPoint { } -\OC\Preview::registerProvider('OC\Preview\PPT'); +\OC\PreviewManager::registerProvider('OC\Preview\PPT'); class PPTX extends MSOfficePowerPoint { @@ -138,5 +138,5 @@ class PPTX extends MSOfficePowerPoint { } -\OC\Preview::registerProvider('OC\Preview\PPTX'); +\OC\PreviewManager::registerProvider('OC\Preview\PPTX'); */ \ No newline at end of file diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index 3eabd201156..0d289e9db94 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -36,5 +36,5 @@ if (extension_loaded('imagick')) { } } - \OC\Preview::registerProvider('OC\Preview\PDF'); + \OC\PreviewManager::registerProvider('OC\Preview\PDF'); } diff --git a/lib/preview/svg.php b/lib/preview/svg.php index bafaf71b15a..5507686af97 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -39,6 +39,6 @@ if (extension_loaded('imagick')) { } } - \OC\Preview::registerProvider('OC\Preview\SVG'); + \OC\PreviewManager::registerProvider('OC\Preview\SVG'); } \ No newline at end of file diff --git a/lib/preview/txt.php b/lib/preview/txt.php index c7b8fabc6b0..acbf34c5e42 100644 --- a/lib/preview/txt.php +++ b/lib/preview/txt.php @@ -46,7 +46,7 @@ class TXT extends Provider { } } -\OC\Preview::registerProvider('OC\Preview\TXT'); +\OC\PreviewManager::registerProvider('OC\Preview\TXT'); class PHP extends TXT { @@ -56,7 +56,7 @@ class PHP extends TXT { } -\OC\Preview::registerProvider('OC\Preview\PHP'); +\OC\PreviewManager::registerProvider('OC\Preview\PHP'); class JavaScript extends TXT { @@ -66,4 +66,4 @@ class JavaScript extends TXT { } -\OC\Preview::registerProvider('OC\Preview\JavaScript'); \ No newline at end of file +\OC\PreviewManager::registerProvider('OC\Preview\JavaScript'); \ No newline at end of file diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index a31b365722e..f9f6fe957b2 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -40,4 +40,4 @@ class Unknown extends Provider { } } -\OC\Preview::registerProvider('OC\Preview\Unknown'); \ No newline at end of file +\OC\PreviewManager::registerProvider('OC\Preview\Unknown'); \ No newline at end of file -- GitLab From 10cc0511af5e1c5a37314ff2fabe0e27f9482e27 Mon Sep 17 00:00:00 2001 From: kondou Date: Fri, 12 Jul 2013 01:36:10 +0200 Subject: [PATCH 097/635] Optimize images with optipng and scour --- core/img/filetypes/application-pdf.png | Bin 1759 -> 1746 bytes core/img/filetypes/application-pdf.svg | 323 ++----- core/img/filetypes/application-rss+xml.svg | 950 +-------------------- core/img/filetypes/application.png | Bin 1235 -> 1018 bytes core/img/filetypes/application.svg | 373 ++------ core/img/filetypes/audio.png | Bin 858 -> 816 bytes core/img/filetypes/audio.svg | 317 +------ core/img/filetypes/code.svg | 419 ++------- core/img/filetypes/file.svg | 229 +---- core/img/filetypes/flash.svg | 366 ++------ core/img/filetypes/folder.svg | 385 ++------- core/img/filetypes/font.png | Bin 1793 -> 1697 bytes core/img/filetypes/font.svg | 371 +------- core/img/filetypes/image-svg+xml.svg | 716 ++-------------- core/img/filetypes/image.png | Bin 978 -> 976 bytes core/img/filetypes/image.svg | 376 ++------ core/img/filetypes/text-html.png | Bin 741 -> 654 bytes core/img/filetypes/text-html.svg | 323 +------ core/img/filetypes/text.png | Bin 757 -> 693 bytes core/img/filetypes/text.svg | 265 +----- 20 files changed, 634 insertions(+), 4779 deletions(-) diff --git a/core/img/filetypes/application-pdf.png b/core/img/filetypes/application-pdf.png index 2cbcb741d84a8e1303608089a33e22180a0e4510..a9ab6d279b6147ad8d0f6319ecdde08a637c8e70 100644 GIT binary patch delta 1655 zcmV--28j9J4blyeZhucnL_t(o!|j({h+S6|$AA0doO3_tqjx4rGo5s1l1|ea)0#A5 zY-w!}n-(c3#gr-(t5~5F^rellB9Wq?)KE|#>RS^LA!$)eA}vaUP(v)$geK!hX2`Tg zCut{4W|Fyc?>&1hAI_cW-1+K@kQX<1vFCF3-TQz3>%abMkAG2BuII2^=kb34e*TwF z8k4`PXU&d*)sp2S;(e2wPF_)R58qIN&pp96(eXG!t}_+@n5}pVeAiY zs8*K*aA!}~j>jI}`RXm(w?}b40b`l~O!hYhEZJ-_APQ(@6~(RFz*vlPbI$-ogiF6W zN_g)g=TDq?lz-nI`5bU~NdW6BH|*-|C`a`_9iw5uSc9<^nzLyF$$&w?5Z}L(j*oAn zF+I)MpTEQ%-}okIc5tm$BW)zQtB8+I)Vz+(!&UL!Ob8SU1B)wx-X znFGK$G2|~SIr_o3OsDEC(gsshh%R#-4#}t;;00I&O z4Fam5imJhgqBcv1T7&egqw6bQC+g^AYIKyp{NVePrl*Md2Do?|7AyGxs#H@!E8XO_+(qf`d+?PCqJJ<`t?~Y;zw-9JeY9yxDIZhx9wUl` z6jLl^<+<<-V>2?F>0Owk767$Ih*$4@9-Nym3@)EN!|=gFOr1VOrC6Yti^zKqq9}@} zVoU9dHebZ52r4Tw0LI6N1V9-(agvc&4pJQ+rkuodmkN|(Ph=hQyJ#8&jgw{0H)v2K zXn!{AN+J~H{Ncllojl3J&=9Uxr7cM)7xLs{N8&x!WI}Dh9VAoRlHH~WR+Pxt4=F?7 z--iyO6BBfKM^q>fdq*yESu2p)A~Lfd0D=fuw`2<1dV9HolD8JO#B;kKS=|2k<8%)U z&=JR!BS&Hl8UztR!@OJuL7JgKF)qRxi+{I{$a!*cLa9)s`__&4IFE{whOn{-0eW^m zNY4WgaCK;iOZ#6&M}|?8sXHspi~&QlR{&1I=5rJZ`6aUu_xBV2@psZjSd>1ypbF=r zxbZgnzV|%2&pwO<0TqmZ(acy-ZDql_mfz2hWWy~?)*IQ{6@5UIV^2Lz`#?XdwtsGA z?LBw1_OUN9wfPSI^Wuxx$%#1zT1BWB=a(>{Y`AqdQ%?iQ5>99rmSN%j_qcrID5v)B z<@aBGlFMh$QvS#$2446v4Bpn%fwY7K$?gG5y#7qJN^$*q(p2!e*bQ3%cw_2qQAAe~ z(VZkD7vAOgQ&02O3;Qr}!oatm!++eqsY!cQ*RwUwECchRUd!5Y+|fzC_a>aOG6PE1 z_#!MN=V)^gtCE=UBS(2-_a0P)fjxV$o9{$K=0ZiV&bPd|gg~uU1690pth)C;8fjRR zr4|6vEU%1KB{EQUp7toBe)=@WpV^J1fepLAMf9<)A21-2+4sD+pQ+A(W`B3bT#}>f z-uq}YLbi5!4d`55&w@adqP3L0Bb+(I@n@bzF$_Gr8~Xb*7MdcQC7@PsWcI9(BsoyX z-?$dv*SE+A7WrppI{E}VJ#&_!1HZsHOV8Jyq>*OkWV{CyRiR$50ZJT4 zIBVu;>Dc}WMAa<|APq9zNPpAp9@4y+X!D9DBIJyvU>)c8A7J92=O_;jQoR3Dgb?P+ zaAu~4ieil=iQ<;Dl(%f55u~=P4~$f&fBo*{)T4d9y^;6XBV$?`8?izhQvSC80NcLv z9P6HVf~%vW#GRd_X_|pCh9pT^I%a)lhBpr$l98F}D=ocpc2T8LX>coByW!R}eP~mX z+kr713%cr@0Vx;}@j)auSap_~2$3MJrKDPuJ9#c`93JxiH&Y_##>dAeTL1v8S+k}X zLTLBi$0FkXm;ZuUYeSl*b?4lbv9Ymhix{|G1YKNw;Z@X-yh2 zwzM{gO^XziVoDW?Rjg17deg>Okw{TcYAC1|^{$DCkW>_th@wOYHN;X)Xm>=`e#8qea^qpnoSAvgd!GOMfBw(^oPRN@%8hLHhDQHC03cfY z<)g;r@99~$YhZ0?K{9&jC1qX07Qh# zzdnwC_YxOQoqu|qUmg1taCAig8!I>M>Fp@T^*^4VVZc~}u@;)6X#xqrz+*@r+)c-a zchH!bVd%%NaMxG93K{~}YBjP(#>h`!rII*q?p_<;TDfV@ssJKPA*$E#jYgo|TCh4l zsxk8*8u=papZz?A!OherC;8LEso(*(;;mgDwolK97@#pV+o6^iQao+&%Uwgl0$?35%EQB>O zAGEO=08v3j!bEFPtIZTBh`}cbxsN|g=O-S)ILE~kf8ebj{ebqwkpZT&!ct#rOitpO z!BqrVf`6cu0SEv@K_w_m6tRYA$4O1VHOa?I2-;?7RO zO$*IhFsi6%bKUDO5CAkM8wD(GaFC8qKSt8mPnKm|9ebNMzxzGRKi{USl&6%$IAai1 zlD76`0l*?6AR79T)(SwCY9?rQGca^D9l!Cym#g=ymjCJZJJTaClsRy zBZ~M8Q!It@TpGjJKxQ+&OLNo$pw{ro+Wjwra|=I;a%JcoBZrSLefA8MVu4~VCLcv0 zilT@rw$#3C@nx)vpw|;23MNVr@qjXZ>NKOT9i}=mLOD(7E)^&x5wUeF-bFJnXp*iH z-+!Q95wBs?>xod53rCMKe)=?%!^5~*m9{jcT*#A49BC9`O%Q4eZZAP?E44YWqQu7j zmofzYb>uKQIZ0RKhzkXh$dQX(*a~E>h|Jsz051a8t(bzg-d?VvF>w?{cmIqzbt(% z3^d&rRVZ%0gT8OQNbZx5B3?iRBVaTb3#zRwSl4p@;+}50jj4Jg%v}O*nFvoj^M5Su z1O2SozMb{=-OKtXKF9RdyZHCZFJq@B=NV`L?iJ&r6-+2Jx8YXmnI~Pr372R93h%wk zm1D;_vwuIo`{L7F85*Mefh`QY^nDn-qp1UF>Eb1v16Fwa*=m*I#*Ji|5b1I^Yyl7% zQ*Vo7y3&~LG$p^mN#EIfPYC+2EP6R=FTlm+CyE>)i`quEb8@I*p`!yPV&9C z;O4Ha20#fLUyP;X9BnRUO`0%q>^QIQ-G_=Wux}rB>)nXRd{+^yi&~ysyr)*Hfhv)6 zthxUI8kt{~r4|6vEU!ST5*sMHi1s+9e)cRUpWBOMo=tndM*N}e3k-+^`+r{a^t07j z&~SFlr8&Cpe}G2AhqKcD9C!VvQw@la{oUw{4^0rM5U`iw}%eXMXX{)b!(hy}fZ1g-d2}$s0%% z5})zcgNNAhjThMP)Kgp=8zbrLB+Ie@#u(BxZP_vFv$MQ$_=t?oR()Sv9MjBAs#Gd% zWotLxo@I}0Nprg}rlTb{X8sKYBO;L(Neot - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/application-rss+xml.svg b/core/img/filetypes/application-rss+xml.svg index 7b4f1127a94..4fd98545a7d 100644 --- a/core/img/filetypes/application-rss+xml.svg +++ b/core/img/filetypes/application-rss+xml.svg @@ -1,914 +1,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/application.png b/core/img/filetypes/application.png index 3518d3116d2a6d0fadd6b09b3b592a2cb322bdce..9152cc1b744f1c06d0d5ae87c2965311f117fc1c 100644 GIT binary patch delta 951 zcmV;o14#VS3Hk?+85aWp002a!ipBr{00VPENmK|32;1RL;E^#re*t|^OjJex|Nj>k z7ZMT@6ciMRiHR5(7#0>5FfcHTjEs(sj#E=pN=iyrR#u3Jh>eYnQBhH7XlSRWr%_Q+ zSXfwET3TIQU0z;ZUteEfU|?ZkVPaxpV`F1vWMpM!WoBk(XJ=<SYo}Qnd zpP-Uu_s;a81tE;T6tgWrBudlDLu&}YQv9hwV zv$M0bw6wLgwYIjlx3{;rxVXByy1To(yu7@=zP`Y~z{SPI$;rvf%gfEp&Ct-$($dn@ z)YRA4*V)R5(w?l1*+CK@^1RwR@u2*n!9b>`fBP0=5>BI0)Q;b8!PM!j2_DRssUB6ddpVVEz|Ca%XS@w3#>hofee=5Uf^Mfq~E%kBsr!sWj&qAZo zXv7$TL1aqq?reU#1Ok8|DM_N!NvGc)IRp>^R0Em;K@gqQ4f?Ht)tV-q9pF`$qDVP&)I(YIcvHfk&4`dkj0_W!`xKvW6gGxSDR}c@|I}Vq<#ICdvB*0_yqk zhUlMgX4YJ&mI1VYl0rzV9QYL`sS0c^k)4ekRZu<6LXK zajcZ`hr{8+v$HdRKQ{tUN_~K72q3fiZ@iogK0)Thf0k27l@(ZP#X5hEj^@bP7OOmh^f( z`u#pxmI2W3_t9GO{{4G|5DW$b_V@P*f`E3r{of=wJ3B*4i4X!QB}yr7-MYo;>8V>Y zpU*iwJY+B!5Cj25QE+i_fiY&S54Mt^&cJFz8e_=w-0cnUxldO0UfrCwX21s6#P{#t zXFi`Z9DfeEy1GJZ&1f{D)9EZFisRVrmb<&Vbh};l_V&p0d?gNGU1H()EPz`%WsQlw&N8W2&m6 z)oLxBigkIdt(^sRq}HP-A`C;c)*KxjadL7(v)Od>&1RF6lM}k#E?R5CFm#(&-LEBq zy$=W>$n%`z<71}NDZ9J7eERf>D2m)^7)2362ztF9w{PF3-EK1&43_k_3~VLADga{) zuYX>>;>L{|eEj(FbKn=vEpU4{-Mo3zy%DPylT8w=F<`G#Qp%!-48wM}+kJL* zbrmK_@;l&dtn%Zg7mLL|qtWPD7>4cfcsvCV^?%2mPG?VRec=0k!x-~Z0Z1veQmXJg jZxYAx-2T1<;8)ncR5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/audio.png b/core/img/filetypes/audio.png index cd9821ec047ff066ac222f7434fd318f1968a6c6..3f56a7e2a9a976c91965495dfe7bc76667df5f75 100644 GIT binary patch delta 747 zcmcb`wt;Peq&PDJ1B1(wu46!ox!B1wgoA_Q_Cx;%6Af+Z8Px)OLR|m<|1T~sE+ix* zA|fIoAt5Fv#>&dd!otGF#>URh4ph#`$;r*l4dFsWfC`XhxwyE13V3*U`1ttv`S}F| z1Ox>IAqGlHN=i#h%gM{0tEi}`s;a7~sj1hit7~XzXliO|X=!O|YwPIf z=<4d~>FMd~>l+vt7#bQH85tQH8=IJzn3|fJnVFfJn_E~|SXx?ISy@?ITie*!*xK6K z+1c6K+dDWoI668yIXO8yJG;2JxVpN!xw*N!yL)(eczSwzd3kwzd;9qK`1<<#`T6<# z`v(LB1O?Rxg@lBJhK7cPg@uQQM@B|QM@PrS#U&>vPntAo%9JTnr%s(VZQ6_(GiJ`5 zIcwIe$c}h_U?2*X1o;IsaPvtiC?7k269jHQe)>XHGGZ?S17p0Wi(`m{rnLz}IrdKV4$WFF9!?CegKJ{?Qq%UcvVBShY8Q@`=vST9FXD&oM3RoX)L7 z%H{|9PlcM^I^=ecxBa}a{6#ijXEUw%dH1iST@nlHT4bu8zuqpkD0oY&T1S{!`TJwn zb3!kP&C)h1POC4n+GClfy_DC?EpVIBbE9*LTDcdN6a*WsogL+}gm;#3_|#Cp9e2bQ zZDEY?w7k5Cb2m$1qvP&5My(4p_v~oU$i48*ox|x_p^}P{hxC?70zY=D3kW%OnPr@M zwSk|5g=L~y#K~1mJM?BL%x(=c+q3ZQ&O>2a7+0(*TmS9+yE64KPbDs%Sxm=%KCPAQ zTLV;`p*g#qU5<0o7REPmd)0o--eK){VAJlt2bzCNHJLh8o0e~Ra=(tbZil;Do&W#< delta 789 zcmV+w1M2*+2HFOY85jlt0047(dh`GQ00eVFNmK|32nc)#WQdV4Jbwb$NkljXNJ~TI#Lga&gFhy2 zv_i{eEm^T$ci!{No3UBfb@h zrTj(`5JD7JS65$s0)J*~2$;F~8sp|`2-xdp?eg;SmyPKV0DzmD8{FUDgE2;S18mQ` zuIsx!*IGOM`1m;ROyJY)cI&u}N>dx~`uZADN@t$|S4u%C)sO4C-c3Mj9RT|$v_Yhl zD9f^6H=s6f+qV68CxO^$DIx%{SS*|q`y}i>nn278K9T3=XMa3AJoG1xb-x87G$CM& zk@2Sp0l?ke9VU|r_V@RLQ=2|I1eBufu`y;0o}Zs%Z*LE`x3_4TX7Kc*Lg2gI2lkD2 zU57MHadB~hBuVi2_&BHo%A+I!D$ce+JJ!Hk>eh9Q)6-KtJw1^GhEh7vfK7xk*1OF% zVtb_Px}Fs09Diw=LQ3gqXefI~0#rGry6w`oZTq#u!$WAT!8s2~^e6(hT8DuBxZ3KL zQudkPgYP6@+-YKK0~o=@ZaM(Svdqc%U1113&@>IU+pVK=)2J)jH#(h8(KO8;OD;I zHk%DLn{v(I?=b>n9wfXd3e09R0CeH`o921I(H%2C7DbV-R;wREh#3IR7!x0Y{!T&x z&`PP_d7gh?E|)8Z000~v9Zi)|Uy>xrwALR=fOD?ewv|GNsw~SshAbBEf6@K`*HYuK TH+&xa00000NkvXXu0mjfDmixI diff --git a/core/img/filetypes/audio.svg b/core/img/filetypes/audio.svg index f742383d632..d5eda38e8aa 100644 --- a/core/img/filetypes/audio.svg +++ b/core/img/filetypes/audio.svg @@ -1,274 +1,49 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/code.svg b/core/img/filetypes/code.svg index 1dee047b11f..61a5c19f511 100644 --- a/core/img/filetypes/code.svg +++ b/core/img/filetypes/code.svg @@ -1,359 +1,66 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/file.svg b/core/img/filetypes/file.svg index f0c0f1daf7e..3d91c341143 100644 --- a/core/img/filetypes/file.svg +++ b/core/img/filetypes/file.svg @@ -1,197 +1,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/flash.svg b/core/img/filetypes/flash.svg index 60cab4ad380..cb823703d9b 100644 --- a/core/img/filetypes/flash.svg +++ b/core/img/filetypes/flash.svg @@ -1,310 +1,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/folder.svg b/core/img/filetypes/folder.svg index dd80b695bb1..92d4cc22718 100644 --- a/core/img/filetypes/folder.svg +++ b/core/img/filetypes/folder.svg @@ -1,329 +1,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/font.png b/core/img/filetypes/font.png index df44a7fc47db6c6edce188fa5e00ead07456bf97..9404c3ca6ac330d3639a00e0b4c618e52172c2a2 100644 GIT binary patch delta 1606 zcmV-M2D$lx4xtT@Zhsz0L_t(oh3!^pY!r1AFNla>MWt6t>Gq)Aw$quNV`p}^d-Oi& zLFs`}0s+xL2obCj@hDNT5I-2sl(TAqaA|Eq6A&qsgdbmc zMx(JEowg(=Cx3U-vreb8VR=&e>YOvGgD)Cm7g>|p%1bG1wKbL9XHDe}Ta%c|OQvYk zV-dhwTPgkSh&u&Au;7_JFE0;}NDrP>d1TM(W0KA%vU|>%8E4DPjLttlcokX~O@Zs5 zO@kX{)8X2JBDj#qI?g4;O?@N+7`;f&DCOwvE;{?pn|~Bd1Cg2~Nq%Qc@zqT!y#4aD zw4UYyW5@Yy#5bv;F4sIbhpR;=*rlPUvdX$Cf@40W`ioF)^{5qNjA@bCUbK z1k2%|bECmv|5B&9a%O_At0~7|KV^u&c~Td*;Di!qKB2^9p42nT8nYC~-z(+WsS}-1~i*sHw5&bguW7gaj~) z;g>rtsJG~BbsSSPAOV_vT)hq=px5i$@%dfs{2&jiG+ax4 zZhtDwGaJBUH1?1jX6U}1P^;n2Hsz;7%d~tKYI%*lmSI8%B!JOaEfx!n9z}K=(cyuN z<>!P44e2P$J?#N6X5dXY-ldXgxw5h8*mfS?4uz&Ie#2b zLsG9G5nnVrq=w%8Cgb5csvR{Sqw)HAW+@Rvi*QF9J0Cn0^Ok0HY@Y_jN2`ZK!ahI$Z2I z5Gev-KVo-;2qsaYCZxTAeW11DeUY{%RBYH4eot;&nBXiQC*1j3B{_A}}y8-~rgWYSk*NS+fTH{r!+qK7OsvuNuJj{ViH+ zC#8h77C{gI!0pXubM1cxKqg1t^5Ie`8ZV`=Q-O_gpoA5MnfnqR1G7JkOQ2c558RzpqxSDvF|N ztJNA^0C?-JJMI;}{yK#Eq<`zp?Dh2oq!ma>kQ6BA;(y`R{$mdx{luLkw~rlp0l2~z zG@H#q0DYe4Ax%>U;FXDqiPr&~$@3gx7!rVoMw-pu$-CFR#8L2ycT4{RvbV>j({tJU zzN7N&rBuR?`6Vr9eAPGBdQ+l;`zEVmtGurKTo0(0w#$(ikIG=0IF$zK~gb+axL`tcuHRh{^ z#7%Xrs|$6F)1_e8Xq5j zt6TH@+QIk(nW_2$Fiz+wH;;}5@^@ufZdFPNDTR7NIcny3i9q)hnYoz+kQkse7XvKT zfkvaz2Vj#B;(T^HM`c<5dg%aTk>rI%nH$^y69}fex3ut}FqW7ZkP-(K(SHo&sBx4o zXba0^q3D^_8+JXtdN6(FgM*td0MJ@*6GGU|>H*;3p+kqxECnbT)AL4hW)*U)utJK; zkj0IXnXI*7W)yZIf;{8gJ_Xut8LDJnc>w@`$A~CmW>{v1Dq`xbJk&P#$e~b%pgG#fUnKwMS8|K%o@OB@_U7l ziG?+melU9S;LjHU8jZ%s0rYi34`$X=Q&X=2hycirDFFK0({CJ`w#AQ*6=nOhahNfT z6S*ye`8;>l7MD5bstAac&3 zW4l|eRtrFPG2o8bpUfP2@~kPoHC?(Rr%U_ycTDk%L;srjoCD4+%t1unWUsGd<9>Ux zw8iPdzJ10OU;fU_o8JV$+_|`D;cZAn9)Pg3QU@RdP%IpfrMb|7S6va(orviUXbvC+ xU_Mpp3y&se=HCWN03epT9;EdD$LaM3_&2hWVXo7r - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/image-svg+xml.svg b/core/img/filetypes/image-svg+xml.svg index f9b378887f3..06df5f54da6 100644 --- a/core/img/filetypes/image-svg+xml.svg +++ b/core/img/filetypes/image-svg+xml.svg @@ -1,666 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/image.png b/core/img/filetypes/image.png index 83d20fdb7762d4b52b398c80e4ecc3fb6f2d5470..087f5dcdbdf61777512cbf7985715f0a12124a19 100644 GIT binary patch delta 908 zcmV;719SY+2hazQ85aWp002a!ipBr{00VPENmK|32;1RL;E^#re*v>lOjJex|Nj60 z00000000000000004OLZDJdx`Dk>{0D=aK5EiElBE-o)GFEB7LF)=YRGBPtWGc+_b zH8nLhHa0gmH#j&rIXO8xIyyT$J3Kr*Jv}`>K0ZG`KR`f0K|w)6LPA4BLqtSGMMXtM zMn*?RM@UFWNl8gce@aSAOG`{lOifKqPEJlwPft)#P*G7)Qc_Y=Q&Ut_R8>_~R#sM5 zS65hASXo(FT3T9LTU%UQTwPsVUS3{bUteHgU}0flVq#)rV`F4wWMyS#XJ=<>mzS5An3$WJo1UJYqN1XurKPEzrV=H$jQmc%F4>k&CSlv&d<-!(b3V;($dt_)YaA1*4Eb7*VowC*xTFN+}zyV z-QC{a-rwKff8gNY;o;%p;^O1ulq(=H}<;=jiC@>FMd}>gwz3>+J08?d|RE z?(XmJ@9^;O@$vEU^78ZZ^T0u}p#T5?26R$RQvd-19xO9ymSSiC00DhTL_t(I%f*sQ zYZOrwguin$vGXD_YJ`lD+2}^lg^_HsaiM$tCxU;(e}5wQ3lvw01`%9H%pyL>DEJ`Y zn0a-Ti|(HE7&ANZZ0?1sTc^&s1^>T-M^o_!4NRO08yYyC=h$Eu2gO~M?wJPWsDJXU zWZ8lS3cDr=U`v)&5KOM|!+ZuTNd=|wz_CKM_P*~Dl~tNV0&t$v+RAXZ!ezw-VY$`Y z%RJW`f1LZ43W8_qEp+CBo5{X*KI?2t7LYtPDfvTlWj;S#I?M2LzjUpNFp}ia&gRnA z$JI^0ew(VPOTu6v4Tm>Zv!gxsZ)Gqo@01lFP!bDO_IMY8`YsSGvbP zGal2x;`(Dh0e0(osa9>^?yLM{plXEn?7P3DrfLzy)t89~B7z8lAR-n@!b5=Tr-e3| iX_X>UOo_e4zpvk=^$&&_6P$Md0000SP4p68%qVTP}IsoR4heA zjrajZ)Trb`lFjbUQ*GGYe7t!ce4jM$fy3-D!`%1W=ggT|A*H09rnD9Pe*%CPpin5Z zB@w#1x`Y?NN<<;VUw;9%Cw`TH5Q3$pB}%1Ib&`Feyg4gS<0*sE1GBGhhAP``Gf1ka*y_#Ly zO;MD_1neQOFMsmz@WAo$F~h^d1cO0zT_>GR6OYH~@9zhoTrP8Yc}clkZkou}nhgo) zx?UrluIp@XZxfA1>FMcVd3l+qrzfJ(D2t1WNGVxeUFGWP3Povty|`6&5U?`Y0=F_Z zkw`E*JBzBS~G8rs#OM)^b%<9R!4wl5{%VmRE5+9v6xbLiybX$xpcuLJ@!fV!%H@$6wlf8OQ-o kqLoMJe`#(1HETP8UxCcTx6i@D5&!@I07*qoM6N<$f>aNnwEzGB diff --git a/core/img/filetypes/image.svg b/core/img/filetypes/image.svg index 440b6af7ac0..50991f7359d 100644 --- a/core/img/filetypes/image.svg +++ b/core/img/filetypes/image.svg @@ -1,321 +1,61 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + diff --git a/core/img/filetypes/text-html.png b/core/img/filetypes/text-html.png index de11613f25f41a5918b041f358a66cd38366eaaf..dd17b7501034216c35e9273dc7e3858d486d2aed 100644 GIT binary patch delta 584 zcmV-O0=NC;1&#%f85aWp002a!ipBr{00VPENmK|32;1RL;E^#re*o}MOjJex|Nj60 z0000000000006$ezM-L^mzS5BnVFuRo}i$hp`oFoqN1atqokyyrKP2&rlzN-r>Ll? zsi~=|s;aB2tE{Z7t*x!EudlGMu(7eRva+(Xv$M3cw6(Rhwzjsnx3{>sxVgExy1Kf% zySu!+yuH1>z`(%4f5E}R!otJD!^FhI$;rve%F4~n&Ck!z($dn_*4Ee8*Vx$D+}zyV z-QC{a-rwKf;Nall;o;)q;^X7vlt)=I7_<=;-L_>FMg~>g((4?Ck9A?d|UF z?(gsK@bK{Q@$vHV^7Hfa^z`)g_4WPz{r~^}4?0_v00007e{@n#Qvd-14-@F=?TSR& z0002}Nkl~m> z5!8BK=WNbCi6o^9lT?xtNt!S343_hg0Nwz;2r~F4*nA46qMvN|13@P7hV}M1xm{Zk z<=zAE_JH4)f9E|^WmW)$*9ApZR&ftu(=Td(b^nUG=x;(4;WYIC-OF_YekvCUDZ36} zb1?zB9cgrCK5(@pJ>52vYB$KEGY_+#3*eXl!S!Z`_)MSU;Q1y1j@+O1&?e&y?u!n{ z#z}i#R5KdF_5d&(HP*AL`dD>c{nxvH6>*svT%Lp^CafL}Rw4NiXuV0xNeCt_lHLKP Wy+U7gQ>a@20000@UpU)i9kYL*p9o?oy783U3|Y)CwUF9H)#u;UE(>D}t7^B~Ka4SDjvyh#&sMATeRa=X57JtfTdfwBW#w92 zYfZb|PTg1vz!*amMSm!zas{w$n{~GVQnzW0$qYPHoAPEla14l@09JqVhS&<=N%JkP`T{f*Zb%lCae&)ax?FM!!>#&kN}2+-+tczSwT0!*h?UtcfhNWEUCSS&Ia3{Xn#=783E89W}30cbXx#BrP|uC=Dy?Q(m2 zi>lnJOi{m&< zCKIA4O8vRl>wj@~cZZZRu^&YdlgR|fad2HXGxt^wgkeanR-;fTFdPmO&-3;56)7c^ zN+s1d!{LxZp+K!xBMigCj$s_fG#ZU%Pb~Jk-7YsbH>oCD#55X>%)VLIUth%^A0ODZ zO{G#v*!b}9fRr-zXv*bZUtN}ECBCW-ngvoyuCA`oT72{V{tkfe`>A9AmzS4VmPHtb znR)jD00@F0v*5b2nl%@IL-l0=PCkxL?!easux*?3^YdH*7PI7!073}s@$vEP`T6-< zuGN3%e-lDj#+c<;6suH12mv_jU^z+wzF8?Mj@k9w=o57qG24cv!y^Cy002ovPDHLk FV1gQzIw$}D diff --git a/core/img/filetypes/text-html.svg b/core/img/filetypes/text-html.svg index bf29fbcbbf2..c41964738d0 100644 --- a/core/img/filetypes/text-html.svg +++ b/core/img/filetypes/text-html.svg @@ -1,280 +1,49 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/img/filetypes/text.png b/core/img/filetypes/text.png index 2b96638d16c9af6b5f98350c4ec102d4975c1b64..6b069c82c119a5bc115cd657b9752215b8cd1044 100644 GIT binary patch delta 623 zcmV-#0+9Xn1+@i`85aWp002a!ipBr{00VPENmK|32;1RL;E^#re*ouDOjJex|Nj60 z0000000000003lUWK&a9c6N4nczAhvd3$?%e0+RsxVgExy1Kf%ySu!+yuH1>zP`S{zrVo1z`?=6!otGC z!^6bH#KpzM#>U3Tf5^zm$;ryf%FN8n&CSiu&d$%z&(YD*+S=OO+}z#W-QM2b-{0Th z;Naom;o{=ruz*=jZ3>=;-O`>FVn0>+9?6?CkCB?e6aG@9*#M@bK~R z@$&NW^Yioc^z`-h_5J<*|NsAsvZUAm000qmQchC<0Rj&be{*}LrlzK*rlzK*t-3L% zIDt{%g4(scvqhP-tQwEXTGu}!N<5}Kh44bjnP3$mu9WY)iKb_v{k)n{q1JI#E z6Lqjtf2Rk_pE1b)*S@L?fF1w^OsWf?_s|~!YNCn&>5F@moo@|Sp}XMVyv_gs002ov JPDHLkV1i{gTR8v# delta 688 zcmV;h0#E(51@#4x85jlt0047(dh`GQ00eVFNmK|32nc)#WQdV4JbwamNkl=Wc2_Dxnwh@dAgkch$;iOg(~ z9cz4Hjln7QZ@|YhXa4h_%UCF-FfpIce~d<>JH7y$&F1&xSw9LJ&G@6&F#ONr$O=;-x9*VoqwAy7&ogh;K^b|ClPd^Y_aq=312 zwORqBqSgN$$03R$JkLW)NgT&0rBZ5iyIlr@!Qm;8QlU3I zUS0rbwOS~plJ@jG41fDgB+erKo`naOv9s!aJgIp`8Ev05Zkti;~2+r zk`~nOKR!MfkAKH0pG7DgM5h#CErUoaVB0oQ%F1mxolZ|{!<(C%vL$}H!>?LT|BKhx*Od^Wp_EG42vZvIIlRARiPeZ5uvNyPqV8N*#UF(t W?ly-EnGJFP0000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- GitLab From 33ac4d93d63b98761cf9c09467dcad7bc5d34bf0 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 12 Jul 2013 10:03:25 +0200 Subject: [PATCH 098/635] OC\Preview - use !== and === instead of != and == --- lib/preview.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 73e01a9e552..5576981225b 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -305,7 +305,7 @@ class Preview { $y = $size[1]; $aspectratio = $x / $y; - if($aspectratio != $wantedaspectratio) { + if($aspectratio !== $wantedaspectratio) { continue; } @@ -691,7 +691,7 @@ class PreviewManager { } $path = \OC\Files\Filesystem::normalizePath($path, false); - if(substr($path, 0, 1) == '/') { + if(substr($path, 0, 1) === '/') { $path = substr($path, 1); } @@ -768,7 +768,7 @@ class PreviewManager { public static function post_delete($args) { $path = $args['path']; - if(substr($path, 0, 1) == '/') { + if(substr($path, 0, 1) === '/') { $path = substr($path, 1); } $preview = new Preview(\OC_User::getUser(), 'files/', $path, 0, 0, false, true); -- GitLab From 21abebf96a45323b81ddf057d3851d25085b59ad Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 12 Jul 2013 11:50:24 +0200 Subject: [PATCH 099/635] OC\Preview - proper handling of a cached previews's filename --- lib/preview.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/preview.php b/lib/preview.php index 5576981225b..08c0b7e20d0 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -283,6 +283,10 @@ class Preview { $fileinfo = $this->fileview->getFileInfo($file); $fileid = $fileinfo['fileid']; + if(is_null($fileid)) { + return false; + } + $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/'; if(!$this->userview->is_dir($previewpath)) { return false; @@ -293,18 +297,19 @@ class Preview { return $previewpath . $maxX . '-' . $maxY . '.png'; } - $wantedaspectratio = $maxX / $maxY; + $wantedaspectratio = (float) ($maxX / $maxY); //array for usable cached thumbnails $possiblethumbnails = array(); $allthumbnails = $this->userview->getDirectoryContent($previewpath); foreach($allthumbnails as $thumbnail) { - $size = explode('-', $thumbnail['name']); - $x = $size[0]; - $y = $size[1]; + $name = rtrim($thumbnail['name'], '.png'); + $size = explode('-', $name); + $x = (int) $size[0]; + $y = (int) $size[1]; - $aspectratio = $x / $y; + $aspectratio = (float) ($x / $y); if($aspectratio !== $wantedaspectratio) { continue; } -- GitLab From c834d93e8778bbbe008c992e6fab5250296ec216 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 12 Jul 2013 14:16:06 +0200 Subject: [PATCH 100/635] OC\Preview - update git submodule --- 3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty b/3rdparty index 21762672395..31ed0ab78e4 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit 217626723957161191572ea50172a3943c30696d +Subproject commit 31ed0ab78e48d7515740b05f64c07a2b0648421f -- GitLab From 1303fe0f9fe7c67764fb48cbb84fcb30e4a32b33 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sun, 14 Jul 2013 00:00:10 +0200 Subject: [PATCH 101/635] OC\Preview - set scale factor down to 2 and upscale cached preview - this got lost in a git stash ... --- lib/preview.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/preview.php b/lib/preview.php index 08c0b7e20d0..03aaaceb9ca 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -60,7 +60,7 @@ class Preview { //set config $this->configMaxX = \OC_Config::getValue('preview_max_x', null); $this->configMaxY = \OC_Config::getValue('preview_max_y', null); - $this->maxScaleFactor = \OC_Config::getValue('preview_max_scale_factor', 10); + $this->maxScaleFactor = \OC_Config::getValue('preview_max_scale_factor', 2); //save parameters $this->setFile($file); @@ -377,6 +377,7 @@ class Preview { if($cached) { $image = new \OC_Image($this->userview->file_get_contents($cached, 'r')); $this->preview = $image->valid() ? $image : null; + $this->resizeAndCrop(); } if(is_null($this->preview)) { -- GitLab From 65affdc9b32629ab4692f77ffd4dff77e026b1dc Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 29 Jul 2013 14:40:26 +0200 Subject: [PATCH 102/635] make previews in files app smaller --- lib/helper.php | 4 ++-- lib/preview.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/helper.php b/lib/helper.php index 6153f318723..0853c792750 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -231,11 +231,11 @@ class OC_Helper { * Returns the path to the preview of the file. */ public static function previewIcon($path) { - return self::linkToRoute( 'core_ajax_preview', array('x' => 44, 'y' => 44, 'file' => urlencode($path) )); + return self::linkToRoute( 'core_ajax_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path) )); } public static function publicPreview_icon( $path, $token ) { - return self::linkToRoute( 'core_ajax_public_preview', array('x' => 44, 'y' => 44, 'file' => urlencode($path), 't' => $token)); + return self::linkToRoute( 'core_ajax_public_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path), 't' => $token)); } /** diff --git a/lib/preview.php b/lib/preview.php index 03aaaceb9ca..c570a17e4a7 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -784,7 +784,7 @@ class PreviewManager { public static function showErrorPreview() { $path = \OC::$SERVERROOT . '/core/img/actions/delete.png'; $preview = new \OC_Image($path); - $preview->preciseResize(44, 44); + $preview->preciseResize(36, 36); $preview->show(); } } \ No newline at end of file -- GitLab From e01bc7de987ddb7d33feb75ad598bdf97c348105 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 29 Jul 2013 14:46:20 +0200 Subject: [PATCH 103/635] Revert "OC\Preview - outsource static methods" This reverts commit 14a35267c15115a1e7d2901ddd9b8c5c7e1b9a31. --- core/routes.php | 7 +++---- lib/preview.php | 37 +++++++++++++--------------------- lib/preview/images.php | 2 +- lib/preview/libreoffice-cl.php | 10 ++++----- lib/preview/movies.php | 2 +- lib/preview/mp3.php | 2 +- lib/preview/msoffice.php | 12 +++++------ lib/preview/pdf.php | 2 +- lib/preview/svg.php | 2 +- lib/preview/txt.php | 6 +++--- lib/preview/unknown.php | 2 +- 11 files changed, 37 insertions(+), 47 deletions(-) diff --git a/core/routes.php b/core/routes.php index c0e658b26dc..41e82f8a73d 100644 --- a/core/routes.php +++ b/core/routes.php @@ -42,13 +42,12 @@ $this->create('js_config', '/core/js/config.js') // Routing $this->create('core_ajax_routes', '/core/routes.json') ->action('OC_Router', 'JSRoutes'); -OC::$CLASSPATH['OC\PreviewManager'] = 'lib/preview.php'; $this->create('core_ajax_preview', '/core/preview.png') - ->action('OC\PreviewManager', 'previewRouter'); + ->action('OC\Preview', 'previewRouter'); $this->create('core_ajax_trashbin_preview', '/core/trashbinpreview.png') - ->action('OC\PreviewManager', 'trashbinPreviewRouter'); + ->action('OC\Preview', 'trashbinPreviewRouter'); $this->create('core_ajax_public_preview', '/core/publicpreview.png') - ->action('OC\PreviewManager', 'publicPreviewRouter'); + ->action('OC\Preview', 'publicPreviewRouter'); OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; $this->create('core_lostpassword_index', '/lostpassword/') ->get() diff --git a/lib/preview.php b/lib/preview.php index c570a17e4a7..113b200c29b 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -44,6 +44,10 @@ class Preview { //preview images object private $preview; + //preview providers + static private $providers = array(); + static private $registeredProviders = array(); + /** * @brief check if thumbnail or bigger version of thumbnail of file is cached * @param string $user userid - if no user is given, OC_User::getUser will be used @@ -78,13 +82,11 @@ class Preview { $this->preview = null; //check if there are preview backends - $providers = PreviewManager::getProviders(); - if(empty($providers)) { - PreviewManager::initProviders(); + if(empty(self::$providers)) { + self::initProviders(); } - $providers = PreviewManager::getProviders(); - if(empty($providers)) { + if(empty(self::$providers)) { \OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR); throw new \Exception('No preview providers'); } @@ -384,8 +386,7 @@ class Preview { $mimetype = $this->fileview->getMimeType($file); $preview = null; - $providers = PreviewManager::getProviders(); - foreach($providers as $supportedmimetype => $provider) { + foreach(self::$providers as $supportedmimetype => $provider) { if(!preg_match($supportedmimetype, $mimetype)) { continue; } @@ -549,16 +550,6 @@ class Preview { return; } } -} - -class PreviewManager { - //preview providers - static private $providers = array(); - static private $registeredProviders = array(); - - public static function getProviders() { - return self::$providers; - } /** * @brief register a new preview provider to be used @@ -574,7 +565,7 @@ class PreviewManager { * @brief create instances of all the registered preview providers * @return void */ - public static function initProviders() { + private static function initProviders() { if(count(self::$providers)>0) { return; } @@ -600,8 +591,8 @@ class PreviewManager { \OC_Util::checkLoggedIn(); $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; - $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44'; - $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44'; + $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36'; + $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36'; $scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; if($file === '') { @@ -644,8 +635,8 @@ class PreviewManager { } $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; - $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44'; - $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44'; + $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36'; + $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36'; $scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; $token = array_key_exists('t', $_GET) ? (string) $_GET['t'] : ''; @@ -781,7 +772,7 @@ class PreviewManager { $preview->deleteAllPreviews(); } - public static function showErrorPreview() { + private static function showErrorPreview() { $path = \OC::$SERVERROOT . '/core/img/actions/delete.png'; $preview = new \OC_Image($path); $preview->preciseResize(36, 36); diff --git a/lib/preview/images.php b/lib/preview/images.php index 84ab9f1ae43..987aa9aef0a 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -30,4 +30,4 @@ class Image extends Provider { } } -\OC\PreviewManager::registerProvider('OC\Preview\Image'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\Image'); \ No newline at end of file diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index ffe8de505f7..2749c4867e9 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -80,7 +80,7 @@ class MSOfficeDoc extends Office { } -\OC\PreviewManager::registerProvider('OC\Preview\MSOfficeDoc'); +\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 { @@ -91,7 +91,7 @@ class MSOffice2003 extends Office { } -\OC\PreviewManager::registerProvider('OC\Preview\MSOffice2003'); +\OC\Preview::registerProvider('OC\Preview\MSOffice2003'); //.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx class MSOffice2007 extends Office { @@ -102,7 +102,7 @@ class MSOffice2007 extends Office { } -\OC\PreviewManager::registerProvider('OC\Preview\MSOffice2007'); +\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 { @@ -113,7 +113,7 @@ class OpenDocument extends Office { } -\OC\PreviewManager::registerProvider('OC\Preview\OpenDocument'); +\OC\Preview::registerProvider('OC\Preview\OpenDocument'); //.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm class StarOffice extends Office { @@ -124,4 +124,4 @@ class StarOffice extends Office { } -\OC\PreviewManager::registerProvider('OC\Preview\StarOffice'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\StarOffice'); \ No newline at end of file diff --git a/lib/preview/movies.php b/lib/preview/movies.php index f4452e02fc2..8531050d112 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -39,5 +39,5 @@ if(!is_null(shell_exec('ffmpeg -version'))) { } } - \OC\PreviewManager::registerProvider('OC\Preview\Movie'); + \OC\Preview::registerProvider('OC\Preview\Movie'); } \ No newline at end of file diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index baa24ad129e..835ff529000 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -43,4 +43,4 @@ class MP3 extends Provider { } -\OC\PreviewManager::registerProvider('OC\Preview\MP3'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\MP3'); \ No newline at end of file diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php index 9f6ea7f74cf..ccf1d674c7a 100644 --- a/lib/preview/msoffice.php +++ b/lib/preview/msoffice.php @@ -20,7 +20,7 @@ class DOC extends Provider { } -\OC\PreviewManager::registerProvider('OC\Preview\DOC'); +\OC\Preview::registerProvider('OC\Preview\DOC'); */ class DOCX extends Provider { @@ -50,7 +50,7 @@ class DOCX extends Provider { } -\OC\PreviewManager::registerProvider('OC\Preview\DOCX'); +\OC\Preview::registerProvider('OC\Preview\DOCX'); class MSOfficeExcel extends Provider { @@ -95,7 +95,7 @@ class XLS extends MSOfficeExcel { } -\OC\PreviewManager::registerProvider('OC\Preview\XLS'); +\OC\Preview::registerProvider('OC\Preview\XLS'); class XLSX extends MSOfficeExcel { @@ -105,7 +105,7 @@ class XLSX extends MSOfficeExcel { } -\OC\PreviewManager::registerProvider('OC\Preview\XLSX'); +\OC\Preview::registerProvider('OC\Preview\XLSX'); /* //There is no (good) php-only solution for converting powerpoint documents to pdfs / pngs ... class MSOfficePowerPoint extends Provider { @@ -128,7 +128,7 @@ class PPT extends MSOfficePowerPoint { } -\OC\PreviewManager::registerProvider('OC\Preview\PPT'); +\OC\Preview::registerProvider('OC\Preview\PPT'); class PPTX extends MSOfficePowerPoint { @@ -138,5 +138,5 @@ class PPTX extends MSOfficePowerPoint { } -\OC\PreviewManager::registerProvider('OC\Preview\PPTX'); +\OC\Preview::registerProvider('OC\Preview\PPTX'); */ \ No newline at end of file diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index 0d289e9db94..3eabd201156 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -36,5 +36,5 @@ if (extension_loaded('imagick')) { } } - \OC\PreviewManager::registerProvider('OC\Preview\PDF'); + \OC\Preview::registerProvider('OC\Preview\PDF'); } diff --git a/lib/preview/svg.php b/lib/preview/svg.php index 5507686af97..bafaf71b15a 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -39,6 +39,6 @@ if (extension_loaded('imagick')) { } } - \OC\PreviewManager::registerProvider('OC\Preview\SVG'); + \OC\Preview::registerProvider('OC\Preview\SVG'); } \ No newline at end of file diff --git a/lib/preview/txt.php b/lib/preview/txt.php index acbf34c5e42..c7b8fabc6b0 100644 --- a/lib/preview/txt.php +++ b/lib/preview/txt.php @@ -46,7 +46,7 @@ class TXT extends Provider { } } -\OC\PreviewManager::registerProvider('OC\Preview\TXT'); +\OC\Preview::registerProvider('OC\Preview\TXT'); class PHP extends TXT { @@ -56,7 +56,7 @@ class PHP extends TXT { } -\OC\PreviewManager::registerProvider('OC\Preview\PHP'); +\OC\Preview::registerProvider('OC\Preview\PHP'); class JavaScript extends TXT { @@ -66,4 +66,4 @@ class JavaScript extends TXT { } -\OC\PreviewManager::registerProvider('OC\Preview\JavaScript'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\JavaScript'); \ No newline at end of file diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index f9f6fe957b2..a31b365722e 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -40,4 +40,4 @@ class Unknown extends Provider { } } -\OC\PreviewManager::registerProvider('OC\Preview\Unknown'); \ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\Unknown'); \ No newline at end of file -- GitLab From 1e4ec2ac276b15232824da056b6253696d324d42 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 29 Jul 2013 15:47:17 +0200 Subject: [PATCH 104/635] add class='preview-icon' to rows in file app that make use of previews --- apps/files/templates/part.list.php | 12 ++++++++-- lib/preview.php | 18 +++++++++++++- lib/public/preview.php | 38 +++++++++--------------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 9e62c991975..b87000a8993 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -34,9 +34,17 @@ $totalsize = 0; ?> - style="background-image:url()" + + style="background-image:url()" class="preview-icon" + + style="background-image:url()" + - style="background-image:url()" + + style="background-image:url()" class="preview-icon" + + style="background-image:url()" + > diff --git a/lib/preview.php b/lib/preview.php index 113b200c29b..245ad64014e 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -771,7 +771,23 @@ class Preview { $preview = new Preview(\OC_User::getUser(), 'files/', $path, 0, 0, false, true); $preview->deleteAllPreviews(); } - + + public static function isMimeSupported($mimetype) { + //check if there are preview backends + if(empty(self::$providers)) { + self::initProviders(); + } + + //remove last element because it has the mimetype * + $providers = array_slice(self::$providers, 0, -1); + foreach($providers as $supportedmimetype => $provider) { + if(preg_match($supportedmimetype, $mimetype)) { + return true; + } + } + return false; + } + private static function showErrorPreview() { $path = \OC::$SERVERROOT . '/core/img/actions/delete.png'; $preview = new \OC_Image($path); diff --git a/lib/public/preview.php b/lib/public/preview.php index a7487c485f1..e488eade4da 100644 --- a/lib/public/preview.php +++ b/lib/public/preview.php @@ -1,33 +1,11 @@ . -* -*/ - -/** - * Public interface of ownCloud for apps to use. - * Preview Class. - * + * 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. */ - -// use OCP namespace for all classes that are considered public. -// This means that they should be used by apps instead of the internal ownCloud classes namespace OCP; /** @@ -47,4 +25,10 @@ class Preview { return(\OC_Preview::show($file,$maxX,$maxY,$scaleup)); } + + + public static function isMimeSupported($mimetype='*') { + return \OC\Preview::isMimeSupported($mimetype); + } + } -- GitLab From 2ea8ee613986216a420fad2795b5e7fa89519d5e Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 29 Jul 2013 16:27:40 +0200 Subject: [PATCH 105/635] add class='preview-icon' in trashbin app as well --- apps/files_trashbin/lib/trash.php | 2 +- apps/files_trashbin/templates/part.list.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 4174ef0d185..71e76770aa9 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -858,6 +858,6 @@ class Trashbin { } public static function preview_icon($path) { - return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 44, 'y' => 44, 'file' => urlencode($path) )); + return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path) )); } } diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php index 44e2fc7293b..71b9a238823 100644 --- a/apps/files_trashbin/templates/part.list.php +++ b/apps/files_trashbin/templates/part.list.php @@ -25,7 +25,11 @@ style="background-image:url()" - style="background-image:url()" + + style="background-image:url()" class="preview-icon" + + style="background-image:url()" + > -- GitLab From b4a523927823ab8bc80c5f1fc0d5bd5ef61f8eb8 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 29 Jul 2013 16:30:04 +0200 Subject: [PATCH 106/635] fix syntax in config.sample.php --- config/config.sample.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.sample.php b/config/config.sample.php index cacca78e970..7629414ef16 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -185,7 +185,7 @@ $CONFIG = array( //links to custom clients 'customclient_desktop' => '', //http://owncloud.org/sync-clients/ 'customclient_android' => '', //https://play.google.com/store/apps/details?id=com.owncloud.android -'customclient_ios' => '' //https://itunes.apple.com/us/app/owncloud/id543672169?mt=8 +'customclient_ios' => '', //https://itunes.apple.com/us/app/owncloud/id543672169?mt=8 // PREVIEW /* the max width of a generated preview, if value is null, there is no limit */ -- GitLab From ac6a3133eca86b853da838ae310534b76e9fb662 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 30 Jul 2013 12:29:12 +0200 Subject: [PATCH 107/635] style fixes --- apps/files/js/files.js | 2 +- apps/files/templates/part.list.php | 2 +- apps/files_sharing/public.php | 2 +- core/ajax/preview.php | 42 ++++ core/ajax/publicpreview.php | 92 +++++++++ core/ajax/trashbinpreview.php | 46 +++++ core/routes.php | 6 +- lib/helper.php | 2 +- lib/preview.php | 308 +++++++---------------------- lib/preview/images.php | 7 +- lib/preview/libreoffice-cl.php | 24 ++- lib/preview/movies.php | 22 ++- lib/preview/mp3.php | 22 ++- lib/preview/msoffice.php | 24 +-- lib/preview/office.php | 7 +- lib/preview/pdf.php | 8 +- lib/preview/txt.php | 15 +- lib/preview/unknown.php | 8 +- lib/template.php | 3 + lib/template/functions.php | 16 ++ 20 files changed, 349 insertions(+), 309 deletions(-) create mode 100644 core/ajax/preview.php create mode 100644 core/ajax/publicpreview.php create mode 100644 core/ajax/trashbinpreview.php diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 53c6de09dd0..8b66ed6747b 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -825,7 +825,7 @@ function getMimeIcon(mime, ready){ getMimeIcon.cache={}; function getPreviewIcon(path, ready){ - ready(OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:44, y:44})); + ready(OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:36, y:36})); } function getUniqueName(name){ diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index a957a94f332..ab1b91167db 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -3,7 +3,7 @@ $totaldirs = 0; $totalsize = 0; ?> 6 $totalsize += $file['size']; if ($file['type'] === 'dir') { $totaldirs++; diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 284b7a30208..650fa6a7c27 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -196,7 +196,7 @@ if (isset($path)) { OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path='); $list->assign('isPublic', true); $list->assign('sharingtoken', $token); - $list->assign('sharingroot', ($path)); + $list->assign('sharingroot', $basePath); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); diff --git a/core/ajax/preview.php b/core/ajax/preview.php new file mode 100644 index 00000000000..a9d127ffcc4 --- /dev/null +++ b/core/ajax/preview.php @@ -0,0 +1,42 @@ +setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); + + $preview->show(); +}catch(\Exception $e) { + \OC_Response::setStatus(500); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + \OC\Preview::showErrorPreview(); + exit; +} \ No newline at end of file diff --git a/core/ajax/publicpreview.php b/core/ajax/publicpreview.php new file mode 100644 index 00000000000..aace24caa21 --- /dev/null +++ b/core/ajax/publicpreview.php @@ -0,0 +1,92 @@ +setFile($sharedFile); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); + + $preview->show(); +}catch(\Exception $e) { + \OC_Response::setStatus(500); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + \OC\Preview::showErrorPreview(); + exit; +} \ No newline at end of file diff --git a/core/ajax/trashbinpreview.php b/core/ajax/trashbinpreview.php new file mode 100644 index 00000000000..d018a57d37b --- /dev/null +++ b/core/ajax/trashbinpreview.php @@ -0,0 +1,46 @@ +setFile($file); + $preview->setMaxX($maxX); + $preview->setMaxY($maxY); + $preview->setScalingUp($scalingUp); + + $preview->showPreview(); +}catch(\Exception $e) { + \OC_Response::setStatus(500); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + \OC\Preview::showErrorPreview(); + exit; +} \ No newline at end of file diff --git a/core/routes.php b/core/routes.php index 41e82f8a73d..75cc4d511c0 100644 --- a/core/routes.php +++ b/core/routes.php @@ -43,11 +43,11 @@ $this->create('js_config', '/core/js/config.js') $this->create('core_ajax_routes', '/core/routes.json') ->action('OC_Router', 'JSRoutes'); $this->create('core_ajax_preview', '/core/preview.png') - ->action('OC\Preview', 'previewRouter'); + ->actionInclude('core/ajax/preview.php'); $this->create('core_ajax_trashbin_preview', '/core/trashbinpreview.png') - ->action('OC\Preview', 'trashbinPreviewRouter'); + ->actionInclude('core/ajax/trashbinpreview.php'); $this->create('core_ajax_public_preview', '/core/publicpreview.png') - ->action('OC\Preview', 'publicPreviewRouter'); + ->actionInclude('core/ajax/publicpreview.php'); OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php'; $this->create('core_lostpassword_index', '/lostpassword/') ->get() diff --git a/lib/helper.php b/lib/helper.php index 460e5679b02..b74e4c4512e 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -233,7 +233,7 @@ class OC_Helper { return self::linkToRoute( 'core_ajax_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path) )); } - public static function publicPreview_icon( $path, $token ) { + public static function publicPreviewIcon( $path, $token ) { return self::linkToRoute( 'core_ajax_public_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path), 't' => $token)); } diff --git a/lib/preview.php b/lib/preview.php index 245ad64014e..9f4d20b4650 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -55,12 +55,12 @@ class Preview { * @param string $file The path to the file where you want a thumbnail from * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image - * @param bool $scalingup Disable/Enable upscaling of previews + * @param bool $scalingUp Disable/Enable upscaling of previews * @return mixed (bool / string) * false if thumbnail does not exist * path to thumbnail if thumbnail exists */ - public function __construct($user='', $root='/', $file='', $maxX=1, $maxY=1, $scalingup=true) { + public function __construct($user='', $root='/', $file='', $maxX=1, $maxY=1, $scalingUp=true) { //set config $this->configMaxX = \OC_Config::getValue('preview_max_x', null); $this->configMaxY = \OC_Config::getValue('preview_max_y', null); @@ -70,11 +70,11 @@ class Preview { $this->setFile($file); $this->setMaxX($maxX); $this->setMaxY($maxY); - $this->setScalingUp($scalingup); + $this->setScalingUp($scalingUp); //init fileviews if($user === ''){ - $user = OC_User::getUser(); + $user = \OC_User::getUser(); } $this->fileview = new \OC\Files\View('/' . $user . '/' . $root); $this->userview = new \OC\Files\View('/' . $user); @@ -120,7 +120,7 @@ class Preview { * @brief returns whether or not scalingup is enabled * @return bool */ - public function getScalingup() { + public function getScalingUp() { return $this->scalingup; } @@ -172,8 +172,8 @@ class Preview { * @return $this */ public function setMaxX($maxX=1) { - if($maxX === 0) { - throw new \Exception('Cannot set width of 0!'); + if($maxX <= 0) { + throw new \Exception('Cannot set width of 0 or smaller!'); } $configMaxX = $this->getConfigMaxX(); if(!is_null($configMaxX)) { @@ -192,8 +192,8 @@ class Preview { * @return $this */ public function setMaxY($maxY=1) { - if($maxY === 0) { - throw new \Exception('Cannot set height of 0!'); + if($maxY <= 0) { + throw new \Exception('Cannot set height of 0 or smaller!'); } $configMaxY = $this->getConfigMaxY(); if(!is_null($configMaxY)) { @@ -208,14 +208,14 @@ class Preview { /** * @brief set whether or not scalingup is enabled - * @param bool $scalingup + * @param bool $scalingUp * @return $this */ - public function setScalingup($scalingup) { + public function setScalingup($scalingUp) { if($this->getMaxScaleFactor() === 1) { - $scalingup = false; + $scalingUp = false; } - $this->scalingup = $scalingup; + $this->scalingup = $scalingUp; return $this; } @@ -245,12 +245,12 @@ class Preview { public function deletePreview() { $file = $this->getFile(); - $fileinfo = $this->fileview->getFileInfo($file); - $fileid = $fileinfo['fileid']; + $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); + $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png'; + $this->userview->unlink($previewPath); + return !$this->userview->file_exists($previewPath); } /** @@ -260,13 +260,13 @@ class Preview { public function deleteAllPreviews() { $file = $this->getFile(); - $fileinfo = $this->fileview->getFileInfo($file); - $fileid = $fileinfo['fileid']; + $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); + $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/'; + $this->userview->deleteAll($previewPath); + $this->userview->rmdir($previewPath); + return !$this->userview->is_dir($previewPath); } /** @@ -279,45 +279,45 @@ class Preview { $file = $this->getFile(); $maxX = $this->getMaxX(); $maxY = $this->getMaxY(); - $scalingup = $this->getScalingup(); + $scalingUp = $this->getScalingUp(); $maxscalefactor = $this->getMaxScaleFactor(); - $fileinfo = $this->fileview->getFileInfo($file); - $fileid = $fileinfo['fileid']; + $fileInfo = $this->fileview->getFileInfo($file); + $fileId = $fileInfo['fileid']; - if(is_null($fileid)) { + if(is_null($fileId)) { return false; } - $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/'; - if(!$this->userview->is_dir($previewpath)) { + $previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/'; + 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')) { - return $previewpath . $maxX . '-' . $maxY . '.png'; + if($this->userview->file_exists($previewPath . $maxX . '-' . $maxY . '.png')) { + return $previewPath . $maxX . '-' . $maxY . '.png'; } - $wantedaspectratio = (float) ($maxX / $maxY); + $wantedAspectRatio = (float) ($maxX / $maxY); //array for usable cached thumbnails - $possiblethumbnails = array(); + $possibleThumbnails = array(); - $allthumbnails = $this->userview->getDirectoryContent($previewpath); - foreach($allthumbnails as $thumbnail) { + $allThumbnails = $this->userview->getDirectoryContent($previewPath); + foreach($allThumbnails as $thumbnail) { $name = rtrim($thumbnail['name'], '.png'); $size = explode('-', $name); $x = (int) $size[0]; $y = (int) $size[1]; - $aspectratio = (float) ($x / $y); - if($aspectratio !== $wantedaspectratio) { + $aspectRatio = (float) ($x / $y); + if($aspectRatio !== $wantedAspectRatio) { continue; } if($x < $maxX || $y < $maxY) { - if($scalingup) { + if($scalingUp) { $scalefactor = $maxX / $x; if($scalefactor > $maxscalefactor) { continue; @@ -326,28 +326,28 @@ class Preview { continue; } } - $possiblethumbnails[$x] = $thumbnail['path']; + $possibleThumbnails[$x] = $thumbnail['path']; } - if(count($possiblethumbnails) === 0) { + if(count($possibleThumbnails) === 0) { return false; } - if(count($possiblethumbnails) === 1) { - return current($possiblethumbnails); + if(count($possibleThumbnails) === 1) { + return current($possibleThumbnails); } - ksort($possiblethumbnails); + ksort($possibleThumbnails); - if(key(reset($possiblethumbnails)) > $maxX) { - return current(reset($possiblethumbnails)); + if(key(reset($possibleThumbnails)) > $maxX) { + return current(reset($possibleThumbnails)); } - if(key(end($possiblethumbnails)) < $maxX) { - return current(end($possiblethumbnails)); + if(key(end($possibleThumbnails)) < $maxX) { + return current(end($possibleThumbnails)); } - foreach($possiblethumbnails as $width => $path) { + foreach($possibleThumbnails as $width => $path) { if($width < $maxX) { continue; }else{ @@ -358,7 +358,7 @@ class Preview { /** * @brief return a preview of a file - * @return image + * @return \OC_Image */ public function getPreview() { if(!is_null($this->preview) && $this->preview->valid()){ @@ -369,10 +369,10 @@ class Preview { $file = $this->getFile(); $maxX = $this->getMaxX(); $maxY = $this->getMaxY(); - $scalingup = $this->getScalingup(); + $scalingUp = $this->getScalingUp(); - $fileinfo = $this->fileview->getFileInfo($file); - $fileid = $fileinfo['fileid']; + $fileInfo = $this->fileview->getFileInfo($file); + $fileId = $fileInfo['fileid']; $cached = $this->isCached(); @@ -386,12 +386,12 @@ class Preview { $mimetype = $this->fileview->getMimeType($file); $preview = null; - foreach(self::$providers as $supportedmimetype => $provider) { - if(!preg_match($supportedmimetype, $mimetype)) { + foreach(self::$providers as $supportedMimetype => $provider) { + if(!preg_match($supportedMimetype, $mimetype)) { continue; } - $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingup, $this->fileview); + $preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileview); if(!($preview instanceof \OC_Image)) { continue; @@ -400,18 +400,18 @@ class Preview { $this->preview = $preview; $this->resizeAndCrop(); - $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/'; - $cachepath = $previewpath . $maxX . '-' . $maxY . '.png'; + $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($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; } @@ -447,13 +447,13 @@ class Preview { /** * @brief resize, crop and fix orientation - * @return image + * @return void */ private function resizeAndCrop() { $image = $this->preview; $x = $this->getMaxX(); $y = $this->getMaxY(); - $scalingup = $this->getScalingup(); + $scalingUp = $this->getScalingUp(); $maxscalefactor = $this->getMaxScaleFactor(); if(!($image instanceof \OC_Image)) { @@ -480,7 +480,7 @@ class Preview { $factor = $factorY; } - if($scalingup === false) { + if($scalingUp === false) { if($factor > 1) { $factor = 1; } @@ -583,182 +583,6 @@ class Preview { array_multisort($keys, SORT_DESC, self::$providers); } - /** - * @brief method that handles preview requests from users that are logged in - * @return void - */ - public static function previewRouter() { - \OC_Util::checkLoggedIn(); - - $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; - $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36'; - $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36'; - $scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; - - if($file === '') { - \OC_Response::setStatus(400); //400 Bad Request - \OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG); - self::showErrorPreview(); - exit; - } - - if($maxX === 0 || $maxY === 0) { - \OC_Response::setStatus(400); //400 Bad Request - \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG); - self::showErrorPreview(); - exit; - } - - try{ - $preview = new Preview(\OC_User::getUser(), 'files'); - $preview->setFile($file); - $preview->setMaxX($maxX); - $preview->setMaxY($maxY); - $preview->setScalingUp($scalingup); - - $preview->show(); - }catch(\Exception $e) { - \OC_Response::setStatus(500); - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); - self::showErrorPreview(); - exit; - } - } - - /** - * @brief method that handles preview requests from users that are not logged in / view shared folders that are public - * @return void - */ - public static function publicPreviewRouter() { - if(!\OC_App::isEnabled('files_sharing')){ - exit; - } - - $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; - $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36'; - $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36'; - $scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; - $token = array_key_exists('t', $_GET) ? (string) $_GET['t'] : ''; - - if($token === ''){ - \OC_Response::setStatus(400); //400 Bad Request - \OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG); - self::showErrorPreview(); - exit; - } - - $linkedItem = \OCP\Share::getShareByToken($token); - if($linkedItem === false || ($linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder')) { - \OC_Response::setStatus(404); - \OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG); - self::showErrorPreview(); - exit; - } - - if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) { - \OC_Response::setStatus(500); - \OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")'); - self::showErrorPreview(); - exit; - } - - $userid = $linkedItem['uid_owner']; - \OC_Util::setupFS($userid); - - $pathid = $linkedItem['file_source']; - $path = \OC\Files\Filesystem::getPath($pathid); - $pathinfo = \OC\Files\Filesystem::getFileInfo($path); - $sharedfile = null; - - if($linkedItem['item_type'] === 'folder') { - $isvalid = \OC\Files\Filesystem::isValidPath($file); - if(!$isvalid) { - \OC_Response::setStatus(400); //400 Bad Request - \OC_Log::write('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . $_SERVER['REMOTE_ADDR'] . '")', \OC_Log::WARN); - self::showErrorPreview(); - exit; - } - $sharedfile = \OC\Files\Filesystem::normalizePath($file); - } - - if($linkedItem['item_type'] === 'file') { - $parent = $pathinfo['parent']; - $path = \OC\Files\Filesystem::getPath($parent); - $sharedfile = $pathinfo['name']; - } - - $path = \OC\Files\Filesystem::normalizePath($path, false); - if(substr($path, 0, 1) === '/') { - $path = substr($path, 1); - } - - if($maxX === 0 || $maxY === 0) { - \OC_Response::setStatus(400); //400 Bad Request - \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG); - self::showErrorPreview(); - exit; - } - - $root = 'files/' . $path; - - try{ - $preview = new Preview($userid, $root); - $preview->setFile($file); - $preview->setMaxX($maxX); - $preview->setMaxY($maxY); - $preview->setScalingUp($scalingup); - - $preview->show(); - }catch(\Exception $e) { - \OC_Response::setStatus(500); - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); - self::showErrorPreview(); - exit; - } - } - - public static function trashbinPreviewRouter() { - \OC_Util::checkLoggedIn(); - - if(!\OC_App::isEnabled('files_trashbin')){ - exit; - } - - $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; - $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44'; - $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44'; - $scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; - - if($file === '') { - \OC_Response::setStatus(400); //400 Bad Request - \OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG); - self::showErrorPreview(); - exit; - } - - if($maxX === 0 || $maxY === 0) { - \OC_Response::setStatus(400); //400 Bad Request - \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG); - self::showErrorPreview(); - exit; - } - - try{ - $preview = new Preview(\OC_User::getUser(), 'files_trashbin/files'); - $preview->setFile($file); - $preview->setMaxX($maxX); - $preview->setMaxY($maxY); - $preview->setScalingUp($scalingup); - - $preview->showPreview(); - }catch(\Exception $e) { - \OC_Response::setStatus(500); - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); - self::showErrorPreview(); - exit; - } - } - public static function post_write($args) { self::post_delete($args); } @@ -780,8 +604,8 @@ class Preview { //remove last element because it has the mimetype * $providers = array_slice(self::$providers, 0, -1); - foreach($providers as $supportedmimetype => $provider) { - if(preg_match($supportedmimetype, $mimetype)) { + foreach($providers as $supportedMimetype => $provider) { + if(preg_match($supportedMimetype, $mimetype)) { return true; } } diff --git a/lib/preview/images.php b/lib/preview/images.php index 987aa9aef0a..9aec967282d 100644 --- a/lib/preview/images.php +++ b/lib/preview/images.php @@ -16,10 +16,13 @@ class Image extends Provider { public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { //get fileinfo - $fileinfo = $fileview->getFileInfo($path); + $fileInfo = $fileview->getFileInfo($path); + if(!$fileInfo) { + return false; + } //check if file is encrypted - if($fileinfo['encrypted'] === true) { + if($fileInfo['encrypted'] === true) { $image = new \OC_Image(stream_get_contents($fileview->fopen($path, 'r'))); }else{ $image = new \OC_Image(); diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index 2749c4867e9..0f4ec3d0348 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -22,28 +22,30 @@ class Office extends Provider { return false; } - $abspath = $fileview->toTmpFile($path); + $absPath = $fileview->toTmpFile($path); - $tmpdir = get_temp_dir(); + $tmpDir = get_temp_dir(); - $exec = $this->cmd . ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ' . escapeshellarg($tmpdir) . ' ' . escapeshellarg($abspath); - $export = 'export HOME=/' . $tmpdir; + $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 = new \imagick($absPath . '.pdf' . '[0]'); $pdf->setImageFormat('jpg'); - }catch(\Exception $e){ + }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'); + unlink($absPath); + unlink($absPath . '.pdf'); return $image->valid() ? $image : false; } @@ -55,11 +57,13 @@ class Office extends Provider { $cmd = \OC_Config::getValue('preview_libreoffice_path', null); } - if($cmd === '' && shell_exec('libreoffice --headless --version')) { + $whichLibreOffice = shell_exec('which libreoffice'); + if($cmd === '' && !empty($whichLibreOffice)) { $cmd = 'libreoffice'; } - if($cmd === '' && shell_exec('openoffice --headless --version')) { + $whichOpenOffice = shell_exec('which openoffice'); + if($cmd === '' && !empty($whichOpenOffice)) { $cmd = 'openoffice'; } diff --git a/lib/preview/movies.php b/lib/preview/movies.php index 8531050d112..e2a1b8edddc 100644 --- a/lib/preview/movies.php +++ b/lib/preview/movies.php @@ -8,7 +8,11 @@ */ namespace OC\Preview; -if(!is_null(shell_exec('ffmpeg -version'))) { +$isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions'))); +$whichFFMPEG = shell_exec('which ffmpeg'); +$isFFMPEGAvailable = !empty($whichFFMPEG); + +if($isShellExecEnabled && $isFFMPEGAvailable) { class Movie extends Provider { @@ -17,23 +21,23 @@ if(!is_null(shell_exec('ffmpeg -version'))) { } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $abspath = \OC_Helper::tmpFile(); - $tmppath = \OC_Helper::tmpFile(); + $absPath = \OC_Helper::tmpFile(); + $tmpPath = \OC_Helper::tmpFile(); $handle = $fileview->fopen($path, 'rb'); $firstmb = stream_get_contents($handle, 1048576); //1024 * 1024 = 1048576 - file_put_contents($abspath, $firstmb); + file_put_contents($absPath, $firstmb); - //$cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath; - $cmd = 'ffmpeg -an -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmppath); + //$cmd = 'ffmpeg -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmpPath; + $cmd = 'ffmpeg -an -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmpPath); shell_exec($cmd); - $image = new \OC_Image($tmppath); + $image = new \OC_Image($tmpPath); - unlink($abspath); - unlink($tmppath); + unlink($absPath); + unlink($tmpPath); return $image->valid() ? $image : false; } diff --git a/lib/preview/mp3.php b/lib/preview/mp3.php index 835ff529000..1eed566315c 100644 --- a/lib/preview/mp3.php +++ b/lib/preview/mp3.php @@ -18,19 +18,21 @@ class MP3 extends Provider { $getID3 = new \getID3(); - $tmppath = $fileview->toTmpFile($path); - - $tags = $getID3->analyze($tmppath); - \getid3_lib::CopyTagsToComments($tags); - $picture = @$tags['id3v2']['APIC'][0]['data']; - - unlink($tmppath); + $tmpPath = $fileview->toTmpFile($path); + + $tags = $getID3->analyze($tmpPath); + \getid3_lib::CopyTagsToComments($tags); + if(isset($tags['id3v2']['APIC'][0]['data'])) { + $picture = @$tags['id3v2']['APIC'][0]['data']; + unlink($tmpPath); + $image = new \OC_Image($picture); + return $image->valid() ? $image : $this->getNoCoverThumbnail(); + } - $image = new \OC_Image($picture); - return $image->valid() ? $image : $this->getNoCoverThumbnail($maxX, $maxY); + return $this->getNoCoverThumbnail(); } - public function getNoCoverThumbnail($maxX, $maxY) { + private function getNoCoverThumbnail() { $icon = \OC::$SERVERROOT . '/core/img/filetypes/audio.png'; if(!file_exists($icon)) { diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php index ccf1d674c7a..e69ab0ab8cb 100644 --- a/lib/preview/msoffice.php +++ b/lib/preview/msoffice.php @@ -32,16 +32,16 @@ class DOCX extends Provider { public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { require_once('phpdocx/classes/TransformDoc.inc'); - $tmpdoc = $fileview->toTmpFile($path); + $tmpDoc = $fileview->toTmpFile($path); $transformdoc = new \TransformDoc(); - $transformdoc->setStrFile($tmpdoc); - $transformdoc->generatePDF($tmpdoc); + $transformdoc->setStrFile($tmpDoc); + $transformdoc->generatePDF($tmpDoc); - $pdf = new \imagick($tmpdoc . '[0]'); + $pdf = new \imagick($tmpDoc . '[0]'); $pdf->setImageFormat('jpg'); - unlink($tmpdoc); + unlink($tmpDoc); $image = new \OC_Image($pdf); @@ -62,23 +62,23 @@ class MSOfficeExcel extends Provider { require_once('PHPExcel/Classes/PHPExcel.php'); require_once('PHPExcel/Classes/PHPExcel/IOFactory.php'); - $abspath = $fileview->toTmpFile($path); - $tmppath = \OC_Helper::tmpFile(); + $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); + $phpexcel = new \PHPExcel($absPath); $excel = \PHPExcel_IOFactory::createWriter($phpexcel, 'PDF'); - $excel->save($tmppath); + $excel->save($tmpPath); - $pdf = new \imagick($tmppath . '[0]'); + $pdf = new \imagick($tmpPath . '[0]'); $pdf->setImageFormat('jpg'); - unlink($abspath); - unlink($tmppath); + unlink($absPath); + unlink($tmpPath); $image = new \OC_Image($pdf); diff --git a/lib/preview/office.php b/lib/preview/office.php index b6783bc5798..b93e1e57c8b 100644 --- a/lib/preview/office.php +++ b/lib/preview/office.php @@ -7,8 +7,13 @@ */ //both, libreoffice backend and php fallback, need imagick if (extension_loaded('imagick')) { + $isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions'))); + $whichLibreOffice = shell_exec('which libreoffice'); + $isLibreOfficeAvailable = !empty($whichLibreOffice); + $whichOpenOffice = shell_exec('which libreoffice'); + $isOpenOfficeAvailable = !empty($whichOpenOffice); //let's see if there is libreoffice or openoffice on this machine - if(shell_exec('libreoffice --headless --version') || shell_exec('openoffice --headless --version') || is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { + if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) { require_once('libreoffice-cl.php'); }else{ //in case there isn't, use our fallback diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index 3eabd201156..723dc1d80d2 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -16,18 +16,18 @@ if (extension_loaded('imagick')) { } public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $tmppath = $fileview->toTmpFile($path); + $tmpPath = $fileview->toTmpFile($path); //create imagick object from pdf try{ - $pdf = new \imagick($tmppath . '[0]'); + $pdf = new \imagick($tmpPath . '[0]'); $pdf->setImageFormat('jpg'); - }catch(\Exception $e){ + }catch (\Exception $e) { \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); return false; } - unlink($tmppath); + unlink($tmpPath); //new image object $image = new \OC_Image($pdf); diff --git a/lib/preview/txt.php b/lib/preview/txt.php index c7b8fabc6b0..89927fd580a 100644 --- a/lib/preview/txt.php +++ b/lib/preview/txt.php @@ -18,24 +18,23 @@ class TXT extends Provider { $content = stream_get_contents($content); $lines = preg_split("/\r\n|\n|\r/", $content); - $numoflines = count($lines); - $fontsize = 5; //5px - $linesize = ceil($fontsize * 1.25); + $fontSize = 5; //5px + $lineSize = ceil($fontSize * 1.25); $image = imagecreate($maxX, $maxY); - $imagecolor = imagecolorallocate($image, 255, 255, 255); - $textcolor = imagecolorallocate($image, 0, 0, 0); + imagecolorallocate($image, 255, 255, 255); + $textColor = imagecolorallocate($image, 0, 0, 0); foreach($lines as $index => $line) { $index = $index + 1; $x = (int) 1; - $y = (int) ($index * $linesize) - $fontsize; + $y = (int) ($index * $lineSize) - $fontSize; - imagestring($image, 1, $x, $y, $line, $textcolor); + imagestring($image, 1, $x, $y, $line, $textColor); - if(($index * $linesize) >= $maxY) { + if(($index * $lineSize) >= $maxY) { break; } } diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php index a31b365722e..ba13ca35d66 100644 --- a/lib/preview/unknown.php +++ b/lib/preview/unknown.php @@ -20,7 +20,7 @@ class Unknown extends Provider { list($type, $subtype) = explode('/', $mimetype); } - $iconsroot = \OC::$SERVERROOT . '/core/img/filetypes/'; + $iconsRoot = \OC::$SERVERROOT . '/core/img/filetypes/'; if(isset($type)){ $icons = array($mimetype, $type, 'text'); @@ -30,10 +30,10 @@ class Unknown extends Provider { foreach($icons as $icon) { $icon = str_replace('/', '-', $icon); - $iconpath = $iconsroot . $icon . '.png'; + $iconPath = $iconsRoot . $icon . '.png'; - if(file_exists($iconpath)) { - return new \OC_Image($iconpath); + if(file_exists($iconPath)) { + return new \OC_Image($iconPath); } } return false; diff --git a/lib/template.php b/lib/template.php index caa1e667c61..9b2c1211e61 100644 --- a/lib/template.php +++ b/lib/template.php @@ -23,6 +23,9 @@ require_once __DIR__.'/template/functions.php'; +/** + * This class provides the templates for ownCloud. + */ class OC_Template extends \OC\Template\Base { private $renderas; // Create a full page? private $path; // The path to the template diff --git a/lib/template/functions.php b/lib/template/functions.php index a864614c9a1..842f28c90e0 100644 --- a/lib/template/functions.php +++ b/lib/template/functions.php @@ -47,6 +47,22 @@ function image_path( $app, $image ) { return OC_Helper::imagePath( $app, $image ); } +/** + * @brief make preview_icon available as a simple function + * Returns the path to the preview of the image. + * @param $path path of file + * @returns link to the preview + * + * For further information have a look at OC_Helper::previewIcon + */ +function preview_icon( $path ) { + return OC_Helper::previewIcon( $path ); +} + +function publicPreview_icon ( $path, $token ) { + return OC_Helper::publicPreviewIcon( $path, $token ); +} + /** * @brief make OC_Helper::mimetypeIcon available as a simple function * @param string $mimetype mimetype -- GitLab From d84d8f71082ba17a9f37f86600a71d20e2481772 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 30 Jul 2013 12:35:39 +0200 Subject: [PATCH 108/635] fix merge conflicts --- lib/template/functions.php | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/lib/template/functions.php b/lib/template/functions.php index 842f28c90e0..a892e310362 100644 --- a/lib/template/functions.php +++ b/lib/template/functions.php @@ -47,22 +47,6 @@ function image_path( $app, $image ) { return OC_Helper::imagePath( $app, $image ); } -/** - * @brief make preview_icon available as a simple function - * Returns the path to the preview of the image. - * @param $path path of file - * @returns link to the preview - * - * For further information have a look at OC_Helper::previewIcon - */ -function preview_icon( $path ) { - return OC_Helper::previewIcon( $path ); -} - -function publicPreview_icon ( $path, $token ) { - return OC_Helper::publicPreviewIcon( $path, $token ); -} - /** * @brief make OC_Helper::mimetypeIcon available as a simple function * @param string $mimetype mimetype @@ -87,7 +71,7 @@ function preview_icon( $path ) { } function publicPreview_icon ( $path, $token ) { - return OC_Helper::publicPreview_icon( $path, $token ); + return OC_Helper::publicPreviewIcon( $path, $token ); } /** -- GitLab From 640253fa31928ff52ba41e53cf50192c4b0002e9 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 30 Jul 2013 13:43:15 +0200 Subject: [PATCH 109/635] fix code style of try catch blocks --- core/ajax/publicpreview.php | 2 +- lib/preview/libreoffice-cl.php | 2 +- lib/preview/pdf.php | 2 +- lib/preview/svg.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/ajax/publicpreview.php b/core/ajax/publicpreview.php index aace24caa21..955fbc2626a 100644 --- a/core/ajax/publicpreview.php +++ b/core/ajax/publicpreview.php @@ -84,7 +84,7 @@ try{ $preview->setScalingUp($scalingUp); $preview->show(); -}catch(\Exception $e) { +} catch (\Exception $e) { \OC_Response::setStatus(500); \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); \OC\Preview::showErrorPreview(); diff --git a/lib/preview/libreoffice-cl.php b/lib/preview/libreoffice-cl.php index 0f4ec3d0348..2f1d08499ef 100644 --- a/lib/preview/libreoffice-cl.php +++ b/lib/preview/libreoffice-cl.php @@ -35,7 +35,7 @@ class Office extends Provider { try{ $pdf = new \imagick($absPath . '.pdf' . '[0]'); $pdf->setImageFormat('jpg'); - }catch (\Exception $e) { + } catch (\Exception $e) { unlink($absPath); unlink($absPath . '.pdf'); \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); diff --git a/lib/preview/pdf.php b/lib/preview/pdf.php index 723dc1d80d2..cc974b68818 100644 --- a/lib/preview/pdf.php +++ b/lib/preview/pdf.php @@ -22,7 +22,7 @@ if (extension_loaded('imagick')) { try{ $pdf = new \imagick($tmpPath . '[0]'); $pdf->setImageFormat('jpg'); - }catch (\Exception $e) { + } catch (\Exception $e) { \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); return false; } diff --git a/lib/preview/svg.php b/lib/preview/svg.php index bafaf71b15a..e939e526b1b 100644 --- a/lib/preview/svg.php +++ b/lib/preview/svg.php @@ -27,7 +27,7 @@ if (extension_loaded('imagick')) { $svg->readImageBlob($content); $svg->setImageFormat('jpg'); - }catch(\Exception $e){ + } catch (\Exception $e) { \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); return false; } -- GitLab From 554b1990e23c76aea182e9b8c2687f8f8b939fb9 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 5 Aug 2013 14:23:30 +0200 Subject: [PATCH 110/635] suppress is_file error msg --- lib/image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/image.php b/lib/image.php index c1b187608a6..4bc38e20e56 100644 --- a/lib/image.php +++ b/lib/image.php @@ -392,7 +392,7 @@ class OC_Image { */ public function loadFromFile($imagepath=false) { // exif_imagetype throws "read error!" if file is less than 12 byte - if(!is_file($imagepath) || !file_exists($imagepath) || filesize($imagepath) < 12 || !is_readable($imagepath)) { + if(!@is_file($imagepath) || !file_exists($imagepath) || filesize($imagepath) < 12 || !is_readable($imagepath)) { // Debug output disabled because this method is tried before loadFromBase64? OC_Log::write('core', 'OC_Image->loadFromFile, couldn\'t load: '.$imagepath, OC_Log::DEBUG); return false; -- GitLab From 3e7a86c6ecd332c268e690399a015ab618e87754 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 6 Aug 2013 15:59:06 +0200 Subject: [PATCH 111/635] remove deleted files while scanning --- lib/files/cache/scanner.php | 2 ++ tests/lib/files/cache/scanner.php | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index adecc2bb901..3349245616d 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -112,6 +112,8 @@ class Scanner extends BasicEmitter { if (!empty($newData)) { $this->cache->put($file, $newData); } + } else { + $this->cache->remove($file); } return $data; } diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php index 263ceadccc7..bb90adce5c1 100644 --- a/tests/lib/files/cache/scanner.php +++ b/tests/lib/files/cache/scanner.php @@ -166,6 +166,16 @@ class Scanner extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->cache->inCache('folder/bar.txt')); } + public function testScanRemovedFile(){ + $this->fillTestFolders(); + + $this->scanner->scan(''); + $this->assertTrue($this->cache->inCache('folder/bar.txt')); + $this->storage->unlink('folder/bar.txt'); + $this->scanner->scanFile('folder/bar.txt'); + $this->assertFalse($this->cache->inCache('folder/bar.txt')); + } + function setUp() { $this->storage = new \OC\Files\Storage\Temporary(array()); $this->scanner = new \OC\Files\Cache\Scanner($this->storage); -- GitLab From 91bd4dd67b7d58f09a4dadff8060f63c6d6b691e Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 7 Aug 2013 11:48:08 +0200 Subject: [PATCH 112/635] implement previews of single shared files --- apps/files_sharing/js/public.js | 2 +- apps/files_sharing/templates/public.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 294223aa094..fbbe9b7f3cb 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -16,7 +16,7 @@ $(document).ready(function() { if (typeof FileActions !== 'undefined') { var mimetype = $('#mimetype').val(); // Show file preview if previewer is available, images are already handled by the template - if (mimetype.substr(0, mimetype.indexOf('/')) != 'image') { + if (mimetype.substr(0, mimetype.indexOf('/')) != 'image' && $('.publicpreview').length() !== 0) { // Trigger default action if not download TODO var action = FileActions.getDefault(mimetype, 'file', OC.PERMISSION_READ); if (typeof action === 'undefined') { diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 746a715f3cc..c164b3ea2b7 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -79,6 +79,10 @@
+ +
+ +