source: main/trunk/greenstone3/web/interfaces/oran/transform/pages/query.xsl@ 24025

Last change on this file since 24025 was 24025, checked in by sjm84, 13 years ago

Added the two requested lucene-specific skin updates (stop words and the sortBy option)

File size: 18.4 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 extension-element-prefixes="java util"
8 exclude-result-prefixes="java util">
9
10 <!-- use the 'main' layout -->
11 <xsl:include href="layouts/main.xsl"/>
12
13 <!-- set page title -->
14 <xsl:template name="pageTitle"><gslib:serviceName/></xsl:template>
15
16 <!-- set page breadcrumbs -->
17 <xsl:template name="breadcrumbs"> <gslib:siteLink/><gslib:rightArrow/><xsl:if test="/page/pageResponse/collection"> <gslib:collectionNameLinked/><gslib:rightArrow/></xsl:if></xsl:template>
18
19 <!-- the page content -->
20 <xsl:template match="/page">
21 <xsl:choose>
22 <xsl:when test="not(pageResponse/documentNodeList)">
23 <xsl:for-each select="pageResponse/service">
24 <form name="QueryForm" method="get" action="{$library_name}">
25 <div>
26 <input type="hidden" name="a" value="q"/>
27 <input type="hidden" name="sa"><xsl:attribute name="value"><xsl:value-of select="/page/pageRequest/@subaction"/></xsl:attribute></input>
28 <input type="hidden" name="rt" value="rd"/>
29 <input type="hidden" name="s" value="{@name}"/>
30 <input type="hidden" name="c" value="{$collName}"/>
31 <xsl:if test="not(paramList/param[@name='startPage'])">
32 <input type="hidden" name="startPage" value="1"/>
33 </xsl:if>
34 <xsl:choose>
35 <xsl:when test="/page/pageRequest/paramList/param[@name = 's1.maxDocs']">
36 <input type="hidden" name="s1.maxDocs">
37 <xsl:attribute name="value">
38 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 's1.maxDocs']/@value"/>
39 </xsl:attribute>
40 </input>
41 </xsl:when>
42 <xsl:otherwise>
43 <input type="hidden" name="s1.maxDocs" value="100"/>
44 </xsl:otherwise>
45 </xsl:choose>
46 <xsl:choose>
47 <xsl:when test="/page/pageRequest/paramList/param[@name = 's1.hitsPerPage']">
48 <input type="hidden" name="s1.hitsPerPage">
49 <xsl:attribute name="value">
50 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 's1.hitsPerPage']/@value"/>
51 </xsl:attribute>
52 </input>
53 </xsl:when>
54 <xsl:otherwise>
55 <input type="hidden" name="s1.hitsPerPage" value="20"/>
56 </xsl:otherwise>
57 </xsl:choose>
58
59 <xsl:variable name="ns">s1.</xsl:variable>
60 <xsl:for-each select="paramList/param">
61 <xsl:choose>
62 <xsl:when test="@name='case' or @name='stem' or @name='accent'">
63 </xsl:when>
64 <xsl:when test="@type='multi'">
65 <xsl:apply-templates select="."><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
66 </xsl:when>
67 <xsl:when test="@name = 'maxDocs' or @name = 'hitsPerPage'"></xsl:when>
68 <xsl:otherwise>
69 <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></xsl:variable>
70 <div class="paramLabel"><xsl:value-of select="displayItem[@name='name']"/></div>
71 <div class="paramValue">
72 <xsl:apply-templates select=".">
73 <xsl:with-param name="default" select="$pvalue"/>
74 <xsl:with-param name="ns" select="$ns"/>
75 </xsl:apply-templates>
76 </div>
77 <br class="clear"/>
78 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:for-each>
81
82 <br/>
83
84 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="displayItem[@name='submit']"/></xsl:attribute></input>
85
86 </div>
87 </form>
88 </xsl:for-each>
89 </xsl:when>
90
91 <xsl:otherwise>
92 <!-- The list of search terms with their frequency and document count -->
93 <p class="termList">
94 <xsl:if test="count(/page/pageResponse/termList/stopword) &gt; 0">
95 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.common')"/><xsl:text> </xsl:text>
96 </xsl:if>
97
98 <xsl:for-each select="/page/pageResponse/termList/stopword">
99 <span style="font-style:italic;"><xsl:value-of select="@name"/></span><xsl:text> </xsl:text>
100 </xsl:for-each>
101 <br /><br />
102
103 <xsl:for-each select="/page/pageResponse/termList/term">
104 <xsl:choose>
105 <!-- If there is only one or two search terms then show the expanded information -->
106 <xsl:when test="count(/page/pageResponse/termList/term) &lt; 3">
107 <span style="font-style:italic;"><xsl:value-of select="@name"/></span>
108 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.occurs')"/><xsl:text> </xsl:text>
109 <xsl:value-of select="@freq"/>
110 <xsl:choose>
111 <xsl:when test="@freq = 1">
112 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.time')"/>
113 </xsl:when>
114 <xsl:otherwise>
115 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.time_plural')"/>
116 </xsl:otherwise>
117 </xsl:choose>
118 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.in')"/><xsl:text> </xsl:text>
119 <xsl:value-of select="@numDocsMatch"/>
120 <xsl:choose>
121 <xsl:when test="@numDocsMatch = 1">
122 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document')"/>
123 </xsl:when>
124 <xsl:otherwise>
125 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document_plural')"/>
126 </xsl:otherwise>
127 </xsl:choose>
128 <br />
129 </xsl:when>
130 <xsl:otherwise>
131 <span style="font-style:italic;"><xsl:value-of select="@name"/></span> (<xsl:value-of select="@freq"/>)
132 </xsl:otherwise>
133 </xsl:choose>
134 </xsl:for-each>
135 </p>
136
137 <ul id="results">
138 <xsl:for-each select="pageResponse/documentNodeList/documentNode">
139 <li class="document">
140 <a>
141 <xsl:choose>
142 <xsl:when test="/page/pageResponse/collection/@name">
143 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=q&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;hl=on&amp;ed=1#<xsl:value-of select="@nodeID"/></xsl:attribute>
144 </xsl:when>
145 <xsl:when test="@collection">
146 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="@collection"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=q&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;hl=on&amp;ed=1#<xsl:value-of select="@nodeID"/></xsl:attribute>
147 </xsl:when>
148 </xsl:choose>
149
150 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
151 </a>
152
153 <!-- If this is results from a cross collection search then add a link to the collection that it is from -->
154 <xsl:if test="@collection">
155 (<a style="background-image:none; padding:3px;">
156 <xsl:attribute name="href">
157 <xsl:value-of select="$library_name"/>?a=p&amp;sa=about&amp;c=<xsl:value-of select="@collection"/>
158 </xsl:attribute>
159 <xsl:value-of select="@collection"/>
160 </a>)
161 </xsl:if>
162 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
163 </li>
164 </xsl:for-each>
165 <br/>
166
167 <!-- Previous/Next buttons-->
168 <xsl:call-template name="prevNextButtons"/>
169 </ul>
170 </xsl:otherwise>
171
172 </xsl:choose>
173
174 </xsl:template>
175
176 <xsl:template name="prevNextButtons">
177 <!-- Current page -->
178 <xsl:variable name="currentPage">
179 <xsl:choose>
180 <xsl:when test="/page/pageRequest/paramList/param[@name='startPage']/@value">
181 <xsl:value-of select="/page/pageRequest/paramList/param[@name='startPage']/@value" />
182 </xsl:when>
183 <xsl:when test="/page/pageRequest/paramList/param[@name='s1.startPage']/@value">
184 <xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.startPage']/@value" />
185 </xsl:when>
186 <xsl:otherwise>1</xsl:otherwise>
187 </xsl:choose>
188 </xsl:variable>
189
190 <!-- Find the total number of documents returned -->
191 <xsl:variable name="docMax">
192 <xsl:choose>
193 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']">
194 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'numDocsReturned']"/>
195 </xsl:when>
196 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'numDocsMatched']">
197 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'numDocsMatched']"/>
198 </xsl:when>
199 <xsl:otherwise><xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/></xsl:otherwise>
200 </xsl:choose>
201 </xsl:variable>
202
203 <!-- Find the number of documents displayed per page -->
204 <xsl:variable name="docsPerPage">
205 <xsl:choose>
206 <xsl:when test="/page/pageRequest/paramList/param[@name='hitsPerPage']">
207 <xsl:value-of select="/page/pageRequest/paramList/param[@name='hitsPerPage']/@value" />
208 </xsl:when>
209 <xsl:when test="/page/pageRequest/paramList/param[@name='s1.hitsPerPage']">
210 <xsl:value-of select="/page/pageRequest/paramList/param[@name='s1.hitsPerPage']/@value" />
211 </xsl:when>
212 <xsl:otherwise>20</xsl:otherwise>
213 </xsl:choose>
214 </xsl:variable>
215
216 <table id="searchResultNavTable"><tr>
217 <!-- Previous button -->
218 <td id="prevArrowTD">
219 <xsl:if test="$currentPage != 1">
220 <a href="{$library_name}?a=q&amp;sa={/page/pageRequest/@subaction}&amp;c={$collName}&amp;s={/page/pageResponse/service/@name}&amp;rt=rd&amp;startPage={$currentPage - 1}">
221 <img src="interfaces/oran/images/previous.png"/>
222 </a>
223 </xsl:if>
224 </td>
225 <td id="prevTD">
226 <xsl:if test="$currentPage != 1">
227 <a href="{$library_name}?a=q&amp;sa={/page/pageRequest/@subaction}&amp;c={$collName}&amp;s={/page/pageResponse/service/@name}&amp;rt=rd&amp;startPage={$currentPage - 1}">Previous</a>
228 </xsl:if>
229 </td>
230
231 <!-- Search result status bar (in english it reads "Displaying X to Y of Z documents") -->
232 <xsl:if test="$docMax &gt; 0">
233 <td id="searchResultsStatusBar">
234 <!-- "Displaying" -->
235 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.displaying')"/><xsl:text> </xsl:text>
236 <!-- "X" -->
237 <xsl:value-of select="($currentPage - 1) * $docsPerPage + 1"/>
238 <!-- "to" -->
239 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.to')"/><xsl:text> </xsl:text>
240 <!-- "Y" -->
241 <xsl:choose>
242 <xsl:when test="($currentPage * $docsPerPage + 1) &gt; $docMax">
243 <xsl:value-of select="$docMax"/>
244 </xsl:when>
245 <xsl:otherwise>
246 <xsl:value-of select="$currentPage * $docsPerPage"/>
247 </xsl:otherwise>
248 </xsl:choose>
249 <!-- "of" -->
250 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.of')"/><xsl:text> </xsl:text>
251 <!-- "Z" -->
252 <xsl:value-of select="$docMax"/>
253 <!-- "document[s]"-->
254 <xsl:choose>
255 <xsl:when test="$docMax = 1">
256 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document')"/>
257 </xsl:when>
258 <xsl:otherwise>
259 <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.document_plural')"/>
260 </xsl:otherwise>
261 </xsl:choose>
262 </td>
263 </xsl:if>
264
265 <!-- Next button -->
266 <td id="nextTD">
267 <xsl:if test="($currentPage * $docsPerPage + 1) &lt; $docMax">
268 <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;startPage={$currentPage + 1}">Next</a>
269 </xsl:if>
270 </td>
271 <td id="nextArrowTD">
272 <xsl:if test="($currentPage * $docsPerPage + 1) &lt; $docMax">
273 <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;startPage={$currentPage + 1}">
274 <img src="interfaces/oran/images/next.png"/>
275 </a>
276 </xsl:if>
277 </td>
278 </tr></table>
279 </xsl:template>
280
281 <!-- puts all the params into a=p&p=h type form - need to change this if use
282 multi params -->
283 <xsl:template match="paramList" mode="cgi">
284 <xsl:param name="ns">s1.</xsl:param>
285 <xsl:for-each select="param">
286 <xsl:variable name='pname' select="@name"/>
287 <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>
288 </xsl:for-each>
289 </xsl:template>
290
291 <xsl:template match="param" mode="calculate-default">
292 <xsl:param name="ns">s1.</xsl:param>
293 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
294 <xsl:choose>
295 <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]">
296 <xsl:choose>
297 <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
298 <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
299 <xsl:value-of select="@value"/>,
300 </xsl:for-each>
301 </xsl:when>
302 <xsl:otherwise>
303 <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
304 </xsl:otherwise>
305 </xsl:choose>
306 </xsl:when>
307 <xsl:otherwise>
308 <xsl:value-of select="@default"/>
309 </xsl:otherwise>
310 </xsl:choose>
311 </xsl:template>
312
313 <!-- invisible params - used by other stuff. in the query form, we set to the default -->
314 <xsl:template match="param[@type='invisible']">
315 <xsl:param name="ns">s1.</xsl:param>
316 <input type='hidden' name='{$ns}{@name}' value='{@default}'/>
317 </xsl:template>
318
319 <!-- boolean params -->
320 <xsl:template match="param[@type='boolean']">
321 <xsl:param name="ns">s1.</xsl:param>
322 <xsl:param name="default"/>
323 <select name='{$ns}{@name}'>
324 <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>
325 <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>
326 </select>
327 </xsl:template>
328
329 <!-- integer params -->
330 <xsl:template match="param[@type='integer']">
331 <xsl:param name="ns">s1.</xsl:param>
332 <xsl:param name="default"/>
333 <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/>
334 </xsl:template>
335
336 <!-- single selection enum params -->
337 <xsl:template match="param[@type='enum_single']">
338 <xsl:param name="ns">s1.</xsl:param>
339 <xsl:param name="default"/>
340 <xsl:choose>
341 <xsl:when test="count(option) = 1">
342 <xsl:value-of select="option/displayItem[@name='name']"/>
343 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
344 </xsl:when>
345 <xsl:otherwise>
346 <select name="{$ns}{@name}">
347 <xsl:for-each select="option">
348 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
349 </xsl:for-each>
350 </select>
351 </xsl:otherwise>
352 </xsl:choose>
353 </xsl:template>
354
355
356 <!-- multiple selection enum params -->
357 <!-- how to do defaults for this?? -->
358 <xsl:template match="param[@type='enum_multi']">
359 <xsl:param name="ns">s1.</xsl:param>
360 <xsl:param name="default"/>
361 <select name="{$ns}{@name}" size="2">
362 <xsl:attribute name="multiple"></xsl:attribute>
363 <xsl:for-each select="option">
364 <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>
365 </xsl:for-each>
366 </select>
367 </xsl:template>
368
369 <!-- string params -->
370 <xsl:template match="param[@type='string']">
371 <xsl:param name="ns">s1.</xsl:param>
372 <xsl:param name="default"/>
373 <input type="text" name="{$ns}{@name}" size="30" value="{$default}"/>
374 </xsl:template>
375
376 <!-- large string params -->
377 <xsl:template match="param[@type='text']">
378 <xsl:param name="ns">s1.</xsl:param>
379 <xsl:param name="default"/>
380 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
381 </xsl:template>
382
383 <!-- multi params - params that are combinations of other params -->
384 <xsl:template match="param[@type='multi']">
385 <xsl:param name="ns">s1.</xsl:param>
386 <xsl:variable name="parent" select="@name"/>
387
388 <table>
389 <tr class="queryfieldheading">
390 <xsl:value-of select="displayItem[@name='name']"/>
391 <xsl:for-each select="param">
392 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
393 </xsl:for-each>
394 </tr>
395 <xsl:apply-templates select="." mode="contents">
396 <xsl:with-param name="occurs" select="@occurs"/>
397 <xsl:with-param name="ns" select="$ns"/>
398 </xsl:apply-templates>
399 </table>
400
401 </xsl:template>
402
403 <xsl:template match="param[@type='multi']" mode="contents">
404 <xsl:param name="ns">s1.</xsl:param>
405 <xsl:param name="occurs">1</xsl:param>
406 <xsl:variable name="pos" select="@occurs - $occurs"/>
407 <tr class="queryfieldrow">
408 <xsl:for-each select="param">
409 <xsl:variable name="pname" select="@name"/>
410 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
411 <td class="queryfieldcell">
412 <xsl:choose>
413 <xsl:when test="not(@ignore) or @ignore != $pos">
414 <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>
415 </xsl:when>
416 <xsl:otherwise><!-- put in a hidden placeholder -->
417 <input type="hidden" name='{$ns}{@name}' value=''/>
418 </xsl:otherwise>
419 </xsl:choose>
420 </td>
421 </xsl:for-each>
422 </tr>
423
424 <!-- recursively call this template to get multiple entries -->
425 <xsl:if test="$occurs &gt; 1">
426 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
427 </xsl:if>
428 </xsl:template>
429
430</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.