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

Last change on this file since 26143 was 26143, checked in by ak19, 9 years ago

Stopwords in Lucene once more being handled with special message, while regular searches (and their messages) still work: for words that occur and that don't occur.

File size: 27.9 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><!-- 0 results. Still need to check for search term being stopwords -->
264 <xsl:choose>
265 <xsl:when test="count(/page/pageResponse/termList/stopword) &gt; 0">
266 <p class="termList">
267 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.common')"/><xsl:text> </xsl:text>
268
269 <xsl:if test="/page/pageResponse/termList/stopword">
270 <xsl:for-each select="/page/pageResponse/termList/stopword">
271 <span style="font-style:italic;"><xsl:value-of select="@name"/></span><xsl:text> </xsl:text>
272 </xsl:for-each>
273 <br /><br />
274 </xsl:if>
275 </p>
276 </xsl:when>
277 <xsl:otherwise><!-- 0 results and not owing to stopwords.-->
278 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.nodocsmatch')"/>
279 </xsl:otherwise>
280 </xsl:choose>
281 </xsl:otherwise>
282 </xsl:choose>
283 </xsl:template>
284
285 <xsl:template name="prevNextButtons">
286 <!-- Current page -->
287 <xsl:variable name="currentPage">
288 <xsl:choose>
289 <xsl:when test="/page/pageRequest/paramList/param[@name='s1.startPage']/@value">
290 <xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.startPage']/@value" />
291 </xsl:when>
292 <xsl:when test="/page/pageRequest/paramList/param[@name='startPage']/@value">
293 <xsl:value-of select="/page/pageRequest/paramList/param[@name='startPage']/@value" />
294 </xsl:when>
295 <xsl:otherwise>1</xsl:otherwise>
296 </xsl:choose>
297 </xsl:variable>
298
299 <xsl:variable name="usesS1">
300 <xsl:choose>
301 <xsl:when test="/page/pageResponse/service/paramList/param[@name='startPage']">true</xsl:when>
302 <xsl:otherwise>false</xsl:otherwise>
303 </xsl:choose>
304 </xsl:variable>
305
306 <!-- Find the total number of documents returned -->
307 <xsl:variable name="docMax">
308 <xsl:choose>
309 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']">
310 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']"/>
311 </xsl:when>
312 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'numDocsMatched']">
313 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'numDocsMatched']"/>
314 </xsl:when>
315 <xsl:otherwise><xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/></xsl:otherwise>
316 </xsl:choose>
317 </xsl:variable>
318
319 <!-- Find the number of documents displayed per page -->
320 <xsl:variable name="docsPerPage">
321 <xsl:choose>
322 <xsl:when test="/page/pageRequest/paramList/param[@name='hitsPerPage']">
323 <xsl:value-of select="/page/pageRequest/paramList/param[@name='hitsPerPage']/@value" />
324 </xsl:when>
325 <xsl:when test="/page/pageRequest/paramList/param[@name='s1.hitsPerPage']">
326 <xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.hitsPerPage']/@value" />
327 </xsl:when>
328 <xsl:otherwise>20</xsl:otherwise>
329 </xsl:choose>
330 </xsl:variable>
331
332 <!-- Find the number of documents displayed per page -->
333 <xsl:variable name="level">
334 <xsl:choose>
335 <xsl:when test="/page/pageRequest/paramList/param[@name='level']">
336 <xsl:value-of select="/page/pageRequest/paramList/param[@name='level']/@value" />
337 </xsl:when>
338 <xsl:when test="/page/pageRequest/paramList/param[@name='s1.level']">
339 <xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.level']/@value" />
340 </xsl:when>
341 <xsl:otherwise>Doc</xsl:otherwise>
342 </xsl:choose>
343 </xsl:variable>
344
345 <table id="searchResultNavTable"><tr>
346 <xsl:variable name="startPageName"><xsl:if test="$usesS1 = 'true'">s1.</xsl:if>startPage</xsl:variable>
347
348 <!-- Previous button -->
349 <td id="prevArrowTD">
350 <xsl:if test="$currentPage != 1">
351 <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}">
352 <img src="interfaces/default/images/previous.png"/>
353 </a>
354 </xsl:if>
355 </td>
356 <td id="prevTD">
357 <xsl:if test="$currentPage != 1">
358 <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>
359 </xsl:if>
360 </td>
361
362 <!-- Search result status bar (in english it reads "Displaying X to Y of Z documents") -->
363 <xsl:if test="$docMax &gt; 0">
364 <td id="searchResultsStatusBar">
365 <!-- "Displaying" -->
366 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.displaying')"/><xsl:text> </xsl:text>
367 <!-- "X" -->
368 <xsl:value-of select="($currentPage - 1) * $docsPerPage + 1"/>
369 <!-- "to" -->
370 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.to')"/><xsl:text> </xsl:text>
371 <!-- "Y" -->
372 <xsl:choose>
373 <xsl:when test="($currentPage * $docsPerPage + 1) &gt; $docMax">
374 <xsl:value-of select="$docMax"/>
375 </xsl:when>
376 <xsl:otherwise>
377 <xsl:value-of select="$currentPage * $docsPerPage"/>
378 </xsl:otherwise>
379 </xsl:choose>
380 <!-- "of" -->
381 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.of')"/><xsl:text> </xsl:text>
382 <!-- "Z" -->
383 <xsl:value-of select="$docMax"/>
384 <!-- "document[s]/section[s]"-->
385 <xsl:choose>
386 <xsl:when test="$docMax = 1">
387 <xsl:text> </xsl:text>
388 <xsl:choose>
389 <xsl:when test="$level = 'Doc'">
390 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document')"/>
391 </xsl:when>
392 <xsl:otherwise>
393 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.section')"/>
394 </xsl:otherwise>
395 </xsl:choose>
396 </xsl:when>
397 <xsl:otherwise>
398 <xsl:text> </xsl:text>
399 <xsl:choose>
400 <xsl:when test="$level = 'Doc'">
401 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document_plural')"/>
402 </xsl:when>
403 <xsl:otherwise>
404 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.section_plural')"/>
405 </xsl:otherwise>
406 </xsl:choose>
407 </xsl:otherwise>
408 </xsl:choose>
409 </td>
410 </xsl:if>
411
412 <!-- Next button -->
413 <td id="nextTD">
414 <xsl:if test="($currentPage * $docsPerPage + 1) &lt; $docMax">
415 <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>
416 </xsl:if>
417 </td>
418 <td id="nextArrowTD">
419 <xsl:if test="($currentPage * $docsPerPage + 1) &lt; $docMax">
420 <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}">
421 <img src="interfaces/default/images/next.png"/>
422 </a>
423 </xsl:if>
424 </td>
425 </tr></table>
426 </xsl:template>
427
428 <!-- puts all the params into a=p&p=h type form - need to change this if use
429 multi params -->
430 <xsl:template match="paramList" mode="cgi">
431 <xsl:param name="ns">s1.</xsl:param>
432 <xsl:for-each select="param">
433 <xsl:variable name='pname' select="@name"/>
434 <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>
435 </xsl:for-each>
436 </xsl:template>
437
438 <xsl:template match="param" mode="calculate-default">
439 <xsl:param name="ns">s1.</xsl:param>
440 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
441 <xsl:choose>
442 <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]">
443 <xsl:choose>
444 <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
445 <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
446 <xsl:value-of select="@value"/>,
447 </xsl:for-each>
448 </xsl:when>
449 <xsl:otherwise>
450 <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
451 </xsl:otherwise>
452 </xsl:choose>
453 </xsl:when>
454 <xsl:otherwise>
455 <xsl:value-of select="@default"/>
456 </xsl:otherwise>
457 </xsl:choose>
458 </xsl:template>
459
460 <!-- invisible params - used by other stuff. in the query form, we set to the default -->
461 <xsl:template match="param[@type='invisible']">
462 <xsl:param name="ns">s1.</xsl:param>
463 <input type='hidden' name='{$ns}{@name}' value='{@default}'/>
464 </xsl:template>
465
466 <!-- boolean params -->
467 <xsl:template match="param[@type='boolean']">
468 <xsl:param name="ns">s1.</xsl:param>
469 <xsl:param name="default"/>
470 <select name='{$ns}{@name}'>
471 <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>
472 <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>
473 </select>
474 </xsl:template>
475
476 <!-- integer params -->
477 <xsl:template match="param[@type='integer']">
478 <xsl:param name="ns">s1.</xsl:param>
479 <xsl:param name="default"/>
480 <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/>
481 </xsl:template>
482
483 <!-- single selection enum params -->
484 <xsl:template match="param[@type='enum_single']">
485 <xsl:param name="ns">s1.</xsl:param>
486 <xsl:param name="default"/>
487 <xsl:choose>
488 <xsl:when test="count(option) = 1">
489 <xsl:value-of select="option/displayItem[@name='name']"/>
490 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
491 </xsl:when>
492 <xsl:otherwise>
493 <select name="{$ns}{@name}">
494 <xsl:for-each select="option">
495 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
496 </xsl:for-each>
497 </select>
498 </xsl:otherwise>
499 </xsl:choose>
500 </xsl:template>
501
502
503 <!-- multiple selection enum params -->
504 <!-- how to do defaults for this?? -->
505 <xsl:template match="param[@type='enum_multi']">
506 <xsl:param name="ns">s1.</xsl:param>
507 <xsl:param name="default"/>
508 <select name="{$ns}{@name}" size="2">
509 <xsl:attribute name="multiple"></xsl:attribute>
510 <xsl:for-each select="option">
511 <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>
512 </xsl:for-each>
513 </select>
514 </xsl:template>
515
516 <!-- string params -->
517 <xsl:template match="param[@type='string']">
518 <xsl:param name="ns">s1.</xsl:param>
519 <xsl:param name="default"/>
520 <input type="text" name="{$ns}{@name}" size="30" value="{$default}"/>
521 </xsl:template>
522
523 <!-- large string params -->
524 <xsl:template match="param[@type='text']">
525 <xsl:param name="ns">s1.</xsl:param>
526 <xsl:param name="default"/>
527 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
528 </xsl:template>
529
530 <!-- multi params - params that are combinations of other params -->
531 <xsl:template match="param[@type='multi']">
532 <xsl:param name="ns">s1.</xsl:param>
533 <xsl:variable name="parent" select="@name"/>
534
535 <table>
536 <tr class="queryfieldheading">
537 <xsl:value-of select="displayItem[@name='name']"/>
538 <xsl:for-each select="param">
539 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
540 </xsl:for-each>
541 </tr>
542 <xsl:apply-templates select="." mode="contents">
543 <xsl:with-param name="occurs" select="@occurs"/>
544 <xsl:with-param name="ns" select="$ns"/>
545 </xsl:apply-templates>
546 </table>
547
548 </xsl:template>
549
550 <xsl:template match="param[@type = 'checkbox_list']">
551 <xsl:param name="ns">s1.</xsl:param>
552 <ul class="checkboxList">
553 <xsl:for-each select="option">
554 <li><input type="checkbox" name="{$ns}{../@name}" value="{@name}"/><xsl:value-of select="displayItem"/></li>
555 </xsl:for-each>
556 </ul>
557 </xsl:template>
558
559 <xsl:template match="param[@type='multi']" mode="contents">
560 <xsl:param name="ns">s1.</xsl:param>
561 <xsl:param name="occurs">1</xsl:param>
562 <xsl:variable name="pos" select="@occurs - $occurs"/>
563 <tr class="queryfieldrow">
564 <xsl:for-each select="param">
565 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
566 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
567 <td class="queryfieldcell">
568 <xsl:choose>
569 <xsl:when test="not(@ignore) or @ignore != $pos">
570 <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>
571 </xsl:when>
572 <xsl:otherwise><!-- put in a hidden placeholder -->
573 <input type="hidden" name='{$ns}{@name}' value=''/>
574 </xsl:otherwise>
575 </xsl:choose>
576 </td>
577 </xsl:for-each>
578 </tr>
579
580 <!-- recursively call this template to get multiple entries -->
581 <xsl:if test="$occurs &gt; 1">
582 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
583 </xsl:if>
584 </xsl:template>
585
586 <xsl:template name="resultsPagePre">
587 <!-- OVERWRITE TO INSERT CONTENT BEFORE THE RESULTS PAGE -->
588 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
589 <xsl:call-template name="mapFeaturesJSONNodes"/>
590 </xsl:if>
591 </xsl:template>
592
593 <xsl:template name="resultsPagePost">
594 <!-- OVERWRITE TO INSERT CONTENT AFTER THE RESULTS PAGE -->
595 </xsl:template>
596
597 <xsl:template name="documentNodePre">
598 <!-- OVERWRITE TO INSERT CONTENT BEFORE EVERY DOCUMENT NODE -->
599 </xsl:template>
600
601 <xsl:template name="documentNodePost">
602 <!-- OVERWRITE TO INSERT CONTENT AFTER EVERY DOCUMENT NODE -->
603 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
604 <xsl:call-template name="mapFeaturesIcon"/>
605 </xsl:if>
606 </xsl:template>
607
608 <xsl:template name="mapFeaturesJSONNodes">
609 <div id="jsonNodes" style="display:none;">
610 <xsl:text>[</xsl:text>
611 <xsl:for-each select="//documentNode">
612 <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
613 <xsl:text>{</xsl:text>
614 <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">",</xsl:text>
615 <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>
616 <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>
617 <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
618 <xsl:text>}</xsl:text>
619 <xsl:if test="not(position() = count(//documentNode))">
620 <xsl:text>,</xsl:text>
621 </xsl:if>
622 </xsl:if>
623 </xsl:for-each>
624 <xsl:text>]</xsl:text>
625 </div>
626
627 <div id="map_canvas" style="margin:0px auto; width:450px; height:500px; float:right;"><xsl:text> </xsl:text></div>
628
629 <!-- Although these aren't visible, they are necessary because it forces Greenstone to include this metadata in the page xml -->
630 <gsf:metadata name="Latitude" hidden="true"/>
631 <gsf:metadata name="Longitude" hidden="true"/>
632 </xsl:template>
633
634 <xsl:template name="mapFeaturesIcon">
635 <td style="padding-left:5px; padding-right:5px;" valign="top">
636 <a href="javascript:focusDocument('{@nodeID}');"><img src="interfaces/{$interface_name}/images/bluemarker.png"/></a>
637 </td>
638 </xsl:template>
639</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.