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

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

Change to allow HList nodes that aren't at the top-level to be displayed; HList is still done as a static link rather than an AJAX toggle link. An improvement would be to make these also be AJAX toggle, and (in the case of an HList) have it auto-close any other HList node in that layer as part of the operation

File size: 14.3 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
32 <!-- this right sidebar -->
33 <xsl:if test="$berryBasketOn 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)))">
34 <div id="rightSidebar">
35 <xsl:if test="$berryBasketOn">
36 <!-- show the berry basket if it's turned on -->
37 <gslib:berryBasket/>
38 <xsl:text> </xsl:text>
39 </xsl:if>
40
41 <xsl:if test="$documentBasketOn">
42 <gslib:documentBasket/>
43 <xsl:text> </xsl:text>
44 </xsl:if>
45 </div>
46 </xsl:if>
47
48 <!--
49 show the clasifier results -
50 you can change the appearance of the results by editing
51 the two templates at the bottom of this file
52 -->
53 <div id="results">
54 <xsl:variable name="collName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
55 <xsl:variable name="serviceName"><xsl:value-of select="service/@name"/></xsl:variable>
56
57 <xsl:call-template name="classifierResultsPre"/>
58
59 <xsl:apply-templates select="classifier">
60 <xsl:with-param name="collName" select="$collName"/>
61 <xsl:with-param name="serviceName" select="$serviceName"/>
62 </xsl:apply-templates>
63 </div>
64
65 <div class="clear"><xsl:text> </xsl:text></div>
66 </xsl:template>
67
68 <xsl:template match="classifier">
69 <xsl:param name="collName"/>
70 <xsl:param name="serviceName"/>
71 <div id="classifiers">
72 <xsl:variable name="cl_name"><xsl:value-of select="@name"/></xsl:variable>
73 <xsl:choose>
74 <xsl:when test="@childType = 'HList'">
75 <xsl:call-template name="HList">
76 <xsl:with-param name='collName' select='$collName'/>
77 <xsl:with-param name='serviceName' select='$serviceName'/>
78 </xsl:call-template>
79 </xsl:when>
80 <xsl:otherwise>
81 <table id="classifiernodelist">
82 <xsl:text> </xsl:text>
83 <xsl:call-template name="processNodeChildren">
84 <xsl:with-param name='collName' select='$collName'/>
85 <xsl:with-param name='serviceName' select='$serviceName'/>
86 </xsl:call-template>
87 </table>
88 </xsl:otherwise>
89 </xsl:choose>
90 </div>
91 </xsl:template>
92
93 <xsl:template name="HList">
94 <xsl:param name="collName"/>
95 <xsl:param name="serviceName"/>
96 <xsl:variable name="selectedNode"><xsl:value-of select="/page/pageRequest/paramList/param[@name = 'cl']/@value"/></xsl:variable>
97 <ul class="horizontalContainer">
98 <xsl:for-each select='classifierNode'>
99 <li>
100 <xsl:attribute name="class">
101 <xsl:if test="starts-with($selectedNode, @nodeID) or (not(contains($selectedNode, '.')) and @nodeID = concat($selectedNode, '.1'))">selectedHorizontalClassifierNode </xsl:if>
102 <xsl:text>horizontalClassifierNode</xsl:text>
103 </xsl:attribute>
104 <xsl:apply-templates select='.'>
105 <xsl:with-param name='collName' select='$collName'/>
106 <xsl:with-param name='serviceName' select='$serviceName'/>
107 </xsl:apply-templates>
108 </li>
109 </xsl:for-each>
110 </ul>
111 <xsl:choose>
112 <!-- if the children are HLists-->
113 <xsl:when test="classifierNode[@childType = 'HList']">
114 <xsl:for-each select='classifierNode'><!-- there should be only one-->
115 <xsl:call-template name="HList">
116 <xsl:with-param name='collName' select='$collName'/>
117 <xsl:with-param name='serviceName' select='$serviceName'/>
118 </xsl:call-template>
119 </xsl:for-each>
120 </xsl:when>
121 <xsl:otherwise>
122 <table id="classifiernodelist">
123 <xsl:for-each select='classifierNode'>
124 <xsl:call-template name="processNodeChildren">
125 <xsl:with-param name='collName' select='$collName'/>
126 <xsl:with-param name='serviceName' select='$serviceName'/>
127 </xsl:call-template>
128 </xsl:for-each>
129 </table>
130 </xsl:otherwise>
131 </xsl:choose>
132 </xsl:template>
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:otherwise>
216 we are in the other wise
217 </xsl:otherwise>
218 </xsl:choose>
219 </xsl:template>
220
221
222 <!-- processing for the recursive bit -->
223 <xsl:template match="classifierNode" mode="process-all-children">
224 <xsl:param name="collName"/>
225 <xsl:param name="serviceName"/>
226
227 <!--
228 ***mod: previous, simpler version
229 <xsl:call-template name="processNodeChildren">
230 <xsl:with-param name='collName' select='$collName'/>
231 <xsl:with-param name='serviceName' select='$serviceName'/>
232 </xsl:call-template>
233 -->
234
235 <xsl:choose>
236 <xsl:when test="@childType = 'HList'">
237 <xsl:call-template name="HList">
238 <xsl:with-param name='collName' select='$collName'/>
239 <xsl:with-param name='serviceName' select='$serviceName'/>
240 </xsl:call-template>
241 </xsl:when>
242 <xsl:otherwise>
243 <xsl:call-template name="processNodeChildren">
244 <xsl:with-param name='collName' select='$collName'/>
245 <xsl:with-param name='serviceName' select='$serviceName'/>
246 </xsl:call-template>
247 </xsl:otherwise>
248 </xsl:choose>
249
250
251 </xsl:template>
252
253
254
255 <!-- 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 -->
256 <xsl:template name="documentNodeWrapper">
257 <xsl:param name="collName"/>
258 <xsl:param name="serviceName"/>
259 <xsl:apply-templates select=".">
260 <xsl:with-param name="collName" select="$collName"/>
261 <xsl:with-param name="serviceName" select="$serviceName"/>
262 </xsl:apply-templates>
263 <!-- The berry (optional) -->
264 <td>
265 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
266 </td>
267 <xsl:call-template name="documentNodePost"/>
268 </xsl:template>
269
270 <!--
271 TEMPLATE FOR DOCUMENTS
272 -->
273 <xsl:template match="documentNode"><!-- priority="3"-->
274 <!-- The book icon -->
275 <td>
276 <img>
277 <xsl:attribute name="src">
278 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/>
279 </xsl:attribute>
280 </img>
281 </td>
282 <!-- The document link -->
283 <td>
284 <a>
285 <xsl:choose>
286 <xsl:when test="@docType = 'paged'">
287 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/></xsl:attribute>
288 </xsl:when>
289 <xsl:otherwise>
290 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;ed=1</xsl:attribute>
291 </xsl:otherwise>
292 </xsl:choose>
293 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
294 </a>
295 </td>
296 <!-- The berry (optional) -->
297 <td>
298 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
299 </td>
300 </xsl:template>
301
302 <xsl:template name="documentNodePost">
303 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
304 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude']">
305 <xsl:call-template name="mapFeaturesIcon"/>
306 </xsl:if>
307 </xsl:if>
308
309
310 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
311 <xsl:if test=" metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'] and metadataList/metadata[@name = 'PhotoType']='Panorama'">
312 <xsl:call-template name="panoramaViewerFeaturesIcon"/>
313 </xsl:if>
314 </xsl:if>
315
316 </xsl:template>
317
318 <!--
319 TEMPLATE FOR GROUPS OF DOCUMENTS
320 -->
321 <xsl:template match="classifierNode[@classifierStyle = 'HList']" >
322 <gsf:link type="classifier" style="static">
323 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
324 </gsf:link>
325 </xsl:template>
326
327 <xsl:template match="classifierNode">
328 <!-- Bookshelf icon -->
329 <td>
330 <gsf:link type="classifier" style="static">
331 <img>
332 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute>
333 </img>
334 </gsf:link>
335 </td>
336 <!-- Link title -->
337 <td>
338 <gsf:link type="classifier">
339 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
340 </gsf:link>
341 </td>
342 </xsl:template>
343
344
345 <xsl:template name="classifierPre">
346 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
347 <xsl:call-template name="mapFeaturesJSONNodes"/>
348 </xsl:if>
349
350 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
351 <xsl:call-template name="panoramaViewerFeaturesJSONNodes"/>
352 </xsl:if>
353
354 </xsl:template>
355
356 <xsl:template name="classifierResultsPre">
357 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
358 <xsl:call-template name="mapFeaturesMap"/>
359 </xsl:if>
360 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
361 <xsl:call-template name="panoramaViewerFeatures"/>
362 </xsl:if>
363 </xsl:template>
364
365 <xsl:template match="/page/xsltparams">
366 <!-- suppress xsltparam block in page -->
367 </xsl:template>
368
369</xsl:stylesheet>
370
Note: See TracBrowser for help on using the repository browser.