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

Last change on this file since 38992 was 38992, checked in by anupama, 4 weeks ago

Moved ugly long repetitive collage app specific template from classifier.xsl into webswing-collage.xsl. It made sense for the (now phased out) applet shim to be in classifier.xsl, when it was thought the user may want to edit it, but now there's nothing user-editable outside GLI/collConfig.xml file for the Collage app, the template replacing the applet shim can move be hidden away in webswing-collage.xsl

File size: 17.8 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="layouts/webswing-collage.xsl" />
7 <xsl:import href="map-tools.xsl" />
8 <xsl:import href="panorama-viewer-tools.xsl" />
9
10 <!-- set page title -->
11 <xsl:template name="pageTitle">
12 <gslib:serviceName />
13 </xsl:template>
14
15 <!-- set page breadcrumbs -->
16 <xsl:template name="breadcrumbs">
17 <gslib:siteLink />
18 <gslib:rightArrow />
19 <gslib:groupLinks/>
20 <gslib:collectionNameLinked />
21 <gslib:rightArrow />
22 </xsl:template>
23
24 <!-- the page content -->
25 <xsl:template match="/page/pageResponse">
26 <xsl:call-template name="floatRightSidebar" />
27 <xsl:call-template name="classifierPre" />
28
29 <script type="text/javascript" src="interfaces/{$interface_name}/js/classifier_scripts.js">
30 <xsl:text> </xsl:text>
31 </script>
32 <gsf:script type="text/javascript">$(window).on("load", openStoredClassifiers);</gsf:script>
33
34 <!--
35 Show the clasifier results - you can change the appearance of the results
36 by editing the two templates at the bottom of this file
37 -->
38 <div id="results">
39 <xsl:variable name="collName">
40 <xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value" />
41 </xsl:variable>
42 <xsl:variable name="serviceName">
43 <xsl:value-of select="service/@name" />
44 </xsl:variable>
45
46 <xsl:call-template name="classifierResultsPre" />
47
48 <xsl:apply-templates select="classifier">
49 <xsl:with-param name="collName" select="$collName" />
50 <xsl:with-param name="serviceName" select="$serviceName" />
51 </xsl:apply-templates>
52
53 <xsl:call-template name="classifierResultsPost" />
54
55 <xsl:call-template name="classifierPost" />
56 </div>
57
58 <div class="clear">
59 <xsl:text> </xsl:text>
60 </div>
61 </xsl:template>
62
63 <xsl:template name="rightSidebar">
64 <div id="rightSidebar">
65 <xsl:comment>Filler to prevent empty div collapse, in event displayBasket empty</xsl:comment>
66 <gslib:displayBaskets />
67 </div>
68 </xsl:template>
69
70 <xsl:template match="classifier">
71 <xsl:param name="collName" />
72 <xsl:param name="serviceName" />
73 <div id="classifiers">
74 <xsl:variable name="cl_name">
75 <xsl:value-of select="@name" />
76 </xsl:variable>
77 <xsl:choose>
78 <xsl:when test="@childType = 'HList'">
79 <xsl:call-template name="HList">
80 <xsl:with-param name='collName' select='$collName' />
81 <xsl:with-param name='serviceName' select='$serviceName' />
82 </xsl:call-template>
83 </xsl:when>
84 <xsl:otherwise>
85 <table class="childrenlist" id="div{@nodeID}">
86
87 <!--<table id="classifiernodelist">-->
88 <xsl:text> </xsl:text>
89 <xsl:call-template name="processNodeChildren">
90 <xsl:with-param name='collName' select='$collName' />
91 <xsl:with-param name='serviceName' select='$serviceName' />
92 </xsl:call-template>
93 </table>
94 </xsl:otherwise>
95 </xsl:choose>
96 </div>
97 </xsl:template>
98
99 <xsl:template name="HList">
100 <xsl:param name="collName" />
101 <xsl:param name="serviceName" />
102 <xsl:variable name="selectedNode">
103 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 'cl']/@value" />
104 </xsl:variable>
105
106 <ul class="horizontalContainer">
107 <xsl:for-each select='classifierNode'>
108 <li id="title{@nodeID}">
109 <xsl:attribute name="class">
110<!-- <xsl:if test="$selectedNode = @nodeID or starts-with($selectedNode, concat(@nodeID, '.')) or (not(contains($selectedNode, '.')) and @nodeID = concat($selectedNode, '.1'))">selectedHorizontalClassifierNode </xsl:if>-->
111 <xsl:if test="$selectedNode = @nodeID or starts-with($selectedNode, concat(@nodeID, '.')) or (@nodeID = concat($selectedNode, '.1'))">selectedHorizontalClassifierNode </xsl:if>
112 <xsl:text>horizontalClassifierNode</xsl:text>
113 </xsl:attribute>
114 <xsl:apply-templates select='.'>
115 <xsl:with-param name='collName' select='$collName' />
116 <xsl:with-param name='serviceName' select='$serviceName' />
117 </xsl:apply-templates>
118 </li>
119 </xsl:for-each>
120 </ul>
121 <xsl:choose>
122 <!-- if the children are HLists-->
123 <xsl:when test="classifierNode[@childType = 'HList']">
124 <xsl:for-each select='classifierNode'>
125 <!-- there should be only one-->
126 <xsl:call-template name="HList">
127 <xsl:with-param name='collName' select='$collName' />
128 <xsl:with-param name='serviceName' select='$serviceName' />
129 </xsl:call-template>
130 </xsl:for-each>
131 </xsl:when>
132 <xsl:otherwise>
133
134 <div id="classifiernodelist{@nodeID}">
135 <xsl:for-each select='classifierNode'>
136 <xsl:if test="classifierNode|documentNode">
137 <table class="childrenlist" id="div{@nodeID}">
138 <xsl:call-template name="processNodeChildren">
139 <xsl:with-param name='collName' select='$collName' />
140 <xsl:with-param name='serviceName' select='$serviceName' />
141 </xsl:call-template>
142 </table>
143 </xsl:if>
144 </xsl:for-each>
145 </div>
146 </xsl:otherwise>
147 </xsl:choose>
148 </xsl:template>
149
150 <xsl:template name="Collage_javascript_deprecated">
151 <script type="text/javascript" src="interfaces/{$interface_name}/js/collage_scripts.js"><xsl:text> </xsl:text></script>
152 <div id="collagewrapper" style="width: 800px; height: 643px; position: relative; background-image:url('sites/{$site_name}/collect/twso/images/oldimagebackground1.png'); text-align: center;" alt="Click to start/stop a collage of images" title="Click to start/stop a collage of images" onmouseover="" onmouseout=""><xsl:text> </xsl:text></div>
153
154 </xsl:template>
155
156 <xsl:template name="processNodeChildren">
157 <xsl:param name="collName" />
158 <xsl:param name="serviceName" />
159
160 <xsl:choose>
161
162 <xsl:when test="@childType = 'VList' or @childType = 'DateList'">
163 <!--
164 <xsl:when test="@childType = 'VList' or @childType = 'HList' or @childType = 'DateList'"> - - **** mod ???? - -
165 -->
166
167 <xsl:value-of select="util:storeString('prevMonth', '')" />
168 <xsl:for-each select='classifierNode|documentNode'>
169 <tr>
170 <xsl:choose>
171 <xsl:when test="name()='documentNode'">
172 <xsl:if test="../@childType = 'DateList'">
173 <xsl:variable name="prevMonth">
174 <xsl:value-of select="util:getString('prevMonth')" />
175 </xsl:variable>
176 <xsl:variable name="currentDate">
177 <gsf:metadata name="Date" pos="1" />
178 </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...-->
179 <xsl:variable name="currentMonth">
180 <xsl:value-of select="util:getDetailFromDate($currentDate, 'month', /page/@lang)" />
181 </xsl:variable>
182 <xsl:value-of select="util:storeString('prevMonth', $currentMonth)" />
183 <td>
184 <xsl:if test="not($currentMonth = $prevMonth)">
185 <xsl:value-of select="$currentMonth" />
186 </xsl:if>
187 <xsl:text> </xsl:text>
188 </td>
189 </xsl:if>
190 <td>
191 <table id="div{@nodeID}">
192 <tr>
193 <xsl:call-template name="documentNodeWrapper">
194 <xsl:with-param name='collName' select='$collName' />
195 <xsl:with-param name='serviceName' select='$serviceName' />
196 </xsl:call-template>
197 </tr>
198 </table>
199 </td>
200 </xsl:when>
201 <xsl:when test="name()='classifierNode' and (@childType = 'VList' or @childType = 'HList')">
202 <!-- *** mod -->
203 <td>
204 <table id="title{@nodeID}">
205 <tr>
206 <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'">
207 <td class="headerTD">
208 <img id="toggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon turnstyleicon">
209 <xsl:attribute name="src">
210 <xsl:choose>
211 <xsl:when test="classifierNode or documentNode">
212 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')" />
213 </xsl:when>
214 <xsl:otherwise>
215 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')" />
216 </xsl:otherwise>
217 </xsl:choose>
218 </xsl:attribute>
219 </img>
220 </td>
221 </xsl:if>
222 <xsl:apply-templates select='.'>
223 <xsl:with-param name='collName' select='$collName' />
224 <xsl:with-param name='serviceName' select='$serviceName' />
225 </xsl:apply-templates>
226 </tr>
227 </table>
228 </td>
229 <xsl:if test="child::classifierNode or child::documentNode">
230 <!--recurse into the children-->
231 <tr>
232 <td>
233 <table class="childrenlist" id="div{@nodeID}">
234
235 <xsl:apply-templates select='.' mode='process-all-children'>
236 <xsl:with-param name='collName' select='$collName' />
237 <xsl:with-param name='serviceName' select='$serviceName' />
238 </xsl:apply-templates>
239 </table>
240 </td>
241 </tr>
242 </xsl:if>
243 </xsl:when>
244 <xsl:otherwise>
245 <td>
246 Unknown classifier style specified:
247 <xsl:value-of select="name()" />
248 </td>
249 </xsl:otherwise>
250 </xsl:choose>
251 </tr>
252 </xsl:for-each>
253 </xsl:when>
254 <xsl:when test="@childType = 'HTML'">
255 <xsl:variable name="URL">
256 <xsl:value-of select="documentNode/@nodeID" />
257 </xsl:variable>
258 <iframe width="100%" height="600" frameborder="0">
259 <xsl:attribute name="src">
260 <xsl:value-of select="$URL" />
261 </xsl:attribute>
262 Frame for
263 <xsl:value-of select="$URL" />
264 </iframe>
265 </xsl:when>
266 <xsl:when test="@childType = 'Collage'">
267 <xsl:choose>
268 <!--test of not(*) means has no children, not(classNode) has no subelements classNode-->
269 <xsl:when test="not(classifierNode)">
270 <!-- the order of calling these templates now matters since the collage applet now
271 serves as a shim in the javascript that gets loaded in the 2nd template call:
272 the javascript now reads in the applet's parameters and uses them to configure
273 the webswing application/applet. It appeared better than the entirely javascript
274 solution we already had (which set the webswing arguments from the pageRequest
275 and xslt variables), as javascript requires familiarity with programming and
276 library designers/developers/we may find it easier to configure applet params
277 than learn/remember how to set webswing params or use javascript.
278 -->
279 <xsl:call-template name="get-collage-settings" />
280 <div id="collage-displaying-info" style="display:none">The Collage Java App</div>
281 <xsl:call-template name="webswing-embed-collage"/>
282 </xsl:when>
283 <xsl:otherwise>
284 <xsl:apply-templates select='classifierNode|documentNode' mode='process-all-children'>
285 <xsl:with-param name='collName' select='$collName' />
286 <xsl:with-param name='serviceName' select='$serviceName' />
287 </xsl:apply-templates>
288 </xsl:otherwise>
289 </xsl:choose>
290 </xsl:when>
291 <xsl:otherwise>
292 we are in the other wise
293 </xsl:otherwise>
294 </xsl:choose>
295 </xsl:template>
296
297 <!-- processing for the recursive bit -->
298 <xsl:template match="classifierNode" mode="process-all-children">
299 <xsl:param name="collName" />
300 <xsl:param name="serviceName" />
301
302 <!--
303 ***mod: previous, simpler version
304 <xsl:call-template name="processNodeChildren">
305 <xsl:with-param name='collName' select='$collName'/>
306 <xsl:with-param name='serviceName' select='$serviceName'/>
307 </xsl:call-template>
308 -->
309
310 <xsl:choose>
311 <xsl:when test="@childType = 'HList'">
312 <tr><td>
313 <xsl:call-template name="HList">
314 <xsl:with-param name='collName' select='$collName' />
315 <xsl:with-param name='serviceName' select='$serviceName' />
316 </xsl:call-template>
317 </td></tr>
318 </xsl:when>
319 <xsl:otherwise>
320 <xsl:call-template name="processNodeChildren">
321 <xsl:with-param name='collName' select='$collName' />
322 <xsl:with-param name='serviceName' select='$serviceName' />
323 </xsl:call-template>
324 </xsl:otherwise>
325 </xsl:choose>
326
327 </xsl:template>
328
329 <!-- 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 -->
330 <xsl:template name="documentNodeWrapper">
331 <xsl:param name="collName" />
332 <xsl:param name="serviceName" />
333
334 <!-- The favourite star (optional) -->
335 <xsl:if test="$favouriteBasketOn">
336 <td valign="top">
337 <xsl:call-template name="documentFavouriteForClassifierOrSearchPage" />
338 </td>
339 </xsl:if>
340
341 <xsl:apply-templates select=".">
342 <xsl:with-param name="collName" select="$collName" />
343 <xsl:with-param name="serviceName" select="$serviceName" />
344 </xsl:apply-templates>
345
346 <xsl:call-template name="documentNodePost" />
347 </xsl:template>
348
349 <!--
350 TEMPLATE FOR DOCUMENTS
351 -->
352 <xsl:template match="documentNode">
353 <td valign="top">
354 <gsf:link type="document">
355 <gsf:icon type="document" />
356 </gsf:link>
357 </td>
358 <td valign="top">
359 <gsf:link type="source">
360 <gsf:choose-metadata>
361 <gsf:metadata name="thumbicon" />
362 <gsf:metadata name="srcicon" />
363 </gsf:choose-metadata>
364 </gsf:link>
365 </td>
366 <td valign="top">
367 <gsf:link type="document">
368 <!-- Defined in header.xsl -->
369 <xsl:call-template name="choose-title" />
370 <gsf:switch>
371 <gsf:metadata name="Source" />
372 <gsf:when test="exists">
373 <br />
374 <i>
375 (
376 <gsf:metadata name="Source" />
377 )
378 </i>
379 </gsf:when>
380 </gsf:switch>
381 </gsf:link>
382 </td>
383 </xsl:template>
384
385 <xsl:template name="documentNodePost">
386 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
387 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude' or @name='Coordinate']">
388 <xsl:call-template name="mapFeaturesIcon" />
389 </xsl:if>
390 </xsl:if>
391
392 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
393 <xsl:if test="metadataList/metadata[@name = 'PhotoType']='Panorama' and ( metadataList/metadata[@name = 'Coordinate'] or ( metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']))">
394 <xsl:call-template name="panoramaViewerFeaturesIcon" />
395 </xsl:if>
396 </xsl:if>
397
398 </xsl:template>
399
400 <!--
401 TEMPLATE FOR GROUPS OF DOCUMENTS
402 -->
403 <xsl:template match="classifierNode[@classifierStyle = 'HList']">
404 <gsf:link type="classifier">
405 <gsf:metadata name="Title" />
406 </gsf:link>
407 </xsl:template>
408
409 <xsl:template match="classifierNode">
410 <td valign="top">
411 <gsf:link type="classifier" style="static">
412 <gsf:icon type="classifier" />
413 </gsf:link>
414 </td>
415 <td valign="top">
416 <gsf:link type="classifier">
417 <gsf:metadata name="Title" />
418 </gsf:link>
419 </td>
420 </xsl:template>
421
422 <xsl:template name="classifierPre">
423 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
424 <xsl:call-template name="mapFeaturesJSONNodes" />
425 </xsl:if>
426
427 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
428 <xsl:call-template name="panoramaViewerFeaturesJSONNodes" />
429 </xsl:if>
430
431 </xsl:template>
432
433 <xsl:template name="classifierResultsPre">
434 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
435 <xsl:call-template name="mapFeaturesMap" />
436 </xsl:if>
437 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
438 <xsl:call-template name="panoramaViewerFeatures" />
439 </xsl:if>
440 </xsl:template>
441
442 <xsl:template name="classifierResultsPost">
443 </xsl:template>
444
445 <xsl:template name="classifierPost">
446 </xsl:template>
447
448 <xsl:template match="/page/xsltparams">
449 <!-- suppress xsltparam block in page -->
450 </xsl:template>
451
452</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.