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

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

Another round of improvements to the oran skin including a tree view of the classifiers

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