# HG changeset patch # User Bernhard Herzog # Date 1370360035 -7200 # Node ID 4365320750bbe30cb507457a2813bfd4dd61f0f5 # Parent 733c32da04b871148e4d856c0ce3b9eb287365d0 Add helpers for links into the Flys wiki with optional SSO support. If a SAML ticket is known for the current user, a HTML form is generated so tha the Ticket is used to authenticate the Wiki access, otherwise a plain Link is generated similar to what the UI used before the SSO links. Part of flys/issue1265 diff -r 733c32da04b8 -r 4365320750bb gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java Tue Jun 04 17:33:55 2013 +0200 @@ -0,0 +1,44 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.client.client.ui; + +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.google.gwt.safehtml.shared.SafeHtmlUtils; + +import org.dive4elements.river.client.client.FLYS; + +public class WikiLinks +{ + public static String linkHTML(FLYS flys, String url, String text) { + String saml = flys.getCurrentUser().getSamlXMLBase64(); + String quotedUrl = SafeHtmlUtils.htmlEscape(url); + String quotedText = SafeHtmlUtils.htmlEscape(text); + if (saml != null) { + return "
" + + "" + + "" + + "
"; + } + else { + return "" + quotedText + ""; + } + } + + public static CellFormatter cellFormatter(final FLYS flys) { + return new CellFormatter() { + public String format(Object value, ListGridRecord record, + int rowNum, int colNum) { + return linkHTML(flys, (String)value, record.getLinkText()); + } + }; + } +}