christian@6197: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde bh@6189: * Software engineering by Intevation GmbH bh@6189: * bh@6189: * This file is Free Software under the GNU AGPL (>=v3) bh@6189: * and comes with ABSOLUTELY NO WARRANTY! Check out the bh@6189: * documentation coming with Dive4Elements River for details. bh@6189: */ bh@6189: bh@6189: package org.dive4elements.river.client.client.ui; bh@6189: bh@6189: import com.smartgwt.client.widgets.grid.CellFormatter; bh@6189: import com.smartgwt.client.widgets.grid.ListGridRecord; bh@6189: import com.google.gwt.safehtml.shared.SafeHtmlUtils; bh@6189: bh@6189: import org.dive4elements.river.client.client.FLYS; bh@6189: bh@6189: public class WikiLinks bh@6189: { aheinecke@6230: public static String imageLinkHTML(FLYS instance, String url, String imageUrl) { aheinecke@6230: String saml = null; aheinecke@6230: if (instance != null && instance.getCurrentUser() != null) { aheinecke@6230: saml = instance.getCurrentUser().getSamlXMLBase64(); aheinecke@6230: } aheinecke@6230: String quotedUrl = SafeHtmlUtils.htmlEscape(url); aheinecke@6230: String quotedImage = SafeHtmlUtils.htmlEscape(imageUrl); aheinecke@6230: aheinecke@6230: if (saml != null) { aheinecke@6230: return "
" aheinecke@6230: + "" aheinecke@6230: + "" aheinecke@6230: + "
"; aheinecke@6230: } aheinecke@6230: else { aheinecke@6230: return ""; aheinecke@6230: } aheinecke@6230: } aheinecke@6230: bh@6189: public static String linkHTML(FLYS flys, String url, String text) { bh@6189: String saml = flys.getCurrentUser().getSamlXMLBase64(); bh@6189: String quotedUrl = SafeHtmlUtils.htmlEscape(url); bh@6189: String quotedText = SafeHtmlUtils.htmlEscape(text); bh@6189: if (saml != null) { bh@6189: return "
" bh@6189: + "" bh@6189: + "" bh@6189: + "
"; bh@6189: } bh@6189: else { bh@6189: return "" + quotedText + ""; bh@6189: } bh@6189: } bh@6189: bh@6189: public static CellFormatter cellFormatter(final FLYS flys) { bh@6189: return new CellFormatter() { bh@6189: public String format(Object value, ListGridRecord record, bh@6189: int rowNum, int colNum) { bh@6189: return linkHTML(flys, (String)value, record.getLinkText()); bh@6189: } bh@6189: }; bh@6189: } bh@6189: }