source: main/trunk/greenstone3/web/interfaces/default/transform/query-common.xsl@ 28559

Last change on this file since 28559 was 28559, checked in by jlwhisler, 10 years ago

Fixed an idiosyncrasy so that when there is only one search index, the index field name will appear in the quick search box -- demonstrated in the Simple Image Collection. This looks better when the index is listed before the search box, so this was fixed too. Now the index label (or index drop box with 2+ indexes) appears before the search box. Related to previous commit.

  • Property svn:executable set to *
File size: 7.0 KB
Line 
1<xsl:stylesheet version="1.0"
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:java="http://xml.apache.org/xslt/java"
4 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
5 xmlns:gslib="http://www.greenstone.org/skinning"
6 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9 <xsl:template name="param-display">
10 <xsl:param name="ns">s1.</xsl:param>
11 <xsl:variable name="pvalue"><xsl:call-template name="param-calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:call-template></xsl:variable>
12 <div class="paramLabel"><xsl:value-of select="displayItem[@name='name']"/></div>
13 <div class="paramValue">
14 <xsl:apply-templates select=".">
15 <xsl:with-param name="default" select="$pvalue"/>
16 <xsl:with-param name="ns" select="$ns"/>
17 </xsl:apply-templates>
18 </div>
19 <br class="clear"/>
20 </xsl:template>
21
22 <xsl:template name="param-calculate-default" match="param" mode="calculate-default">
23 <xsl:param name="ns">s1.</xsl:param>
24 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
25 <xsl:choose>
26 <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]">
27 <xsl:choose>
28 <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
29 <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
30 <xsl:value-of select="@value"/>,
31 </xsl:for-each>
32 </xsl:when>
33 <xsl:otherwise>
34 <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
35 </xsl:otherwise>
36 </xsl:choose>
37 </xsl:when>
38 <xsl:otherwise>
39 <xsl:value-of select="@default"/>
40 </xsl:otherwise>
41 </xsl:choose>
42 </xsl:template>
43
44 <!-- invisible params - used by other stuff. in the query form, we set to the default -->
45 <xsl:template match="param[@type='invisible']">
46 <xsl:param name="ns">s1.</xsl:param>
47 <input type='hidden' name='{$ns}{@name}' value='{@default}'/>
48 </xsl:template>
49
50 <!-- boolean params -->
51 <xsl:template match="param[@type='boolean']">
52 <xsl:param name="ns">s1.</xsl:param>
53 <xsl:param name="default"/>
54 <select name='{$ns}{@name}'>
55 <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>
56 <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>
57 </select>
58 </xsl:template>
59
60 <!-- integer params -->
61 <xsl:template match="param[@type='integer']">
62 <xsl:param name="ns">s1.</xsl:param>
63 <xsl:param name="default"/>
64 <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/>
65 </xsl:template>
66
67 <!-- single selection enum params -->
68 <xsl:template match="param[@type='enum_single']">
69 <xsl:param name="ns">s1.</xsl:param>
70 <xsl:param name="hideSingle">false</xsl:param>
71 <xsl:param name="default"/>
72 <xsl:choose>
73 <xsl:when test="count(option) = 1">
74 <xsl:if test="$hideSingle = 'false'">
75 <xsl:value-of select="option/displayItem[@name='name']"/>:
76 </xsl:if>
77 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
78 </xsl:when>
79 <xsl:otherwise>
80 <select name="{$ns}{@name}">
81 <xsl:for-each select="option">
82 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
83 </xsl:for-each>
84 </select>
85 </xsl:otherwise>
86 </xsl:choose>
87 </xsl:template>
88 <!-- multiple selection enum params -->
89 <!-- how to do defaults for this?? -->
90 <xsl:template match="param[@type='enum_multi']">
91 <xsl:param name="ns">s1.</xsl:param>
92 <xsl:param name="default"/>
93 <select name="{$ns}{@name}" size="2">
94 <xsl:attribute name="multiple"></xsl:attribute>
95 <xsl:for-each select="option">
96 <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>
97 </xsl:for-each>
98 </select>
99 </xsl:template>
100
101 <xsl:template match="param[@type='string']">
102 <xsl:param name="ns">s1.</xsl:param>
103 <xsl:param name="default"/>
104 <input type="text" name="{$ns}{@name}" size="30" value="{$default}"/>
105 </xsl:template>
106
107
108 <!-- large string params -->
109 <xsl:template match="param[@type='text']">
110 <xsl:param name="ns">s1.</xsl:param>
111 <xsl:param name="default"/>
112 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
113 </xsl:template>
114
115 <!-- multi params - params that are combinations of other params -->
116 <xsl:template match="param[@type='multi']">
117 <xsl:param name="ns">s1.</xsl:param>
118 <xsl:variable name="parent" select="@name"/>
119
120 <table>
121 <tr class="queryfieldheading">
122 <xsl:value-of select="displayItem[@name='name']"/>
123 <xsl:for-each select="param">
124 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
125 </xsl:for-each>
126 </tr>
127 <xsl:apply-templates select="." mode="contents">
128 <xsl:with-param name="occurs" select="@occurs"/>
129 <xsl:with-param name="ns" select="$ns"/>
130 </xsl:apply-templates>
131 </table>
132
133 </xsl:template>
134
135 <xsl:template match="param[@type = 'checkbox_list']">
136 <xsl:param name="ns">s1.</xsl:param>
137 <ul class="checkboxList">
138 <xsl:for-each select="option">
139 <li><input type="checkbox" name="{$ns}{../@name}" value="{@name}"/><xsl:value-of select="displayItem"/></li>
140 </xsl:for-each>
141 </ul>
142 </xsl:template>
143
144 <xsl:template match="param[@type='multi']" mode="contents">
145 <xsl:param name="ns">s1.</xsl:param>
146 <xsl:param name="occurs">1</xsl:param>
147 <xsl:variable name="pos" select="@occurs - $occurs"/>
148 <tr class="queryfieldrow">
149 <xsl:for-each select="param">
150 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
151 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
152 <td class="queryfieldcell">
153 <xsl:choose>
154 <xsl:when test="not(@ignore) or @ignore != $pos">
155 <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>
156 </xsl:when>
157 <xsl:otherwise><!-- put in a hidden placeholder -->
158 <input type="hidden" name='{$ns}{@name}' value=''/>
159 </xsl:otherwise>
160 </xsl:choose>
161 </td>
162 </xsl:for-each>
163 </tr>
164
165 <!-- recursively call this template to get multiple entries -->
166 <xsl:if test="$occurs &gt; 1">
167 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
168 </xsl:if>
169 </xsl:template>
170
171</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.