source: trunk/gsdl3/web/interfaces/default/transform/querytools.xsl@ 5134

Last change on this file since 5134 was 5134, checked in by kjdon, 21 years ago

have modified the results navigation arrows. hits per page param will go onto teh preferences page (soon). the xslt will use a service specified hitsPerPage param if available otherwise use its own one. this affects which docs in the results list to display - if the service is doing the paging, we display all teh results with possible some links - depends on teh numDocsMatched metadata. if teh interface is doing the paging, we have all tehresults, but only display part of them.

  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 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 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9 <!-- have changed this so it uses service hitsPerPage and startPage if available, otherwise uses interface ones -->
10 <xsl:template name="resultNavigation">
11 <xsl:variable name="param-list" select="/page/pageRequest/paramList"/>
12 <!-- hits per page -->
13 <xsl:variable name="hpp">
14 <xsl:choose>
15 <xsl:when test="$param-list/param[@name='s1.hitsPerPage']"><xsl:value-of select="$param-list/param[@name='s1.hitsPerPage']/@value"/></xsl:when>
16 <xsl:when test="$param-list/param[@name='hitsPerPage']"><xsl:value-of select="$param-list/param[@name='hitsPerPage']/@value"/></xsl:when>
17 <xsl:otherwise>20</xsl:otherwise>
18 </xsl:choose>
19 </xsl:variable>
20 <!-- hits type -->
21 <xsl:variable name='ht'>
22 <xsl:choose>
23 <xsl:when test="$param-list/param[@name='s1.hitsPerPage']">s</xsl:when>
24 <xsl:otherwise>i</xsl:otherwise>
25 </xsl:choose>
26 </xsl:variable>
27 <!-- total docs -->
28 <xsl:variable name="td">
29 <xsl:choose>
30 <xsl:when test="$ht='s'">
31 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name='numDocsMatched']/@value"/>
32 </xsl:when>
33 <xsl:otherwise>
34 <xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/>
35 </xsl:otherwise>
36 </xsl:choose>
37 </xsl:variable>
38 <!-- only continue if hpp != -1 and td > hpp -->
39 <xsl:if test="not($hpp=-1) and $td &gt; $hpp">
40 <!-- start page -->
41 <xsl:variable name="here">
42 <xsl:choose>
43 <xsl:when test="$param-list/param[@name='s1.startPage']"><xsl:value-of select="$param-list/param[@name='s1.startPage']/@value"/></xsl:when>
44 <xsl:when test="$param-list/param[@name='startPage']"><xsl:value-of select="$param-list/param[@name='startPage']/@value"/></xsl:when>
45 <xsl:otherwise>1</xsl:otherwise>
46 </xsl:choose>
47 </xsl:variable>
48 <xsl:variable name="sa" select="/page/pageRequest/@subaction"/>
49 <xsl:variable name="service" select="$param-list/param[@name='s']/@value"/>
50 <xsl:variable name="prev" select="$here - 1"/>
51 <xsl:variable name="next" select="$here + 1"/>
52 <xsl:variable name="page-param"><xsl:if test="$ht='s'">s1.</xsl:if>startPage</xsl:variable>
53 <p />
54 <center>
55 <table cellspacing='0' cellpadding='0' width='70%'>
56 <tr>
57 <td align='left'>
58 <xsl:if test="$here &gt; 1"><a href="{$library_name}?a=q&amp;sa={$sa}&amp;s={$service}&amp;rt=r&amp;{$page-param}={$prev}"><img src="interfaces/default/images/less.gif" width='30' height='16' border='0' align='top'/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.matches')"/><xsl:text> </xsl:text><xsl:value-of select="number(($prev - 1)*$hpp + 1)"/> - <xsl:value-of select="number(($prev * $hpp))"/></a></xsl:if>
59 </td>
60 <td align='right'>
61 <xsl:if test="(($here * $hpp) + 1) &lt; $td">
62 <xsl:variable name='m' select="number($next * $hpp)"/>
63 <xsl:variable name='mm'><xsl:choose><xsl:when test="$m &lt; $td"><xsl:value-of select='$m'/></xsl:when><xsl:otherwise><xsl:value-of select='$td'/></xsl:otherwise></xsl:choose></xsl:variable>
64 <a href="{$library_name}?a=q&amp;sa={$sa}&amp;s={$service}&amp;rt=r&amp;{$page-param}={$next}"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.matches')"/><xsl:text> </xsl:text><xsl:value-of select="number(($next - 1)*$hpp + 1)"/> - <xsl:value-of select="$mm"/><img src="interfaces/default/images/more.gif" width='30' height='16' border='0' align='top'/></a></xsl:if></td> </tr>
65 </table>
66 </center>
67 </xsl:if>
68 </xsl:template>
69
70
71 <!-- the default doc node template for the query results -->
72 <!-- eventually shouldn't need sib arg here -->
73 <xsl:template match="documentNode">
74 <xsl:param name="collName"/>
75 <td>
76 <a><xsl:attribute name="href"><xsl:value-of select='$library_name'/>?a=d&amp;c=<xsl:value-of select='$collName'/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="@nodeType='leaf'">&amp;sib=1</xsl:if>&amp;dt=<xsl:value-of select='@docType'/></xsl:attribute>
77 <xsl:apply-templates select="." mode="displayNodeIcon"/>
78 </a>
79 </td>
80 <td><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></td>
81 </xsl:template>
82
83 <xsl:template name="termInfo">
84 <xsl:if test="count(termList/term) > 0">
85 <small>
86 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.wordcount')"/>
87 <xsl:for-each select="termList/term">
88 <xsl:if test="position() > 1">, </xsl:if>
89 <xsl:value-of select="@name"/>: <xsl:value-of select="@freq"/>
90 </xsl:for-each>
91 </small>
92 <br/>
93 </xsl:if>
94 </xsl:template>
95
96 <xsl:template name="matchDocs">
97 <!-- If the number of matching documents is known, display it -->
98 <xsl:variable name="numDocsMatched" select="metadataList/metadata[@name='numDocsMatched']/@value"/>
99 <xsl:if test="$numDocsMatched">
100 <xsl:choose>
101 <xsl:when test="$numDocsMatched='0'">
102 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.nodocsmatch')"/>
103 </xsl:when>
104 <xsl:when test="$numDocsMatched='1'">
105 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.onedocsmatch')"/>
106 </xsl:when>
107 <xsl:otherwise>
108 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.manydocsmatch', $numDocsMatched)"/>
109 </xsl:otherwise>
110 </xsl:choose>
111 </xsl:if>
112 </xsl:template>
113
114
115 <xsl:template name="resultList">
116 <xsl:param name="collName"/>
117 <xsl:variable name="param-list" select="/page/pageRequest/paramList"/>
118 <!-- hits per page -->
119 <xsl:variable name="hpp">
120 <xsl:choose>
121 <xsl:when test="$param-list/param[@name='s1.hitsPerPage']"><xsl:value-of select="$param-list/param[@name='s1.hitsPerPage']/@value"/></xsl:when>
122 <xsl:when test="$param-list/param[@name='hitsPerPage']"><xsl:value-of select="$param-list/param[@name='hitsPerPage']/@value"/></xsl:when>
123 <xsl:otherwise>20</xsl:otherwise>
124 </xsl:choose>
125 </xsl:variable>
126 <xsl:choose>
127 <xsl:when test="$param-list/param[@name='s1.hitsPerPage'] or $hpp=-1">
128 <!-- the service has handled the paging, just output all the docs -->
129 <table>
130 <xsl:for-each select="documentNodeList/documentNode">
131 <tr>
132 <xsl:apply-templates select=".">
133 <xsl:with-param name="collName" select="$collName"/>
134 </xsl:apply-templates>
135 </tr>
136 </xsl:for-each>
137 </table>
138 </xsl:when>
139 <xsl:otherwise>
140 <!-- we have done the paging, only show a selection of the docs -->
141 <!-- start page -->
142 <xsl:variable name="sp">
143 <xsl:choose>
144 <xsl:when test="$param-list/param[@name='s1.startPage']"><xsl:value-of select="$param-list/param[@name='s1.startPage']/@value"/></xsl:when>
145 <xsl:when test="$param-list/param[@name='startPage']"><xsl:value-of select="$param-list/param[@name='startPage']/@value"/></xsl:when>
146 <xsl:otherwise>1</xsl:otherwise>
147 </xsl:choose>
148 </xsl:variable>
149 <table>
150 <xsl:for-each select="documentNodeList/documentNode">
151 <xsl:if test=" (position()&gt; (($sp - 1)*$hpp) and position() &lt;= ($sp * $hpp))">
152 <tr>
153 <xsl:apply-templates select=".">
154 <xsl:with-param name="collName" select="$collName"/>
155 </xsl:apply-templates>
156 </tr>
157 </xsl:if>
158 </xsl:for-each>
159 </table>
160 </xsl:otherwise>
161 </xsl:choose>
162 </xsl:template>
163
164</xsl:stylesheet>
165
166
Note: See TracBrowser for help on using the repository browser.