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

Last change on this file since 33261 was 33261, checked in by davidb, 5 years ago

XSL changes to support for either berries or favourites

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