source: greenstone3/trunk/web/interfaces/default/transform/util.xsl@ 18482

Last change on this file since 18482 was 18482, checked in by max, 15 years ago

Simplified the site home transformation, library.xsl defines the output method and allow the user to create its own gslib elements, addind util.xsl containing all the gslib elements provided by us.

File size: 6.6 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:gslib="http://www.greenstone.org/XSL/Library"
5 xmlns:util="http://org.greenstone.gsdl3.util.XSLTUtil"
6 exclude-result-prefixes="util gslib gsf xslt">
7
8 <!-- some global parameters - these are set by whoever is invoking the transformation -->
9 <xsl:param name="interface_name"/>
10 <xsl:param name="library_name"/>
11
12 <!-- every pages ....................................................................... -->
13
14 <xsl:variable name="a"><xsl:value-of select="/page/pageRequest/paramList/param[@name='a']/@value"/> </xsl:variable>
15 <xsl:variable name="collections" select="/page/pageResponse/collectionList/collection"/>
16
17
18 <xsl:template name="textDirectionAttribute">
19 <xsl:attribute name="dir"><xsl:if test="/page/@lang='ar' or /page/@lang='fa' or /page/@lang='he' or /page/@lang='ur' or /page/@lang='ps' or /page/@lang='prs'">rtl</xsl:if></xsl:attribute>
20 </xsl:template>
21
22
23 <xsl:template name="defaultDividerBar">
24 <xsl:param name='text'/>
25 <xsl:choose>
26 <xsl:when test="$text">
27 <div class="divbar"><xsl:value-of select="$text"/></div>
28 </xsl:when>
29 <xsl:otherwise>
30 <div class="divbar"><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></div>
31 </xsl:otherwise>
32 </xsl:choose>
33 </xsl:template>
34
35
36 <xsl:template match="error">
37 Error: <xsl:value-of select="."/>
38 </xsl:template>
39
40
41<xsl:template name="displayErrorsIfAny">
42 <xsl:if test="descendant::error">
43 <script language="Javascript">
44 <xsl:text disable-output-escaping="yes">
45 function removeAllChildren(node) {
46 while (node.hasChildNodes()) {
47 node.removeChild(node.firstChild);
48 }
49 }
50
51 function toggleHideError(obj) {
52 if (obj.style.display == "none") {
53 obj.style.display = "";
54 hide_link = document.getElementById("hide");
55 removeAllChildren(hide_link);
56 hide_link.appendChild(document.createTextNode("</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'hide_error')"/><xsl:text disable-output-escaping="yes">"));
57 } else {
58 obj.style.display = "none";
59 hide_link = document.getElementById("hide");
60 removeAllChildren(hide_link);
61 hide_link.appendChild(document.createTextNode("</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'show_error')"/><xsl:text disable-output-escaping="yes">"));
62 }
63 }
64 </xsl:text>
65 </script>
66 <p align='right'><a id="hide" href="javascript:toggleHideError(error);"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'show_error')"/></a></p>
67 <div id="error" style="display: none;">
68 <xsl:apply-templates select="descendant::error"/>
69 </div>
70 </xsl:if>
71</xsl:template>
72
73
74 <xsl:template name="noTextBar">
75 <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
76 </xsl:template>
77
78
79 <xsl:template name="poweredByGS3TextBar">
80 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'gs3power')"/>
81 </xsl:template>
82
83
84 <!-- site home ....................................................................... -->
85
86<xsl:template name="homePageTitle">
87 <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
88<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'gsdl')"/><xsl:text> </xsl:text>
89</xsl:template>
90
91
92 <xsl:template name="selectACollectionTextBar">
93 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home.select_a_collection')"/>
94 </xsl:template>
95
96
97 <xsl:template name="crossCollectionQuickSearchForm">
98 <xsl:apply-templates select="serviceList/service[@name='TextQuery']"/>
99 </xsl:template>
100
101 <xsl:template match="service[@name='TextQuery']">
102 <form name="QuickSearch" method="get" action="{$library_name}">
103 <input type="hidden" name="a" value="q"/>
104 <input type="hidden" name="rt" value="rd"/>
105 <input type="hidden" name="s" value="{@name}"/>
106 <input type="hidden" name="s1.collection" value="all"/>
107 <input type="text" name="s1.query" size="20"/>
108 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home.quick_search')"/></xsl:attribute></input>
109 </form>
110 </xsl:template>
111
112
113<xsl:template name="collectionLinkWithImage">
114 <xsl:choose>
115 <xsl:when test="displayItem[@name='icon']">
116 <a href="{$library_name}?a=p&amp;sa=about&amp;c={@name}">
117 <img>
118 <xsl:attribute name="src">
119 <xsl:value-of select="metadataList/metadata[@name='httpPath']"/>/images/<xsl:value-of select="displayItem[@name='icon']"/>
120 </xsl:attribute>
121 <xsl:attribute name="alt">
122 <xsl:value-of select="displayItem[@name='name']"/>
123 </xsl:attribute>
124 </img>
125 </a>
126 </xsl:when>
127 <xsl:otherwise>
128 <a class="noimage" href="{$library_name}?a=p&amp;sa=about&amp;c={@name}">
129 <xsl:value-of select="displayItem[@name='name']"/>
130 </a>
131 </xsl:otherwise>
132 </xsl:choose>
133</xsl:template>
134
135
136 <xsl:template name="serviceClusterList">
137 <xsl:apply-templates select="serviceClusterList"/>
138 </xsl:template>
139
140 <xsl:template match="serviceClusterList">
141 <xsl:for-each select="serviceCluster">
142 <a href="{$library_name}?a=p&amp;sa=about&amp;c={@name}"><xsl:value-of select='@name'/><xsl:value-of select="displayItem[@name='name']"/></a>
143 </xsl:for-each>
144 </xsl:template>
145
146
147 <xsl:template name="serviceLink">
148 <a href="{$library_name}?a=q&amp;rt=d&amp;s={@name}"><xsl:value-of select="displayItem[@name='name']"/></a><xsl:value-of select="displayItem[@name='description']"/>
149 </xsl:template>
150
151
152 <xsl:template name="authenticationLink">
153 <xsl:for-each select="serviceList/service[@type='authen']">
154 <li><a href="{$library_name}?a=g&amp;rt=r&amp;sa=authen&amp;s={@name}&amp;s1.aup=Login&amp;s1.un=&amp;s1.asn="><xsl:value-of select="displayItem[@name='name']"/></a><xsl:value-of select="displayItem[@name='description']"/></li></xsl:for-each>
155 </xsl:template>
156
157
158 <xsl:template name="libraryInterfaceLink">
159 <li><a href="{$library_name}?a=p&amp;sa=gli4gs3"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home.librarian_interface')"/></a></li>
160 </xsl:template>
161
162
163<xsl:template name="greenstoneLogoAlternateText">
164<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'gsdl')"/>
165</xsl:template>
166
167<!-- about page - collection home ....................................................................... -->
168
169
170
171
172</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.