Add possibility to change album image.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 23 Sep 2011 09:32:24 +0000 (11:32 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 23 Sep 2011 09:32:24 +0000 (11:32 +0200)
src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java
src/main/resources/i18n/sone.en.properties
src/main/resources/templates/imageBrowser.html

index 8e3a3e9..fd4bf7c 100644 (file)
@@ -57,6 +57,11 @@ public class EditAlbumPage extends SoneTemplatePage {
                        if (!webInterface.getCore().isLocalSone(album.getSone())) {
                                throw new RedirectException("noPermission.html");
                        }
+                       String albumImageId = request.getHttpRequest().getPartAsStringFailsafe("album-image", 36);
+                       if (webInterface.getCore().getImage(albumImageId, false) == null) {
+                               albumImageId = null;
+                       }
+                       album.setAlbumImage(albumImageId);
                        String title = request.getHttpRequest().getPartAsStringFailsafe("title", 100).trim();
                        if (title.length() == 0) {
                                templateContext.set("titleMissing", true);
index e3a2e8a..75f9d41 100644 (file)
@@ -192,8 +192,10 @@ Page.ImageBrowser.Header.Images=Images
 Page.ImageBrowser.CreateAlbum.Button.CreateAlbum=Create Album
 Page.ImageBrowser.Album.Edit.Title=Edit Album
 Page.ImageBrowser.Album.Delete.Title=Delete Album
+Page.ImageBrowser.Album.Label.AlbumImage=Album Image:
 Page.ImageBrowser.Album.Label.Title=Title:
 Page.ImageBrowser.Album.Label.Description=Description:
+Page.ImageBrowser.Album.AlbumImage.Choose=Choose Album Image…
 Page.ImageBrowser.Album.Button.Save=Save Album
 Page.ImageBrowser.Album.Button.Delete=Delete Album
 Page.ImageBrowser.Image.Edit.Title=Edit Image
index a63f1a7..bb21d46 100644 (file)
                                                <input type="hidden" name="formPassword" value="<%formPassword|html>" />
                                                <input type="hidden" name="album" value="<%album.id|html>" />
 
+                                               <%if ! album.images.empty>
+                                                       <div>
+                                                               <label for="album-image"><%= Page.ImageBrowser.Album.Label.AlbumImage|l10n|html></label>
+                                                               <select name="album-image">
+                                                                       <option disabled="disabled"><%= Page.ImageBrowser.Album.AlbumImage.Choose|l10n|html></option>
+                                                                       <%foreach album.images image>
+                                                                               <option value="<% image.id|html>"<%if album.albumImage.id|match key=image.id> selected="selected"<%/if>><% image.title|html></option>
+                                                                       <%/foreach>
+                                                               </select>
+                                                       </div>
+                                               <%/if>
                                                <div>
                                                        <label for="title"><%= Page.ImageBrowser.Album.Label.Title|l10n|html></label>
                                                        <input type="text" name="title" value="<%album.title|html>" />