source: main/trunk/model-interfaces-dev/wmtb/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.4 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 <xsl:import href="footer.xsl"/>
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" class="banner-overlay-on">
28 <div class="wrapper">
29
30 <!-- Whakatohea.co.nz's navbar -->
31 <xsl:call-template name="whakatohea-navbar"/>
32
33 <div class="site-canvas">
34 <div class="wrapper-old col0">
35 <div id="topline">
36 <ul>
37 <xsl:call-template name="loginLinks"/>
38 <li><a href="{$library_name}/collection/{$collNameChecked}/page/pref">Preferences</a></li>
39 <li><a href="{$library_name}/collection/{$collNameChecked}/page/help">Help</a></li>
40 </ul>
41 <br class="clear" />
42 </div>
43 </div>
44 <div class="wrapper-old">
45 <div id="header-old">
46
47 <div class="banner-wrap">
48 <div class="wsite-elements wsite-not-footer wsite-header-elements">
49 <div class="wsite-section-wrap">
50 <div class="wsite-section wsite-header-section wsite-section-bg-image" style="height: auto;background-image: url(&quot;interfaces/{$interface_name}/images/digital-library.jpg&quot;) ;background-repeat: no-repeat ;background-position: 50.00% 21.94% ;background-size: 100% ;background-color: transparent ;background-size: cover;" >
51 <div class="wsite-section-content">
52
53 <div class="container">
54 <div class="banner">
55 <div class="wsite-section-elements">
56 <h2 class="wsite-content-title" style="text-align:center;"><font size="6"><a href="{$library_name}"><xsl:call-template name="siteName"/></a></font></h2>
57
58 <!-- Why does this feel like it's still inside the banner-wrap? -->
59 <xsl:if test="page/pageResponse/collection">
60 <div>
61 <p>&#160;
62 <a href="{$library_name}/collection/{$collNameChecked}/page/about">
63 <xsl:value-of select="page/pageResponse/collection/displayItemList/displayItem[@name='name']"/>
64 </a>
65 </p>
66 <br class="clear"/>
67 </div>
68 </xsl:if>
69 </div>
70 </div>
71 </div>
72
73 </div>
74 <!--<div class=""></div>-->
75 </div>
76 </div>
77
78 </div>
79
80 </div><!-- end banner-wrap -->
81 </div>
82 </div>
83
84 <div class="wrapper-old col2">
85 <div id="topbar">
86 <div id="topnav">
87 <ul>
88 <xsl:call-template name="navBar"/>
89 </ul>
90 </div>
91 <!--**********************************************************************-->
92 <xsl:choose>
93 <xsl:when test="page/pageRequest/@subaction='home'">
94 <xsl:call-template name="crossCollSearch"/>
95 </xsl:when>
96 <xsl:when test="page/pageRequest/paramList/param/@name='c' and /page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
97 <xsl:call-template name="quick-search-area"/>
98 </xsl:when>
99 <xsl:otherwise/>
100 </xsl:choose>
101 <!--**********************************************************************-->
102 </div>
103 </div>
104
105 <div class="outer">
106 <div id="gs_content">
107 <xsl:apply-templates select="/page"/>
108 </div>
109 <br class="clear" />
110
111 </div><!-- end class main-wrap-->
112 <xsl:call-template name="wmtb-footer"/>
113
114 </div> <!-- end site-canvas -->
115 </div> <!-- end wrapper-->
116 </body>
117</html>
118</xsl:template>
119
120
121<xsl:template name="navBar">
122<xsl:choose>
123 <xsl:when test="page/pageResponse/collection">
124 <!-- Using select statement to count only non-empty elements, is harder than testing
125 for non-empty elements. Solution of using normalize-space() is from
126 https://stackoverflow.com/questions/31602369/xsl-return-only-the-first-non-empty-element
127 -->
128 <xsl:variable name="count" select="count(/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier/displayItem[@name = 'name'][normalize-space()])"/>
129 <xsl:variable name="currentPage" select="page/pageRequest/@fullURL"/>
130
131<li><a href="{$library_name}">DL Home</a></li>
132<li>
133<xsl:if test="page/pageRequest/@subaction='about'"><xsl:attribute name="class">active</xsl:attribute></xsl:if>
134<a href="{$library_name}/collection/{$collNameChecked}/page/about">About</a>
135</li>
136
137<xsl:choose>
138<xsl:when test="$count > 3">
139<li><a href="{$currentPage}">Browse</a>
140<ul>
141<xsl:call-template name="Browsing"/>
142</ul>
143</li>
144</xsl:when>
145<xsl:otherwise>
146<xsl:call-template name="Browsing"/>
147</xsl:otherwise>
148</xsl:choose>
149<!--
150<xsl:if test="/page/pageResponse/collection/serviceList/service/@type='query'">
151<li><a href="{$currentPage}">Search</a>
152<ul>
153<xsl:for-each select="/page/pageResponse/collection/serviceList/service[@type='query']">
154<xsl:variable name="search" select="@name"/>
155<xsl:variable name="search_name" select="displayItem[@name='name']"/>
156<li><a href="{$library_name}/collection/{$collNameChecked}/search/{$search}"><xsl:value-of select="$search_name"/></a></li>
157</xsl:for-each>
158</ul>
159</li>
160</xsl:if>
161-->
162</xsl:when>
163<xsl:otherwise> </xsl:otherwise>
164</xsl:choose>
165</xsl:template>
166
167<xsl:template name="Browsing">
168 <xsl:for-each select="/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
169 <xsl:choose>
170 <!-- Only display browsing classifiers that have a name.
171 Those that don't have a name are empty classifiers
172 denoted by no value/empty value for displayItem name=name elements.
173 Testing for non empty elements is easy: not() test. -->
174 <xsl:when test="not(displayItem[@name='name'] ='')">
175 <li>
176 <xsl:choose>
177 <!-- If this tab is selected then colour it differently -->
178 <xsl:when test="util:contains(/page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value, @name)">
179 <xsl:attribute name='class'>active</xsl:attribute>
180 </xsl:when>
181 <xsl:otherwise> </xsl:otherwise>
182 </xsl:choose>
183 <a>
184 <!-- Add a title element to the <a> tag if a description exists for this classifier -->
185 <xsl:if test="displayItem[@name='description']">
186 <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
187 </xsl:if>
188
189 <!-- Add the href element to the <a> tag -->
190 <xsl:choose>
191 <xsl:when test="@name">
192 <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>
193 </xsl:when>
194 <xsl:otherwise>
195 <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>
196 </xsl:otherwise>
197 </xsl:choose>
198
199 <!-- Add the actual text of the <a> tag -->
200 <xsl:value-of select="displayItem[@name='name']"/>
201 </a>
202 </li>
203 </xsl:when>
204 </xsl:choose>
205 </xsl:for-each>
206</xsl:template>
207
208<xsl:template name="crossCollSearch">
209 <div id="search">
210 <xsl:for-each select="/page/pageResponse/serviceList/service[@name='TextQuery']">
211 <form name="QuickSearch" method="get" action="{$library_name}">
212 <input type="hidden" name="a" value="q"/>
213 <input type="hidden" name="rt" value="rd"/>
214 <input type="hidden" name="s" value="{@name}"/>
215 <input type="hidden" name="s1.collection" value="all"/>
216 <input type="text" name="s1.query" id="search-text" value="Search all collections
" onfocus="this.value=(this.value=='Search all collections
')? '' : this.value ;" />
217 <input type="submit" name="go" id="go" value="Search" />
218 </form>
219 </xsl:for-each>
220 </div>
221 <br class="clear" />
222</xsl:template>
223
224<xsl:template name="CollectionSearch">
225<div id="search">
226<xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
227<form action="{$library_name}/collection/{$collNameChecked}/search/TextQuery">
228<!-- This parameter says that we have come from the quick search area -->
229<input type="hidden" name="qs" value="1"/>
230<input type="hidden" name="rt" value="rd"/>
231<input type="hidden" name="s1.level">
232<xsl:attribute name="value">
233<xsl:choose>
234<xsl:when test="/page/pageRequest/paramList/param[@name = 's1.level']">
235<xsl:value-of select="/page/pageRequest/paramList/param[@name = 's1.level']/@value"/>
236</xsl:when>
237<xsl:otherwise>
238<xsl:value-of select="/page/pageResponse/collection/serviceList/service[@name='TextQuery']/paramList/param[@name = 'level']/@default"/>
239</xsl:otherwise>
240</xsl:choose>
241</xsl:attribute>
242</input>
243<xsl:choose>
244<xsl:when test="/page/pageResponse/service[@name = 'TextQuery']/paramList/param[@name = 'startPage']">
245<input type="hidden" name="s1.startPage" value="1"/>
246</xsl:when>
247<xsl:otherwise>
248<input type="hidden" name="startPage" value="1"/>
249</xsl:otherwise>
250</xsl:choose>
251<xsl:if test="not(/page/pageRequest/paramList/param[@name = 's1.hitsPerPage'])">
252<input type="hidden" name="s1.hitsPerPage" value="20"/>
253</xsl:if>
254<xsl:if test="not(/page/pageRequest/paramList/param[@name = 's1.maxDocs'])">
255<input type="hidden" name="s1.maxDocs" value="100"/>
256</xsl:if>
257<!-- The query text box -->
258<span class="querybox">
259<xsl:variable name="qs">
260<xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']" mode="calculate-default"/>
261</xsl:variable>
262<nobr>
263<xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']">
264<xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs, /page/@lang)"/>
265</xsl:apply-templates>
266</nobr>
267</span>
268<!-- The submit button (for TextQuery) -->
269<xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
270<input type="submit" name="go" id="go" value="Search" > </input>
271<br/>
272</xsl:if>
273</form>
274</div>
275<br class="clear" />
276<!--<div id="advanced"><a href="{$library_name}/collection/{$collNameChecked}/search/TextQuery">advanced search</a></div>-->
277</xsl:template>
278
279
280<xsl:template name="loginLinks">
281 <xsl:variable name="username" select="/page/pageRequest/userInformation/@username"/>
282 <xsl:variable name="groups" select="/page/pageRequest/userInformation/@groups"/>
283
284 <xsl:choose>
285 <xsl:when test="$username">
286 <!-- Depositor link: only for logged-in users.
287 CSS class=login to make Depositor link blue to indicate it's only available when logged in.
288 Don't put this depositorTitleAndLink inside the test for whether user 'admin' is
289 in the current list of groups, as we want the depositor link to be visible for any
290 logged in user. The collection they want to deposit a doc into will determine whether
291 that user has the right to modify that collection.
292 -->
293 <li class="login"><gslib:depositorTitleAndLink/></li>
294 <xsl:if test="contains($groups,'admin')">
295 <li class="login"><a href="{$library_name}/admin/AddUser">Add user</a></li>
296 <li class="login"><a href="{$library_name}/admin/ListUsers">Administration</a></li>
297 </xsl:if>
298 <li class="login"><a href="{$library_name}/admin/AccountSettings?s1.username={$username}">Logged in as: <xsl:value-of select="$username"/></a></li>
299 <li class="login"><a href="{$library_name}?logout=">Logout</a></li>
300 </xsl:when>
301 <xsl:otherwise>
302 <li class="login">
303 <a href="{$library_name}?a=p&amp;sa=login&amp;redirectURL={$library_name}%3Fa=p%26sa=home">Login
304 <xsl:attribute name="title">
305 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_tip')"/>
306 </xsl:attribute>
307 </a>
308 </li>
309 </xsl:otherwise>
310 </xsl:choose>
311</xsl:template>
312
313<xsl:template name="quick-search-area">
314 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
315 <xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
316
317 <div id="quicksearcharea">
318 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
319 <xsl:choose>
320 <xsl:when test="not(page/pageRequest[@action='q']) or /page/pageRequest/paramList/param[@name='qs']/@value = '1'">
321 <form action="{$library_name}/collection/{$collNameChecked}/search/TextQuery">
322 <!-- This parameter says that we have come from the quick search area -->
323
324 <input type="hidden" name="qs" value="1"/>
325 <input type="hidden" name="rt" value="rd"/>
326 <!-- don't hide indexing levels: code further down will hide it if there's only 1 indexing level.
327 and display a dropdown if the collection's configured with more than 1 index level available -->
328 <!--<input type="hidden" name="s1.level">
329 <xsl:attribute name="value">
330 <xsl:value-of select="/page/pageResponse/collection/serviceList/service[@name='TextQuery']/paramList/param[@name = 'level']/@default"/>
331 </xsl:attribute>
332 </input>
333 -->
334 <xsl:choose>
335 <xsl:when test="/page/pageResponse/service[@name = 'TextQuery']/paramList/param[@name = 'startPage']">
336 <input type="hidden" name="s1.startPage" value="1"/>
337 </xsl:when>
338 <xsl:otherwise>
339 <input type="hidden" name="startPage" value="1"/>
340 </xsl:otherwise>
341 </xsl:choose>
342
343 <!-- The query text box -->
344 <span class="querybox">
345 <xsl:variable name="qs">
346 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']" mode="calculate-default"/>
347 </xsl:variable>
348 <nobr>
349 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']">
350 <!--
351 <xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs, /page/@lang)"/>
352 -->
353 <xsl:with-param name="default" select="normalize-space($qs)"/>
354
355 </xsl:apply-templates>
356 </nobr>
357 </span>
358 <!-- The index selection list -->
359 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']/@type = 'enum_single'">
360 <span class="textselect">
361 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']">
362 <xsl:with-param name="default">
363 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']" mode="calculate-default"/>
364 </xsl:with-param>
365 <xsl:with-param name="hideSingle">false</xsl:with-param>
366 <xsl:with-param name="quickSearch">true</xsl:with-param>
367 </xsl:apply-templates>
368 </span>
369 </xsl:if>
370 <!-- The partition selection list -->
371 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexSubcollection']/@type = 'enum_single'">
372 <span class="textselect">
373 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexSubcollection']">
374 <xsl:with-param name="default">
375 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexSubcollection']" mode="calculate-default"/>
376 </xsl:with-param>
377 <xsl:with-param name="hideSingle">true</xsl:with-param>
378 <xsl:with-param name="quickSearch">true</xsl:with-param>
379 </xsl:apply-templates>
380 </span>
381 </xsl:if>
382
383 <!-- The index level selection list. hideSingle=true to hide the dropdown if there's only 1 level (the default). -->
384 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='level']/@type = 'enum_single'">
385 <span class="textselect">
386 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='level']">
387 <xsl:with-param name="default">
388 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='level']" mode="calculate-default"/>
389 </xsl:with-param>
390 <xsl:with-param name="hideSingle">true</xsl:with-param>
391 <xsl:with-param name="quickSearch">true</xsl:with-param>
392 </xsl:apply-templates>
393 </span>
394 </xsl:if>
395
396 <!-- The language selection list -->
397 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexLanguage']/@type = 'enum_single'">
398 <span class="textselect">
399 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexLanguage']">
400 <xsl:with-param name="default">
401 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexLanguage']" mode="calculate-default"/>
402 </xsl:with-param>
403 <xsl:with-param name="hideSingle">true</xsl:with-param>
404 <xsl:with-param name="quickSearch">true</xsl:with-param>
405 </xsl:apply-templates>
406 </span>
407 </xsl:if>
408 <!-- The submit button (for TextQuery) -->
409 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
410 <input type="submit" id="quickSearchSubmitButton">
411 <xsl:attribute name="value">
412 <xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/displayItem[@name='submit']"/>
413 </xsl:attribute>
414 </input>
415 <br/>
416 </xsl:if>
417 </form>
418 </xsl:when>
419 <xsl:otherwise><br/></xsl:otherwise>
420 </xsl:choose>
421 </xsl:if>
422
423 </div>
424 <!--<br class="clear" />-->
425 <!--<span id="advanced">-->
426
427 <!-- The list of other search types -->
428 <div class="query-form-links">
429 <ul>
430 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
431 <xsl:if test="/page/pageRequest/paramList/param[@name='qs']/@value = 1 or not(@name = /page/pageRequest/paramList/param[@name='s']/@value)">
432 <li class="ui-state-default ui-corner-all">
433 <a class="query-form-links">
434 <xsl:attribute name="href">
435 <xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collNameChecked"/>/search/<xsl:value-of select="@name"/>
436 </xsl:attribute>
437 <xsl:value-of select="displayItem[@name='name']"/>
438 </a>
439 </li>
440 </xsl:if>
441 </xsl:for-each>
442 </ul>
443 </div>
444 </xsl:if>
445 <!--<br class="clear" />
446 <div id="advanced"><a href="{$library_name}/collection/{$collNameChecked}/search/TextQuery">form search</a></div>
447 <div id="advanced"><a href="{$library_name}/collection/{$collNameChecked}/search/AdvancedFieldQuery">advanced search</a></div>
448 -->
449 </xsl:template>
450
451</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.