diff --git a/core/src/main/java/org/fao/geonet/util/XslUtil.java b/core/src/main/java/org/fao/geonet/util/XslUtil.java index 149584d5a3..ae7e05f852 100644 --- a/core/src/main/java/org/fao/geonet/util/XslUtil.java +++ b/core/src/main/java/org/fao/geonet/util/XslUtil.java @@ -75,11 +75,11 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; +import java.io.InputStreamReader; +import java.util.*; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -103,6 +103,86 @@ public final class XslUtil { private static final char CS_WKT = ' '; private static ThreadLocal allowScripting = new InheritableThreadLocal(); + private static String headerUrl; + private static String headerHeight; + + + public static String getGeorchestraHeaderUrl(){ + + if(XslUtil.headerUrl == null) { + + // Set default value + XslUtil.headerUrl = "/header/"; + + // Load value from datadir + Properties properties = XslUtil.loadDatadirProperties(); + if (properties.containsKey("headerUrl")) + XslUtil.headerUrl = properties.getProperty("headerUrl"); + } + + return XslUtil.headerUrl; + } + + public static String getGeorchestraHeaderHeight(){ + + if(XslUtil.headerHeight == null) { + + // Set default value + XslUtil.headerHeight = "90"; + + // Load value from datadir + Properties properties = XslUtil.loadDatadirProperties(); + if (properties.containsKey("headerHeight")) + XslUtil.headerHeight = properties.getProperty("headerHeight"); + } + + return XslUtil.headerHeight; + } + + private static Properties loadProperties(File path, Properties prop) throws IOException { + FileInputStream fisProp = null; + try { + fisProp = new FileInputStream(path); + InputStreamReader isrProp = new InputStreamReader(fisProp, "UTF8"); + prop.load(isrProp); + } finally { + if (fisProp != null) { + fisProp.close(); + } + } + return prop; + } + + private static Properties loadDatadirProperties(){ + + String globalDatadirPath = System.getProperty("georchestra.datadir"); + Properties properties = new Properties(); + + if (globalDatadirPath != null) { + File defaultConfiguration = new File(String.format("%s%s%s", globalDatadirPath, + File.separator, "default.properties")); + File geoserverConfiguration = new File(String.format("%s%s%s%s%s", globalDatadirPath, + File.separator, "geonetwork", File.separator, "geonetwork.properties")); + + if (defaultConfiguration.canRead()) { + try { + XslUtil.loadProperties(defaultConfiguration, properties); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (geoserverConfiguration.canRead()) { + try { + XslUtil.loadProperties(geoserverConfiguration, properties); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return properties; + } + + /** * clean the src of ' and <> */ diff --git a/web/src/main/webapp/xslt/base-layout.xsl b/web/src/main/webapp/xslt/base-layout.xsl index 3d322842ad..1e87e37b23 100644 --- a/web/src/main/webapp/xslt/base-layout.xsl +++ b/web/src/main/webapp/xslt/base-layout.xsl @@ -68,7 +68,7 @@ and a facet search to get main site information. --> - +
diff --git a/web/src/main/webapp/xslt/common/base-variables.xsl b/web/src/main/webapp/xslt/common/base-variables.xsl index 6249cfccff..8b86a84ced 100644 --- a/web/src/main/webapp/xslt/common/base-variables.xsl +++ b/web/src/main/webapp/xslt/common/base-variables.xsl @@ -33,6 +33,9 @@ + + +