[Dive4elements-commits] [PATCH 2 of 4] Add imageLinkHTML function to WikiLinks class

Wald Commits scm-commit at wald.intevation.org
Fri Jun 7 11:50:00 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1370598467 -7200
# Node ID 954dbb0806f361dcc4dab69e771f02ebe585323a
# Parent  3fea9701d58d948e5a91ffb550bbdf1857ef6b7f
Add imageLinkHTML function to WikiLinks class

diff -r 3fea9701d58d -r 954dbb0806f3 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Thu Jun 06 18:23:17 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java	Fri Jun 07 11:47:47 2013 +0200
@@ -16,6 +16,27 @@
 
 public class WikiLinks
 {
+    public static String imageLinkHTML(FLYS instance, String url, String imageUrl) {
+        String saml = null;
+        if (instance != null && instance.getCurrentUser() != null) {
+            saml = instance.getCurrentUser().getSamlXMLBase64();
+        }
+        String quotedUrl = SafeHtmlUtils.htmlEscape(url);
+        String quotedImage = SafeHtmlUtils.htmlEscape(imageUrl);
+
+        if (saml != null) {
+            return "<form method=\"POST\" target=\"_blank\" action=\""
+                + quotedUrl + "\">"
+                + "<input type=\"hidden\" name=\"saml\" value=\""
+                + SafeHtmlUtils.htmlEscape(saml) + "\">"
+                + "<input type=\"image\" src=\""+ quotedImage + "\">"
+                + "</form>";
+        }
+        else {
+            return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>";
+        }
+    }
+
     public static String linkHTML(FLYS flys, String url, String text) {
         String saml = flys.getCurrentUser().getSamlXMLBase64();
         String quotedUrl = SafeHtmlUtils.htmlEscape(url);


More information about the Dive4elements-commits mailing list