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: christian@6546: import com.google.gwt.core.client.GWT; christian@6546: import com.google.gwt.safehtml.shared.SafeHtmlUtils; rrenkert@6272: import com.smartgwt.client.types.FormMethod; rrenkert@6272: import com.smartgwt.client.widgets.form.DynamicForm; christian@6546: import com.smartgwt.client.widgets.form.fields.HiddenItem; rrenkert@6272: import com.smartgwt.client.widgets.form.fields.LinkItem; rrenkert@6272: import com.smartgwt.client.widgets.form.fields.events.ClickEvent; rrenkert@6272: import com.smartgwt.client.widgets.form.fields.events.ClickHandler; bh@6189: bh@6189: import org.dive4elements.river.client.client.FLYS; christian@6546: import org.dive4elements.river.client.shared.model.User; bh@6189: bh@6189: public class WikiLinks bh@6189: { tom@8856: public static String imageLinkForm( tom@8856: FLYS instance, tom@8856: String url, tom@8856: String imageUrl, tom@8856: String formName tom@8856: ) { 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 { tom@8856: return ""; aheinecke@6230: } aheinecke@6230: } aheinecke@6230: tom@8856: public static DynamicForm linkDynamicForm( tom@8856: FLYS flys, tom@8856: String url, tom@8856: String text tom@8856: ) { christian@6546: User currentUser = flys.getCurrentUser(); bh@6189: String quotedUrl = SafeHtmlUtils.htmlEscape(url); bh@6189: String quotedText = SafeHtmlUtils.htmlEscape(text); christian@6546: christian@6546: if (currentUser != null) { christian@6546: String saml = currentUser.getSamlXMLBase64(); teichmann@6986: if (saml != null) { teichmann@6986: final DynamicForm form = new DynamicForm(); teichmann@6986: form.setMethod(FormMethod.POST); teichmann@6986: form.setTarget("_blank"); teichmann@6986: form.setAction(quotedUrl); teichmann@6986: form.setCanSubmit(true); teichmann@6986: LinkItem item = new LinkItem("saml"); teichmann@6986: item.setTextBoxStyle("font-size: large;"); teichmann@6986: item.setShowTitle(false); teichmann@6986: item.setLinkTitle(quotedText); teichmann@6986: item.setValue(SafeHtmlUtils.htmlEscape(saml)); teichmann@6986: item.addClickHandler(new ClickHandler() { teichmann@6986: @Override teichmann@6986: public void onClick(ClickEvent event) { teichmann@6986: form.submitForm(); teichmann@6986: } teichmann@6986: }); teichmann@6986: form.setFields(item); teichmann@6986: return form; teichmann@6986: } bh@6189: } teichmann@6986: DynamicForm form = new DynamicForm(); teichmann@6986: LinkItem item = new LinkItem(quotedText); teichmann@6986: item.setShowTitle(false); rrenkert@7943: item.setLinkTitle(quotedText); teichmann@6986: item.setTarget(quotedUrl); rrenkert@7943: form.setItems(item); teichmann@6986: return form; bh@6189: } christian@6546: christian@6546: public static DynamicForm dynamicForm(FLYS flys, String url) { christian@6546: User currentUser = flys.getCurrentUser(); christian@6546: String quotedUrl = SafeHtmlUtils.htmlEscape(url); christian@6546: christian@6546: if (currentUser != null) { christian@6546: String saml = currentUser.getSamlXMLBase64(); teichmann@6986: if (saml != null) { teichmann@6986: saml = SafeHtmlUtils.htmlEscape(saml); teichmann@6986: GWT.log("saml=" + saml); teichmann@6986: DynamicForm form = new DynamicForm(); teichmann@6986: form.setID("wikiDynamicForm"); teichmann@6986: form.setMethod(FormMethod.POST); teichmann@6986: form.setTarget("_blank"); teichmann@6986: form.setAction(quotedUrl); teichmann@6986: form.setCanSubmit(true); teichmann@6986: HiddenItem item = new HiddenItem("saml"); teichmann@6986: item.setDefaultValue(saml); teichmann@6986: item.setValue(saml); teichmann@6986: form.setFields(item); teichmann@6986: //form.setValue("saml", saml); teichmann@6986: return form; teichmann@6986: } christian@6546: } teichmann@6986: DynamicForm form = new DynamicForm(); teichmann@6986: form.setTarget("_blank"); teichmann@6986: form.setAction(quotedUrl); teichmann@6986: return form; christian@6546: } bh@6189: }