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

Last change on this file since 33594 was 33594, checked in by kjdon, 4 years ago

call gslib:displayBasket instead of replicating the code here

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