@@ -23,10 +23,10 @@ |
||
23 | 23 | |
24 | 24 | //.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m) |
25 | 25 | class MSOffice2003 extends Office { |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getMimeType() { |
|
30 | - return '/application\/vnd.ms-.*/'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getMimeType() { |
|
30 | + return '/application\/vnd.ms-.*/'; |
|
31 | + } |
|
32 | 32 | } |
@@ -28,41 +28,41 @@ |
||
28 | 28 | use OCP\Preview\IProvider; |
29 | 29 | |
30 | 30 | abstract class Provider implements IProvider { |
31 | - private $options; |
|
31 | + private $options; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor |
|
35 | - * |
|
36 | - * @param array $options |
|
37 | - */ |
|
38 | - public function __construct(array $options = []) { |
|
39 | - $this->options = $options; |
|
40 | - } |
|
33 | + /** |
|
34 | + * Constructor |
|
35 | + * |
|
36 | + * @param array $options |
|
37 | + */ |
|
38 | + public function __construct(array $options = []) { |
|
39 | + $this->options = $options; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string Regex with the mimetypes that are supported by this provider |
|
44 | - */ |
|
45 | - abstract public function getMimeType(); |
|
42 | + /** |
|
43 | + * @return string Regex with the mimetypes that are supported by this provider |
|
44 | + */ |
|
45 | + abstract public function getMimeType(); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Check if a preview can be generated for $path |
|
49 | - * |
|
50 | - * @param \OCP\Files\FileInfo $file |
|
51 | - * @return bool |
|
52 | - */ |
|
53 | - public function isAvailable(\OCP\Files\FileInfo $file) { |
|
54 | - return true; |
|
55 | - } |
|
47 | + /** |
|
48 | + * Check if a preview can be generated for $path |
|
49 | + * |
|
50 | + * @param \OCP\Files\FileInfo $file |
|
51 | + * @return bool |
|
52 | + */ |
|
53 | + public function isAvailable(\OCP\Files\FileInfo $file) { |
|
54 | + return true; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Generates thumbnail which fits in $maxX and $maxY and keeps the aspect ratio, for file at path $path |
|
59 | - * |
|
60 | - * @param string $path Path of file |
|
61 | - * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
62 | - * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
63 | - * @param bool $scalingup Disable/Enable upscaling of previews |
|
64 | - * @param \OC\Files\View $fileview fileview object of user folder |
|
65 | - * @return bool|\OCP\IImage false if no preview was generated |
|
66 | - */ |
|
67 | - abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); |
|
57 | + /** |
|
58 | + * Generates thumbnail which fits in $maxX and $maxY and keeps the aspect ratio, for file at path $path |
|
59 | + * |
|
60 | + * @param string $path Path of file |
|
61 | + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
62 | + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
63 | + * @param bool $scalingup Disable/Enable upscaling of previews |
|
64 | + * @param \OC\Files\View $fileview fileview object of user folder |
|
65 | + * @return bool|\OCP\IImage false if no preview was generated |
|
66 | + */ |
|
67 | + abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); |
|
68 | 68 | } |
@@ -28,45 +28,45 @@ |
||
28 | 28 | |
29 | 29 | class WatcherConnector { |
30 | 30 | |
31 | - /** @var IRootFolder */ |
|
32 | - private $root; |
|
31 | + /** @var IRootFolder */ |
|
32 | + private $root; |
|
33 | 33 | |
34 | - /** @var SystemConfig */ |
|
35 | - private $config; |
|
34 | + /** @var SystemConfig */ |
|
35 | + private $config; |
|
36 | 36 | |
37 | - /** |
|
38 | - * WatcherConnector constructor. |
|
39 | - * |
|
40 | - * @param IRootFolder $root |
|
41 | - * @param SystemConfig $config |
|
42 | - */ |
|
43 | - public function __construct(IRootFolder $root, |
|
44 | - SystemConfig $config) { |
|
45 | - $this->root = $root; |
|
46 | - $this->config = $config; |
|
47 | - } |
|
37 | + /** |
|
38 | + * WatcherConnector constructor. |
|
39 | + * |
|
40 | + * @param IRootFolder $root |
|
41 | + * @param SystemConfig $config |
|
42 | + */ |
|
43 | + public function __construct(IRootFolder $root, |
|
44 | + SystemConfig $config) { |
|
45 | + $this->root = $root; |
|
46 | + $this->config = $config; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return Watcher |
|
51 | - */ |
|
52 | - private function getWatcher() { |
|
53 | - return \OC::$server->query(Watcher::class); |
|
54 | - } |
|
49 | + /** |
|
50 | + * @return Watcher |
|
51 | + */ |
|
52 | + private function getWatcher() { |
|
53 | + return \OC::$server->query(Watcher::class); |
|
54 | + } |
|
55 | 55 | |
56 | - public function connectWatcher() { |
|
57 | - // Do not connect if we are not setup yet! |
|
58 | - if ($this->config->getValue('instanceid', null) !== null) { |
|
59 | - $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { |
|
60 | - $this->getWatcher()->postWrite($node); |
|
61 | - }); |
|
56 | + public function connectWatcher() { |
|
57 | + // Do not connect if we are not setup yet! |
|
58 | + if ($this->config->getValue('instanceid', null) !== null) { |
|
59 | + $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { |
|
60 | + $this->getWatcher()->postWrite($node); |
|
61 | + }); |
|
62 | 62 | |
63 | - $this->root->listen('\OC\Files', 'preDelete', function (Node $node) { |
|
64 | - $this->getWatcher()->preDelete($node); |
|
65 | - }); |
|
63 | + $this->root->listen('\OC\Files', 'preDelete', function (Node $node) { |
|
64 | + $this->getWatcher()->preDelete($node); |
|
65 | + }); |
|
66 | 66 | |
67 | - $this->root->listen('\OC\Files', 'postDelete', function (Node $node) { |
|
68 | - $this->getWatcher()->postDelete($node); |
|
69 | - }); |
|
70 | - } |
|
71 | - } |
|
67 | + $this->root->listen('\OC\Files', 'postDelete', function (Node $node) { |
|
68 | + $this->getWatcher()->postDelete($node); |
|
69 | + }); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | } |
@@ -23,10 +23,10 @@ |
||
23 | 23 | |
24 | 24 | //.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt |
25 | 25 | class OpenDocument extends Office { |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getMimeType() { |
|
30 | - return '/application\/vnd.oasis.opendocument.*/'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getMimeType() { |
|
30 | + return '/application\/vnd.oasis.opendocument.*/'; |
|
31 | + } |
|
32 | 32 | } |
@@ -25,10 +25,10 @@ |
||
25 | 25 | |
26 | 26 | //.psd |
27 | 27 | class Photoshop extends Bitmap { |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - */ |
|
31 | - public function getMimeType() { |
|
32 | - return '/application\/x-photoshop/'; |
|
33 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + */ |
|
31 | + public function getMimeType() { |
|
32 | + return '/application\/x-photoshop/'; |
|
33 | + } |
|
34 | 34 | } |
@@ -23,10 +23,10 @@ |
||
23 | 23 | namespace OC\Preview; |
24 | 24 | |
25 | 25 | class PNG extends Image { |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getMimeType() { |
|
30 | - return '/image\/png/'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getMimeType() { |
|
30 | + return '/image\/png/'; |
|
31 | + } |
|
32 | 32 | } |
@@ -29,42 +29,42 @@ |
||
29 | 29 | |
30 | 30 | abstract class Image extends Provider { |
31 | 31 | |
32 | - /** |
|
33 | - * {@inheritDoc} |
|
34 | - */ |
|
35 | - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
36 | - //get fileinfo |
|
37 | - $fileInfo = $fileview->getFileInfo($path); |
|
38 | - if (!$fileInfo) { |
|
39 | - return false; |
|
40 | - } |
|
32 | + /** |
|
33 | + * {@inheritDoc} |
|
34 | + */ |
|
35 | + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { |
|
36 | + //get fileinfo |
|
37 | + $fileInfo = $fileview->getFileInfo($path); |
|
38 | + if (!$fileInfo) { |
|
39 | + return false; |
|
40 | + } |
|
41 | 41 | |
42 | - $maxSizeForImages = \OC::$server->getConfig()->getSystemValue('preview_max_filesize_image', 50); |
|
43 | - $size = $fileInfo->getSize(); |
|
42 | + $maxSizeForImages = \OC::$server->getConfig()->getSystemValue('preview_max_filesize_image', 50); |
|
43 | + $size = $fileInfo->getSize(); |
|
44 | 44 | |
45 | - if ($maxSizeForImages !== -1 && $size > ($maxSizeForImages * 1024 * 1024)) { |
|
46 | - return false; |
|
47 | - } |
|
45 | + if ($maxSizeForImages !== -1 && $size > ($maxSizeForImages * 1024 * 1024)) { |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | - $image = new \OC_Image(); |
|
49 | + $image = new \OC_Image(); |
|
50 | 50 | |
51 | - $useTempFile = $fileInfo->isEncrypted() || !$fileInfo->getStorage()->isLocal(); |
|
52 | - if ($useTempFile) { |
|
53 | - $fileName = $fileview->toTmpFile($path); |
|
54 | - } else { |
|
55 | - $fileName = $fileview->getLocalFile($path); |
|
56 | - } |
|
57 | - $image->loadFromFile($fileName); |
|
58 | - $image->fixOrientation(); |
|
59 | - if ($useTempFile) { |
|
60 | - unlink($fileName); |
|
61 | - } |
|
62 | - if ($image->valid()) { |
|
63 | - $image->scaleDownToFit($maxX, $maxY); |
|
51 | + $useTempFile = $fileInfo->isEncrypted() || !$fileInfo->getStorage()->isLocal(); |
|
52 | + if ($useTempFile) { |
|
53 | + $fileName = $fileview->toTmpFile($path); |
|
54 | + } else { |
|
55 | + $fileName = $fileview->getLocalFile($path); |
|
56 | + } |
|
57 | + $image->loadFromFile($fileName); |
|
58 | + $image->fixOrientation(); |
|
59 | + if ($useTempFile) { |
|
60 | + unlink($fileName); |
|
61 | + } |
|
62 | + if ($image->valid()) { |
|
63 | + $image->scaleDownToFit($maxX, $maxY); |
|
64 | 64 | |
65 | - return $image; |
|
66 | - } |
|
67 | - return false; |
|
68 | - } |
|
65 | + return $image; |
|
66 | + } |
|
67 | + return false; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
@@ -25,10 +25,10 @@ |
||
25 | 25 | |
26 | 26 | //.tiff |
27 | 27 | class TIFF extends Bitmap { |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - */ |
|
31 | - public function getMimeType() { |
|
32 | - return '/image\/tiff/'; |
|
33 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + */ |
|
31 | + public function getMimeType() { |
|
32 | + return '/image\/tiff/'; |
|
33 | + } |
|
34 | 34 | } |
@@ -23,10 +23,10 @@ |
||
23 | 23 | |
24 | 24 | //.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx |
25 | 25 | class MSOffice2007 extends Office { |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getMimeType() { |
|
30 | - return '/application\/vnd.openxmlformats-officedocument.*/'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getMimeType() { |
|
30 | + return '/application\/vnd.openxmlformats-officedocument.*/'; |
|
31 | + } |
|
32 | 32 | } |