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

Last change on this file since 31652 was 31652, checked in by kjdon, 4 years ago

classifierNodeLink template is needed by config_format as well as classifier.xsl, so I have moved it into query-common as this gets included everywhere.

  • Property svn:executable set to *
File size: 8.3 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">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">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:param name="quickSearch">false</xsl:param>
73 <xsl:choose>
74 <xsl:when test="count(option) = 1">
75 <xsl:if test="$hideSingle = 'false'">
76 <xsl:value-of select="option/displayItem[@name='name']"/>
77 </xsl:if>
78 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
79 </xsl:when>
80 <xsl:otherwise>
81 <select name="{$ns}{@name}">
82 <xsl:for-each select="option">
83 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
84 </xsl:for-each>
85 </select>
86 </xsl:otherwise>
87 </xsl:choose>
88 </xsl:template>
89 <!-- multiple selection enum params -->
90 <!-- how to do defaults for this?? -->
91 <xsl:template match="param[@type='enum_multi']">
92 <xsl:param name="ns">s1.</xsl:param>
93 <xsl:param name="default"/>
94 <select name="{$ns}{@name}" size="2">
95 <xsl:attribute name="multiple"></xsl:attribute>
96 <xsl:for-each select="option">
97 <option value="{@name}"><xsl:if test="contains($default, concat(',', @name, ','))"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
98 </xsl:for-each>
99 </select>
100 </xsl:template>
101
102 <xsl:template match="param[@type='string']">
103 <xsl:param name="ns">s1.</xsl:param>
104 <xsl:param name="default"/>
105 <input type="text" name="{$ns}{@name}" size="30" value="{$default}"/>
106 </xsl:template>
107
108
109 <!-- large string params -->
110 <xsl:template match="param[@type='text']">
111 <xsl:param name="ns">s1.</xsl:param>
112 <xsl:param name="default"/>
113 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
114 </xsl:template>
115
116 <!-- multi params - params that are combinations of other params -->
117 <xsl:template match="param[@type='multi']">
118 <xsl:param name="ns">s1.</xsl:param>
119 <xsl:variable name="parent" select="@name"/>
120
121 <table>
122 <tr class="queryfieldheading">
123 <xsl:value-of select="displayItem[@name='name']"/>
124 <xsl:for-each select="param">
125 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
126 </xsl:for-each>
127 </tr>
128 <xsl:apply-templates select="." mode="contents">
129 <xsl:with-param name="occurs" select="@occurs"/>
130 <xsl:with-param name="ns" select="$ns"/>
131 </xsl:apply-templates>
132 </table>
133
134 </xsl:template>
135
136 <xsl:template match="param[@type = 'checkbox_list']">
137 <xsl:param name="ns">s1.</xsl:param>
138 <ul class="checkboxList">
139 <xsl:for-each select="option">
140 <li><input type="checkbox" name="{$ns}{../@name}" value="{@name}"/><xsl:value-of select="displayItem"/></li>
141 </xsl:for-each>
142 </ul>
143 </xsl:template>
144
145 <xsl:template match="param[@type='multi']" mode="contents">
146 <xsl:param name="ns">s1.</xsl:param>
147 <xsl:param name="occurs">1</xsl:param>
148 <xsl:variable name="pos" select="@occurs - $occurs"/>
149 <tr class="queryfieldrow">
150 <xsl:for-each select="param">
151 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
152 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
153 <td class="queryfieldcell">
154 <xsl:choose>
155 <xsl:when test="not(@ignore) or @ignore != $pos">
156 <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>
157 </xsl:when>
158 <xsl:otherwise><!-- put in a hidden placeholder -->
159 <input type="hidden" name='{$ns}{@name}' value=''/>
160 </xsl:otherwise>
161 </xsl:choose>
162 </td>
163 </xsl:for-each>
164 </tr>
165
166 <!-- recursively call this template to get multiple entries -->
167 <xsl:if test="$occurs &gt; 1">
168 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
169 </xsl:if>
170 </xsl:template>
171
172 <xsl:template name="classifierNodeLink">
173 <xsl:param name="link-type">dynamic</xsl:param>
174 <xsl:param name="node-id"></xsl:param>
175 <xsl:variable name="final-link-type">
176 <xsl:choose>
177 <xsl:when test="$link-type='static'">static</xsl:when>
178 <xsl:when test="$link-type='javascript'">javascript</xsl:when>
179 <xsl:when test="@classifierStyle = 'HList'">static</xsl:when>
180 <xsl:when test="not(/page/pageResponse/format[@type='browse']/gsf:option[@name='turnstyleClassifiers']) or /page/pageResponse/format[@type='browse']/gsf:option[@name='turnstyleClassifiers']/@value='true'">javascript</xsl:when>
181 <xsl:otherwise>static</xsl:otherwise>
182 </xsl:choose>
183 </xsl:variable>
184 <xsl:choose>
185 <xsl:when test="$final-link-type='static'">
186 <xsl:value-of select='$library_name'/>/collection/<xsl:value-of select='/page/pageResponse/collection/@name'/>/browse/<xsl:choose><xsl:when test="$node-id"><xsl:value-of select="$node-id"/></xsl:when><xsl:otherwise><xsl:value-of select='util:replace(@nodeID, ".", "/")'/></xsl:otherwise></xsl:choose>
187 </xsl:when>
188 <xsl:otherwise>javascript:toggleSection('<xsl:value-of select="@nodeID"/>');</xsl:otherwise>
189 </xsl:choose>
190 </xsl:template>
191
192</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.