Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
9cb54e38
Commit
9cb54e38
authored
Nov 28, 2014
by
Joas Schilling
Browse files
Fix intendation and doc blocks of preview providers
parent
fca9d325
Changes
8
Show whitespace changes
Inline
Side-by-side
lib/private/preview.php
View file @
9cb54e38
...
...
@@ -16,11 +16,6 @@ namespace OC;
use
OC\Preview\Provider
;
use
OCP\Files\NotFoundException
;
require_once
'preview/image.php'
;
require_once
'preview/movie.php'
;
require_once
'preview/mp3.php'
;
require_once
'preview/svg.php'
;
require_once
'preview/txt.php'
;
require_once
'preview/office-cl.php'
;
require_once
'preview/bitmap.php'
;
...
...
lib/private/preview/image.php
View file @
9cb54e38
...
...
@@ -9,11 +9,16 @@
namespace
OC\Preview
;
class
Image
extends
Provider
{
/**
* {@inheritDoc}
*/
public
function
getMimeType
()
{
return
'/image\/(?!tiff$)(?!svg.*).*/'
;
}
/**
* {@inheritDoc}
*/
public
function
getThumbnail
(
$path
,
$maxX
,
$maxY
,
$scalingup
,
$fileview
)
{
//get fileinfo
$fileInfo
=
$fileview
->
getFileInfo
(
$path
);
...
...
lib/private/preview/markdown.php
0 → 100644
View file @
9cb54e38
<?php
/**
* Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace
OC\Preview
;
class
MarkDown
extends
TXT
{
/**
* {@inheritDoc}
*/
public
function
getMimeType
()
{
return
'/text\/(x-)?markdown/'
;
}
}
lib/private/preview/movie.php
View file @
9cb54e38
...
...
@@ -8,14 +8,20 @@
*/
namespace
OC\Preview
;
class
Movie
extends
Provider
{
class
Movie
extends
Provider
{
public
static
$avconvBinary
;
public
static
$ffmpegBinary
;
/**
* {@inheritDoc}
*/
public
function
getMimeType
()
{
return
'/video\/.*/'
;
}
/**
* {@inheritDoc}
*/
public
function
getThumbnail
(
$path
,
$maxX
,
$maxY
,
$scalingup
,
$fileview
)
{
// TODO: use proc_open() and stream the source file ?
...
...
@@ -54,12 +60,10 @@ namespace OC\Preview;
* @param int $maxX
* @param int $maxY
* @param string $absPath
* @param string $tmpPath
* @param int $second
* @return bool|\OC_Image
*/
private
function
generateThumbNail
(
$maxX
,
$maxY
,
$absPath
,
$second
)
{
private
function
generateThumbNail
(
$maxX
,
$maxY
,
$absPath
,
$second
)
{
$tmpPath
=
\
OC_Helper
::
tmpFile
();
if
(
self
::
$avconvBinary
)
{
...
...
@@ -87,4 +91,4 @@ namespace OC\Preview;
unlink
(
$tmpPath
);
return
false
;
}
}
}
lib/private/preview/mp3.php
View file @
9cb54e38
...
...
@@ -8,11 +8,16 @@
namespace
OC\Preview
;
class
MP3
extends
Provider
{
/**
* {@inheritDoc}
*/
public
function
getMimeType
()
{
return
'/audio\/mpeg/'
;
}
/**
* {@inheritDoc}
*/
public
function
getThumbnail
(
$path
,
$maxX
,
$maxY
,
$scalingup
,
$fileview
)
{
$getID3
=
new
\
getID3
();
...
...
@@ -31,6 +36,12 @@ class MP3 extends Provider {
return
$this
->
getNoCoverThumbnail
();
}
/**
* Generates a default image when the file has no cover
*
* @return false|\OC_Image False if the default image is missing or invalid,
* otherwise the image is returned as \OC_Image
*/
private
function
getNoCoverThumbnail
()
{
$icon
=
\
OC
::
$SERVERROOT
.
'/core/img/filetypes/audio.png'
;
...
...
lib/private/preview/provider.php
View file @
9cb54e38
...
...
@@ -29,7 +29,7 @@ abstract class Provider {
* @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
object
$fileview fileview object of user folder
* @param
\OC\Files\View
$fileview fileview object of user folder
* @return mixed
* false if no preview was generated
* OC_Image object of the preview
...
...
lib/private/preview/svg.php
View file @
9cb54e38
...
...
@@ -7,17 +7,20 @@
*/
namespace
OC\Preview
;
use
Imagick
;
class
SVG
extends
Provider
{
class
SVG
extends
Provider
{
/**
* {@inheritDoc}
*/
public
function
getMimeType
()
{
return
'/image\/svg\+xml/'
;
}
public
function
getThumbnail
(
$path
,
$maxX
,
$maxY
,
$scalingup
,
$fileview
)
{
/**
* {@inheritDoc}
*/
public
function
getThumbnail
(
$path
,
$maxX
,
$maxY
,
$scalingup
,
$fileview
)
{
try
{
$svg
=
new
Imagick
();
$svg
=
new
\
Imagick
();
$svg
->
setBackgroundColor
(
new
\
ImagickPixel
(
'transparent'
));
$content
=
stream_get_contents
(
$fileview
->
fopen
(
$path
,
'r'
));
...
...
@@ -37,11 +40,10 @@ use Imagick;
return
false
;
}
//new image object
$image
=
new
\
OC_Image
();
$image
->
loadFromData
(
$svg
);
//check if image object is valid
return
$image
->
valid
()
?
$image
:
false
;
}
}
}
lib/private/preview/txt.php
View file @
9cb54e38
...
...
@@ -26,7 +26,6 @@ class TXT extends Provider {
* {@inheritDoc}
*/
public
function
getThumbnail
(
$path
,
$maxX
,
$maxY
,
$scalingup
,
$fileview
)
{
$content
=
$fileview
->
fopen
(
$path
,
'r'
);
$content
=
stream_get_contents
(
$content
,
3000
);
...
...
@@ -73,10 +72,3 @@ class TXT extends Provider {
return
$image
->
valid
()
?
$image
:
false
;
}
}
class
MarkDown
extends
TXT
{
public
function
getMimeType
()
{
return
'/text\/(x-)?markdown/'
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment