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

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

checking in a batch of changes to the oran skin. more work yet to do.

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