source: main/trunk/greenstone3/web/interfaces/default/transform/pages/query.xsl@ 26455

Last change on this file since 26455 was 26455, checked in by sjm84, 8 years ago

Reformatting this file ahead of some changes

File size: 22.7 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 xmlns:gslib="http://www.greenstone.org/skinning"
7 xmlns:gsvar="http://www.greenstone.org/skinning-var"
8 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
9 extension-element-prefixes="java util"
10 exclude-result-prefixes="java util gsf">
11
12 <!-- use the 'main' layout -->
13 <xsl:import href="layouts/main.xsl"/>
14
15 <xsl:include href="query-common.xsl"/>
16 <!-- set page title -->
17 <xsl:template name="pageTitle">
18 <gslib:serviceName/>
19 </xsl:template>
20
21 <!-- set page breadcrumbs -->
22 <xsl:template name="breadcrumbs">
23 <gslib:siteLink/>
24 <gslib:rightArrow/>
25 <xsl:if test="/page/pageResponse/collection">
26 <gslib:collectionNameLinked/>
27 <gslib:rightArrow/>
28 </xsl:if>
29 </xsl:template>
30
31 <!-- the page content -->
32 <xsl:template match="/page">
33 <xsl:if test="not(/page/pageRequest/paramList/param[@name = 'qs']) or /page/pageRequest/paramList/param[@name = 'qs']/@value = ''">
34 <xsl:call-template name="queryPage"/>
35 </xsl:if>
36 <xsl:call-template name="resultsPage"/>
37 </xsl:template>
38
39 <xsl:template name="resultsPage">
40 <xsl:call-template name="resultsPagePre"/>
41 <xsl:call-template name="displayMatchDocs"/>
42 <xsl:call-template name="displayTermInfo"/>
43 <xsl:call-template name="displayResults"/>
44 <xsl:call-template name="resultsPagePost"/>
45 </xsl:template>
46
47 <!-- optional cgi-params for links to document pages -->
48 <xsl:variable name="opt-doc-link-args">p.s=<gsvar:this-service/>
49 </xsl:variable>
50
51 <xsl:template name="displayResults">
52 <xsl:if test="/page/pageResponse/facetList/facet">
53 <script type="text/javascript" src="interfaces/{$interface_name}/js/facet-scripts.js">
54 <xsl:text/>
55 </script>
56 <div id="facetSelector">
57 <xsl:for-each select="/page/pageResponse/facetList/facet">
58 <xsl:if test="count(count) > 0">
59 <ul class="facetTable ui-widget-content" indexName="{@name}">
60 <xsl:variable name="serviceName">
61 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 's']/@value"/>
62 </xsl:variable>
63 <xsl:variable name="indexShortName">
64 <xsl:value-of select="@name"/>
65 </xsl:variable>
66 <xsl:variable name="countSize">
67 <xsl:choose>
68 <xsl:when test="/page/pageResponse/format[@type='search']/gsf:option[@name='facetTableRows']">
69 <xsl:value-of select="/page/pageResponse/format[@type='search']/gsf:option[@name='facetTableRows']/@value"/>
70 </xsl:when>
71 <xsl:otherwise>8</xsl:otherwise>
72 </xsl:choose>
73 </xsl:variable>
74
75 <li class="ui-widget-header" style="text-transform:capitalize; text-align:center;">
76 <xsl:choose>
77 <xsl:when test="/page/pageResponse/collection/serviceList/service[@name = $serviceName]/paramList/param[@name = 'index']">
78 <xsl:value-of select="/page/pageResponse/collection/serviceList/service[@name = $serviceName]/paramList/param[@name = 'index']/option[@name = $indexShortName]/displayItem"/>
79 </xsl:when>
80 <xsl:when test="/page/pageResponse/collection/serviceList/service[@name = $serviceName]/paramList/param[@name = 'complexField']/param[@name = 'fqf']">
81 <xsl:value-of select="/page/pageResponse/collection/serviceList/service[@name = $serviceName]/paramList/param[@name = 'complexField']/param[@name = 'fqf']/option[@name = $indexShortName]/displayItem"/>
82 </xsl:when>
83 </xsl:choose>
84 </li>
85 <xsl:for-each select="count">
86 <li>
87 <xsl:attribute name="style">
88 <xsl:if test="position() > $countSize">display:none;<xsl:value-of select="$indexShortName"/>
89 </xsl:if>
90 </xsl:attribute>
91 <input type="checkbox" onclick="performRefinedSearch();"/>
92 <span>
93 <xsl:value-of select="@name"/>
94 </span>(<xsl:value-of select="."/>)
95 </li>
96 </xsl:for-each>
97 <xsl:if test="count(count) > $countSize">
98 <li class="expandCollapseFacetList{$indexShortName}">
99 <a class="expandCollapseFacetListLink{$indexShortName}" href="javascript:expandFacetList('{$indexShortName}', {$countSize});">See more...</a>
100 </li>
101 </xsl:if>
102 </ul>
103 </xsl:if>
104 </xsl:for-each>
105 </div>
106 </xsl:if>
107 <div id="resultsArea">
108 <xsl:attribute name="class">
109 <xsl:if test="/page/pageResponse/facetList/facet">facetedResults</xsl:if>
110 </xsl:attribute>
111 <table id="resultsTable">
112 <xsl:for-each select="pageResponse/documentNodeList/documentNode">
113 <tr id="div{@nodeID}" class="document">
114 <xsl:apply-templates select="."/>
115 <xsl:call-template name="documentNodePost"/>
116 </tr>
117 </xsl:for-each>
118 <br/>
119 </table>
120
121 <!-- Previous/Next buttons-->
122 <xsl:call-template name="prevNextButtons"/>
123 </div>
124 <xsl:if test="/page/pageResponse/facetList/facet">
125 <div style="clear:both;">
126 <xsl:text/>
127 </div>
128 </xsl:if>
129 </xsl:template>
130
131 <xsl:template name="queryPage">
132 <xsl:for-each select="pageResponse/service">
133 <form name="QueryForm" method="get" action="{$library_name}/collection/{$collName}/search/{@name}">
134 <div>
135 <input type="hidden" name="a" value="q"/>
136 <input type="hidden" name="sa">
137 <xsl:attribute name="value">
138 <xsl:value-of select="/page/pageRequest/@subaction"/>
139 </xsl:attribute>
140 </input>
141 <input type="hidden" name="rt" value="rd"/>
142 <xsl:choose>
143 <xsl:when test="/page/pageRequest/paramList/param[@name = 's1.maxDocs']">
144 <input type="hidden" name="s1.maxDocs">
145 <xsl:attribute name="value">
146 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 's1.maxDocs']/@value"/>
147 </xsl:attribute>
148 </input>
149 </xsl:when>
150 <xsl:otherwise>
151 <input type="hidden" name="s1.maxDocs" value="100"/>
152 </xsl:otherwise>
153 </xsl:choose>
154 <xsl:choose>
155 <xsl:when test="/page/pageRequest/paramList/param[@name = 's1.hitsPerPage']">
156 <input type="hidden" name="s1.hitsPerPage">
157 <xsl:attribute name="value">
158 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 's1.hitsPerPage']/@value"/>
159 </xsl:attribute>
160 </input>
161 </xsl:when>
162 <xsl:otherwise>
163 <input type="hidden" name="s1.hitsPerPage" value="20"/>
164 </xsl:otherwise>
165 </xsl:choose>
166
167 <xsl:variable name="ns">s1.</xsl:variable>
168 <xsl:for-each select="paramList/param">
169 <xsl:choose>
170 <xsl:when test="@name = 'maxDocs' or @name = 'hitsPerPage'">
171 </xsl:when>
172 <xsl:when test="@type='multi'">
173 <xsl:apply-templates select=".">
174 <xsl:with-param name="ns" select="$ns"/>
175 </xsl:apply-templates>
176 </xsl:when>
177 <xsl:otherwise>
178 <xsl:call-template name="param-display">
179 <xsl:with-param name="ns" select="$ns"/>
180 </xsl:call-template>
181 </xsl:otherwise>
182 </xsl:choose>
183 </xsl:for-each>
184 <br/>
185 <input type="submit">
186 <xsl:attribute name="value">
187 <xsl:value-of select="displayItem[@name='submit']"/>
188 </xsl:attribute>
189 </input>
190 </div>
191 </form>
192 </xsl:for-each>
193 </xsl:template>
194
195 <xsl:template name="displayMatchDocs">
196 <div id="matchdocs">
197 <xsl:variable name="numDocsMatched" select="/page/pageResponse/metadataList/metadata[@name='numDocsMatched']"/>
198 <xsl:variable name="numDocsReturned">
199 <xsl:call-template name="numDocsReturned"/>
200 </xsl:variable>
201 <!-- select="/page/pageResponse/metadataList/metadata[@name='numDocsReturned']"/>-->
202 <xsl:variable name="docLevel">
203 <xsl:call-template name="documentLevel"/>
204 </xsl:variable>
205 <xsl:variable name="docLevelText">
206 <xsl:call-template name="documentLevelText">
207 <xsl:with-param name="numDocsMatched" select="$numDocsMatched"/>
208 <xsl:with-param name="level" select="$docLevelText"/>
209 </xsl:call-template>
210 </xsl:variable>
211 <xsl:choose>
212 <xsl:when test="$numDocsMatched='0' or $numDocsReturned='0'">
213 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.nodocsmatch', $docLevelText)"/>
214 </xsl:when>
215 <xsl:when test="$numDocsMatched='1' or $numDocsReturned='1'">
216 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.onedocsmatch', $docLevelText)"/>
217 </xsl:when>
218 <xsl:when test="$numDocsMatched">
219 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.manydocsmatch', concat($numDocsMatched, ';', $docLevelText))"/>
220 <xsl:if test="$numDocsReturned and not($numDocsMatched=$numDocsReturned)"> (<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.docsreturned', concat($numDocsReturned, ';', $docLevelText))"/>)</xsl:if>
221 </xsl:when>
222 <xsl:when test="$numDocsReturned">
223 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.atleastdocsmatch', concat($numDocsReturned, ';', $docLevelText))"/>
224 </xsl:when>
225 </xsl:choose>
226 </div>
227
228 </xsl:template>
229
230 <xsl:template name="numDocsMatched">
231 <xsl:choose>
232 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'numDocsMatched']">
233 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'numDocsMatched']"/>
234 </xsl:when>
235 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']">
236 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']"/>
237 </xsl:when>
238 <xsl:otherwise>
239 <xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/>
240 </xsl:otherwise>
241 </xsl:choose>
242 </xsl:template>
243
244 <xsl:template name="numDocsReturned">
245 <xsl:choose>
246 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']">
247 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']"/>
248 </xsl:when>
249 <xsl:otherwise>
250 <xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/>
251 </xsl:otherwise>
252 </xsl:choose>
253 </xsl:template>
254
255 <xsl:template name="documentLevel">
256 <xsl:choose>
257 <xsl:when test="/page/pageRequest/paramList/param[@name='level']">
258 <xsl:value-of select="/page/pageRequest/paramList/param[@name='level']/@value" />
259 </xsl:when>
260 <xsl:when test="/page/pageRequest/paramList/param[@name='s1.level']">
261 <xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.level']/@value" />
262 </xsl:when>
263 <xsl:otherwise>Doc</xsl:otherwise>
264 </xsl:choose>
265 </xsl:template>
266
267 <xsl:template name="documentLevelText">
268 <xsl:param name="numDocsMatched">0</xsl:param>
269 <xsl:param name="level">Doc</xsl:param>
270 <xsl:choose>
271 <xsl:when test="$numDocsMatched = 1">
272 <xsl:choose>
273 <xsl:when test="$level = 'Doc'">
274 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document')"/>
275 </xsl:when>
276 <xsl:otherwise>
277 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.section')"/>
278 </xsl:otherwise>
279 </xsl:choose>
280 </xsl:when>
281 <!-- 0 or more than one use plural. is that the case for all langs??-->
282 <xsl:otherwise>
283 <xsl:choose>
284 <xsl:when test="$level = 'Doc'">
285 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document_plural')"/>
286 </xsl:when>
287 <xsl:otherwise>
288 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.section_plural')"/>
289 </xsl:otherwise>
290 </xsl:choose>
291 </xsl:otherwise>
292 </xsl:choose>
293 </xsl:template>
294
295 <xsl:template name="displayTermInfo">
296
297 <!-- Find the number of documents displayed per page -->
298 <xsl:variable name="level">
299 <xsl:call-template name="documentLevel"/>
300 </xsl:variable>
301
302 <!-- The list of search terms with their frequency and document count -->
303 <p class="termList">
304 <xsl:if test="count(/page/pageResponse/termList/stopword) &gt; 0">
305 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.common')"/>
306 <xsl:text/>
307 <xsl:for-each select="/page/pageResponse/termList/stopword">
308 <span style="font-style:italic;">
309 <xsl:value-of select="@name"/>
310 </span>
311 <xsl:text/>
312 </xsl:for-each>
313 <br />
314 <br />
315 </xsl:if>
316
317 <!-- If there is only one or two search terms then show the expanded information -->
318 <xsl:choose>
319 <xsl:when test="count(/page/pageResponse/termList/term) &lt; 3">
320 <xsl:for-each select="/page/pageResponse/termList/term">
321 <xsl:variable name="occursTextKey">
322 <xsl:choose>
323 <xsl:when test="@freq = 1">query.termoccurs.1.1</xsl:when>
324 <xsl:when test="@numDocsMatch = 1">query.termoccurs.x.1</xsl:when>
325 <xsl:otherwise>query.termoccurs.x.x</xsl:otherwise>
326 </xsl:choose>
327 </xsl:variable>
328 <xsl:variable name="levelText">
329 <xsl:call-template name="documentLevelText">
330 <xsl:with-param name="level" select="$level"/>
331 <xsl:with-param name="numDocsMatched" select="@numDocsMatch"/>
332 </xsl:call-template>
333 </xsl:variable>
334 <span class="termInfo">
335 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, $occursTextKey, concat(@name,';', @freq,';', @numDocsMatch,';', $levelText))"/>
336 </span>
337 <br/>
338 </xsl:for-each>
339 </xsl:when>
340 <xsl:otherwise>
341 <xsl:for-each select="/page/pageResponse/termList/term">
342 <span style="font-style:italic;">
343 <xsl:value-of select="@name"/>
344 </span> (<xsl:value-of select="@freq"/>)
345 </xsl:for-each>
346 </xsl:otherwise>
347 </xsl:choose>
348 </p>
349 </xsl:template>
350
351 <xsl:template name="prevNextButtons">
352 <!-- Current page -->
353 <xsl:variable name="currentPage">
354 <xsl:choose>
355 <xsl:when test="/page/pageRequest/paramList/param[@name='s1.startPage']/@value">
356 <xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.startPage']/@value" />
357 </xsl:when>
358 <xsl:when test="/page/pageRequest/paramList/param[@name='startPage']/@value">
359 <xsl:value-of select="/page/pageRequest/paramList/param[@name='startPage']/@value" />
360 </xsl:when>
361 <xsl:otherwise>1</xsl:otherwise>
362 </xsl:choose>
363 </xsl:variable>
364
365 <xsl:variable name="usesS1">
366 <xsl:choose>
367 <xsl:when test="/page/pageResponse/service/paramList/param[@name='startPage']">true</xsl:when>
368 <xsl:otherwise>false</xsl:otherwise>
369 </xsl:choose>
370 </xsl:variable>
371
372 <!-- Find the total number of documents returned -->
373 <xsl:variable name="docMax">
374 <xsl:choose>
375 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']">
376 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']"/>
377 </xsl:when>
378 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'numDocsMatched']">
379 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'numDocsMatched']"/>
380 </xsl:when>
381 <xsl:otherwise>
382 <xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/>
383 </xsl:otherwise>
384 </xsl:choose>
385 </xsl:variable>
386
387 <!-- Find the number of documents displayed per page -->
388 <xsl:variable name="docsPerPage">
389 <xsl:choose>
390 <xsl:when test="/page/pageRequest/paramList/param[@name='hitsPerPage']">
391 <xsl:value-of select="/page/pageRequest/paramList/param[@name='hitsPerPage']/@value" />
392 </xsl:when>
393 <xsl:when test="/page/pageRequest/paramList/param[@name='s1.hitsPerPage']">
394 <xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.hitsPerPage']/@value" />
395 </xsl:when>
396 <xsl:otherwise>20</xsl:otherwise>
397 </xsl:choose>
398 </xsl:variable>
399
400 <!-- Find the number of documents displayed per page -->
401 <xsl:variable name="level">
402 <xsl:choose>
403 <xsl:when test="/page/pageRequest/paramList/param[@name='level']">
404 <xsl:value-of select="/page/pageRequest/paramList/param[@name='level']/@value" />
405 </xsl:when>
406 <xsl:when test="/page/pageRequest/paramList/param[@name='s1.level']">
407 <xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.level']/@value" />
408 </xsl:when>
409 <xsl:otherwise>Doc</xsl:otherwise>
410 </xsl:choose>
411 </xsl:variable>
412
413 <table id="searchResultNavTable">
414 <tr>
415 <xsl:variable name="startPageName">
416 <xsl:if test="$usesS1 = 'true'">s1.</xsl:if>startPage</xsl:variable>
417
418 <!-- Previous button -->
419 <td id="prevArrowTD">
420 <xsl:if test="$currentPage != 1">
421 <a href="{$library_name}?a=q&amp;sa={/page/pageRequest/@subaction}&amp;c={$collName}&amp;s={/page/pageResponse/service/@name}&amp;rt=rd&amp;{$startPageName}={$currentPage - 1}&amp;qs={/page/pageRequest/paramList/param[@name='qs']/@value}">
422 <img src="interfaces/default/images/previous.png"/>
423 </a>
424 </xsl:if>
425 </td>
426 <td id="prevTD">
427 <xsl:if test="$currentPage != 1">
428 <a href="{$library_name}?a=q&amp;sa={/page/pageRequest/@subaction}&amp;c={$collName}&amp;s={/page/pageResponse/service/@name}&amp;rt=rd&amp;{$startPageName}={$currentPage - 1}&amp;qs={/page/pageRequest/paramList/param[@name='qs']/@value}">Previous</a>
429 </xsl:if>
430 </td>
431
432 <!-- Search result status bar (in english it reads "Displaying X to Y of Z documents") -->
433 <xsl:if test="$docMax &gt; 0">
434 <xsl:variable name="startdoc" select="($currentPage - 1) * $docsPerPage + 1"/>
435 <xsl:variable name="enddoc">
436 <xsl:choose>
437 <xsl:when test="($currentPage * $docsPerPage + 1) &gt; $docMax">
438 <xsl:value-of select="$docMax"/>
439 </xsl:when>
440 <xsl:otherwise>
441 <xsl:value-of select="$currentPage * $docsPerPage"/>
442 </xsl:otherwise>
443 </xsl:choose>
444 </xsl:variable>
445 <xsl:variable name="level">
446 <xsl:choose>
447 <xsl:when test="$docMax = 1">
448 <xsl:text/>
449 <xsl:choose>
450 <xsl:when test="$level = 'Doc'">
451 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document')"/>
452 </xsl:when>
453 <xsl:otherwise>
454 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.section')"/>
455 </xsl:otherwise>
456 </xsl:choose>
457 </xsl:when>
458 <xsl:otherwise>
459 <xsl:text/>
460 <xsl:choose>
461 <xsl:when test="$level = 'Doc'">
462 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document_plural')"/>
463 </xsl:when>
464 <xsl:otherwise>
465 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.section_plural')"/>
466 </xsl:otherwise>
467 </xsl:choose>
468 </xsl:otherwise>
469 </xsl:choose>
470 </xsl:variable>
471 <td id="searchResultsStatusBar">
472 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.displayingnumdocs', concat($startdoc,';', $enddoc, ';', $docMax, ';', $level))"/>
473 </td>
474 </xsl:if>
475
476 <!-- Next button -->
477 <td id="nextTD">
478 <xsl:if test="($currentPage * $docsPerPage + 1) &lt; $docMax">
479 <a href="{$library_name}?a=q&amp;sa={/page/pageRequest/paramList/param[@name = 'sa']/@value}&amp;c={$collName}&amp;s={/page/pageResponse/service/@name}&amp;rt=rd&amp;{$startPageName}={$currentPage + 1}&amp;qs={/page/pageRequest/paramList/param[@name='qs']/@value}">Next</a>
480 </xsl:if>
481 </td>
482 <td id="nextArrowTD">
483 <xsl:if test="($currentPage * $docsPerPage + 1) &lt; $docMax">
484 <a href="{$library_name}?a=q&amp;sa={/page/pageRequest/paramList/param[@name = 'sa']/@value}&amp;c={$collName}&amp;s={/page/pageResponse/service/@name}&amp;rt=rd&amp;{$startPageName}={$currentPage + 1}&amp;qs={/page/pageRequest/paramList/param[@name='qs']/@value}">
485 <img src="interfaces/default/images/next.png"/>
486 </a>
487 </xsl:if>
488 </td>
489 </tr>
490 </table>
491 </xsl:template>
492
493 <!-- puts all the params into a=p&p=h type form - need to change this if use
494 multi params -->
495 <xsl:template match="paramList" mode="cgi">
496 <xsl:param name="ns">s1.</xsl:param>
497 <xsl:for-each select="param">
498 <xsl:variable name='pname' select="@name"/>
499 <xsl:text>&amp;</xsl:text>
500 <xsl:value-of select="$ns"/>
501 <xsl:value-of select="@name"/>=<xsl:apply-templates select="." mode="calculate-default">
502 <xsl:with-param name='ns' select='$ns'/>
503 </xsl:apply-templates>
504 </xsl:for-each>
505 </xsl:template>
506
507 <xsl:template name="resultsPagePre">
508 <!-- OVERWRITE TO INSERT CONTENT BEFORE THE RESULTS PAGE -->
509 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
510 <xsl:call-template name="mapFeaturesJSONNodes"/>
511 </xsl:if>
512 </xsl:template>
513
514 <xsl:template name="resultsPagePost">
515 <!-- OVERWRITE TO INSERT CONTENT AFTER THE RESULTS PAGE -->
516 </xsl:template>
517
518 <xsl:template name="documentNodePre">
519 <!-- OVERWRITE TO INSERT CONTENT BEFORE EVERY DOCUMENT NODE -->
520 </xsl:template>
521
522 <xsl:template name="documentNodePost">
523 <!-- OVERWRITE TO INSERT CONTENT AFTER EVERY DOCUMENT NODE -->
524 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
525 <xsl:call-template name="mapFeaturesIcon"/>
526 </xsl:if>
527 </xsl:template>
528
529 <xsl:template name="mapFeaturesJSONNodes">
530 <div id="jsonNodes" style="display:none;">
531 <xsl:text>[</xsl:text>
532 <xsl:for-each select="//documentNode">
533 <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
534 <xsl:text>{</xsl:text>
535 <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text>
536 <xsl:value-of select="@nodeID"/>
537 <xsl:text disable-output-escaping="yes">",</xsl:text>
538 <xsl:text disable-output-escaping="yes">"title":"</xsl:text>
539 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
540 <xsl:text disable-output-escaping="yes">",</xsl:text>
541 <xsl:text disable-output-escaping="yes">"lat":</xsl:text>
542 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/>
543 <xsl:text>,</xsl:text>
544 <xsl:text disable-output-escaping="yes">"lng":</xsl:text>
545 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
546 <xsl:text>}</xsl:text>
547 <xsl:if test="not(position() = count(//documentNode))">
548 <xsl:text>,</xsl:text>
549 </xsl:if>
550 </xsl:if>
551 </xsl:for-each>
552 <xsl:text>]</xsl:text>
553 </div>
554
555 <div id="map_canvas" style="margin:0px auto; width:450px; height:500px; float:right;">
556 <xsl:text/>
557 </div>
558
559 <!-- Although these aren't visible, they are necessary because it forces Greenstone to include this metadata in the page xml -->
560 <gsf:metadata name="Latitude" hidden="true"/>
561 <gsf:metadata name="Longitude" hidden="true"/>
562 </xsl:template>
563
564 <xsl:template name="mapFeaturesIcon">
565 <td style="padding-left:5px; padding-right:5px;" valign="top">
566 <a href="javascript:focusDocument('{@nodeID}');">
567 <img src="interfaces/default/images/map_marker.png"/>
568 </a>
569 </td>
570 </xsl:template>
571</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.