creating and retrive thumbnails for intermediate galleries
This commit is contained in:
parent
7ba8dbb920
commit
de09883d86
|
@ -97,6 +97,8 @@ function handleGetGallery($path) {
|
||||||
while ($r = $result->fetchRow()) {
|
while ($r = $result->fetchRow()) {
|
||||||
$album_name = $r['album_name'];
|
$album_name = $r['album_name'];
|
||||||
$size=OC_Gallery_Album::getAlbumSize($r['album_id']);
|
$size=OC_Gallery_Album::getAlbumSize($r['album_id']);
|
||||||
|
// this is a fallback mechanism and seems expensive
|
||||||
|
if ($size == 0) $size = OC_Gallery_Album::getIntermediateGallerySize($r['album_path']);
|
||||||
|
|
||||||
$a[] = array('name' => utf8_encode($album_name), 'numOfItems' => min($size, 10),'path'=>substr($r['album_path'], $pathLen));
|
$a[] = array('name' => utf8_encode($album_name), 'numOfItems' => min($size, 10),'path'=>substr($r['album_path'], $pathLen));
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,11 +98,19 @@ class OC_Gallery_Album {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAlbumSize($id){
|
public static function getAlbumSize($id){
|
||||||
$sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?';
|
$sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?';
|
||||||
$stmt = OC_DB::prepare($sql);
|
$stmt = OC_DB::prepare($sql);
|
||||||
$result=$stmt->execute(array($id))->fetchRow();
|
$result=$stmt->execute(array($id))->fetchRow();
|
||||||
return $result['size'];
|
return $result['size'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getIntermediateGallerySize($path) {
|
||||||
|
$path .= '%';
|
||||||
|
$sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos photos, *PREFIX*gallery_albums albums WHERE photos.album_id = albums.album_id AND uid_owner = ? AND file_path LIKE ?';
|
||||||
|
$stmt = OC_DB::prepare($sql);
|
||||||
|
$result = $stmt->execute(array(OC_User::getUser(), $path))->fetchRow();
|
||||||
|
return $result['size'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -95,6 +95,15 @@ class OC_Gallery_Scanner {
|
||||||
foreach ($a as $e) {
|
foreach ($a as $e) {
|
||||||
$p .= ($p == '/'?'':'/').$e;
|
$p .= ($p == '/'?'':'/').$e;
|
||||||
OC_Gallery_Album::create(OC_User::getUser(), $e, $p);
|
OC_Gallery_Album::create(OC_User::getUser(), $e, $p);
|
||||||
|
$arr = OC_FileCache::searchByMime('image','', OC_Filesystem::getRoot().$p);
|
||||||
|
$step = floor(count($arr)/10);
|
||||||
|
if ($step == 0) $step = 1;
|
||||||
|
$na = array();
|
||||||
|
for ($j = 0; $j < count($arr); $j+=$step) {
|
||||||
|
$na[] = $p.$arr[$j];
|
||||||
|
}
|
||||||
|
if (count($na))
|
||||||
|
self::createThumbnails($e, $na);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue