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

Last change on this file was 38950, checked in by anupama, 3 days ago

Added an applet shim for phind and this time correctly set the display for the collage (and phind) applet to none by setting it in the applet's style attribute, where it belongs, instead of as its own attribute on the element.

File size: 21.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="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
151 <xsl:template name="collage-applet-shim">
152 <!--<xsl:text>TODO: Here is the collage applet</xsl:text>-->
153 <!-- Copied from GS2.88's about.dm (document.dm has more applet params).
154
155 Modified params: codebase, GsdlCollageApplet class' package, gwcgi, collection, classifier value="CL2.3", hrefMustHave value="cl=CL3.1". Param isJava2's value changed from auto to true.
156 And made all param XML elements self-closing.
157 -->
158 <!-- When run in the browser or as an application, it's enough to specify "applet" for codebase
159 as the relative folder where to find the jars (we seem to be in the "web" dir then,
160 so can directly look in web's "applet" subdirectory for the jar). But for running
161 this applet with the appletviewer, we need the "full URL path" to the applet folder,
162 which is off /greenstone3 (the servlet_context). Though once the collage applet is run
163 in the appletviewer, a securityexception is thrown as it appears to run in a sandbox
164 that has no permission to download URLs or follow external links or something. That's
165 as far as the Java appletviewer executable can run Greenstone's collage applet program.
166 But being able to run it through the appletviewer this far gives us some confidence that
167 the collage applet actually successfully starts running as an applet.
168
169TODO: double-quotes for attributes.
170 -->
171 <applet
172 style="display:none"
173 id="collage-applet-element"
174 code="org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet.class"
175 archive="GsdlCollageApplet.jar, webswing-api.jar"
176 width="800"
177 height="400">
178 <xsl:attribute name="codebase">/<xsl:value-of select="$servlet_context"/>/applet</xsl:attribute>
179
180 <!-- declaring some local variables -->
181 <xsl:variable name="coll_name">
182 <xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/>
183 </xsl:variable>
184 <xsl:variable name="classifier">
185 <xsl:value-of select="/page/pageRequest/paramList/param[@name='cl']/@value"/>
186 </xsl:variable>
187 <xsl:variable name="fullURL">
188 <xsl:value-of select="/page/pageRequest/@fullURL"/>
189 </xsl:variable>
190 <xsl:variable name="url_protocol_prefix">
191 <xsl:value-of select="substring-before (/page/pageRequest/@fullURL,'/')"/>
192 </xsl:variable>
193
194 <!-- setting the applet parameters: first the dynamic ones -->
195
196 <!-- pageRequest attribute "baseURL" lacks protocol prefix and looks like
197 e.g "//localhost:8383/greenstone3/", but we want to set xsl:variable "baseurl"
198 to all of e.g "http://localhost:8383/greenstone3/" -->
199 <param name="baseurl">
200 <xsl:attribute name="value">
201 <xsl:value-of select="$url_protocol_prefix"/><xsl:value-of select="/page/pageRequest/@baseURL"/>
202 </xsl:attribute>
203 </param>
204
205 <param name="library" value="{$library_name}" />
206 <param name="collection" value="{$coll_name}" />
207 <param name="classifier" value="{$classifier}.1" /><!-- e.g. "CL3.1".
208 The first level subclassifier (.1) contains the hidden classifier structure
209 that the collage app starts exploring from for images -->
210
211 <param name="documentroot" value="{$servlet_context}" /> <!-- e.g. "greenstone3" -->
212
213 <param name="hrefMustHave"><xsl:attribute name="value"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$coll_name"/>/browse/<xsl:value-of select="$classifier"/></xsl:attribute></param><!-- e.g. "library/collection/smallbea/browse/CL3" -->
214
215 <!-- applet parameters that are fixed for GS3 or we probably don't want to modify -->
216 <param name="gsdlversion" value="3" />
217 <param name="imageMustNotHave" value="interfaces/" />
218
219 <!-- applet parameters that can be manually adjusted -->
220 <param name="imageType" value=".jpg%.png" />
221 <param name="verbosity" value="3" />
222 <param name="maxDepth" value="500"/>
223 <param name="maxDisplay" value="25" />
224 <param name="refreshDelay" value="1500"/>
225 <param name="isJava2" value="auto"/>
226 <param name="bgcolor" value="#96c29a" />
227The Collage Applet.
228
229 </applet>
230 </xsl:template>
231
232 <xsl:template name="Collage_javascript_deprecated">
233 <script type="text/javascript" src="interfaces/{$interface_name}/js/collage_scripts.js"><xsl:text> </xsl:text></script>
234 <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>
235
236 </xsl:template>
237
238 <xsl:template name="processNodeChildren">
239 <xsl:param name="collName" />
240 <xsl:param name="serviceName" />
241
242 <xsl:choose>
243
244 <xsl:when test="@childType = 'VList' or @childType = 'DateList'">
245 <!--
246 <xsl:when test="@childType = 'VList' or @childType = 'HList' or @childType = 'DateList'"> - - **** mod ???? - -
247 -->
248
249 <xsl:value-of select="util:storeString('prevMonth', '')" />
250 <xsl:for-each select='classifierNode|documentNode'>
251 <tr>
252 <xsl:choose>
253 <xsl:when test="name()='documentNode'">
254 <xsl:if test="../@childType = 'DateList'">
255 <xsl:variable name="prevMonth">
256 <xsl:value-of select="util:getString('prevMonth')" />
257 </xsl:variable>
258 <xsl:variable name="currentDate">
259 <gsf:metadata name="Date" pos="1" />
260 </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...-->
261 <xsl:variable name="currentMonth">
262 <xsl:value-of select="util:getDetailFromDate($currentDate, 'month', /page/@lang)" />
263 </xsl:variable>
264 <xsl:value-of select="util:storeString('prevMonth', $currentMonth)" />
265 <td>
266 <xsl:if test="not($currentMonth = $prevMonth)">
267 <xsl:value-of select="$currentMonth" />
268 </xsl:if>
269 <xsl:text> </xsl:text>
270 </td>
271 </xsl:if>
272 <td>
273 <table id="div{@nodeID}">
274 <tr>
275 <xsl:call-template name="documentNodeWrapper">
276 <xsl:with-param name='collName' select='$collName' />
277 <xsl:with-param name='serviceName' select='$serviceName' />
278 </xsl:call-template>
279 </tr>
280 </table>
281 </td>
282 </xsl:when>
283 <xsl:when test="name()='classifierNode' and (@childType = 'VList' or @childType = 'HList')">
284 <!-- *** mod -->
285 <td>
286 <table id="title{@nodeID}">
287 <tr>
288 <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'">
289 <td class="headerTD">
290 <img id="toggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon turnstyleicon">
291 <xsl:attribute name="src">
292 <xsl:choose>
293 <xsl:when test="classifierNode or documentNode">
294 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')" />
295 </xsl:when>
296 <xsl:otherwise>
297 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')" />
298 </xsl:otherwise>
299 </xsl:choose>
300 </xsl:attribute>
301 </img>
302 </td>
303 </xsl:if>
304 <xsl:apply-templates select='.'>
305 <xsl:with-param name='collName' select='$collName' />
306 <xsl:with-param name='serviceName' select='$serviceName' />
307 </xsl:apply-templates>
308 </tr>
309 </table>
310 </td>
311 <xsl:if test="child::classifierNode or child::documentNode">
312 <!--recurse into the children-->
313 <tr>
314 <td>
315 <table class="childrenlist" id="div{@nodeID}">
316
317 <xsl:apply-templates select='.' mode='process-all-children'>
318 <xsl:with-param name='collName' select='$collName' />
319 <xsl:with-param name='serviceName' select='$serviceName' />
320 </xsl:apply-templates>
321 </table>
322 </td>
323 </tr>
324 </xsl:if>
325 </xsl:when>
326 <xsl:otherwise>
327 <td>
328 Unknown classifier style specified:
329 <xsl:value-of select="name()" />
330 </td>
331 </xsl:otherwise>
332 </xsl:choose>
333 </tr>
334 </xsl:for-each>
335 </xsl:when>
336 <xsl:when test="@childType = 'HTML'">
337 <xsl:variable name="URL">
338 <xsl:value-of select="documentNode/@nodeID" />
339 </xsl:variable>
340 <iframe width="100%" height="600" frameborder="0">
341 <xsl:attribute name="src">
342 <xsl:value-of select="$URL" />
343 </xsl:attribute>
344 Frame for
345 <xsl:value-of select="$URL" />
346 </iframe>
347 </xsl:when>
348 <xsl:when test="@childType = 'Collage'">
349 <xsl:choose>
350 <xsl:when test="not(*)">
351 <!-- the order of calling these templates now matters since the collage applet now
352 serves as a shim in the javascript that gets loaded in the 2nd template call:
353 the javascript now reads in the applet's parameters and uses them to configure
354 the webswing application/applet. It appeared better than the entirely javascript
355 solution we already had (which set the webswing arguments from the pageRequest
356 and xslt variables), as javascript requires familiarity with programming and
357 library designers/developers/we may find it easier to configure applet params
358 than learn/remember how to set webswing params or use javascript.
359 -->
360 <xsl:call-template name="collage-applet-shim" />
361 <xsl:call-template name="webswing-embed-collage"/>
362 </xsl:when>
363 <xsl:otherwise>
364 <xsl:apply-templates select='classifierNode|documentNode' mode='process-all-children'>
365 <xsl:with-param name='collName' select='$collName' />
366 <xsl:with-param name='serviceName' select='$serviceName' />
367 </xsl:apply-templates>
368 </xsl:otherwise>
369 </xsl:choose>
370 </xsl:when>
371 <xsl:otherwise>
372 we are in the other wise
373 </xsl:otherwise>
374 </xsl:choose>
375 </xsl:template>
376
377 <!-- processing for the recursive bit -->
378 <xsl:template match="classifierNode" mode="process-all-children">
379 <xsl:param name="collName" />
380 <xsl:param name="serviceName" />
381
382 <!--
383 ***mod: previous, simpler version
384 <xsl:call-template name="processNodeChildren">
385 <xsl:with-param name='collName' select='$collName'/>
386 <xsl:with-param name='serviceName' select='$serviceName'/>
387 </xsl:call-template>
388 -->
389
390 <xsl:choose>
391 <xsl:when test="@childType = 'HList'">
392 <tr><td>
393 <xsl:call-template name="HList">
394 <xsl:with-param name='collName' select='$collName' />
395 <xsl:with-param name='serviceName' select='$serviceName' />
396 </xsl:call-template>
397 </td></tr>
398 </xsl:when>
399 <xsl:otherwise>
400 <xsl:call-template name="processNodeChildren">
401 <xsl:with-param name='collName' select='$collName' />
402 <xsl:with-param name='serviceName' select='$serviceName' />
403 </xsl:call-template>
404 </xsl:otherwise>
405 </xsl:choose>
406
407 </xsl:template>
408
409 <!-- 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 -->
410 <xsl:template name="documentNodeWrapper">
411 <xsl:param name="collName" />
412 <xsl:param name="serviceName" />
413
414 <!-- The favourite star (optional) -->
415 <xsl:if test="$favouriteBasketOn">
416 <td valign="top">
417 <xsl:call-template name="documentFavouriteForClassifierOrSearchPage" />
418 </td>
419 </xsl:if>
420
421 <xsl:apply-templates select=".">
422 <xsl:with-param name="collName" select="$collName" />
423 <xsl:with-param name="serviceName" select="$serviceName" />
424 </xsl:apply-templates>
425
426 <xsl:call-template name="documentNodePost" />
427 </xsl:template>
428
429 <!--
430 TEMPLATE FOR DOCUMENTS
431 -->
432 <xsl:template match="documentNode">
433 <td valign="top">
434 <gsf:link type="document">
435 <gsf:icon type="document" />
436 </gsf:link>
437 </td>
438 <td valign="top">
439 <gsf:link type="source">
440 <gsf:choose-metadata>
441 <gsf:metadata name="thumbicon" />
442 <gsf:metadata name="srcicon" />
443 </gsf:choose-metadata>
444 </gsf:link>
445 </td>
446 <td valign="top">
447 <gsf:link type="document">
448 <!-- Defined in header.xsl -->
449 <xsl:call-template name="choose-title" />
450 <gsf:switch>
451 <gsf:metadata name="Source" />
452 <gsf:when test="exists">
453 <br />
454 <i>
455 (
456 <gsf:metadata name="Source" />
457 )
458 </i>
459 </gsf:when>
460 </gsf:switch>
461 </gsf:link>
462 </td>
463 </xsl:template>
464
465 <xsl:template name="documentNodePost">
466 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
467 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude' or @name='Coordinate']">
468 <xsl:call-template name="mapFeaturesIcon" />
469 </xsl:if>
470 </xsl:if>
471
472 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
473 <xsl:if test="metadataList/metadata[@name = 'PhotoType']='Panorama' and ( metadataList/metadata[@name = 'Coordinate'] or ( metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']))">
474 <xsl:call-template name="panoramaViewerFeaturesIcon" />
475 </xsl:if>
476 </xsl:if>
477
478 </xsl:template>
479
480 <!--
481 TEMPLATE FOR GROUPS OF DOCUMENTS
482 -->
483 <xsl:template match="classifierNode[@classifierStyle = 'HList']">
484 <gsf:link type="classifier">
485 <gsf:metadata name="Title" />
486 </gsf:link>
487 </xsl:template>
488
489 <xsl:template match="classifierNode">
490 <td valign="top">
491 <gsf:link type="classifier" style="static">
492 <gsf:icon type="classifier" />
493 </gsf:link>
494 </td>
495 <td valign="top">
496 <gsf:link type="classifier">
497 <gsf:metadata name="Title" />
498 </gsf:link>
499 </td>
500 </xsl:template>
501
502 <xsl:template name="classifierPre">
503 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
504 <xsl:call-template name="mapFeaturesJSONNodes" />
505 </xsl:if>
506
507 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
508 <xsl:call-template name="panoramaViewerFeaturesJSONNodes" />
509 </xsl:if>
510
511 </xsl:template>
512
513 <xsl:template name="classifierResultsPre">
514 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
515 <xsl:call-template name="mapFeaturesMap" />
516 </xsl:if>
517 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
518 <xsl:call-template name="panoramaViewerFeatures" />
519 </xsl:if>
520 </xsl:template>
521
522 <xsl:template name="classifierResultsPost">
523 </xsl:template>
524
525 <xsl:template name="classifierPost">
526 </xsl:template>
527
528 <xsl:template match="/page/xsltparams">
529 <!-- suppress xsltparam block in page -->
530 </xsl:template>
531
532</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.