source: main/trunk/greenstone3/web/interfaces/default/transform/pages/classifier.xsl@ 34579

Last change on this file since 34579 was 34579, checked in by davidb, 3 years ago

Changes so the rightSidebar for query.xsl and classifier.xsl display corrected (float right). The previous approach had been 'bolted' on to the end of displayBaskets was not properly contained within the div that was floated right

File size: 13.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
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 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
8 extension-element-prefixes="java util"
9 exclude-result-prefixes="java util gsf">
10
11 <!-- use the 'main' layout -->
12 <xsl:import href="layouts/main.xsl"/>
13 <xsl:import href="map-tools.xsl"/>
14 <xsl:import href="panorama-viewer-tools.xsl"/>
15
16 <!-- set page title -->
17 <xsl:template name="pageTitle"><gslib:serviceName/></xsl:template>
18
19 <!-- set page breadcrumbs -->
20 <xsl:template name="breadcrumbs"><gslib:siteLink/><gslib:rightArrow/><gslib:collectionNameLinked/><gslib:rightArrow/></xsl:template>
21
22 <!-- optional cgi-params for links to document pages -->
23 <xsl:variable name="opt-doc-link-args"></xsl:variable>
24
25 <!-- the page content -->
26 <xsl:template match="/page/pageResponse">
27 <xsl:call-template name="floatRightSidebar"/>
28 <xsl:call-template name="classifierPre"/>
29
30 <script type="text/javascript" src="interfaces/{$interface_name}/js/classifier_scripts.js"><xsl:text> </xsl:text></script>
31 <script type="text/javascript">$(window).load(openStoredClassifiers);</script>
32
33 <!--
34 show the clasifier results -
35 you can change the appearance of the results by editing
36 the two templates at the bottom of this file
37 -->
38 <div id="results">
39 <xsl:variable name="collName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
40 <xsl:variable name="serviceName"><xsl:value-of select="service/@name"/></xsl:variable>
41
42 <xsl:call-template name="classifierResultsPre"/>
43
44 <xsl:apply-templates select="classifier">
45 <xsl:with-param name="collName" select="$collName"/>
46 <xsl:with-param name="serviceName" select="$serviceName"/>
47 </xsl:apply-templates>
48 </div>
49
50 <div class="clear"><xsl:text> </xsl:text></div>
51 </xsl:template>
52
53 <xsl:template name="rightSidebar">
54 <div id="rightSideBar">
55 <xsl:comment>Filler to prevent empty div collapse, in event displayBasket empty</xsl:comment>
56 <gslib:displayBaskets/>
57 </div>
58 </xsl:template>
59
60 <xsl:template match="classifier">
61 <xsl:param name="collName"/>
62 <xsl:param name="serviceName"/>
63 <div id="classifiers">
64 <xsl:variable name="cl_name"><xsl:value-of select="@name"/></xsl:variable>
65 <xsl:choose>
66 <xsl:when test="@childType = 'HList'">
67 <xsl:call-template name="HList">
68 <xsl:with-param name='collName' select='$collName'/>
69 <xsl:with-param name='serviceName' select='$serviceName'/>
70 </xsl:call-template>
71 </xsl:when>
72 <xsl:otherwise>
73 <table id="classifiernodelist">
74 <xsl:text> </xsl:text>
75 <xsl:call-template name="processNodeChildren">
76 <xsl:with-param name='collName' select='$collName'/>
77 <xsl:with-param name='serviceName' select='$serviceName'/>
78 </xsl:call-template>
79 </table>
80 </xsl:otherwise>
81 </xsl:choose>
82 </div>
83 </xsl:template>
84
85 <xsl:template name="HList">
86 <xsl:param name="collName"/>
87 <xsl:param name="serviceName"/>
88 <xsl:variable name="selectedNode"><xsl:value-of select="/page/pageRequest/paramList/param[@name = 'cl']/@value"/></xsl:variable>
89 <ul class="horizontalContainer">
90 <xsl:for-each select='classifierNode'>
91 <li>
92 <xsl:attribute name="class">
93 <xsl:if test="$selectedNode = @nodeID or starts-with($selectedNode, concat(@nodeID, '.')) or (not(contains($selectedNode, '.')) and @nodeID = concat($selectedNode, '.1'))">selectedHorizontalClassifierNode </xsl:if>
94 <xsl:text>horizontalClassifierNode</xsl:text>
95 </xsl:attribute>
96 <xsl:apply-templates select='.'>
97 <xsl:with-param name='collName' select='$collName'/>
98 <xsl:with-param name='serviceName' select='$serviceName'/>
99 </xsl:apply-templates>
100 </li>
101 </xsl:for-each>
102 </ul>
103 <xsl:choose>
104 <!-- if the children are HLists-->
105 <xsl:when test="classifierNode[@childType = 'HList']">
106 <xsl:for-each select='classifierNode'><!-- there should be only one-->
107 <xsl:call-template name="HList">
108 <xsl:with-param name='collName' select='$collName'/>
109 <xsl:with-param name='serviceName' select='$serviceName'/>
110 </xsl:call-template>
111 </xsl:for-each>
112 </xsl:when>
113 <xsl:otherwise>
114 <table id="classifiernodelist">
115 <xsl:for-each select='classifierNode'>
116 <xsl:call-template name="processNodeChildren">
117 <xsl:with-param name='collName' select='$collName'/>
118 <xsl:with-param name='serviceName' select='$serviceName'/>
119 </xsl:call-template>
120 </xsl:for-each>
121 </table>
122 </xsl:otherwise>
123 </xsl:choose>
124 </xsl:template>
125
126 <xsl:template name="processNodeChildren">
127 <xsl:param name="collName"/>
128 <xsl:param name="serviceName"/>
129
130 <xsl:choose>
131
132 <xsl:when test="@childType = 'VList' or @childType = 'DateList'">
133 <!--
134 <xsl:when test="@childType = 'VList' or @childType = 'HList' or @childType = 'DateList'"> - - **** mod ???? - -
135 -->
136
137 <xsl:value-of select="util:storeString('prevMonth', '')"/>
138 <xsl:for-each select='classifierNode|documentNode'>
139 <tr>
140 <xsl:choose>
141 <xsl:when test="name()='documentNode'">
142 <xsl:if test="../@childType = 'DateList'">
143 <xsl:variable name="prevMonth"><xsl:value-of select="util:getString('prevMonth')"/></xsl:variable>
144 <xsl:variable name="currentDate"><gsf:metadata name="Date" pos="1"/></xsl:variable> <!-- note pos=1 won't work if a document can be included in a datelist multiple times. currently only the first date is used...-->
145 <xsl:variable name="currentMonth"><xsl:value-of select="util:getDetailFromDate($currentDate, 'month', /page/@lang)"/></xsl:variable>
146 <xsl:value-of select="util:storeString('prevMonth', $currentMonth)"/>
147 <td>
148 <xsl:if test="not($currentMonth = $prevMonth)">
149 <xsl:value-of select="$currentMonth"/>
150 </xsl:if>
151 <xsl:text> </xsl:text>
152 </td>
153 </xsl:if>
154 <td>
155 <table id="div{@nodeID}"><tr>
156 <xsl:call-template name="documentNodeWrapper">
157 <xsl:with-param name='collName' select='$collName'/>
158 <xsl:with-param name='serviceName' select='$serviceName'/>
159 </xsl:call-template>
160 </tr></table>
161 </td>
162 </xsl:when>
163 <xsl:when test="name()='classifierNode' and (@childType = 'VList' or @childType = 'HList')"><!-- *** mod -->
164 <td>
165 <table id="title{@nodeID}"><tr>
166 <xsl:if test="not(/page/pageResponse/format[@type='browse']/gsf:option[@name='turnstyleClassifiers']) or /page/pageResponse/format[@type='browse']/gsf:option[@name='turnstyleClassifiers']/@value='true'">
167 <td class="headerTD">
168 <img id="toggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon turnstyleicon">
169 <xsl:attribute name="src">
170 <xsl:choose>
171 <xsl:when test="classifierNode or documentNode">
172 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
173 </xsl:when>
174 <xsl:otherwise>
175 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
176 </xsl:otherwise>
177 </xsl:choose>
178 </xsl:attribute>
179 </img>
180 </td>
181 </xsl:if>
182 <xsl:apply-templates select='.'>
183 <xsl:with-param name='collName' select='$collName'/>
184 <xsl:with-param name='serviceName' select='$serviceName'/>
185 </xsl:apply-templates>
186 </tr></table>
187 </td>
188 <xsl:if test="child::classifierNode or child::documentNode">
189 <!--recurse into the children-->
190 <tr><td><table class="childrenlist" id="div{@nodeID}">
191 <xsl:apply-templates select='.' mode='process-all-children'>
192 <xsl:with-param name='collName' select='$collName'/>
193 <xsl:with-param name='serviceName' select='$serviceName'/>
194 </xsl:apply-templates>
195 </table></td></tr>
196 </xsl:if>
197 </xsl:when>
198 <xsl:otherwise><td>Unknown classifier style specified: <xsl:value-of select="name()"/></td></xsl:otherwise>
199 </xsl:choose>
200 </tr>
201 </xsl:for-each>
202 </xsl:when>
203 <xsl:when test="@childType = 'HTML'">
204 <xsl:variable name="URL"><xsl:value-of select="documentNode/@nodeID"/></xsl:variable>
205 <iframe width="100%" height="600" frameborder="0"><xsl:attribute name="src"><xsl:value-of select="$URL"/></xsl:attribute>Frame for <xsl:value-of select="$URL"/></iframe>
206 </xsl:when>
207 <xsl:otherwise>
208 we are in the other wise
209 </xsl:otherwise>
210 </xsl:choose>
211 </xsl:template>
212
213
214 <!-- processing for the recursive bit -->
215 <xsl:template match="classifierNode" mode="process-all-children">
216 <xsl:param name="collName"/>
217 <xsl:param name="serviceName"/>
218
219 <!--
220 ***mod: previous, simpler version
221 <xsl:call-template name="processNodeChildren">
222 <xsl:with-param name='collName' select='$collName'/>
223 <xsl:with-param name='serviceName' select='$serviceName'/>
224 </xsl:call-template>
225 -->
226
227 <xsl:choose>
228 <xsl:when test="@childType = 'HList'">
229 <xsl:call-template name="HList">
230 <xsl:with-param name='collName' select='$collName'/>
231 <xsl:with-param name='serviceName' select='$serviceName'/>
232 </xsl:call-template>
233 </xsl:when>
234 <xsl:otherwise>
235 <xsl:call-template name="processNodeChildren">
236 <xsl:with-param name='collName' select='$collName'/>
237 <xsl:with-param name='serviceName' select='$serviceName'/>
238 </xsl:call-template>
239 </xsl:otherwise>
240 </xsl:choose>
241
242
243 </xsl:template>
244
245
246
247 <!-- this is a wrapper node, which the interface can use to add stuff into the classifier display that isn't part of and doesn't depend on the documentNode template which may come from the collection -->
248 <xsl:template name="documentNodeWrapper">
249 <xsl:param name="collName"/>
250 <xsl:param name="serviceName"/>
251 <xsl:apply-templates select=".">
252 <xsl:with-param name="collName" select="$collName"/>
253 <xsl:with-param name="serviceName" select="$serviceName"/>
254 </xsl:apply-templates>
255 <!-- The berry/favourite (optional) -->
256 <td valign="top">
257 <xsl:if test="/page/pageResponse/interfaceOptions/option[@name = 'berryBasket']/@value = 'true'">
258 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
259 </xsl:if>
260 <xsl:if test="/page/pageResponse/interfaceOptions/option[@name = 'favouriteBasket']/@value = 'true'">
261 <xsl:call-template name="documentFavouriteForClassifierOrSearchPage"/>
262 </xsl:if>
263
264 </td>
265 <xsl:call-template name="documentNodePost"/>
266 </xsl:template>
267
268 <!--
269 TEMPLATE FOR DOCUMENTS
270 -->
271 <xsl:template match="documentNode">
272 <td valign="top">
273 <gsf:link type="document">
274 <gsf:icon type="document"/>
275 </gsf:link>
276 </td>
277 <td valign="top">
278 <gsf:link type="source">
279 <gsf:choose-metadata>
280 <gsf:metadata name="thumbicon"/>
281 <gsf:metadata name="srcicon"/>
282 </gsf:choose-metadata>
283 </gsf:link>
284 </td>
285 <td valign="top">
286 <gsf:link type="document">
287 <!-- Defined in header.xsl -->
288 <xsl:call-template name="choose-title"/>
289 <gsf:switch>
290 <gsf:metadata name="Source"/>
291 <gsf:when test="exists"><br/><i>(<gsf:metadata name="Source"/>)</i></gsf:when>
292 </gsf:switch>
293 </gsf:link>
294 </td>
295 </xsl:template>
296
297
298 <xsl:template name="documentNodePost">
299 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
300 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude' or @name='Coordinate']">
301 <xsl:call-template name="mapFeaturesIcon"/>
302 </xsl:if>
303 </xsl:if>
304
305 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
306 <xsl:if test="metadataList/metadata[@name = 'PhotoType']='Panorama' and ( metadataList/metadata[@name = 'Coordinate'] or ( metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']))">
307 <xsl:call-template name="panoramaViewerFeaturesIcon"/>
308 </xsl:if>
309 </xsl:if>
310
311 </xsl:template>
312
313 <!--
314 TEMPLATE FOR GROUPS OF DOCUMENTS
315 -->
316 <xsl:template match="classifierNode[@classifierStyle = 'HList']" >
317 <gsf:link type="classifier" style="static">
318 <gsf:metadata name="Title"/>
319 </gsf:link>
320 </xsl:template>
321
322 <xsl:template match="classifierNode">
323 <td valign="top">
324 <gsf:link type="classifier" style="static">
325 <gsf:icon type="classifier"/>
326 </gsf:link>
327 </td>
328 <td valign="top">
329 <gsf:link type="classifier">
330 <gsf:metadata name="Title"/>
331 </gsf:link>
332 </td>
333 </xsl:template>
334
335
336 <xsl:template name="classifierPre">
337 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
338 <xsl:call-template name="mapFeaturesJSONNodes"/>
339 </xsl:if>
340
341 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
342 <xsl:call-template name="panoramaViewerFeaturesJSONNodes"/>
343 </xsl:if>
344
345 </xsl:template>
346
347 <xsl:template name="classifierResultsPre">
348 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
349 <xsl:call-template name="mapFeaturesMap"/>
350 </xsl:if>
351 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
352 <xsl:call-template name="panoramaViewerFeatures"/>
353 </xsl:if>
354 </xsl:template>
355
356 <xsl:template match="/page/xsltparams">
357 <!-- suppress xsltparam block in page -->
358 </xsl:template>
359
360</xsl:stylesheet>
361
Note: See TracBrowser for help on using the repository browser.