Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
f029312e
Commit
f029312e
authored
10 years ago
by
Thomas Müller
Browse files
Options
Downloads
Patches
Plain Diff
fixing typos/spellings
parent
c7324f7e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/preview.php
+11
-4
11 additions, 4 deletions
lib/private/preview.php
tests/lib/preview.php
+16
-16
16 additions, 16 deletions
tests/lib/preview.php
with
27 additions
and
20 deletions
lib/private/preview.php
+
11
−
4
View file @
f029312e
...
...
@@ -13,6 +13,8 @@
*/
namespace
OC
;
use
OC\Preview\Provider
;
require_once
'preview/image.php'
;
require_once
'preview/movies.php'
;
require_once
'preview/mp3.php'
;
...
...
@@ -46,8 +48,9 @@ class Preview {
// index is path, value is fileinfo
static
public
$deleteFileMapper
=
array
();
//preview images object
/**
* preview images object
*
* @var \OC_Image
*/
private
$preview
;
...
...
@@ -198,7 +201,7 @@ class Preview {
}
/**
* @brief set mimetype explicit
e
ly
* @brief set mimetype explicitly
* @param string $mimetype
*/
public
function
setMimetype
(
$mimetype
)
{
...
...
@@ -361,6 +364,7 @@ class Preview {
return
false
;
}
/**
* @brief get possible bigger thumbnails of the given image
* @param int $fileId fileId of the original image
...
...
@@ -396,6 +400,7 @@ class Preview {
return
$possibleThumbnails
;
}
private
function
getDimensionsFromFilename
(
$name
)
{
$size
=
explode
(
'-'
,
$name
);
$x
=
(
int
)
$size
[
0
];
...
...
@@ -403,6 +408,7 @@ class Preview {
$aspectRatio
=
(
float
)
(
$x
/
$y
);
return
array
(
'x'
=>
$x
,
'y'
=>
$y
,
'aspectRatio'
=>
$aspectRatio
);
}
private
function
unscalable
(
$x
,
$y
)
{
$maxX
=
$this
->
getMaxX
();
...
...
@@ -422,6 +428,7 @@ class Preview {
}
return
false
;
}
/**
* @brief return a preview of a file
* @return \OC_Image
...
...
@@ -464,6 +471,7 @@ class Preview {
\OC_Log
::
write
(
'core'
,
'Generating preview for "'
.
$file
.
'" with "'
.
get_class
(
$provider
)
.
'"'
,
\OC_Log
::
DEBUG
);
/** @var $provider Provider */
$preview
=
$provider
->
getThumbnail
(
$file
,
$maxX
,
$maxY
,
$scalingUp
,
$this
->
fileView
);
if
(
!
(
$preview
instanceof
\OC_Image
))
{
...
...
@@ -507,7 +515,6 @@ class Preview {
$this
->
getPreview
();
}
$this
->
preview
->
show
(
'image/png'
);
return
;
}
/**
...
...
@@ -516,7 +523,6 @@ class Preview {
*/
public
function
show
()
{
$this
->
showPreview
();
return
;
}
/**
...
...
@@ -653,6 +659,7 @@ class Preview {
$class
=
$provider
[
'class'
];
$options
=
$provider
[
'options'
];
/** @var $object Provider */
$object
=
new
$class
(
$options
);
self
::
$providers
[
$object
->
getMimeType
()]
=
$object
;
...
...
This diff is collapsed.
Click to expand it.
tests/lib/preview.php
+
16
−
16
View file @
f029312e
...
...
@@ -17,9 +17,9 @@ class Preview extends \PHPUnit_Framework_TestCase {
$rootView
->
mkdir
(
'/'
.
$user
);
$rootView
->
mkdir
(
'/'
.
$user
.
'/files'
);
$sample
f
ile
=
'/'
.
$user
.
'/files/test.txt'
;
$sample
F
ile
=
'/'
.
$user
.
'/files/test.txt'
;
$rootView
->
file_put_contents
(
$sample
f
ile
,
'dummy file data'
);
$rootView
->
file_put_contents
(
$sample
F
ile
,
'dummy file data'
);
$x
=
50
;
$y
=
50
;
...
...
@@ -27,16 +27,16 @@ class Preview extends \PHPUnit_Framework_TestCase {
$preview
=
new
\OC\Preview
(
$user
,
'files/'
,
'test.txt'
,
$x
,
$y
);
$preview
->
getPreview
();
$file
i
nfo
=
$rootView
->
getFileInfo
(
$sample
f
ile
);
$file
i
d
=
$file
i
nfo
[
'fileid'
];
$file
I
nfo
=
$rootView
->
getFileInfo
(
$sample
F
ile
);
$file
I
d
=
$file
I
nfo
[
'fileid'
];
$thumb
c
ache
f
ile
=
'/'
.
$user
.
'/'
.
\OC\Preview
::
THUMBNAILS_FOLDER
.
'/'
.
$file
i
d
.
'/'
.
$x
.
'-'
.
$y
.
'.png'
;
$thumb
C
ache
F
ile
=
'/'
.
$user
.
'/'
.
\OC\Preview
::
THUMBNAILS_FOLDER
.
'/'
.
$file
I
d
.
'/'
.
$x
.
'-'
.
$y
.
'.png'
;
$this
->
assertEquals
(
$rootView
->
file_exists
(
$thumb
c
ache
f
ile
),
true
);
$this
->
assertEquals
(
$rootView
->
file_exists
(
$thumb
C
ache
F
ile
),
true
);
$preview
->
deletePreview
();
$this
->
assertEquals
(
$rootView
->
file_exists
(
$thumb
c
ache
f
ile
),
false
);
$this
->
assertEquals
(
$rootView
->
file_exists
(
$thumb
C
ache
F
ile
),
false
);
}
public
function
testAreAllPreviewsDeleted
()
{
...
...
@@ -46,9 +46,9 @@ class Preview extends \PHPUnit_Framework_TestCase {
$rootView
->
mkdir
(
'/'
.
$user
);
$rootView
->
mkdir
(
'/'
.
$user
.
'/files'
);
$sample
f
ile
=
'/'
.
$user
.
'/files/test.txt'
;
$sample
F
ile
=
'/'
.
$user
.
'/files/test.txt'
;
$rootView
->
file_put_contents
(
$sample
f
ile
,
'dummy file data'
);
$rootView
->
file_put_contents
(
$sample
F
ile
,
'dummy file data'
);
$x
=
50
;
$y
=
50
;
...
...
@@ -56,16 +56,16 @@ class Preview extends \PHPUnit_Framework_TestCase {
$preview
=
new
\OC\Preview
(
$user
,
'files/'
,
'test.txt'
,
$x
,
$y
);
$preview
->
getPreview
();
$file
i
nfo
=
$rootView
->
getFileInfo
(
$sample
f
ile
);
$file
i
d
=
$file
i
nfo
[
'fileid'
];
$file
I
nfo
=
$rootView
->
getFileInfo
(
$sample
F
ile
);
$file
I
d
=
$file
I
nfo
[
'fileid'
];
$thumb
c
ache
f
older
=
'/'
.
$user
.
'/'
.
\OC\Preview
::
THUMBNAILS_FOLDER
.
'/'
.
$file
i
d
.
'/'
;
$thumb
C
ache
F
older
=
'/'
.
$user
.
'/'
.
\OC\Preview
::
THUMBNAILS_FOLDER
.
'/'
.
$file
I
d
.
'/'
;
$this
->
assertEquals
(
$rootView
->
is_dir
(
$thumb
c
ache
f
older
),
true
);
$this
->
assertEquals
(
$rootView
->
is_dir
(
$thumb
C
ache
F
older
),
true
);
$preview
->
deleteAllPreviews
();
$this
->
assertEquals
(
$rootView
->
is_dir
(
$thumb
c
ache
f
older
),
false
);
$this
->
assertEquals
(
$rootView
->
is_dir
(
$thumb
C
ache
F
older
),
false
);
}
public
function
testIsMaxSizeWorking
()
{
...
...
@@ -81,9 +81,9 @@ class Preview extends \PHPUnit_Framework_TestCase {
$rootView
->
mkdir
(
'/'
.
$user
);
$rootView
->
mkdir
(
'/'
.
$user
.
'/files'
);
$sample
f
ile
=
'/'
.
$user
.
'/files/test.txt'
;
$sample
F
ile
=
'/'
.
$user
.
'/files/test.txt'
;
$rootView
->
file_put_contents
(
$sample
f
ile
,
'dummy file data'
);
$rootView
->
file_put_contents
(
$sample
F
ile
,
'dummy file data'
);
$preview
=
new
\OC\Preview
(
$user
,
'files/'
,
'test.txt'
,
1000
,
1000
);
$image
=
$preview
->
getPreview
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment