root/main/trunk/greenstone3/web/interfaces/default/transform/util.xsl @ 23336

Revision 23336, 12.5 KB (checked in by sjb48, 9 years ago)

Continued work on XHTML parsing for format statement saving. Found js code for ensuring XHTML (innerXHTML). Removed a few unneccessary bits of code from default servlet that were lingering around from when we first started playing with format statements.

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