root/greenstone3/trunk/web/interfaces/oran/transform/util.xsl @ 19856

Revision 19856, 19.5 KB (checked in by oranfry, 10 years ago)

reorganising transform for new interface

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    <xsl:variable name="berrybasketswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='berrybasket']/@value"/></xsl:variable>
18    <xsl:variable name="berryBasketOn" select="/page/pageRequest/paramList/param[@name='berrybasket' and @value='on']"/>
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    <xsl:template name="defaultDividerBar">
31   <xsl:param name='text'/>
32      <xsl:choose>
33      <xsl:when test="$text">
34     <div class="divbar"><xsl:value-of select="$text"/></div>
35      </xsl:when>
36      <xsl:otherwise>
37     <div class="divbar"><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></div>
38      </xsl:otherwise>
39    </xsl:choose>
40  </xsl:template>
41 
42 
43    <xsl:template match="error">
44    Error: <xsl:value-of select="."/>
45  </xsl:template>
46 
47 
48<xsl:template name="displayErrorsIfAny">
49      <xsl:if test="descendant::error">
50      <script language="Javascript">
51    <xsl:text disable-output-escaping="yes">
52      function removeAllChildren(node) {
53        while (node.hasChildNodes()) {
54          node.removeChild(node.firstChild);
55        }
56      }
57
58      function toggleHideError(obj) {
59        if (obj.style.display == "none") {
60          obj.style.display = "";
61          hide_link = document.getElementById("hide");
62          removeAllChildren(hide_link);
63          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">"));
64        } else {
65          obj.style.display = "none";
66          hide_link = document.getElementById("hide");
67          removeAllChildren(hide_link);
68          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">"));
69        }
70      }
71    </xsl:text>
72      </script>
73      <p align='right'><a id="hide" href="javascript:toggleHideError(error);"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'show_error')"/></a></p>
74      <div id="error" style="display: none;">
75    <xsl:apply-templates select="descendant::error"/>
76      </div>
77    </xsl:if>
78</xsl:template>
79
80
81    <xsl:template name="noTextBar">
82        <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
83    </xsl:template>
84   
85   
86    <xsl:template name="poweredByGS3TextBar">
87        <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'gs3power')"/>
88    </xsl:template>
89 
90 
91    <!-- site home ....................................................................... -->
92
93<xsl:template name="siteHomePageTitle">
94 <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
95<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'gsdl')"/><xsl:text> </xsl:text>
96</xsl:template>
97
98
99    <xsl:template name="selectACollectionTextBar">
100     <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home.select_a_collection')"/>
101  </xsl:template>
102 
103 
104    <xsl:template name="crossCollectionQuickSearchForm">
105        <xsl:apply-templates select="serviceList/service[@name='TextQuery']"/>
106    </xsl:template>
107   
108    <xsl:template match="service[@name='TextQuery']">
109        <form name="QuickSearch" method="get" action="{$library_name}">
110            <input type="hidden" name="a" value="q"/>
111            <input type="hidden" name="rt" value="rd"/>
112            <input type="hidden" name="s" value="{@name}"/>
113            <input type="hidden" name="s1.collection" value="all"/>
114            <input type="text" name="s1.query" size="20"/>
115            <input type="submit"><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home.quick_search')"/></xsl:attribute></input>
116        </form>
117    </xsl:template>
118
119    <xsl:template name="collectionLinkWithImage">
120        <xsl:choose>
121            <xsl:when test="displayItem[@name='icon']">
122                <!-- <a href="{$library_name}/{@name}"> -->
123                <a href="{$library_name}?a=p&amp;sa=about&amp;c={@name}">
124                    <xsl:attribute name="style">background-image: url('<xsl:value-of select="metadataList/metadata[@name='httpPath']"/>/images/icon-160x120.gif');</xsl:attribute>
125                    <b><xsl:value-of select="displayItem[@name='name']"/></b>
126                </a>
127            </xsl:when>
128            <xsl:otherwise>
129                <a href="{$library_name}?a=p&amp;sa=about&amp;c={@name}"> 
130                    <xsl:value-of select="displayItem[@name='name']"/>
131                </a>
132            </xsl:otherwise>
133        </xsl:choose>
134    </xsl:template>
135
136
137    <xsl:template name="serviceClusterList">
138        <xsl:apply-templates select="serviceClusterList"/>
139    </xsl:template>
140   
141      <xsl:template match="serviceClusterList">
142        <xsl:for-each select="serviceCluster">
143          <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>
144        </xsl:for-each>
145      </xsl:template>
146
147     
148      <xsl:template name="serviceLink">
149      <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']"/>
150      </xsl:template>
151
152     
153   <xsl:template name="authenticationLink">
154   <xsl:for-each select="serviceList/service[@type='authen']">
155      <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>
156  </xsl:template>
157 
158 
159   <xsl:template name="libraryInterfaceLink">
160   <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>
161  </xsl:template>
162 
163 
164<xsl:template name="greenstoneLogoAlternateText">
165<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'gsdl')"/>
166</xsl:template>
167
168<!-- about page - collection home ....................................................................... -->
169<xsl:variable name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
170<xsl:param name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
171<xsl:param name="pageType"/>
172<xsl:variable name="this-element" select="/page/pageResponse/collection|/page/pageResponse/serviceCluster"/>
173<xsl:variable name="this-service" select="/page/pageResponse/service/@name"/>
174
175
176<xsl:template name="aboutCollectionPageTitle">
177 <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
178<xsl:value-of select="/page/pageResponse/collection/displayItem[@name='name']"/><xsl:text> </xsl:text>
179</xsl:template>
180
181   
182<xsl:template name="collectionHomeLinkWithLogoIfAvailable">
183<a href="{$library_name}?a=p&amp;sa=about&amp;c={$collName}">
184      <xsl:choose>
185        <xsl:when test="$this-element/displayItem[@name='icon']">
186          <img border="0">
187        <xsl:attribute name="src">
188          <xsl:value-of select="$this-element/metadataList/metadata[@name='httpPath']"/>/images/<xsl:value-of select="$this-element/displayItem[@name='icon']"/>
189        </xsl:attribute>   
190        <xsl:attribute name="alt">
191          <xsl:value-of select="$this-element/displayItem[@name='name']"/>
192        </xsl:attribute>
193        <xsl:attribute name="title">
194          <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'aboutpage')"/>
195        </xsl:attribute>
196          </img>
197        </xsl:when>
198        <xsl:otherwise>
199          <xsl:value-of select="$this-element/displayItem[@name='name']"/>
200        </xsl:otherwise>
201      </xsl:choose>
202    </a>
203</xsl:template>
204
205
206<xsl:template name="homeButtonTop">
207<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>
208<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home_b')"/></a>
209</xsl:template>
210
211
212<xsl:template name="helpButtonTop">
213    <xsl:choose>
214      <xsl:when test="$pageType='help'">
215    <li><a><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/></a></li>
216      </xsl:when>
217      <xsl:otherwise>
218    <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>
219        <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/>
220      </a></li>
221      </xsl:otherwise>
222    </xsl:choose>
223</xsl:template>
224
225
226<xsl:template name="preferencesButtonTop">
227    <xsl:choose>
228      <xsl:when test="$pageType='pref'">
229    <li><a><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/></a></li>
230      </xsl:when>
231      <xsl:otherwise>
232    <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>
233        <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/>
234      </a></li>
235      </xsl:otherwise>
236    </xsl:choose>
237</xsl:template>
238
239<xsl:template name="servicesNavigationBar">
240        <xsl:for-each select="$this-element/serviceList/service">
241          <xsl:variable name="action"><xsl:choose>
242          <xsl:when test="@name=$this-service">CURRENT</xsl:when>
243          <xsl:when test="@type='query'">q</xsl:when>
244          <xsl:when test="@type='browse'">b</xsl:when>
245          <xsl:when test="@type='process'">pr</xsl:when>
246          <xsl:when test="@type='applet'">a</xsl:when>
247          <xsl:otherwise>DO_NOT_DISPLAY</xsl:otherwise>
248        </xsl:choose></xsl:variable>
249          <xsl:choose>
250        <xsl:when test="$action='CURRENT'">
251          <li><a><xsl:value-of select="displayItem[@name='name']"/></a></li>
252        </xsl:when>
253        <xsl:when test="$action !='DO_NOT_DISPLAY'">
254          <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>
255        </xsl:when>
256          </xsl:choose>
257        </xsl:for-each>
258</xsl:template>
259
260
261<xsl:template name="collectionDescriptionTextAndServicesLinks">
262    <xsl:apply-templates select="pageResponse/collection|serviceCluster"/>
263</xsl:template>
264
265<xsl:template match="collection|serviceCluster">
266      <xsl:value-of select="displayItem[@name='description']" disable-output-escaping="yes"/>
267     
268      <xsl:apply-templates select="serviceList">
269    <xsl:with-param name="collName" select="$collName"/>
270      </xsl:apply-templates>
271</xsl:template>
272
273
274 <xsl:template match="serviceList">
275    <xsl:param name="collName"/>
276    <h3><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'about.services')"/></h3>
277    <xsl:choose>
278      <xsl:when test="service">
279    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'about.servicehelp')"/>
280      </xsl:when>
281      <xsl:otherwise>
282    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'about.noservices')"/>
283      </xsl:otherwise>
284    </xsl:choose>
285   
286   
287    <xsl:if test="service">
288      <ul id="servicelist">     
289    <xsl:for-each select="service">
290      <xsl:variable name="action"><xsl:choose>
291          <xsl:when test="@type='query'">q</xsl:when>
292          <xsl:when test="@type='browse'">b</xsl:when>
293          <xsl:when test="@type='process'">pr</xsl:when>
294          <xsl:when test="@type='applet'">a</xsl:when>
295          <xsl:otherwise>DO_NOT_DISPLAY</xsl:otherwise>
296        </xsl:choose></xsl:variable>
297      <xsl:if test="$action !='DO_NOT_DISPLAY'">
298        <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>
299      </xsl:if>
300    </xsl:for-each>
301      </ul>
302    </xsl:if>
303  </xsl:template>
304
305
306
307<!-- classifier page ............................................................................ -->
308<xsl:template name="collectionName">
309    <xsl:value-of select="/page/pageResponse/collection/displayItem[@name='name']"/>
310</xsl:template>
311
312<xsl:template name="collectionShortName">
313    <xsl:value-of select="/page/pageResponse/collection/@name"/>
314</xsl:template>
315
316<xsl:template name="navigationTab">
317
318    <xsl:variable name="isCurrent" select="@name=/page/pageResponse/service/@name"/>
319
320    <xsl:variable name="action"><xsl:choose>
321        <xsl:when test="@type='query'">q</xsl:when>
322        <xsl:when test="@type='browse'">b</xsl:when>
323        <xsl:when test="@type='process'">pr</xsl:when>
324        <xsl:when test="@type='applet'">a</xsl:when>
325        <xsl:otherwise>DO_NOT_DISPLAY</xsl:otherwise>
326    </xsl:choose></xsl:variable>
327
328    <xsl:if test="$action!='DO_NOT_DISPLAY'">
329        <li>
330            <xsl:if test="$isCurrent">
331                <xsl:attribute name="class">current</xsl:attribute>
332            </xsl:if>
333            <a>
334                <xsl:if test="displayItem[@name='description']">
335                    <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
336                </xsl:if>
337                <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=<xsl:value-of select="$action"/>&amp;rt=d&amp;s=<xsl:value-of select="@name"/>&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:attribute>
338                <xsl:value-of select="displayItem[@name='name']"/>
339            </a>
340        </li>
341    </xsl:if>
342
343</xsl:template>
344
345
346<xsl:template name="classifierLink">
347    <xsl:if test="@name=/page/pageResponse/classifier/@name"><xsl:attribute name="class">current</xsl:attribute></xsl:if>
348    <a href="{$library_name}?a=b&amp;rt=r&amp;s={/page/pageResponse/service/@name}&amp;c={/page/pageResponse/collection/@name}&amp;cl={@name}">
349        <xsl:value-of select="displayItem[@name='description']"/>
350    </a>
351</xsl:template>
352
353<!--
354BERRY BASKET TEMPLATES
355These get used on many different pages to add the
356berry basket function to the site
357-->
358
359<!-- put the drag&drop berry basket on the page -->
360<xsl:template name="berryBasket">
361    <xsl:if test="$berryBasketOn">
362        <div id="berrybasket" class="hide">
363            <span>Berry Basket</span>
364            <span id="berryBasketExpandCollapseLinks" style="display: none;">
365                <a id="berryBasketExpandLink" href="javascript:showBasket()">Expand</a>
366                <a id="berryBasketCollapseLink" style="display: none;" href="javascript:hideBasket()">Collapse</a>
367            </span>
368            <div id="baskethandle"><span><xsl:text> </xsl:text></span></div>
369            <div id ="berries"><span><xsl:text> </xsl:text></span></div>
370        </div>
371    </xsl:if>
372</xsl:template>
373
374<!-- include the required javascript and css for berry baskets -->
375<xsl:template name="berryBasketHeadTags">
376    <script type="text/javascript" src="interfaces/{$interface_name}/js/YAHOO.js"><xsl:text> </xsl:text></script>
377    <script type="text/javascript" src="interfaces/{$interface_name}/js/event.js"><xsl:text> </xsl:text></script>
378    <script type="text/javascript" src="interfaces/{$interface_name}/js/connection.js"><xsl:text> </xsl:text></script>
379    <script type="text/javascript" src="interfaces/{$interface_name}/js/dom.js"><xsl:text> </xsl:text></script>
380    <script type="text/javascript" src="interfaces/{$interface_name}/js/dragdrop.js"><xsl:text> </xsl:text></script>
381    <script type="text/javascript" src="interfaces/{$interface_name}/js/ygDDPlayer.js"><xsl:text> </xsl:text></script>
382    <script type="text/javascript" src="interfaces/{$interface_name}/js/ygDDOnTop.js"><xsl:text> </xsl:text></script>
383    <script type="text/javascript" src="interfaces/{$interface_name}/js/berrybasket.js"><xsl:text> </xsl:text></script>
384    <link rel="stylesheet" href="interfaces/{$interface_name}/style/berry.css" type="text/css"/> 
385</xsl:template>
386
387<!--
388create a little berry which can be drag&dropped onto the berry basket
389used on classifier and search result pages
390-->
391<xsl:template name="documentBerryForClassifierOrSearchPage">
392    <xsl:if test="$berryBasketOn">
393        <img class="pick" src="interfaces/{$interface_name}/images/berry.png" alt="in basket" width="15" height="15" border="0">
394            <xsl:attribute name="id"><xsl:value-of select="/page/pageResponse/collection/@name"/>:<xsl:value-of select="@nodeID"/></xsl:attribute>
395        </img>
396    </xsl:if>
397</xsl:template>
398
399<!--
400create little berrys which can be drag&dropped onto the berry basket
401used on the document page
402-->
403<xsl:template name="documentBerryForDocumentPage">
404    <xsl:variable name="selectedNode"><xsl:value-of select="/page/pageResponse/document/@selectedNode"/></xsl:variable>
405    <xsl:variable name="rootNode"><xsl:value-of select="/page/pageResponse/document/documentNode[@nodeType='root']/@nodeID"/></xsl:variable>
406
407    <xsl:if test="$berryBasketOn"> 
408        <div id="documentberries">
409            <img class='pick' id="{/page/pageResponse/collection/@name}:{$rootNode}" src="interfaces/{$interface_name}/images/berry.png" alt="in basket" width="15" height="15" border="0"/>
410            <span id="{/page/pageResponse/collection/@name}:{$rootNode}:root" class="documentberry">the whole document</span>
411
412            <xsl:if test="$selectedNode != $rootNode">
413                <img class='pick'  id="{/page/pageResponse/collection/@name}:{$selectedNode}" src="interfaces/{$interface_name}/images/berry.png" alt="in basket" width="15" height="15" border="0"/>
414                <span id="{/page/pageResponse/collection/@name}:{$selectedNode}:section" class="documentberry">the current section</span>
415            </xsl:if>
416        </div>
417    </xsl:if>
418</xsl:template>
419
420
421<!-- document page -->
422<xsl:template name="documentTitle">
423    <xsl:value-of select="/page/pageResponse/document/documentNode/metadataList/metadata[@name='Title']"/>
424</xsl:template>
425
426
427<xsl:template name="coverImage">
428    <img><xsl:attribute name='src'><xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<xsl:value-of select="metadataList/metadata[@name='archivedir']"/>/cover.jpg</xsl:attribute></img>
429</xsl:template>
430
431<xsl:template name="previousNextButtons">
432    <!-- prev -->
433    <a>
434        <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@selectedNode"/>.pp&amp;sib=1&amp;p.s=<xsl:value-of select='/page/pageRequest/paramList/param[@name="p.s"]/@value'/>&amp;p.sa=<xsl:value-of select='/page/pageRequest/paramList/param[@name="p.sa"]/@value'/>&amp;p.a=<xsl:value-of select='/page/pageRequest/paramList/param[@name="p.a"]/@value'/></xsl:attribute>
435        <img class="lessarrow" src="interfaces/{$interface_name}/images/previous.png"/>
436    </a>
437
438    <!-- next -->
439    <a>
440        <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@selectedNode"/>.np&amp;sib=1&amp;p.s=<xsl:value-of select='/page/pageRequest/paramList/param[@name="p.s"]/@value'/>&amp;p.sa=<xsl:value-of select='/page/pageRequest/paramList/param[@name="p.sa"]/@value'/>&amp;p.a=<xsl:value-of select='/page/pageRequest/paramList/param[@name="p.a"]/@value'/></xsl:attribute>
441        <img class="morearrow" src="interfaces/{$interface_name}/images/next.png"/>
442    </a>
443
444</xsl:template>
445
446
447
448</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.