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

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

Lots of upgrades to the oran skin, getting it ready to be the default skin for Greenstone3

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