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
02e4e0e0
Commit
02e4e0e0
authored
12 years ago
by
Bart Visscher
Browse files
Options
Downloads
Patches
Plain Diff
Gallery: Get all the image information for a directory at once
parent
bf09edcb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/gallery/lib/managers.php
+20
-4
20 additions, 4 deletions
apps/gallery/lib/managers.php
with
20 additions
and
4 deletions
apps/gallery/lib/managers.php
+
20
−
4
View file @
02e4e0e0
...
...
@@ -4,6 +4,7 @@ namespace OC\Pictures;
class
DatabaseManager
{
private
static
$instance
=
null
;
protected
$cache
=
array
();
const
TAG
=
'DatabaseManager'
;
public
static
function
getInstance
()
{
...
...
@@ -12,13 +13,27 @@ class DatabaseManager {
return
self
::
$instance
;
}
protected
function
getPathData
(
$path
)
{
$stmt
=
\OCP\DB
::
prepare
(
'SELECT * FROM *PREFIX*pictures_images_cache
WHERE uid_owner LIKE ? AND path like ? AND path not like ?'
);
$path_match
=
$path
.
'/%'
;
$path_notmatch
=
$path
.
'/%/%'
;
$result
=
$stmt
->
execute
(
array
(
\OCP\USER
::
getUser
(),
$path_match
,
$path_notmatch
));
$this
->
cache
[
$path
]
=
array
();
while
((
$row
=
$result
->
fetchRow
())
!=
false
)
{
$this
->
cache
[
$path
][
$row
[
'path'
]]
=
$row
;
}
}
public
function
getFileData
(
$path
)
{
$gallery_path
=
\OCP\Config
::
getSystemValue
(
'datadirectory'
)
.
'/'
.
\OC_User
::
getUser
()
.
'/gallery'
;
$path
=
$gallery_path
.
$path
;
$stmt
=
\OCP\DB
::
prepare
(
'SELECT * FROM *PREFIX*pictures_images_cache WHERE uid_owner LIKE ? AND path = ?'
);
$result
=
$stmt
->
execute
(
array
(
\OCP\USER
::
getUser
(),
$path
));
if
((
$row
=
$result
->
fetchRow
())
!=
false
)
{
return
$row
;
$dir
=
dirname
(
$path
);
if
(
!
isset
(
$this
->
cache
[
$dir
]))
{
$this
->
getPathData
(
$dir
);
}
if
(
isset
(
$this
->
cache
[
$dir
][
$path
]))
{
return
$this
->
cache
[
$dir
][
$path
];
}
$image
=
new
\OC_Image
();
if
(
!
$image
->
loadFromFile
(
$path
))
{
...
...
@@ -28,6 +43,7 @@ class DatabaseManager {
$stmt
->
execute
(
array
(
\OCP\USER
::
getUser
(),
$path
,
$image
->
width
(),
$image
->
height
()));
$ret
=
array
(
'path'
=>
$path
,
'width'
=>
$image
->
width
(),
'height'
=>
$image
->
height
());
unset
(
$image
);
$this
->
cache
[
$dir
][
$path
]
=
$ret
;
return
$ret
;
}
...
...
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