From 9968d4b91ef653a69a32d2485ef600572247bd3b Mon Sep 17 00:00:00 2001 From: rpiazzi Date: Fri, 23 Sep 2011 15:14:03 +0000 Subject: The buergerkarte.at header-pages has changed to dynamic php pages. Therefore standalone.jsp now has to read the header php files from the net, make some changes and insert the header. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@824 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- pdf-as-web/src/main/webapp/sitemesh/standalone.jsp | 189 ++++++++++++++++++--- 1 file changed, 164 insertions(+), 25 deletions(-) (limited to 'pdf-as-web/src/main/webapp/sitemesh/standalone.jsp') diff --git a/pdf-as-web/src/main/webapp/sitemesh/standalone.jsp b/pdf-as-web/src/main/webapp/sitemesh/standalone.jsp index 1349a67..740a587 100644 --- a/pdf-as-web/src/main/webapp/sitemesh/standalone.jsp +++ b/pdf-as-web/src/main/webapp/sitemesh/standalone.jsp @@ -1,37 +1,176 @@ - -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%> - + -<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%> +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> +<%@taglib prefix="page" uri="http://www.opensymphony.com/sitemesh/page" %> + +<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %> <%@ page import="at.gv.egiz.pdfas.web.helper.LocalRequestHelper" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> +<%@ page import="java.net.URL" %> +<%@ page import="java.net.URLConnection" %> +<%@ page import="java.io.InputStream" %> +<%@ page import="java.io.InputStreamReader" %> +<%@ page import="java.io.BufferedReader" %> +<%@ page import="net.htmlparser.jericho.Source" %> +<%@ page import="net.htmlparser.jericho.Element" %> +<%@ page import="net.htmlparser.jericho.Attributes" %> +<%@ page import="net.htmlparser.jericho.Attribute" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.Iterator" %> +<%@ page import="java.util.Locale" %> +<%@ page import="at.gv.egiz.pdfas.web.i18n.LocaleParamFilter" %> +<%@ page import="java.nio.charset.Charset" %> +<%@ page import="at.gv.egiz.pdfas.web.session.SessionAttributes" %> + - +<%@page import="java.nio.charset.Charset"%> + + + + + <% - boolean testMode = request.getContextPath().startsWith("/test-"); + + String headerUrl="http://www.buergerkarte.at/header.php?lang="; + //String headerUrl="http://www.buergerkarte.at/header.php"; + String serverUrl=LocalRequestHelper.getLocalServerAddress(request,response); + + String requestLang = (String)request.getParameter("lang"); + + String language = ""; + + URL urlHeader = new URL(headerUrl); + + if (requestLang!=null) { + if (requestLang.equals("de")) { + urlHeader = new URL(headerUrl+"de"); + language="de"; + } + else { + urlHeader = new URL(headerUrl+"en"); + language="en"; + } + } + else { + urlHeader = new URL(headerUrl+"de"); + language="de"; + } + + URLConnection ucHeader = urlHeader.openConnection(); + + InputStream isHeader = ucHeader.getInputStream(); + + //Read the header php files from the server + BufferedReader brHeader = new BufferedReader(new InputStreamReader(isHeader, Charset.forName("UTF-8"))); + + String phpLine=""; + String phpHeader=""; + while ((phpLine=brHeader.readLine())!=null) { + phpHeader += phpLine; + } + + phpHeader = phpHeader.substring(phpHeader.indexOf(""), phpHeader.length()); + + Source source = new Source(phpHeader); + List list = source.getAllElements(); + Iterator it = list.iterator(); + while (it.hasNext()) { + Element element = (Element)it.next(); + + //Set the absolute path for each element with src or href + String attributeValueSrc = element.getAttributeValue("src"); + String attributeValueHref = element.getAttributeValue("href"); + + if ((attributeValueSrc!=null) || (attributeValueHref!=null)) { + + String attribute = ""; + + if ((attributeValueSrc!=null) && (attributeValueHref!=null)) { + phpHeader = phpHeader.replace(attributeValueSrc, serverUrl+attributeValueSrc); + phpHeader = phpHeader.replace(attributeValueHref, serverUrl+attributeValueHref); + } + else { + if (attributeValueSrc!=null) { + phpHeader = phpHeader.replace(attributeValueSrc, serverUrl+attributeValueSrc); + } + if (attributeValueHref!=null) { + phpHeader = phpHeader.replace(attributeValueHref, serverUrl+attributeValueHref); + } + } + } + } + + //Insert a hidden language fake link, that is shown when the change of language is disabled + int positionToInsertLangLink = 0; + source = new Source(phpHeader); + list = source.getAllElements("ul"); + it = list.iterator(); + while (it.hasNext()) { + Element element = (Element)it.next(); + positionToInsertLangLink = element.getEnd(); + } + + String languagelink; + if (!language.equals("de")) { + languagelink = "
\"DeutscheDeutsche Version
"; + languagelink += "
\"DeutscheDeutsche Version
"; + } + else { + languagelink = "
\"EnglishEnglish Version
"; + languagelink += "
\"EnglishEnglish Version
"; + } + + + String firstPart = phpHeader.substring(0, positionToInsertLangLink); + String secondPart = phpHeader.substring(positionToInsertLangLink, phpHeader.length()); + + phpHeader = firstPart+languagelink+secondPart; + %> - - + PDF Signature + + <% + if (language.equals("de")) { %> + + <% } else { %> + + <% } %> + + + + - - <fmt:message key="<%= testMode ? \"test.common.title\" : \"common.title\" %>"/> - + + + - + - - - - -
- - - - -
-
+ <%= phpHeader %> + +
+ +
+ +
+ +
+
+
+ - -- cgit v1.2.3