source: main/trunk/greenstone3/web/interfaces/default/transform/pages/classifier.xsl-for-gs311@ 35170

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

Next stage in developing collaging, to be activated in next release of GS3

File size: 14.0 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
86 <xsl:template name="HList">
87 <xsl:param name="collName"/>
88 <xsl:param name="serviceName"/>
89 <xsl:variable name="selectedNode"><xsl:value-of select="/page/pageRequest/paramList/param[@name = 'cl']/@value"/></xsl:variable>
90 <ul class="horizontalContainer">
91 <xsl:for-each select='classifierNode'>
92 <li>
93 <xsl:attribute name="class">
94 <xsl:if test="$selectedNode = @nodeID or starts-with($selectedNode, concat(@nodeID, '.')) or (not(contains($selectedNode, '.')) and @nodeID = concat($selectedNode, '.1'))">selectedHorizontalClassifierNode </xsl:if>
95 <xsl:text>horizontalClassifierNode</xsl:text>
96 </xsl:attribute>
97 <xsl:apply-templates select='.'>
98 <xsl:with-param name='collName' select='$collName'/>
99 <xsl:with-param name='serviceName' select='$serviceName'/>
100 </xsl:apply-templates>
101 </li>
102 </xsl:for-each>
103 </ul>
104 <xsl:choose>
105 <!-- if the children are HLists-->
106 <xsl:when test="classifierNode[@childType = 'HList']">
107 <xsl:for-each select='classifierNode'><!-- there should be only one-->
108 <xsl:call-template name="HList">
109 <xsl:with-param name='collName' select='$collName'/>
110 <xsl:with-param name='serviceName' select='$serviceName'/>
111 </xsl:call-template>
112 </xsl:for-each>
113 </xsl:when>
114 <xsl:otherwise>
115 <table id="classifiernodelist">
116 <xsl:for-each select='classifierNode'>
117 <xsl:call-template name="processNodeChildren">
118 <xsl:with-param name='collName' select='$collName'/>
119 <xsl:with-param name='serviceName' select='$serviceName'/>
120 </xsl:call-template>
121 </xsl:for-each>
122 </table>
123 </xsl:otherwise>
124 </xsl:choose>
125 </xsl:template>
126
127 <xsl:template name="Collage">
128 <script type="text/javascript" src="interfaces/{$interface_name}/js/collage_scripts.js"><xsl:text> </xsl:text></script>
129 <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>
130
131 </xsl:template>
132
133
134 <xsl:template name="processNodeChildren">
135 <xsl:param name="collName"/>
136 <xsl:param name="serviceName"/>
137
138 <xsl:choose>
139
140 <xsl:when test="@childType = 'VList' or @childType = 'DateList'">
141 <!--
142 <xsl:when test="@childType = 'VList' or @childType = 'HList' or @childType = 'DateList'"> - - **** mod ???? - -
143 -->
144
145 <xsl:value-of select="util:storeString('prevMonth', '')"/>
146 <xsl:for-each select='classifierNode|documentNode'>
147 <tr>
148 <xsl:choose>
149 <xsl:when test="name()='documentNode'">
150 <xsl:if test="../@childType = 'DateList'">
151 <xsl:variable name="prevMonth"><xsl:value-of select="util:getString('prevMonth')"/></xsl:variable>
152 <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...-->
153 <xsl:variable name="currentMonth"><xsl:value-of select="util:getDetailFromDate($currentDate, 'month', /page/@lang)"/></xsl:variable>
154 <xsl:value-of select="util:storeString('prevMonth', $currentMonth)"/>
155 <td>
156 <xsl:if test="not($currentMonth = $prevMonth)">
157 <xsl:value-of select="$currentMonth"/>
158 </xsl:if>
159 <xsl:text> </xsl:text>
160 </td>
161 </xsl:if>
162 <td>
163 <table id="div{@nodeID}"><tr>
164 <xsl:call-template name="documentNodeWrapper">
165 <xsl:with-param name='collName' select='$collName'/>
166 <xsl:with-param name='serviceName' select='$serviceName'/>
167 </xsl:call-template>
168 </tr></table>
169 </td>
170 </xsl:when>
171 <xsl:when test="name()='classifierNode' and (@childType = 'VList' or @childType = 'HList')"><!-- *** mod -->
172 <td>
173 <table id="title{@nodeID}"><tr>
174 <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'">
175 <td class="headerTD">
176 <img id="toggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon turnstyleicon">
177 <xsl:attribute name="src">
178 <xsl:choose>
179 <xsl:when test="classifierNode or documentNode">
180 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
181 </xsl:when>
182 <xsl:otherwise>
183 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
184 </xsl:otherwise>
185 </xsl:choose>
186 </xsl:attribute>
187 </img>
188 </td>
189 </xsl:if>
190 <xsl:apply-templates select='.'>
191 <xsl:with-param name='collName' select='$collName'/>
192 <xsl:with-param name='serviceName' select='$serviceName'/>
193 </xsl:apply-templates>
194 </tr></table>
195 </td>
196 <xsl:if test="child::classifierNode or child::documentNode">
197 <!--recurse into the children-->
198 <tr><td><table class="childrenlist" id="div{@nodeID}">
199 <xsl:apply-templates select='.' mode='process-all-children'>
200 <xsl:with-param name='collName' select='$collName'/>
201 <xsl:with-param name='serviceName' select='$serviceName'/>
202 </xsl:apply-templates>
203 </table></td></tr>
204 </xsl:if>
205 </xsl:when>
206 <xsl:otherwise><td>Unknown classifier style specified: <xsl:value-of select="name()"/></td></xsl:otherwise>
207 </xsl:choose>
208 </tr>
209 </xsl:for-each>
210 </xsl:when>
211 <xsl:when test="@childType = 'HTML'">
212 <xsl:variable name="URL"><xsl:value-of select="documentNode/@nodeID"/></xsl:variable>
213 <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>
214 </xsl:when>
215 <xsl:when test="@childType = 'Collage'">
216 <xsl:call-template name="Collage" />
217 </xsl:when>
218 <xsl:otherwise>
219 we are in the other wise
220 </xsl:otherwise>
221 </xsl:choose>
222 </xsl:template>
223
224
225 <!-- processing for the recursive bit -->
226 <xsl:template match="classifierNode" mode="process-all-children">
227 <xsl:param name="collName"/>
228 <xsl:param name="serviceName"/>
229
230 <!--
231 ***mod: previous, simpler version
232 <xsl:call-template name="processNodeChildren">
233 <xsl:with-param name='collName' select='$collName'/>
234 <xsl:with-param name='serviceName' select='$serviceName'/>
235 </xsl:call-template>
236 -->
237
238 <xsl:choose>
239 <xsl:when test="@childType = 'HList'">
240 <xsl:call-template name="HList">
241 <xsl:with-param name='collName' select='$collName'/>
242 <xsl:with-param name='serviceName' select='$serviceName'/>
243 </xsl:call-template>
244 </xsl:when>
245 <xsl:otherwise>
246 <xsl:call-template name="processNodeChildren">
247 <xsl:with-param name='collName' select='$collName'/>
248 <xsl:with-param name='serviceName' select='$serviceName'/>
249 </xsl:call-template>
250 </xsl:otherwise>
251 </xsl:choose>
252
253
254 </xsl:template>
255
256
257
258 <!-- 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 -->
259 <xsl:template name="documentNodeWrapper">
260 <xsl:param name="collName"/>
261 <xsl:param name="serviceName"/>
262 <xsl:apply-templates select=".">
263 <xsl:with-param name="collName" select="$collName"/>
264 <xsl:with-param name="serviceName" select="$serviceName"/>
265 </xsl:apply-templates>
266 <!-- The berry/favourite (optional) -->
267 <td valign="top">
268 <xsl:if test="/page/pageResponse/interfaceOptions/option[@name = 'berryBasket']/@value = 'true'">
269 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
270 </xsl:if>
271 <xsl:if test="/page/pageResponse/interfaceOptions/option[@name = 'favouriteBasket']/@value = 'true'">
272 <xsl:call-template name="documentFavouriteForClassifierOrSearchPage"/>
273 </xsl:if>
274
275 </td>
276 <xsl:call-template name="documentNodePost"/>
277 </xsl:template>
278
279 <!--
280 TEMPLATE FOR DOCUMENTS
281 -->
282 <xsl:template match="documentNode">
283 <td valign="top">
284 <gsf:link type="document">
285 <gsf:icon type="document"/>
286 </gsf:link>
287 </td>
288 <td valign="top">
289 <gsf:link type="source">
290 <gsf:choose-metadata>
291 <gsf:metadata name="thumbicon"/>
292 <gsf:metadata name="srcicon"/>
293 </gsf:choose-metadata>
294 </gsf:link>
295 </td>
296 <td valign="top">
297 <gsf:link type="document">
298 <!-- Defined in header.xsl -->
299 <xsl:call-template name="choose-title"/>
300 <gsf:switch>
301 <gsf:metadata name="Source"/>
302 <gsf:when test="exists"><br/><i>(<gsf:metadata name="Source"/>)</i></gsf:when>
303 </gsf:switch>
304 </gsf:link>
305 </td>
306 </xsl:template>
307
308
309 <xsl:template name="documentNodePost">
310 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
311 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude' or @name='Coordinate']">
312 <xsl:call-template name="mapFeaturesIcon"/>
313 </xsl:if>
314 </xsl:if>
315
316 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
317 <xsl:if test="metadataList/metadata[@name = 'PhotoType']='Panorama' and ( metadataList/metadata[@name = 'Coordinate'] or ( metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']))">
318 <xsl:call-template name="panoramaViewerFeaturesIcon"/>
319 </xsl:if>
320 </xsl:if>
321
322 </xsl:template>
323
324 <!--
325 TEMPLATE FOR GROUPS OF DOCUMENTS
326 -->
327 <xsl:template match="classifierNode[@classifierStyle = 'HList']" >
328 <gsf:link type="classifier" style="static">
329 <gsf:metadata name="Title"/>
330 </gsf:link>
331 </xsl:template>
332
333 <xsl:template match="classifierNode">
334 <td valign="top">
335 <gsf:link type="classifier" style="static">
336 <gsf:icon type="classifier"/>
337 </gsf:link>
338 </td>
339 <td valign="top">
340 <gsf:link type="classifier">
341 <gsf:metadata name="Title"/>
342 </gsf:link>
343 </td>
344 </xsl:template>
345
346
347 <xsl:template name="classifierPre">
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="mapFeaturesJSONNodes"/>
350 </xsl:if>
351
352 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
353 <xsl:call-template name="panoramaViewerFeaturesJSONNodes"/>
354 </xsl:if>
355
356 </xsl:template>
357
358 <xsl:template name="classifierResultsPre">
359 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
360 <xsl:call-template name="mapFeaturesMap"/>
361 </xsl:if>
362 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
363 <xsl:call-template name="panoramaViewerFeatures"/>
364 </xsl:if>
365 </xsl:template>
366
367 <xsl:template match="/page/xsltparams">
368 <!-- suppress xsltparam block in page -->
369 </xsl:template>
370
371</xsl:stylesheet>
372
Note: See TracBrowser for help on using the repository browser.