source: main/trunk/model-interfaces-dev/opotiki/transform/layouts/main.xsl@ 34313

Last change on this file since 34313 was 34313, checked in by ak19, 4 years ago

Correcting XSL to not add classifiers that are empty.

File size: 19.0 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
5 xmlns:java="http://xml.apache.org/xslt/java"
6 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
7 xmlns:gslib="http://www.greenstone.org/skinning"
8 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
9
10 xmlns:lxslt="http://xml.apache.org/xslt"
11 xmlns:result="http://www.example.com/results"
12 xmlns:exsl="http://exslt.org/common"
13
14 extension-element-prefixes="java util result exsl"
15 exclude-result-prefixes="util java util">
16
17
18<!-- The main layout is defined here -->
19<!-- Every page in our library uses this template -->
20<xsl:template name="mainTemplate">
21<html>
22 <head>
23 <!-- ***** in header.xsl ***** -->
24 <xsl:call-template name="create-html-header"/>
25 <xsl:call-template name="basketHeadTags"/>
26 </head>
27 <body id="top">
28 <div class="wrapper col0">
29 <div id="topline">
30 <ul>
31 <xsl:call-template name="loginLinks"/>
32 <li><a href="{$library_name}/collection/{$collNameChecked}/page/pref">Preferences</a></li>
33 <li><a href="{$library_name}/collection/{$collNameChecked}/page/help">Help</a></li>
34 </ul>
35 <br class="clear" />
36 </div>
37 </div>
38 <div class="wrapper">
39 <div id="header">
40 <div class="fl_left">
41 <h1><a href="{$library_name}"><xsl:call-template name="siteName"/></a></h1>
42 <p>&#160;
43 <xsl:if test="page/pageResponse/collection">
44 <a href="{$library_name}/collection/{$collNameChecked}/page/about">
45 <xsl:value-of select="page/pageResponse/collection/displayItemList/displayItem[@name='name']"/>
46 </a>
47 </xsl:if>
48 </p>
49 </div>
50 <br class="clear"/>
51 </div>
52 </div>
53 <div class="wrapper col2">
54 <div id="topbar">
55 <div id="topnav">
56 <ul>
57 <xsl:call-template name="navBar"/>
58 </ul>
59 </div>
60 <!--**********************************************************************-->
61 <xsl:choose>
62 <xsl:when test="page/pageRequest/@subaction='home'">
63 <xsl:call-template name="crossCollSearch"/>
64 </xsl:when>
65 <xsl:when test="page/pageRequest/paramList/param/@name='c' and /page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
66 <xsl:call-template name="quick-search-area"/>
67 </xsl:when>
68 <xsl:otherwise/>
69 </xsl:choose>
70 <!--**********************************************************************-->
71 </div>
72 </div>
73 <div class="wrapper">
74 <div class="container" id="gs_content">
75 <xsl:apply-templates select="/page"/>
76 </div>
77 <br class="clear" />
78 </div>
79 <xsl:call-template name="gs_footer"/>
80 </body>
81</html>
82</xsl:template>
83
84
85<!-- Template controlling the footer. -->
86<xsl:template name="gs_footer">
87<!-- Put footer in here. -->
88<!-- ******DO NOT REMOVE THE LINK TO OS TEMPLATES: Template is free to use/modify, but this link MUST remain on all pages. Do not remove Copyright information. Replace "Your Webpage Here" (and it's link) with your own information.-->
89<div class="wrapper col8">
90 <div id="copyright">
91 <p class="fl_left">Developed in partnership between <a href="http://www.whakatohea.co.nz/">Whakatōhea Māori Trust Board</a> and the <a href="https://www.waikato.ac.nz/">University of Waikato</a></p>
92 <p class="fl_right">Powered by <a href="http://www.greenstone.org/" title="Greenstone Digital Library Software">Greenstone3</a></p>
93 <p class="fl_right">Copyright &#169; 2013 - All Rights Reserved
94 - Template by <a href="http://www.os-templates.com/" title="Free Website Templates">OS Templates</a></p>
95 <br class="clear" />
96 </div>
97</div>
98</xsl:template>
99
100<xsl:template name="navBar">
101<xsl:choose>
102 <xsl:when test="page/pageResponse/collection">
103 <!-- Using select statement to count only non-empty elements, is harder than testing
104 for non-empty elements. Solution of using normalize-space() is from
105 https://stackoverflow.com/questions/31602369/xsl-return-only-the-first-non-empty-element
106 -->
107<xsl:variable name="count" select="count(/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier/displayItem[@name = 'name'][normalize-space()])"/>
108<xsl:variable name="currentPage" select="page/pageRequest/@fullURL"/>
109
110<li><a href="{$library_name}">DL Home</a></li>
111<li>
112<xsl:if test="page/pageRequest/@subaction='about'"><xsl:attribute name="class">active</xsl:attribute></xsl:if>
113<a href="{$library_name}/collection/{$collNameChecked}/page/about">About</a>
114</li>
115
116<xsl:choose>
117<xsl:when test="$count > 3">
118<li><a href="{$currentPage}">Browse</a>
119<ul>
120<xsl:call-template name="Browsing"/>
121</ul>
122</li>
123</xsl:when>
124<xsl:otherwise>
125<xsl:call-template name="Browsing"/>
126</xsl:otherwise>
127</xsl:choose>
128<!--
129<xsl:if test="/page/pageResponse/collection/serviceList/service/@type='query'">
130<li><a href="{$currentPage}">Search</a>
131<ul>
132<xsl:for-each select="/page/pageResponse/collection/serviceList/service[@type='query']">
133<xsl:variable name="search" select="@name"/>
134<xsl:variable name="search_name" select="displayItem[@name='name']"/>
135<li><a href="{$library_name}/collection/{$collNameChecked}/search/{$search}"><xsl:value-of select="$search_name"/></a></li>
136</xsl:for-each>
137</ul>
138</li>
139</xsl:if>
140-->
141</xsl:when>
142<xsl:otherwise> </xsl:otherwise>
143</xsl:choose>
144</xsl:template>
145
146<xsl:template name="Browsing">
147 <xsl:for-each select="/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
148 <xsl:choose>
149 <!-- Only display browsing classifiers that have a name.
150 Those that don't have a name are empty classifiers
151 denoted by no value/empty value for displayItem name=name elements.
152 Testing for non empty elements is easy: not() test. -->
153 <xsl:when test="not(displayItem[@name='name'] ='')">
154 <li>
155 <xsl:choose>
156 <!-- If this tab is selected then colour it differently -->
157 <xsl:when test="util:contains(/page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value, @name)">
158 <xsl:attribute name='class'>active</xsl:attribute>
159 </xsl:when>
160 <xsl:otherwise> </xsl:otherwise>
161 </xsl:choose>
162 <a>
163 <!-- Add a title element to the <a> tag if a description exists for this classifier -->
164 <xsl:if test="displayItem[@name='description']">
165 <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
166 </xsl:if>
167
168 <!-- Add the href element to the <a> tag -->
169 <xsl:choose>
170 <xsl:when test="@name">
171 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>/browse/<xsl:value-of select="@name"/></xsl:attribute>
172 </xsl:when>
173 <xsl:otherwise>
174 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>/browse/1</xsl:attribute>
175 </xsl:otherwise>
176 </xsl:choose>
177
178 <!-- Add the actual text of the <a> tag -->
179 <xsl:value-of select="displayItem[@name='name']"/>
180 </a>
181 </li>
182 </xsl:when>
183 </xsl:choose>
184 </xsl:for-each>
185</xsl:template>
186
187<xsl:template name="crossCollSearch">
188 <div id="search">
189 <xsl:for-each select="/page/pageResponse/serviceList/service[@name='TextQuery']">
190 <form name="QuickSearch" method="get" action="{$library_name}">
191 <input type="hidden" name="a" value="q"/>
192 <input type="hidden" name="rt" value="rd"/>
193 <input type="hidden" name="s" value="{@name}"/>
194 <input type="hidden" name="s1.collection" value="all"/>
195 <input type="text" name="s1.query" id="search-text" value="Search all collections
" onfocus="this.value=(this.value=='Search all collections
')? '' : this.value ;" />
196 <input type="submit" name="go" id="go" value="Search" />
197 </form>
198 </xsl:for-each>
199 </div>
200 <br class="clear" />
201</xsl:template>
202
203<xsl:template name="CollectionSearch">
204<div id="search">
205<xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
206<form action="{$library_name}/collection/{$collNameChecked}/search/TextQuery">
207<!-- This parameter says that we have come from the quick search area -->
208<input type="hidden" name="qs" value="1"/>
209<input type="hidden" name="rt" value="rd"/>
210<input type="hidden" name="s1.level">
211<xsl:attribute name="value">
212<xsl:choose>
213<xsl:when test="/page/pageRequest/paramList/param[@name = 's1.level']">
214<xsl:value-of select="/page/pageRequest/paramList/param[@name = 's1.level']/@value"/>
215</xsl:when>
216<xsl:otherwise>
217<xsl:value-of select="/page/pageResponse/collection/serviceList/service[@name='TextQuery']/paramList/param[@name = 'level']/@default"/>
218</xsl:otherwise>
219</xsl:choose>
220</xsl:attribute>
221</input>
222<xsl:choose>
223<xsl:when test="/page/pageResponse/service[@name = 'TextQuery']/paramList/param[@name = 'startPage']">
224<input type="hidden" name="s1.startPage" value="1"/>
225</xsl:when>
226<xsl:otherwise>
227<input type="hidden" name="startPage" value="1"/>
228</xsl:otherwise>
229</xsl:choose>
230<xsl:if test="not(/page/pageRequest/paramList/param[@name = 's1.hitsPerPage'])">
231<input type="hidden" name="s1.hitsPerPage" value="20"/>
232</xsl:if>
233<xsl:if test="not(/page/pageRequest/paramList/param[@name = 's1.maxDocs'])">
234<input type="hidden" name="s1.maxDocs" value="100"/>
235</xsl:if>
236<!-- The query text box -->
237<span class="querybox">
238<xsl:variable name="qs">
239<xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']" mode="calculate-default"/>
240</xsl:variable>
241<nobr>
242<xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']">
243<xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs, /page/@lang)"/>
244</xsl:apply-templates>
245</nobr>
246</span>
247<!-- The submit button (for TextQuery) -->
248<xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
249<input type="submit" name="go" id="go" value="Search" > </input>
250<br/>
251</xsl:if>
252</form>
253</div>
254<br class="clear" />
255<!--<div id="advanced"><a href="{$library_name}/collection/{$collNameChecked}/search/TextQuery">advanced search</a></div>-->
256</xsl:template>
257
258
259<xsl:template name="loginLinks">
260 <xsl:variable name="username" select="/page/pageRequest/userInformation/@username"/>
261 <xsl:variable name="groups" select="/page/pageRequest/userInformation/@groups"/>
262
263 <xsl:choose>
264 <xsl:when test="$username">
265 <!-- Depositor link: only for logged-in users.
266 CSS class=login to make Depositor link blue to indicate it's only available when logged in.
267 Don't put this depositorTitleAndLink inside the test for whether user 'admin' is
268 in the current list of groups, as we want the depositor link to be visible for any
269 logged in user. The collection they want to deposit a doc into will determine whether
270 that user has the right to modify that collection.
271 -->
272 <li class="login"><gslib:depositorTitleAndLink/></li>
273 <xsl:if test="contains($groups,'admin')">
274 <li class="login"><a href="{$library_name}/admin/AddUser">Add user</a></li>
275 <li class="login"><a href="{$library_name}/admin/ListUsers">Administration</a></li>
276 </xsl:if>
277 <li class="login"><a href="{$library_name}/admin/AccountSettings?s1.username={$username}">Logged in as: <xsl:value-of select="$username"/></a></li>
278 <li class="login"><a href="{$library_name}?logout=">Logout</a></li>
279 </xsl:when>
280 <xsl:otherwise>
281 <li class="login">
282 <a href="{$library_name}?a=p&amp;sa=login&amp;redirectURL={$library_name}%3Fa=p%26sa=home">Login
283 <xsl:attribute name="title">
284 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_tip')"/>
285 </xsl:attribute>
286 </a>
287 </li>
288 </xsl:otherwise>
289 </xsl:choose>
290</xsl:template>
291
292<xsl:template name="quick-search-area">
293 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
294 <xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
295
296 <div id="quicksearcharea">
297 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
298 <xsl:choose>
299 <xsl:when test="not(page/pageRequest[@action='q']) or /page/pageRequest/paramList/param[@name='qs']/@value = '1'">
300 <form action="{$library_name}/collection/{$collNameChecked}/search/TextQuery">
301 <!-- This parameter says that we have come from the quick search area -->
302
303 <input type="hidden" name="qs" value="1"/>
304 <input type="hidden" name="rt" value="rd"/>
305 <!-- don't hide indexing levels: code further down will hide it if there's only 1 indexing level.
306 and display a dropdown if the collection's configured with more than 1 index level available -->
307 <!--<input type="hidden" name="s1.level">
308 <xsl:attribute name="value">
309 <xsl:value-of select="/page/pageResponse/collection/serviceList/service[@name='TextQuery']/paramList/param[@name = 'level']/@default"/>
310 </xsl:attribute>
311 </input>
312 -->
313 <xsl:choose>
314 <xsl:when test="/page/pageResponse/service[@name = 'TextQuery']/paramList/param[@name = 'startPage']">
315 <input type="hidden" name="s1.startPage" value="1"/>
316 </xsl:when>
317 <xsl:otherwise>
318 <input type="hidden" name="startPage" value="1"/>
319 </xsl:otherwise>
320 </xsl:choose>
321
322 <!-- The query text box -->
323 <span class="querybox">
324 <xsl:variable name="qs">
325 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']" mode="calculate-default"/>
326 </xsl:variable>
327 <nobr>
328 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']">
329 <!--
330 <xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs, /page/@lang)"/>
331 -->
332 <xsl:with-param name="default" select="normalize-space($qs)"/>
333
334 </xsl:apply-templates>
335 </nobr>
336 </span>
337 <!-- The index selection list -->
338 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']/@type = 'enum_single'">
339 <span class="textselect">
340 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']">
341 <xsl:with-param name="default">
342 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']" mode="calculate-default"/>
343 </xsl:with-param>
344 <xsl:with-param name="hideSingle">false</xsl:with-param>
345 <xsl:with-param name="quickSearch">true</xsl:with-param>
346 </xsl:apply-templates>
347 </span>
348 </xsl:if>
349 <!-- The partition selection list -->
350 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexSubcollection']/@type = 'enum_single'">
351 <span class="textselect">
352 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexSubcollection']">
353 <xsl:with-param name="default">
354 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexSubcollection']" mode="calculate-default"/>
355 </xsl:with-param>
356 <xsl:with-param name="hideSingle">true</xsl:with-param>
357 <xsl:with-param name="quickSearch">true</xsl:with-param>
358 </xsl:apply-templates>
359 </span>
360 </xsl:if>
361
362 <!-- The index level selection list. hideSingle=true to hide the dropdown if there's only 1 level (the default). -->
363 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='level']/@type = 'enum_single'">
364 <span class="textselect">
365 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='level']">
366 <xsl:with-param name="default">
367 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='level']" mode="calculate-default"/>
368 </xsl:with-param>
369 <xsl:with-param name="hideSingle">true</xsl:with-param>
370 <xsl:with-param name="quickSearch">true</xsl:with-param>
371 </xsl:apply-templates>
372 </span>
373 </xsl:if>
374
375 <!-- The language selection list -->
376 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexLanguage']/@type = 'enum_single'">
377 <span class="textselect">
378 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexLanguage']">
379 <xsl:with-param name="default">
380 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexLanguage']" mode="calculate-default"/>
381 </xsl:with-param>
382 <xsl:with-param name="hideSingle">true</xsl:with-param>
383 <xsl:with-param name="quickSearch">true</xsl:with-param>
384 </xsl:apply-templates>
385 </span>
386 </xsl:if>
387 <!-- The submit button (for TextQuery) -->
388 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
389 <input type="submit" id="quickSearchSubmitButton">
390 <xsl:attribute name="value">
391 <xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/displayItem[@name='submit']"/>
392 </xsl:attribute>
393 </input>
394 <br/>
395 </xsl:if>
396 </form>
397 </xsl:when>
398 <xsl:otherwise><br/></xsl:otherwise>
399 </xsl:choose>
400 </xsl:if>
401
402 </div>
403 <!--<br class="clear" />-->
404 <!--<span id="advanced">-->
405
406 <!-- The list of other search types -->
407 <div class="query-form-links">
408 <ul>
409 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
410 <xsl:if test="/page/pageRequest/paramList/param[@name='qs']/@value = 1 or not(@name = /page/pageRequest/paramList/param[@name='s']/@value)">
411 <li class="ui-state-default ui-corner-all">
412 <a class="query-form-links">
413 <xsl:attribute name="href">
414 <xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collNameChecked"/>/search/<xsl:value-of select="@name"/>
415 </xsl:attribute>
416 <xsl:value-of select="displayItem[@name='name']"/>
417 </a>
418 </li>
419 </xsl:if>
420 </xsl:for-each>
421 </ul>
422 </div>
423 </xsl:if>
424 <!--<br class="clear" />
425 <div id="advanced"><a href="{$library_name}/collection/{$collNameChecked}/search/TextQuery">form search</a></div>
426 <div id="advanced"><a href="{$library_name}/collection/{$collNameChecked}/search/AdvancedFieldQuery">advanced search</a></div>
427 -->
428 </xsl:template>
429
430</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.