view gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 6197:cefad5546373

Fix Non-UTF8 Umlaut characters.
author Christian Lins <christian.lins@intevation.de>
date Wed, 05 Jun 2013 11:54:24 +0200
parents 4365320750bb
children 954dbb0806f3
line wrap: on
line source
/* 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 "<form method=\"POST\" target=\"_blank\" action=\""
                + quotedUrl + "\">"
                + "<input type=\"hidden\" name=\"saml\" value=\""
                + SafeHtmlUtils.htmlEscape(saml) + "\">"
                + "<input type=\"submit\" value=\"" + quotedText + "\">"
                + "</form>";
        }
        else {
            return "<a href=\"" + quotedUrl + "\">" + quotedText + "</a>";
        }
    }

    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());
            }
        };
    }
}

http://dive4elements.wald.intevation.org