root/main/trunk/greenstone3/web/interfaces/default-client-xslt/transform/util.xsl @ 23972

Revision 23972, 12.5 KB (checked in by sjm84, 8 years ago)

Moving traditional to default-client-xslt

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:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
6  xmlns:util="http://org.greenstone.gsdl3.util.XSLTUtil"
7  exclude-result-prefixes="util gslib gsf">
8 
9  <!-- some global parameters - these are set by whoever is invoking the transformation -->
10  <xsl:param name="interface_name"/>
11  <xsl:param name="library_name"/>
12
13  <xsl:include href="xml-to-string.xsl"/>
14 
15  <!-- every pages ................................................. -->
16 
17  <xsl:variable name="a"><xsl:value-of select="/page/pageRequest/paramList/param[@name='a']/@value"/></xsl:variable>
18  <xsl:variable name="collections" select="/page/pageResponse/collectionList/collection"/>
19 
20 
21  <xsl:template name="textDirectionAttribute">
22    <xsl:attribute name="dir">
23      <xsl:choose>
24    <xsl:when 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:when>
25    <xsl:otherwise>ltr</xsl:otherwise>
26      </xsl:choose>
27    </xsl:attribute>
28  </xsl:template>
29 
30 
31  <xsl:template name="defaultDividerBar">
32    <xsl:param name='text'/>
33    <xsl:choose>
34      <xsl:when test="$text">
35    <div class="divbar"><xsl:value-of select="$text"/></div>
36      </xsl:when>
37      <xsl:otherwise>
38    <div class="divbar"><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></div>
39      </xsl:otherwise>
40    </xsl:choose>
41  </xsl:template>
42 
43 
44  <xsl:template match="error">
45    Error: <xsl:value-of select="."/>
46  </xsl:template>
47 
48 
49  <xsl:template name="displayErrorsIfAny">
50    <xsl:if test="descendant::error">
51      <script language="Javascript">
52    <xsl:text disable-output-escaping="yes">
53      function removeAllChildren(node) {
54      while (node.hasChildNodes()) {
55      node.removeChild(node.firstChild);
56      }
57      }
58
59      function toggleHideError(obj) {
60      if (obj.style.display == "none") {
61      obj.style.display = "";
62      hide_link = document.getElementById("hide");
63      removeAllChildren(hide_link);
64      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">"));
65      } else {
66      obj.style.display = "none";
67      hide_link = document.getElementById("hide");
68      removeAllChildren(hide_link);
69      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">"));
70      }
71      }
72    </xsl:text>
73      </script>
74      <p align='right'><a id="hide" href="javascript:toggleHideError(error);"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'show_error')"/></a></p>
75      <div id="error" style="display: none;">
76    <xsl:apply-templates select="descendant::error"/>
77      </div>
78    </xsl:if>
79  </xsl:template>
80
81
82  <xsl:template name="noTextBar">
83    <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
84  </xsl:template>
85 
86 
87  <xsl:template name="poweredByGS3TextBar">
88    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'gs3power')"/>
89  </xsl:template>
90 
91 
92  <!-- site home ...................................................... -->
93
94  <xsl:template name="siteHomePageTitle">
95    <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
96    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'gsdl')"/><xsl:text> </xsl:text>
97  </xsl:template>
98
99
100  <xsl:template name="selectACollectionTextBar">
101    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home.select_a_collection')"/>
102  </xsl:template>
103 
104 
105  <xsl:template name="crossCollectionQuickSearchForm">
106    <xsl:apply-templates select="serviceList/service[@name='TextQuery']" mode="quicksearch"/>
107  </xsl:template>
108 
109  <xsl:template match="service[@name='TextQuery']" mode="quicksearch">
110    <form name="QuickSearch" method="get" action="{$library_name}">
111      <input type="hidden" name="a" value="q"/>
112      <input type="hidden" name="rt" value="rd"/>
113      <input type="hidden" name="s" value="{@name}"/>
114      <input type="hidden" name="s1.collection" value="all"/>
115      <input type="text" name="s1.query" size="20"/>
116      <input type="submit"><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home.quick_search')"/></xsl:attribute></input>
117    </form>
118  </xsl:template>
119 
120  <xsl:template name="collectionLinkWithImage">
121    <xsl:choose>
122      <xsl:when test="displayItem[@name='icon']">
123    <a href="{$library_name}?a=p&amp;sa=about&amp;c={@name}">
124      <img>
125        <xsl:attribute name="src">
126          <xsl:value-of select="metadataList/metadata[@name='httpPath']"/>/images/<xsl:value-of select="displayItem[@name='icon']"/>
127        </xsl:attribute>
128        <xsl:attribute name="alt">
129          <xsl:value-of select="displayItem[@name='name']"/>
130        </xsl:attribute>
131      </img>
132    </a> 
133      </xsl:when>
134      <xsl:otherwise>
135    <a class="noimage" href="{$library_name}?a=p&amp;sa=about&amp;c={@name}"> 
136      <xsl:value-of select="displayItem[@name='name']"/>
137    </a>
138      </xsl:otherwise>
139    </xsl:choose>
140  </xsl:template>
141 
142 
143  <xsl:template name="serviceClusterList">
144    <xsl:apply-templates select="serviceClusterList"/>
145  </xsl:template>
146 
147  <xsl:template match="serviceClusterList">
148    <xsl:for-each select="serviceCluster">
149      <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>
150    </xsl:for-each>
151  </xsl:template>
152
153 
154  <xsl:template name="serviceLink">
155    <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']"/>
156  </xsl:template>
157
158 
159  <xsl:template name="authenticationLink">
160    <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']"/>
161  </xsl:template>
162 
163 
164  <xsl:template name="libraryInterfaceLink">
165    <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>
166  </xsl:template>
167 
168 
169  <xsl:template name="greenstoneLogoAlternateText">
170    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'gsdl')"/>
171  </xsl:template>
172
173  <!-- about page - collection home ......................... -->
174  <xsl:variable name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
175  <xsl:param name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
176  <xsl:param name="pageType"/>
177  <xsl:variable name="this-element" select="/page/pageResponse/collection|/page/pageResponse/serviceCluster"/>
178  <xsl:variable name="this-service" select="/page/pageResponse/service/@name"/>
179
180
181  <xsl:template name="aboutCollectionPageTitle">
182    <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
183    <xsl:value-of select="/page/pageResponse/*/displayItem[@name='name']"/><xsl:text> </xsl:text>
184  </xsl:template>
185
186 
187  <xsl:template name="collectionHomeLinkWithLogoIfAvailable">
188    <a href="{$library_name}?a=p&amp;sa=about&amp;c={$collName}">
189      <xsl:choose>
190    <xsl:when test="$this-element/displayItem[@name='icon']">
191      <img border="0">
192        <xsl:attribute name="src">
193          <xsl:value-of select="$this-element/metadataList/metadata[@name='httpPath']"/>/images/<xsl:value-of select="$this-element/displayItem[@name='icon']"/>
194        </xsl:attribute>   
195        <xsl:attribute name="alt">
196          <xsl:value-of select="$this-element/displayItem[@name='name']"/>
197        </xsl:attribute>
198        <xsl:attribute name="title">
199          <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'aboutpage')"/>
200        </xsl:attribute>
201      </img>
202    </xsl:when>
203    <xsl:otherwise>
204      <xsl:value-of select="$this-element/displayItem[@name='name']"/>
205    </xsl:otherwise>
206      </xsl:choose>
207    </a>
208  </xsl:template>
209
210
211  <xsl:template name="homeButtonTop">
212    <a href="{$library_name}?a=p&amp;sa=home"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home_tip')"/></xsl:attribute>
213      <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home_b')"/></a>
214  </xsl:template>
215
216
217  <xsl:template name="helpButtonTop">
218    <xsl:choose>
219      <xsl:when test="$pageType='help'">
220    <li><a><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/></a></li>
221      </xsl:when>
222      <xsl:otherwise>
223    <li><a href="{$library_name}?a=p&amp;sa=help&amp;c={$collName}"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_tip')"/></xsl:attribute>
224        <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/>
225      </a></li>
226      </xsl:otherwise>
227    </xsl:choose>
228  </xsl:template>
229
230
231  <xsl:template name="preferencesButtonTop">
232    <xsl:choose>
233      <xsl:when test="$pageType='pref'">
234    <li><a><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/></a></li>
235      </xsl:when>
236      <xsl:otherwise>
237    <li><a href="{$library_name}?a=p&amp;sa=pref&amp;c={$collName}"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_tip')"/></xsl:attribute>
238        <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/>
239      </a></li>
240      </xsl:otherwise>
241    </xsl:choose>
242  </xsl:template>
243
244  <xsl:template name="servicesNavigationBar">
245    <xsl:for-each select="$this-element/serviceList/service">
246      <xsl:variable name="action"><xsl:choose>
247      <xsl:when test="@hidden='true'">DO_NOT_DISPLAY</xsl:when>
248      <xsl:when test="@name=$this-service">CURRENT</xsl:when>
249      <xsl:when test="@type='query'">q</xsl:when>
250      <xsl:when test="@type='browse'">b</xsl:when>
251      <xsl:when test="@type='process'">pr</xsl:when>
252      <xsl:when test="@type='applet'">a</xsl:when>
253      <xsl:otherwise>DO_NOT_DISPLAY</xsl:otherwise>
254    </xsl:choose></xsl:variable>
255      <xsl:choose>
256    <xsl:when test="$action='CURRENT'">
257      <li><a><xsl:value-of select="displayItem[@name='name']"/></a></li>
258    </xsl:when>
259    <xsl:when test="$action !='DO_NOT_DISPLAY'">
260      <li><a href="{$library_name}?a={$action}&amp;rt=d&amp;s={@name}&amp;c={$collName}"><xsl:if test="displayItem[@name='description']"><xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></a></li>
261    </xsl:when>
262      </xsl:choose>
263    </xsl:for-each>
264  </xsl:template>
265
266
267  <xsl:template name="collectionDescriptionTextAndServicesLinks">
268    <xsl:apply-templates select="pageResponse/collection|serviceCluster"/>
269  </xsl:template>
270
271  <xsl:template match="collection|serviceCluster">
272    <xsl:value-of select="displayItem[@name='description']" disable-output-escaping="yes"/>
273   
274    <xsl:apply-templates select="serviceList">
275      <xsl:with-param name="collName" select="$collName"/>
276    </xsl:apply-templates>
277  </xsl:template>
278
279
280  <xsl:template match="serviceList">
281    <xsl:param name="collName"/>
282    <h3><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'about.services')"/></h3>
283    <xsl:choose>
284      <xsl:when test="service">
285    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'about.servicehelp')"/>
286      </xsl:when>
287      <xsl:otherwise>
288    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'about.noservices')"/>
289      </xsl:otherwise>
290    </xsl:choose>
291   
292   
293    <xsl:if test="service">
294      <ul id="servicelist">     
295    <xsl:for-each select="service">
296      <xsl:variable name="action"><xsl:choose>
297          <xsl:when test="@hidden='true'">DO_NOT_DISPLAY</xsl:when>
298          <xsl:when test="@type='query'">q</xsl:when>
299          <xsl:when test="@type='browse'">b</xsl:when>
300          <xsl:when test="@type='process'">pr</xsl:when>
301          <xsl:when test="@type='applet'">a</xsl:when>
302          <xsl:otherwise>DO_NOT_DISPLAY</xsl:otherwise>
303        </xsl:choose></xsl:variable>
304      <xsl:if test="$action !='DO_NOT_DISPLAY'">
305        <li><a href="{$library_name}?a={$action}&amp;rt=d&amp;s={@name}&amp;c={$collName}"><xsl:value-of select="displayItem[@name='name']"/></a><xsl:value-of select="displayItem[@name='description']"/></li>
306      </xsl:if>
307    </xsl:for-each>
308      </ul>
309    </xsl:if>
310  </xsl:template>
311
312</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.