@Override
protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
+ String imageId = (request.getMethod() == Method.POST) ? request.getHttpRequest().getPartAsStringFailsafe("image", 36) : request.getHttpRequest().getParam("image");
+ Image image = webInterface.getCore().getImage(imageId, false);
+ if (image == null) {
+ throw new RedirectException("invalid.html");
+ }
+ if (!webInterface.getCore().isLocalSone(image.getSone())) {
+ throw new RedirectException("noPermission.html");
+ }
if (request.getMethod() == Method.POST) {
- String imageId = request.getHttpRequest().getPartAsStringFailsafe("image", 36);
- Image image = webInterface.getCore().getImage(imageId, false);
- if (image == null) {
- throw new RedirectException("invalid.html");
- }
- if (!webInterface.getCore().isLocalSone(image.getSone())) {
- throw new RedirectException("noPermission.html");
+ if (request.getHttpRequest().isPartSet("abortDelete")) {
+ throw new RedirectException("imageBrowser.html?image=" + image.getId());
}
webInterface.getCore().deleteImage(image);
throw new RedirectException("imageBrowser.html?album=" + image.getAlbum().getId());
}
+ templateContext.set("image", image);
}
}
Template imageBrowserTemplate = TemplateParser.parse(createReader("/templates/imageBrowser.html"));
Template createAlbumTemplate = TemplateParser.parse(createReader("/templates/createAlbum.html"));
Template deleteAlbumTemplate = TemplateParser.parse(createReader("/templates/deleteAlbum.html"));
+ Template deleteImageTemplate = TemplateParser.parse(createReader("/templates/deleteImage.html"));
Template noPermissionTemplate = TemplateParser.parse(createReader("/templates/noPermission.html"));
Template optionsTemplate = TemplateParser.parse(createReader("/templates/options.html"));
Template aboutTemplate = TemplateParser.parse(createReader("/templates/about.html"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteAlbumPage(deleteAlbumTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UploadImagePage(invalidTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImagePage(emptyTemplate, this)));
- pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteImagePage(emptyTemplate, this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteImagePage(deleteImageTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustPage(emptyTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustPage(emptyTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustPage(emptyTemplate, this)));
Page.UploadImage.Error.InvalidImage=The image you were trying to upload could not be recognized. Please upload only JPEG (*.jpg or *.jpeg), or PNG (*.png) images.
Page.EditImage.Title=Edit Image
+
Page.DeleteImage.Title=Delete Image
+Page.DeleteImage.Page.Title=Delete Image
+Page.DeleteImage.Text.ImageWillBeGone=This will remove the image “{image}” from your album “{album}”. If it has already been inserted into Freenet it can not be removed from there forcefully. Do you want to do delete the image?
+Page.DeleteImage.Button.Yes=Yes, delete image.
+Page.DeleteImage.Button.No=No, don’t delete image.
+
Page.EditAlbum.Title=Edit Album
Page.DeleteAlbum.Title=Delete Album
--- /dev/null
+<%include include/head.html>
+
+ <h1><%= Page.DeleteImage.Page.Title|l10n|html></h1>
+
+ <p><%= Page.DeleteImage.Text.ImageWillBeGone|l10n|replace needle="{image}" replacementKey=image.title|replace needle="{album}" replacementKey=image.album.title|html></p>
+
+ <form method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="image" value="<%image.id|html>" />
+ <button type="submit" name="confirmDelete" value="1"><%= Page.DeleteImage.Button.Yes|l10n|html></button>
+ <button type="submit" name="abortDelete" value="1"><%= Page.DeleteImage.Button.No|l10n|html></button>
+ </form>
+
+<%include include/tail.html>
<h2><%= Page.ImageBrowser.Image.Delete.Title|l10n|html></h2>
- <form id="delete-image" action="deleteImage.html" method="post">
- <input type="hidden" name="formPassword" value="<%formPassword|html>" />
+ <form id="delete-image" action="deleteImage.html" method="get">
<input type="hidden" name="image" value="<%image.id|html>" />
<button type="submit"><%= Page.ImageBrowser.Image.Button.Delete|l10n|html></button>
</form>