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

Last change on this file since 35812 was 35812, checked in by cstephen, 2 years ago

Format classifier.xsl

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