@@ -29,29 +29,29 @@ |
||
29 | 29 | * @since 17.0.0 |
30 | 30 | */ |
31 | 31 | interface IProviderV2 { |
32 | - /** |
|
33 | - * @return string Regex with the mimetypes that are supported by this provider |
|
34 | - * @since 17.0.0 |
|
35 | - */ |
|
36 | - public function getMimeType(): string; |
|
32 | + /** |
|
33 | + * @return string Regex with the mimetypes that are supported by this provider |
|
34 | + * @since 17.0.0 |
|
35 | + */ |
|
36 | + public function getMimeType(): string; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Check if a preview can be generated for $path |
|
40 | - * |
|
41 | - * @param FileInfo $file |
|
42 | - * @return bool |
|
43 | - * @since 17.0.0 |
|
44 | - */ |
|
45 | - public function isAvailable(FileInfo $file): bool; |
|
38 | + /** |
|
39 | + * Check if a preview can be generated for $path |
|
40 | + * |
|
41 | + * @param FileInfo $file |
|
42 | + * @return bool |
|
43 | + * @since 17.0.0 |
|
44 | + */ |
|
45 | + public function isAvailable(FileInfo $file): bool; |
|
46 | 46 | |
47 | - /** |
|
48 | - * get thumbnail for file at path $path |
|
49 | - * |
|
50 | - * @param File $file |
|
51 | - * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
52 | - * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
53 | - * @return null|\OCP\IImage null if no preview was generated |
|
54 | - * @since 17.0.0 |
|
55 | - */ |
|
56 | - public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage; |
|
47 | + /** |
|
48 | + * get thumbnail for file at path $path |
|
49 | + * |
|
50 | + * @param File $file |
|
51 | + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
52 | + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
53 | + * @return null|\OCP\IImage null if no preview was generated |
|
54 | + * @since 17.0.0 |
|
55 | + */ |
|
56 | + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage; |
|
57 | 57 | } |
@@ -23,10 +23,10 @@ |
||
23 | 23 | |
24 | 24 | //.doc, .dot |
25 | 25 | class MSOfficeDoc extends Office { |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getMimeType(): string { |
|
30 | - return '/application\/msword/'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getMimeType(): string { |
|
30 | + return '/application\/msword/'; |
|
31 | + } |
|
32 | 32 | } |
@@ -27,79 +27,79 @@ |
||
27 | 27 | use OCP\Preview\IProviderV2; |
28 | 28 | |
29 | 29 | abstract class ProviderV2 implements IProviderV2 { |
30 | - private $options; |
|
30 | + private $options; |
|
31 | 31 | |
32 | - private $tmpFiles = []; |
|
32 | + private $tmpFiles = []; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor |
|
36 | - * |
|
37 | - * @param array $options |
|
38 | - */ |
|
39 | - public function __construct(array $options = []) { |
|
40 | - $this->options = $options; |
|
41 | - } |
|
34 | + /** |
|
35 | + * Constructor |
|
36 | + * |
|
37 | + * @param array $options |
|
38 | + */ |
|
39 | + public function __construct(array $options = []) { |
|
40 | + $this->options = $options; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return string Regex with the mimetypes that are supported by this provider |
|
45 | - */ |
|
46 | - abstract public function getMimeType(): string ; |
|
43 | + /** |
|
44 | + * @return string Regex with the mimetypes that are supported by this provider |
|
45 | + */ |
|
46 | + abstract public function getMimeType(): string ; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Check if a preview can be generated for $path |
|
50 | - * |
|
51 | - * @param FileInfo $file |
|
52 | - * @return bool |
|
53 | - */ |
|
54 | - public function isAvailable(FileInfo $file): bool { |
|
55 | - return true; |
|
56 | - } |
|
48 | + /** |
|
49 | + * Check if a preview can be generated for $path |
|
50 | + * |
|
51 | + * @param FileInfo $file |
|
52 | + * @return bool |
|
53 | + */ |
|
54 | + public function isAvailable(FileInfo $file): bool { |
|
55 | + return true; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * get thumbnail for file at path $path |
|
60 | - * |
|
61 | - * @param File $file |
|
62 | - * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
63 | - * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
64 | - * @return null|\OCP\IImage false if no preview was generated |
|
65 | - * @since 17.0.0 |
|
66 | - */ |
|
67 | - abstract public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage; |
|
58 | + /** |
|
59 | + * get thumbnail for file at path $path |
|
60 | + * |
|
61 | + * @param File $file |
|
62 | + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
63 | + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
64 | + * @return null|\OCP\IImage false if no preview was generated |
|
65 | + * @since 17.0.0 |
|
66 | + */ |
|
67 | + abstract public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage; |
|
68 | 68 | |
69 | - /** |
|
70 | - * Get a path to either the local file or temporary file |
|
71 | - * |
|
72 | - * @param File $file |
|
73 | - * @param int $maxSize maximum size for temporary files |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - protected function getLocalFile(File $file, int $maxSize = null): string { |
|
77 | - $useTempFile = $file->isEncrypted() || !$file->getStorage()->isLocal(); |
|
78 | - if ($useTempFile) { |
|
79 | - $absPath = \OC::$server->getTempManager()->getTemporaryFile(); |
|
69 | + /** |
|
70 | + * Get a path to either the local file or temporary file |
|
71 | + * |
|
72 | + * @param File $file |
|
73 | + * @param int $maxSize maximum size for temporary files |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + protected function getLocalFile(File $file, int $maxSize = null): string { |
|
77 | + $useTempFile = $file->isEncrypted() || !$file->getStorage()->isLocal(); |
|
78 | + if ($useTempFile) { |
|
79 | + $absPath = \OC::$server->getTempManager()->getTemporaryFile(); |
|
80 | 80 | |
81 | - $content = $file->fopen('r'); |
|
81 | + $content = $file->fopen('r'); |
|
82 | 82 | |
83 | - if ($maxSize) { |
|
84 | - $content = stream_get_contents($content, $maxSize); |
|
85 | - } |
|
83 | + if ($maxSize) { |
|
84 | + $content = stream_get_contents($content, $maxSize); |
|
85 | + } |
|
86 | 86 | |
87 | - file_put_contents($absPath, $content); |
|
88 | - $this->tmpFiles[] = $absPath; |
|
89 | - return $absPath; |
|
90 | - } else { |
|
91 | - return $file->getStorage()->getLocalFile($file->getInternalPath()); |
|
92 | - } |
|
93 | - } |
|
87 | + file_put_contents($absPath, $content); |
|
88 | + $this->tmpFiles[] = $absPath; |
|
89 | + return $absPath; |
|
90 | + } else { |
|
91 | + return $file->getStorage()->getLocalFile($file->getInternalPath()); |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Clean any generated temporary files |
|
97 | - */ |
|
98 | - protected function cleanTmpFiles() { |
|
99 | - foreach ($this->tmpFiles as $tmpFile) { |
|
100 | - unlink($tmpFile); |
|
101 | - } |
|
95 | + /** |
|
96 | + * Clean any generated temporary files |
|
97 | + */ |
|
98 | + protected function cleanTmpFiles() { |
|
99 | + foreach ($this->tmpFiles as $tmpFile) { |
|
100 | + unlink($tmpFile); |
|
101 | + } |
|
102 | 102 | |
103 | - $this->tmpFiles = []; |
|
104 | - } |
|
103 | + $this->tmpFiles = []; |
|
104 | + } |
|
105 | 105 | } |
@@ -25,10 +25,10 @@ |
||
25 | 25 | |
26 | 26 | |
27 | 27 | class PDF extends Bitmap { |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - */ |
|
31 | - public function getMimeType(): string { |
|
32 | - return '/application\/pdf/'; |
|
33 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + */ |
|
31 | + public function getMimeType(): string { |
|
32 | + return '/application\/pdf/'; |
|
33 | + } |
|
34 | 34 | } |
@@ -25,10 +25,10 @@ |
||
25 | 25 | |
26 | 26 | //.psd |
27 | 27 | class Photoshop extends Bitmap { |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - */ |
|
31 | - public function getMimeType(): string { |
|
32 | - return '/application\/x-photoshop/'; |
|
33 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + */ |
|
31 | + public function getMimeType(): string { |
|
32 | + return '/application\/x-photoshop/'; |
|
33 | + } |
|
34 | 34 | } |
@@ -24,10 +24,10 @@ |
||
24 | 24 | |
25 | 25 | // .otf, .ttf and .pfb |
26 | 26 | class Font extends Bitmap { |
27 | - /** |
|
28 | - * {@inheritDoc} |
|
29 | - */ |
|
30 | - public function getMimeType(): string { |
|
31 | - return '/application\/(?:font-sfnt|x-font$)/'; |
|
32 | - } |
|
27 | + /** |
|
28 | + * {@inheritDoc} |
|
29 | + */ |
|
30 | + public function getMimeType(): string { |
|
31 | + return '/application\/(?:font-sfnt|x-font$)/'; |
|
32 | + } |
|
33 | 33 | } |
@@ -23,10 +23,10 @@ |
||
23 | 23 | |
24 | 24 | //.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm |
25 | 25 | class StarOffice extends Office { |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getMimeType(): string { |
|
30 | - return '/application\/vnd.sun.xml.*/'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getMimeType(): string { |
|
30 | + return '/application\/vnd.sun.xml.*/'; |
|
31 | + } |
|
32 | 32 | } |
@@ -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(): string { |
|
30 | - return '/application\/vnd.openxmlformats-officedocument.*/'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getMimeType(): string { |
|
30 | + return '/application\/vnd.openxmlformats-officedocument.*/'; |
|
31 | + } |
|
32 | 32 | } |
@@ -25,10 +25,10 @@ |
||
25 | 25 | |
26 | 26 | //.tiff |
27 | 27 | class TIFF extends Bitmap { |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - */ |
|
31 | - public function getMimeType(): string { |
|
32 | - return '/image\/tiff/'; |
|
33 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + */ |
|
31 | + public function getMimeType(): string { |
|
32 | + return '/image\/tiff/'; |
|
33 | + } |
|
34 | 34 | } |