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

Last change on this file since 20465 was 20465, checked in by oranfry, 15 years ago

work on the new interface

File size: 9.3 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
35 <xsl:variable name="ns">s1.</xsl:variable>
36 <xsl:for-each select="paramList/param">
37 <xsl:choose>
38 <xsl:when test="@type='multi'">
39 <xsl:apply-templates select="."><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
40 </xsl:when>
41 <xsl:otherwise>
42 <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></xsl:variable>
43 <div class="paramLabel"><xsl:value-of select="displayItem[@name='name']"/></div>
44 <div class="paramValue">
45 <xsl:apply-templates select=".">
46 <xsl:with-param name="default" select="$pvalue"/>
47 <xsl:with-param name="ns" select="$ns"/>
48 </xsl:apply-templates>
49 </div>
50 <br class="clear"/>
51 </xsl:otherwise>
52 </xsl:choose>
53 </xsl:for-each>
54
55 <br/>
56
57 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="displayItem[@name='submit']"/></xsl:attribute></input>
58
59 </div>
60 </form>
61 </xsl:for-each>
62
63 </xsl:when>
64
65 <xsl:otherwise>
66
67 <ul id="results">
68 <xsl:for-each select="pageResponse/documentNodeList/documentNode">
69 <li class="document">
70 <a>
71 <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=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/></xsl:attribute>
72 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
73 </a>
74 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
75 </li>
76 </xsl:for-each>
77 </ul>
78 </xsl:otherwise>
79
80 </xsl:choose>
81
82 </xsl:template>
83
84
85 <!-- puts all the params into a=p&p=h type form - need to change this if use
86 multi params -->
87 <xsl:template match="paramList" mode="cgi">
88 <xsl:param name="ns">s1.</xsl:param>
89 <xsl:for-each select="param">
90 <xsl:variable name='pname' select="@name"/>
91 <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>
92 </xsl:for-each>
93 </xsl:template>
94
95 <xsl:template match="param" mode="calculate-default">
96 <xsl:param name="ns">s1.</xsl:param>
97 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
98 <xsl:choose>
99 <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]">
100 <xsl:choose>
101 <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
102 <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
103 <xsl:value-of select="@value"/>,
104 </xsl:for-each>
105 </xsl:when>
106 <xsl:otherwise>
107 <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
108 </xsl:otherwise>
109 </xsl:choose>
110 </xsl:when>
111 <xsl:otherwise>
112 <xsl:value-of select="@default"/>
113 </xsl:otherwise>
114 </xsl:choose>
115 </xsl:template>
116
117 <!-- invisible params - used by other stuff. in the query form, we set to teh default -->
118 <xsl:template match="param[@type='invisible']">
119 <xsl:param name="ns">s1.</xsl:param>
120 <input type='hidden' name='{$ns}{@name}' value='{@default}'/>
121 </xsl:template>
122
123 <!-- boolean params -->
124 <xsl:template match="param[@type='boolean']">
125 <xsl:param name="ns">s1.</xsl:param>
126 <xsl:param name="default"/>
127 <select name='{$ns}{@name}'>
128 <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>
129 <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>
130 </select>
131 </xsl:template>
132
133 <!-- integer params -->
134 <xsl:template match="param[@type='integer']">
135 <xsl:param name="ns">s1.</xsl:param>
136 <xsl:param name="default"/>
137 <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/>
138 </xsl:template>
139
140 <!-- single selection enum params -->
141 <xsl:template match="param[@type='enum_single']">
142 <xsl:param name="ns">s1.</xsl:param>
143 <xsl:param name="default"/>
144 <xsl:choose>
145 <xsl:when test="count(option) = 1">
146 <xsl:value-of select="option/displayItem[@name='name']"/>
147 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
148 </xsl:when>
149 <xsl:otherwise>
150 <select name="{$ns}{@name}">
151 <xsl:for-each select="option">
152 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
153 </xsl:for-each>
154 </select>
155 </xsl:otherwise>
156 </xsl:choose>
157 </xsl:template>
158
159
160 <!-- multiple selection enum params -->
161 <!-- how to do defaults for this?? -->
162 <xsl:template match="param[@type='enum_multi']">
163 <xsl:param name="ns">s1.</xsl:param>
164 <xsl:param name="default"/>
165 <select name="{$ns}{@name}" size="2">
166 <xsl:attribute name="multiple"></xsl:attribute>
167 <xsl:for-each select="option">
168 <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>
169 </xsl:for-each>
170 </select>
171 </xsl:template>
172
173 <!-- string params -->
174 <xsl:template match="param[@type='string']">
175 <xsl:param name="ns">s1.</xsl:param>
176 <xsl:param name="default"/>
177 <input type="text" name="{$ns}{@name}" size="30" value="{$default}"/>
178 </xsl:template>
179
180 <!-- large string params -->
181 <xsl:template match="param[@type='text']">
182 <xsl:param name="ns">s1.</xsl:param>
183 <xsl:param name="default"/>
184 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
185 </xsl:template>
186
187 <!-- multi params - params that are combinations of other params -->
188 <xsl:template match="param[@type='multi']">
189 <xsl:param name="ns">s1.</xsl:param>
190 <xsl:variable name="parent" select="@name"/>
191
192 <table>
193 <tr class="queryfieldheading">
194 <xsl:value-of select="displayItem[@name='name']"/>
195 <xsl:for-each select="param">
196 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
197 </xsl:for-each>
198 </tr>
199 <xsl:apply-templates select="." mode="contents">
200 <xsl:with-param name="occurs" select="@occurs"/>
201 <xsl:with-param name="ns" select="$ns"/>
202 </xsl:apply-templates>
203 </table>
204
205 </xsl:template>
206
207 <xsl:template match="param[@type='multi']" mode="contents">
208 <xsl:param name="ns">s1.</xsl:param>
209 <xsl:param name="occurs">1</xsl:param>
210 <xsl:variable name="pos" select="@occurs - $occurs"/>
211 <tr class="queryfieldrow">
212 <xsl:for-each select="param">
213 <xsl:variable name="pname" select="@name"/>
214 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
215 <td class="queryfieldcell">
216 <xsl:choose>
217 <xsl:when test="not(@ignore) or @ignore != $pos">
218 <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>
219 </xsl:when>
220 <xsl:otherwise><!-- put in a hidden placeholder -->
221 <input type="hidden" name='{$ns}{@name}' value=''/>
222 </xsl:otherwise>
223 </xsl:choose>
224 </td>
225 </xsl:for-each>
226 </tr>
227
228 <!-- recursively call this template to get multiple entries -->
229 <xsl:if test="$occurs &gt; 1">
230 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
231 </xsl:if>
232 </xsl:template>
233
234</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.