diff options
Diffstat (limited to 'apps/gallery')
32 files changed, 285 insertions, 100 deletions
diff --git a/apps/gallery/ajax/cover.php b/apps/gallery/ajax/cover.php index 181a919375d..068a6e9c4ec 100644 --- a/apps/gallery/ajax/cover.php +++ b/apps/gallery/ajax/cover.php @@ -70,11 +70,11 @@ $x = min((int)($x/($box_size/$result->numRows())), $result->numRows()-1); // get $result->seek($x); // never throws $path = $result->fetchRow(); $path = $path['file_path']; -$tmp = OC::$CONFIG_DATADIRECTORY . $path; -$imagesize = getimagesize($tmp); +$imagePath = OC_Filesystem::getLocalFile($img); +$imagesize = getimagesize($imagePath); header('Content-Type: image/png'); -$image = CroppedThumbnail($tmp, $box_size, $box_size); +$image = CroppedThumbnail($imagePath, $box_size, $box_size); imagepng($image); imagedestroy($image); diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php index f162fe2bc46..0c2674f8859 100644 --- a/apps/gallery/ajax/galleryOp.php +++ b/apps/gallery/ajax/galleryOp.php @@ -34,7 +34,11 @@ function handleRename($oldname, $newname) { function handleRemove($name) { OC_JSON::checkLoggedIn(); + $album_id = OC_Gallery_Album::find(OC_User::getUser(), $name); + $album_id = $album_id->fetchRow(); + $album_id = $album_id['album_id']; OC_Gallery_Album::remove(OC_User::getUser(), $name); + OC_Gallery_Photo::removeByAlbumId($album_id); } function handleGetThumbnails($albumname) { diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml index c275f39bb25..9aecb0c781d 100644 --- a/apps/gallery/appinfo/info.xml +++ b/apps/gallery/appinfo/info.xml @@ -2,7 +2,7 @@ <info> <id>gallery</id> <name>Gallery</name> - <version>0.2</version> + <version>0.3</version> <licence>AGPL</licence> <author>Bartek Przybylski</author> <require>2</require> diff --git a/apps/gallery/css/styles.css b/apps/gallery/css/styles.css index 4ada23b0b06..7872b6445ca 100644 --- a/apps/gallery/css/styles.css +++ b/apps/gallery/css/styles.css @@ -1,11 +1,14 @@ -div#gallery_list { margin: 90pt 20pt; } -div#gallery_list.leftcontent { padding-top: 15pt; margin: 0; position: absolute; bottom:0px; text-align: center; overflow: scroll; } -div#gallery_album_box { width: 200px; text-align: center; border: 0; display: inline-block; margin: 5pt; vertical-align: top; padding: 10px; position: relative; overflow: hidden; color: #999; } -div#gallery_album_box:hover { color: black; } -.leftcontent div#gallery_album_box { margin: 5px; } -div#gallery_album_box h1 { font-size: 9pt; font-family: Verdana; } -div#gallery_album_cover { width: 199px; height: 199px; border: solid 1pt #999; padding: 0; } -div#gallery_control_overlay { border: 0; position:absolute; right: 10pt; background-color: #333; opacity: 0.5; visibility:hidden; padding: 0 5pt; } -div#gallery_control_overlay a { color:white; } -#gallery_images.rightcontent { padding:10px 5px; position:absolute; bottom: 0px; overflow: scroll; } - +div#gallery_list { margin: 70pt 20pt 0 20pt; } +div#gallery_list.leftcontent { padding-top: 15pt; margin: 0; position: absolute; bottom:0px; text-align: center; overflow: auto; } +div.gallery_album_box { width: 200px; position:relative; text-align: center; border: 0; display: inline-block; margin: 5pt; vertical-align: top; padding: 20px 5px 5px 5px; position: relative; -webkit-transition: color 0.5s ease-in-out; -o-transition: color 0.5s ease-in-out; -moz-transition: color 0.5s ease-in-out;color: #BBB;} +div.gallery_album_box h1 { font-size: 9pt; font-family: Verdana; } +div.gallery_album_decoration { width: 200px; position: absolute; border: 0; height: 20px; top: 20px; text-align:right; vertical-align:middle; background-color: #eee; opacity: 0; -webkit-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out; -o-transition: opacity 0.5s ease-in-out; border-bottom-right-radius: 7px; border-bottom-left-radius: 7px; -moz-border-radius-bottomright: 7px; -moz-border-radius-bottomleft:7px;} +div.gallery_album_box:hover { color: black; } +div.gallery_album_box:hover div.gallery_album_decoration { opacity: 0.7;} +div.gallery_album_decoration a {padding: 0 4pt; cursor: pointer;} +div.gallery_album_cover { width: 200px; height: 200px; border: 0; padding: 0; position:relative;} +div.gallery_album_box:hover div.gallery_control_overlay { opacity:0.5 } +div.gallery_control_overlay a { color:white; } +#gallery_images.rightcontent { padding:10px 5px; bottom: 0px; overflow: auto; right:0px} +#scan { position:absolute; right:13.5em; top:0em; } +#scan #scanprogressbar { position:relative; display:inline-block; width:10em; height:1.5em; top:.4em; } diff --git a/apps/gallery/img/delete.png b/apps/gallery/img/delete.png Binary files differnew file mode 100644 index 00000000000..bc0c782882d --- /dev/null +++ b/apps/gallery/img/delete.png diff --git a/apps/gallery/img/rename.png b/apps/gallery/img/rename.png Binary files differnew file mode 100644 index 00000000000..9993a092df1 --- /dev/null +++ b/apps/gallery/img/rename.png diff --git a/apps/gallery/img/share.png b/apps/gallery/img/share.png Binary files differnew file mode 100644 index 00000000000..62c4627f317 --- /dev/null +++ b/apps/gallery/img/share.png diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js index e50593c0087..e78db221cff 100644 --- a/apps/gallery/js/album_cover.js +++ b/apps/gallery/js/album_cover.js @@ -10,6 +10,10 @@ $(document).ready(function() { if (targetDiv) { $(targetDiv).html(''); Albums.display(targetDiv); + $('#gallery_list').sortable({revert:true}); + $('.gallery_album_box').each(function(i, e) { + $(e).draggable({connectToSortable: '#gallery_list', handle: '.dummy'}) + }); } else { alert('Error occured: no such layer `gallery_list`'); } @@ -37,14 +41,15 @@ var totalAlbums = 0; function scanForAlbums() { var albumCounter = 0; var totalAlbums = 0; - $('#notification').text("Scanning directories"); - $("#notification").fadeIn(); - $("#notification").slideDown(); $.getJSON('ajax/galleryOp.php?operation=filescan', function(r) { if (r.status == 'success') { totalAlbums = r.paths.length; - $('#notification').text("Creating thumbnails ... " + Math.floor((albumCounter/totalAlbums)*100) + "%"); + if (totalAlbums == 0) { + $('#notification').text(t('gallery', "No photos found")).fadeIn().slideDown().delay(3000).fadeOut().slideUp(); + return; + } + $('#scanprogressbar').progressbar({ value: (albumCounter/totalAlbums)*100 }).fadeIn(); for(var a in r.paths) { $.getJSON('ajax/galleryOp.php?operation=partial_create&path='+r.paths[a], function(r) { @@ -53,10 +58,9 @@ function scanForAlbums() { } albumCounter++; - $('#notification').text("Creating thumbnails ... " + Math.floor((albumCounter/totalAlbums)*100) + "%"); + $('#scanprogressbar').progressbar({ value: (albumCounter/totalAlbums)*100 }); if (albumCounter == totalAlbums) { - $("#notification").fadeOut(); - $("#notification").slideUp(); + $('#scanprogressbar').fadeOut(); var targetDiv = document.getElementById('gallery_list'); if (targetDiv) { targetDiv.innerHTML = ''; @@ -74,35 +78,71 @@ function scanForAlbums() { } function galleryRemove(albumName) { - if (confirm("Do you wan't to remove album " + albumName + "?")) { - $.getJSON("ajax/galleryOp.php", {operation: "remove", name: albumName}, function(r) { - if (r.status == "success") { - $("#gallery_album_box[title='"+albumName+"']").remove(); - Albums.remove(albumName); - } else { - alert("Error: " + r.cause); - } - }); - } + // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore! + $( "#dialog:ui-dialog" ).dialog( "destroy" ); + $('#albumName', $("#dialog-confirm")).text(albumName); + + $( '#dialog-confirm' ).dialog({ + resizable: false, + height:150, + buttons: [{ + text: t('gallery', 'OK'), + click: function() { + $.getJSON("ajax/galleryOp.php", {operation: "remove", name: albumName}, function(r) { + if (r.status == "success") { + $(".gallery_album_box").filterAttr('data-album',albumName).remove(); + Albums.remove(albumName); + } else { + alert("Error: " + r.cause); + } + $('#dialog-confirm').dialog('close'); + }); + }}, + { + text: t('gallery', 'Cancel'), + click: function() { + $( this ).dialog( 'close' ); + }}] + }); } function galleryRename(name) { - var result = window.prompt("Input new gallery name", name); - if (result) { - if (Albums.find(result)) { - alert("Album named '" + result + "' already exists"); - return; - } - $.getJSON("ajax/galleryOp.php", {operation: "rename", oldname: name, newname: result}, function(r) { - if (r.status == "success") { - Albums.rename($("#gallery_album_box[title='"+name+"']"), result); - } else { - alert("Error: " + r.cause); - } - }); - - } else { - alert("Album name can't be empty") - } + $('#name', $('#dialog-form')).val(name); + $( "#dialog-form" ).dialog({ + height: 140, + width: 350, + modal: false, + buttons: [{ + text: t('gallery', 'Change name'), + click: function() { + var newname = $('#name', $('#dialog-form')).val(); + if (newname == name || newname == '') { + $(this).dialog("close"); + return; + } + if (Albums.find(newname)) { + alert("Album ", newname, " exists"); + $(this).dialog("close"); + return; + } + $.getJSON("ajax/galleryOp.php", {operation: "rename", oldname: name, newname: newname}, function(r) { + if (r.status == "success") { + Albums.rename($(".gallery_album_box").filterAttr('data-album',name), newname); + } else { + alert("Error: " + r.cause); + } + $('#dialog-form').dialog("close"); + }); + + } + }, + { + text: t('gallery', 'Cancel'), + click: function() { + $( this ).dialog( "close" ); + } + } + ], + }); } diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js index 546aadba49f..59efb5b5659 100644 --- a/apps/gallery/js/albums.js +++ b/apps/gallery/js/albums.js @@ -41,27 +41,34 @@ Albums={ // displays gallery in linear representation // on given element, and apply default styles for gallery display: function(element) { - var displayTemplate = '<div id="gallery_album_box" title="*NAME*"><div id="gallery_control_overlay"><a href="#" onclick="galleryRename(\'*NAME*\');return false;">rename</a> | <a href="#" onclick="galleryRemove(\'*NAME*\');">remove</a></div><a href="?view=*NAME*"><div id="gallery_album_cover" title="*NAME*"></div></a><h1>*NAME*</h1></div></div>'; + var displayTemplate = '<div class="gallery_album_box"><div class="dummy"></div><a class="view"><div class="gallery_album_cover"></div></a><h1></h1><div class="gallery_album_decoration"><a><img src="img/share.png" title="Share"></a><a class="rename"><img src="img/rename.png" title="Rename"></a><a class="remove"><img src="img/delete.png" title="Delete"></a></div></div>'; for (var i in Albums.albums) { var a = Albums.albums[i]; - var local = $(displayTemplate.replace(/\*NAME\*/g, a.name)); - $("#gallery_album_cover", local).css('background-repeat', 'no-repeat'); - $("#gallery_album_cover", local).css('background-position', '0'); - $("#gallery_album_cover", local).css('background-image','url("ajax/galleryOp.php?operation=get_covers&albumname='+a.name+'")'); - local.mouseover(function(e) { - $("#gallery_control_overlay", this).css('visibility','visible'); - }); - local.mouseout(function(e) { - $("#gallery_control_overlay", this).css('visibility','hidden'); - }); - $("#gallery_album_cover", local).mousemove(function(e) { + var local=$(displayTemplate); + local.attr('data-album',a.name); + $(".gallery_album_decoration a.rename", local).click(function(name,event){ + event.preventDefault(); + galleryRename(name); + }.bind(null,a.name)); + $(".gallery_album_decoration a.remove", local).click(function(name,event){ + event.preventDefault(); + galleryRemove(name); + }.bind(null,a.name)); + $("a.view", local).attr('href','?view='+a.name); + $('h1',local).text(a.name); + $(".gallery_album_cover", local).attr('title',a.name); + $(".gallery_album_cover", local).css('background-repeat', 'no-repeat'); + $(".gallery_album_cover", local).css('background-position', '0'); + $(".gallery_album_cover", local).css('background-image','url("ajax/galleryOp.php?operation=get_covers&albumname='+a.name+'")'); + $(".gallery_album_cover", local).mousemove(function(e) { var albumMetadata = Albums.find(this.title); if (albumMetadata == undefined) { return; } - var x = Math.min(Math.floor((e.layerX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)), albumMetadata.numOfCovers-1); - x *= this.offsetWidth-1; + var x = Math.floor((e.layerX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)); + x *= this.offsetWidth; + if (x < 0) x=0; $(this).css('background-position', -x+'px 0'); }); $(element).append(local); @@ -69,8 +76,8 @@ Albums={ }, rename: function(element, new_name) { if (new_name) { - $(element).attr("title", new_name); - $("a", element).attr("href", "?view="+new_name); + $(element).attr("data-album", new_name); + $("a.view", element).attr("href", "?view="+new_name); $("h1", element).text(new_name); } } diff --git a/apps/gallery/l10n/ar.php b/apps/gallery/l10n/ar.php new file mode 100644 index 00000000000..64eec0f735d --- /dev/null +++ b/apps/gallery/l10n/ar.php @@ -0,0 +1,10 @@ +<?php $TRANSLATIONS = array( +"Gallery" => "معرض صور", +"Scanning directories" => "بحث في المجلدات", +"No photos found" => "لم يتم العثور على صور", +"Creating thumbnails" => "صناعة مصغرات", +"Do you wan't to remove album" => "هل تريد محي الالبوم", +"Input new gallery name" => "أدخل اسم معرض جديد", +"Rescan" => "اعادة البحث", +"Back" => "رجوع" +); diff --git a/apps/gallery/l10n/ca.php b/apps/gallery/l10n/ca.php index f3eb40df553..39463a055e4 100644 --- a/apps/gallery/l10n/ca.php +++ b/apps/gallery/l10n/ca.php @@ -1,5 +1,10 @@ <?php $TRANSLATIONS = array( "Gallery" => "Galeria", +"Scanning directories" => "S'estan escanejant carpetes", +"No photos found" => "No s'han trobat fotos", +"Creating thumbnails" => "S'estan creant miniatures", +"Do you wan't to remove album" => "Voleu eliminar l'àlbum", +"Input new gallery name" => "Escriviu el nom nou de la galeria", "Rescan" => "Escaneja de nou", "Back" => "Enrera" ); diff --git a/apps/gallery/l10n/cs_CZ.php b/apps/gallery/l10n/cs_CZ.php new file mode 100644 index 00000000000..446374389ad --- /dev/null +++ b/apps/gallery/l10n/cs_CZ.php @@ -0,0 +1,10 @@ +<?php $TRANSLATIONS = array( +"Gallery" => "Galerie", +"Scanning directories" => "Prohledávám adresáře", +"No photos found" => "Nenalezeny žádné fotky", +"Creating thumbnails" => "Vytvářím náhledy", +"Do you wan't to remove album" => "Chcete odstranit album?", +"Input new gallery name" => "Zadejte nový název galerie", +"Rescan" => "Opakované prohledání", +"Back" => "Zpět" +); diff --git a/apps/gallery/l10n/da.php b/apps/gallery/l10n/da.php new file mode 100644 index 00000000000..713ffdbadc9 --- /dev/null +++ b/apps/gallery/l10n/da.php @@ -0,0 +1,10 @@ +<?php $TRANSLATIONS = array( +"Gallery" => "Galleri", +"Scanning directories" => "Gennemgår mapper", +"No photos found" => "Ingen billeder fundet", +"Creating thumbnails" => "Danner miniaturer", +"Do you wan't to remove album" => "Ønsker du at fjerne albummet", +"Input new gallery name" => "Indtast navn på nyt galleri", +"Rescan" => "Genindlæs", +"Back" => "Tilbage" +); diff --git a/apps/gallery/l10n/de.php b/apps/gallery/l10n/de.php index b7f1934189a..e72df4e5cb0 100644 --- a/apps/gallery/l10n/de.php +++ b/apps/gallery/l10n/de.php @@ -1,5 +1,10 @@ <?php $TRANSLATIONS = array( "Gallery" => "Galerie", +"Scanning directories" => "Ordner werden durchsucht.", +"No photos found" => "Keine Fotos gefunden", +"Creating thumbnails" => "Thumbnails werden erstellt.", +"Do you wan't to remove album" => "Soll das Album entfernt werden?", +"Input new gallery name" => "Gib den Albumnamen ein.", "Rescan" => "Rescan", "Back" => "Zurück" ); diff --git a/apps/gallery/l10n/es.php b/apps/gallery/l10n/es.php new file mode 100644 index 00000000000..96cee7b1d8b --- /dev/null +++ b/apps/gallery/l10n/es.php @@ -0,0 +1,10 @@ +<?php $TRANSLATIONS = array( +"Gallery" => "Galería", +"Scanning directories" => "Escaneando directorios", +"No photos found" => "No se encontraron fotos", +"Creating thumbnails" => "Creando miniaturas", +"Do you wan't to remove album" => "Quieres eliminar el álbum", +"Input new gallery name" => "Introduce el nuevo nombre de la galería", +"Rescan" => "Refrescar", +"Back" => "Atrás" +); diff --git a/apps/gallery/l10n/et_EE.php b/apps/gallery/l10n/et_EE.php new file mode 100644 index 00000000000..1a862db78f7 --- /dev/null +++ b/apps/gallery/l10n/et_EE.php @@ -0,0 +1,5 @@ +<?php $TRANSLATIONS = array( +"Gallery" => "Galerii", +"Rescan" => "Skänni uuesti", +"Back" => "Tagasi" +); diff --git a/apps/gallery/l10n/fr.php b/apps/gallery/l10n/fr.php index 17902bd70c9..6668ec6da6b 100644 --- a/apps/gallery/l10n/fr.php +++ b/apps/gallery/l10n/fr.php @@ -1,5 +1,9 @@ <?php $TRANSLATIONS = array( "Gallery" => "Galerie", +"Scanning directories" => "Analyse des répertoires", +"Creating thumbnails" => "Création des miniatures", +"Do you wan't to remove album" => "Voulez-vous supprimer l'album", +"Input new gallery name" => "Entrez le nom de l'album", "Rescan" => "Analyser à nouveau", "Back" => "Retour" ); diff --git a/apps/gallery/l10n/ia.php b/apps/gallery/l10n/ia.php new file mode 100644 index 00000000000..6c65a396d99 --- /dev/null +++ b/apps/gallery/l10n/ia.php @@ -0,0 +1,3 @@ +<?php $TRANSLATIONS = array( +"Back" => "Retro" +); diff --git a/apps/gallery/l10n/it.php b/apps/gallery/l10n/it.php index 0f95cc3af66..789940f0e78 100644 --- a/apps/gallery/l10n/it.php +++ b/apps/gallery/l10n/it.php @@ -1,5 +1,10 @@ <?php $TRANSLATIONS = array( "Gallery" => "Galleria", +"Scanning directories" => "Analisi cartelle in corso", +"No photos found" => "Nessuna foto trovata", +"Creating thumbnails" => "Creazione anteprime in corso", +"Do you wan't to remove album" => "Vuoi rimuovere l'album", +"Input new gallery name" => "Inserisci il nome della nuova galleria", "Rescan" => "Rileggi", "Back" => "Indietro" ); diff --git a/apps/gallery/l10n/ja_JP.php b/apps/gallery/l10n/ja_JP.php new file mode 100644 index 00000000000..20916cca85a --- /dev/null +++ b/apps/gallery/l10n/ja_JP.php @@ -0,0 +1,10 @@ +<?php $TRANSLATIONS = array( +"Gallery" => "ギャラリー", +"Scanning directories" => "ディレクトリをスキャン中", +"No photos found" => "写真が見つかりませんでした", +"Creating thumbnails" => "サムネイルを作成中", +"Do you wan't to remove album" => "アルバムを削除しますか", +"Input new gallery name" => "新しいギャラリー名を作る", +"Rescan" => "再スキャン", +"Back" => "戻る" +); diff --git a/apps/gallery/l10n/pl.php b/apps/gallery/l10n/pl.php index d0c51c0f814..20baaf713ab 100644 --- a/apps/gallery/l10n/pl.php +++ b/apps/gallery/l10n/pl.php @@ -1,6 +1,10 @@ <?php $TRANSLATIONS = array( - "Gallery" => "Galeria", - "Rescan" => "Przeskanuj", - "Back" => "Wróć" +"Gallery" => "Galeria", +"Scanning directories" => "Skanuje katalogi", +"No photos found" => "Nie znaleziono zdjęć", +"Creating thumbnails" => "Tworzenie miniatur", +"Do you wan't to remove album" => "Czy chcesz usunąć album", +"Input new gallery name" => "Wprowadź nową nazwę galerii", +"Rescan" => "Przeskanuj", +"Back" => "Wróć" ); -?> diff --git a/apps/gallery/l10n/ru.php b/apps/gallery/l10n/ru.php new file mode 100644 index 00000000000..cc211f6c1e2 --- /dev/null +++ b/apps/gallery/l10n/ru.php @@ -0,0 +1,9 @@ +<?php $TRANSLATIONS = array( +"Gallery" => "Галерея", +"Scanning directories" => "Сканирование папок", +"Creating thumbnails" => "Создание миниатюр", +"Do you wan't to remove album" => "Вы желаете удалить альбом", +"Input new gallery name" => "Введите название галереи", +"Rescan" => "Пересканировать", +"Back" => "Назад" +); diff --git a/apps/gallery/l10n/sk_SK.php b/apps/gallery/l10n/sk_SK.php index d8ae41af96e..26301562cfd 100644 --- a/apps/gallery/l10n/sk_SK.php +++ b/apps/gallery/l10n/sk_SK.php @@ -1,5 +1,10 @@ <?php $TRANSLATIONS = array( "Gallery" => "Galéria", +"Scanning directories" => "Prehľadávam priečinky", +"No photos found" => "Neboli nájdené žiadne fotografie", +"Creating thumbnails" => "Vytváram náhľady", +"Do you wan't to remove album" => "Chcete odstrániť album", +"Input new gallery name" => "Vložte meno novej galérie", "Rescan" => "Znovu oskenovať", "Back" => "Späť" ); diff --git a/apps/gallery/l10n/th_TH.php b/apps/gallery/l10n/th_TH.php new file mode 100644 index 00000000000..fa6c84f03dc --- /dev/null +++ b/apps/gallery/l10n/th_TH.php @@ -0,0 +1,10 @@ +<?php $TRANSLATIONS = array( +"Gallery" => "แกลอรี่", +"Scanning directories" => "กำลังสแกนไดเร็กทอรี่", +"No photos found" => "ไม่พบรูปภาพที่ต้องการ", +"Creating thumbnails" => "การสร้างรูปขนาดย่อ", +"Do you wan't to remove album" => "คุณต้องการลบอัลบั้มนี้ออกหรือไม่", +"Input new gallery name" => "กรอกชื่อแกลอรี่ใหม่", +"Rescan" => "ตรวจสอบอีกครั้ง", +"Back" => "ย้อนกลับ" +); diff --git a/apps/gallery/l10n/zh_CN.php b/apps/gallery/l10n/zh_CN.php index c506600c4c0..c7d37692ae0 100644 --- a/apps/gallery/l10n/zh_CN.php +++ b/apps/gallery/l10n/zh_CN.php @@ -1,5 +1,9 @@ <?php $TRANSLATIONS = array( -"Gallery" => "画廊", +"Gallery" => "图库", +"Scanning directories" => "扫描目录", +"Creating thumbnails" => "创建缩略图", +"Do you wan't to remove album" => "您是否想要移除相册", +"Input new gallery name" => "输入新图库名称", "Rescan" => "重新扫描", "Back" => "返回" ); diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index 72653c8de15..4eb12cc0b81 100644 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -28,7 +28,7 @@ class OC_Gallery_Album { } public static function rename($oldname, $newname, $owner) { - $stmt = OC_DB::prepare('UPDATE OR IGNORE *PREFIX*gallery_albums SET album_name=? WHERE uid_owner=? AND album_name=?'); + $stmt = OC_DB::prepare('UPDATE *PREFIX*gallery_albums SET album_name=? WHERE uid_owner=? AND album_name=?'); $stmt->execute(array($newname, $owner, $oldname)); } @@ -69,12 +69,14 @@ class OC_Gallery_Album { $sql .= ' AND album_path = ?'; $args[] = $path; } + $sql .= ' ORDER BY album_name ASC'; + $stmt = OC_DB::prepare($sql); return $stmt->execute($args); } public static function changePath($oldname, $newname, $owner) { - $stmt = OC_DB::prepare('UPDATE OR IGNORE *PREFIX*gallery_albums SET album_path=? WHERE uid_owner=? AND album_path=?'); + $stmt = OC_DB::prepare('UPDATE *PREFIX*gallery_albums SET album_path=? WHERE uid_owner=? AND album_path=?'); $stmt->execute(array($newname, $owner, $oldname)); } diff --git a/apps/gallery/lib/hooks_handlers.php b/apps/gallery/lib/hooks_handlers.php index 7248e67f0a2..236a4b96a07 100644 --- a/apps/gallery/lib/hooks_handlers.php +++ b/apps/gallery/lib/hooks_handlers.php @@ -32,10 +32,8 @@ class OC_Gallery_Hooks_Handlers { private static $APP_TAG = "Gallery"; private static function isPhoto($filename) { - OC_Log::write(self::$APP_TAG, "Checking file ".$filename." with mimetype ".OC_Filesystem::getMimeType($filename), OC_Log::DEBUG); - if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/") - return true; - return false; + $ext = strtolower(substr($filename, strrpos($filename, '.')+1)); + return $ext=='png' || $ext=='jpeg' || $ext=='jpg' || $ext=='gif'; } private static function directoryContainsPhotos($dirpath) { @@ -65,21 +63,8 @@ class OC_Gallery_Hooks_Handlers { if (!self::isPhoto($fullpath)) return; - OC_Log::write(self::$APP_TAG, 'Adding file with path '. $fullpath, OC_Log::DEBUG); $path = substr($fullpath, 0, strrpos($fullpath, '/')); - if ($path == '') $path = '/'; - $album = OC_Gallery_Album::find(OC_User::getUser(), null, $path); - - if ($album->numRows() == 0) { - $album = self::createAlbum($path); - } - $album = $album->fetchRow(); - $albumId = $album['album_id']; - $photo = OC_Gallery_Photo::find($albumId, $fullpath); - if ($photo->numRows() == 0) { // don't duplicate photo entries - OC_Log::write(self::$APP_TAG, 'Adding new photo to album', OC_Log::DEBUG); - OC_Gallery_Photo::create($albumId, $fullpath); - } + OC_Gallery_Scanner::scanDir($path, $albums); } @@ -87,6 +72,7 @@ class OC_Gallery_Hooks_Handlers { $path = $params[OC_Filesystem::signal_param_path]; if (OC_Filesystem::is_dir($path) && self::directoryContainsPhotos($path)) { OC_Gallery_Album::removeByPath($path, OC_User::getUser()); + OC_Gallery_Photo::removeByPath($path.'/%'); } elseif (self::isPhoto($path)) { OC_Gallery_Photo::removeByPath($path); } diff --git a/apps/gallery/lib/images_utils.php b/apps/gallery/lib/images_utils.php index 0cfa52eb564..126298913be 100644 --- a/apps/gallery/lib/images_utils.php +++ b/apps/gallery/lib/images_utils.php @@ -21,7 +21,11 @@ * */ -require_once('../../../lib/base.php'); +if (file_exists('../../../lib/base.php')) + require_once('../../../lib/base.php'); +elseif (file_exists('lib/base.php')) + require_once('lib/base.php'); + OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('gallery'); diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 14b0c4b2a07..d1fb166aee9 100644 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -47,7 +47,7 @@ class OC_Gallery_Photo{ } public static function removeByPath($path) { - $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE file_path = ?'); + $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE file_path LIKE ?'); $stmt->execute(array($path)); } diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 4ce38a99531..dfb9edebfea 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -59,9 +59,10 @@ class OC_Gallery_Scanner { $albums['imagesCount'] = $current_album['imagesCount']; $albums['albumName'] = $current_album['name']; - $result = OC_Gallery_Album::find(OC_User::getUser(), $current_album['name']); + $result = OC_Gallery_Album::find(OC_User::getUser(), /*$current_album['name']*/ null, $path); + // don't duplicate galleries with same path (bug oc-33) if ($result->numRows() == 0 && count($current_album['images'])) { - OC_Gallery_Album::create(OC_User::getUser(), $current_album['name'], $path); + OC_Gallery_Album::create(OC_User::getUser(), $current_album['name'], $path); $result = OC_Gallery_Album::find(OC_User::getUser(), $current_album['name']); } $albumId = $result->fetchRow(); @@ -81,15 +82,15 @@ class OC_Gallery_Scanner { $file_count = min(count($files), 10); $thumbnail = imagecreatetruecolor($file_count*200, 200); for ($i = 0; $i < $file_count; $i++) { - CroppedThumbnail(OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/files/'.$files[$i], 200, 200, $thumbnail, $i*200); + $imagePath = OC_Filesystem::getLocalFile($files[$i]); + CroppedThumbnail($imagePath, 200, 200, $thumbnail, $i*200); } imagepng($thumbnail, OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/' . $albumName.'.png'); } public static function isPhoto($filename) { - if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/") - return 1; - return 0; + $ext = strtolower(substr($filename, strrpos($filename, '.')+1)); + return $ext=='png' || $ext=='jpeg' || $ext=='jpg' || $ext=='gif'; } public static function find_paths($path) { diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index eb6ebd1bb7b..4c2fbcfe6c6 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -7,8 +7,24 @@ $l = new OC_L10N('gallery'); <div id="notification"><div id="gallery_notification_text">Creating thumbnails</div></div> <div id="controls"> - <input type="button" value="<?php echo $l->t('Rescan');?>" onclick="javascript:scanForAlbums();" /> - <br/> + <div id="scan"> + <div id="scanprogressbar"></div> + <input type="button" value="<?php echo $l->t('Rescan');?>" onclick="javascript:scanForAlbums();" /> + </div> </div> <div id="gallery_list"> </div> + +<div id="dialog-confirm" title="<?php echo $l->t('Remove confirmation');?>" style="display: none"> + <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo $l->t('Do you want to remove album');?> <span id="albumName"></span>?</p> +</div> + +<div id="dialog-form" title="<?php echo $l->t('Change album name');?>" style="display:none"> + <form> + <fieldset> + <label for="name"><?php echo $l->t('New album name');?></label> + <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" /> + </fieldset> + </form> +</div> + diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php index 55a2ee09e4a..6b513a672d5 100644 --- a/apps/gallery/templates/view_album.php +++ b/apps/gallery/templates/view_album.php @@ -32,3 +32,16 @@ foreach ($_['photos'] as $a) { } ?> </div> + +<div id="dialog-confirm" title="<?php echo $l->t('Remove confirmation');?>" style="display: none"> + <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo $l->t('Do you want to remove album');?> <span id="albumName"></span>?</p> +</div> + +<div id="dialog-form" title="<?php echo $l->t('Change album name');?>" style="display:none"> + <form> + <fieldset> + <label for="name"><?php echo $l->t('New album name');?></label> + <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" /> + </fieldset> + </form> +</div> |