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

Last change on this file since 26136 was 26136, checked in by sjm84, 9 years ago

Fixed query terms disappearing in Form and Advanced searches

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