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

Last change on this file since 31552 was 31552, checked in by kjdon, 7 years ago

moved all templates from classifiertools to pages/classifier

File size: 14.6 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 <!-- the page content -->
25 <xsl:template match="/page/pageResponse">
26 <xsl:call-template name="classifierPre"/>
27
28 <script type="text/javascript" src="interfaces/{$interface_name}/js/classifier_scripts.js"><xsl:text> </xsl:text></script>
29 <script type="text/javascript">$(window).load(openStoredClassifiers);</script>
30
31 <!-- this right sidebar -->
32 <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)))">
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="$documentBasketOn">
41 <gslib:documentBasket/>
42 <xsl:text> </xsl:text>
43 </xsl:if>
44 </div>
45 </xsl:if>
46
47 <!--
48 show the clasifier results -
49 you can change the appearance of the results by editing
50 the two templates at the bottom of this file
51 -->
52 <div id="results">
53 <xsl:variable name="collName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
54 <xsl:variable name="serviceName"><xsl:value-of select="service/@name"/></xsl:variable>
55
56 <xsl:call-template name="classifierResultsPre"/>
57
58 <xsl:apply-templates select="classifier">
59 <xsl:with-param name="collName" select="$collName"/>
60 <xsl:with-param name="serviceName" select="$serviceName"/>
61 </xsl:apply-templates>
62 </div>
63
64 <div class="clear"><xsl:text> </xsl:text></div>
65 </xsl:template>
66
67 <xsl:template match="classifier">
68 <xsl:param name="collName"/>
69 <xsl:param name="serviceName"/>
70 <div id="classifiers">
71 <xsl:variable name="cl_name"><xsl:value-of select="@name"/></xsl:variable>
72 <xsl:choose>
73 <xsl:when test="@childType = 'HList'">
74 <xsl:call-template name="HList">
75 <xsl:with-param name='collName' select='$collName'/>
76 <xsl:with-param name='serviceName' select='$serviceName'/>
77 </xsl:call-template>
78 </xsl:when>
79 <xsl:otherwise>
80 <table id="classifiernodelist">
81 <xsl:text> </xsl:text>
82 <xsl:call-template name="processNodeChildren">
83 <xsl:with-param name='collName' select='$collName'/>
84 <xsl:with-param name='serviceName' select='$serviceName'/>
85 </xsl:call-template>
86 </table>
87 </xsl:otherwise>
88 </xsl:choose>
89 </div>
90 </xsl:template>
91
92 <xsl:template name="HList">
93 <xsl:param name="collName"/>
94 <xsl:param name="serviceName"/>
95 <ul class="horizontalContainer">
96 <xsl:for-each select='classifierNode'>
97 <li>
98 <xsl:attribute name="class">
99 <xsl:if test="@nodeID = /page/pageRequest/paramList/param[@name = 'cl']/@value">selectedHorizontalClassifierNode </xsl:if>
100 <xsl:text>horizontalClassifierNode</xsl:text>
101 </xsl:attribute>
102 <xsl:apply-templates select='.'>
103 <xsl:with-param name='collName' select='$collName'/>
104 <xsl:with-param name='serviceName' select='$serviceName'/>
105 </xsl:apply-templates>
106 </li>
107 </xsl:for-each>
108 </ul>
109 <table id="classifiernodelist">
110 <xsl:for-each select='classifierNode'>
111 <xsl:call-template name="processNodeChildren">
112 <xsl:with-param name='collName' select='$collName'/>
113 <xsl:with-param name='serviceName' select='$serviceName'/>
114 </xsl:call-template>
115 </xsl:for-each>
116 </table>
117 </xsl:template>
118
119 <xsl:template name="processNodeChildren">
120 <xsl:param name="collName"/>
121 <xsl:param name="serviceName"/>
122
123 <xsl:choose>
124 <xsl:when test="@childType = 'VList' or @childType = 'DateList'">
125 <xsl:value-of select="util:storeString('prevMonth', '')"/>
126 <xsl:for-each select='classifierNode|documentNode'>
127 <tr>
128 <xsl:choose>
129 <xsl:when test="name()='documentNode'">
130 <xsl:if test="../@childType = 'DateList'">
131 <xsl:variable name="prevMonth"><xsl:value-of select="util:getString('prevMonth')"/></xsl:variable>
132 <xsl:variable name="currentDate"><gsf:metadata name="Date"/></xsl:variable>
133 <xsl:variable name="currentMonth"><xsl:value-of select="util:getDetailFromDate($currentDate, 'month', /page/@lang)"/></xsl:variable>
134 <xsl:value-of select="util:storeString('prevMonth', $currentMonth)"/>
135 <td>
136 <xsl:if test="not($currentMonth = $prevMonth)">
137 <xsl:value-of select="$currentMonth"/>
138 </xsl:if>
139 <xsl:text> </xsl:text>
140 </td>
141 </xsl:if>
142 <td>
143 <table id="div{@nodeID}"><tr>
144 <xsl:call-template name="documentNodeWrapper">
145 <xsl:with-param name='collName' select='$collName'/>
146 <xsl:with-param name='serviceName' select='$serviceName'/>
147 </xsl:call-template>
148 </tr></table>
149 </td>
150 </xsl:when>
151 <xsl:when test="name()='classifierNode' and @childType = 'VList'">
152 <td>
153 <table id="title{@nodeID}"><tr>
154 <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'">
155 <td class="headerTD">
156 <img id="toggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
157 <xsl:attribute name="src">
158 <xsl:choose>
159 <xsl:when test="classifierNode or documentNode">
160 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
161 </xsl:when>
162 <xsl:otherwise>
163 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
164 </xsl:otherwise>
165 </xsl:choose>
166 </xsl:attribute>
167 </img>
168 </td>
169 </xsl:if>
170 <xsl:apply-templates select='.'>
171 <xsl:with-param name='collName' select='$collName'/>
172 <xsl:with-param name='serviceName' select='$serviceName'/>
173 </xsl:apply-templates>
174 </tr></table>
175 </td>
176 <xsl:if test="child::classifierNode or child::documentNode">
177 <!--recurse into the children-->
178 <tr><td><table class="childrenlist" id="div{@nodeID}">
179 <xsl:apply-templates select='.' mode='process-all-children'>
180 <xsl:with-param name='collName' select='$collName'/>
181 <xsl:with-param name='serviceName' select='$serviceName'/>
182 </xsl:apply-templates>
183 </table></td></tr>
184 </xsl:if>
185 </xsl:when>
186 <xsl:otherwise>Unknown classifier style specified</xsl:otherwise>
187 </xsl:choose>
188 </tr>
189 </xsl:for-each>
190 </xsl:when>
191 <xsl:when test="@childType = 'HTML'">
192 <xsl:variable name="URL"><xsl:value-of select="documentNode/@nodeID"/></xsl:variable>
193 <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>
194 </xsl:when>
195 <xsl:otherwise>
196 we are in the other wise
197 </xsl:otherwise>
198 </xsl:choose>
199 </xsl:template>
200
201
202 <!-- processing for the recursive bit -->
203 <xsl:template match="classifierNode" mode="process-all-children">
204 <xsl:param name="collName"/>
205 <xsl:param name="serviceName"/>
206 <xsl:call-template name="processNodeChildren">
207 <xsl:with-param name='collName' select='$collName'/>
208 <xsl:with-param name='serviceName' select='$serviceName'/>
209 </xsl:call-template>
210 </xsl:template>
211
212
213
214 <!-- 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 -->
215 <xsl:template name="documentNodeWrapper">
216 <xsl:param name="collName"/>
217 <xsl:param name="serviceName"/>
218 <xsl:apply-templates select=".">
219 <xsl:with-param name="collName" select="$collName"/>
220 <xsl:with-param name="serviceName" select="$serviceName"/>
221 </xsl:apply-templates>
222 <!-- The berry (optional) -->
223 <td>
224 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
225 </td>
226 <xsl:call-template name="documentNodePost"/>
227 </xsl:template>
228
229 <!--
230 TEMPLATE FOR DOCUMENTS
231 -->
232 <xsl:template match="documentNode"><!-- priority="3"-->
233 <!-- The book icon -->
234 <td>
235 <img>
236 <xsl:attribute name="src">
237 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/>
238 </xsl:attribute>
239 </img>
240 </td>
241 <!-- The document link -->
242 <td>
243 <a>
244 <xsl:choose>
245 <xsl:when test="@docType = 'paged'">
246 <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>
247 </xsl:when>
248 <xsl:otherwise>
249 <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>
250 </xsl:otherwise>
251 </xsl:choose>
252 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
253 </a>
254 </td>
255 <!-- The berry (optional) -->
256 <td>
257 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
258 </td>
259 </xsl:template>
260
261 <xsl:template name="documentNodePost">
262 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
263 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude']">
264 <xsl:call-template name="mapFeaturesIcon"/>
265 </xsl:if>
266 </xsl:if>
267
268
269 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
270 <xsl:if test=" metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'] and metadataList/metadata[@name = 'PhotoType']='Panorama'">
271 <xsl:call-template name="panoramaViewerFeaturesIcon"/>
272 </xsl:if>
273 </xsl:if>
274
275 </xsl:template>
276
277 <!--
278 TEMPLATE FOR GROUPS OF DOCUMENTS
279 -->
280 <xsl:template match="classifierNode[@classifierStyle = 'HList']" >
281 <gsf:link type="classifier">
282 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
283 </gsf:link>
284 </xsl:template>
285
286 <xsl:template match="classifierNode"><!-- priority="3"-->
287
288 <!--<table id="title{@nodeID}"><tbody><tr>-->
289 <!-- Bookshelf icon -->
290 <td>
291 <img>
292 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute>
293 </img>
294 </td>
295 <!-- Link title -->
296 <td>
297 <a href="javascript:toggleSection('{@nodeID}');">
298 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
299 </a>
300 </td>
301 <!--</tr></tbody></table>-->
302
303 <!-- Show any documents or sub-groups in this group -->
304 <!-- <xsl:if test="documentNode|classifierNode">
305 <div id="div{@nodeID}" class="classifierContainer">
306 <table>
307 <xsl:for-each select="documentNode|classifierNode">
308 <tr>
309 <xsl:apply-templates select="."/>
310 </tr>
311 </xsl:for-each>
312 </table>
313 </div>
314 </xsl:if>-->
315 </xsl:template>
316
317 <xsl:template name="classifierPre">
318 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
319 <xsl:call-template name="mapFeaturesJSONNodes"/>
320 </xsl:if>
321
322 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
323 <xsl:call-template name="panoramaViewerFeaturesJSONNodes"/>
324 </xsl:if>
325
326 </xsl:template>
327
328 <xsl:template name="classifierResultsPre">
329 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
330 <xsl:call-template name="mapFeaturesMap"/>
331 </xsl:if>
332 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
333 <xsl:call-template name="panoramaViewerFeatures"/>
334 </xsl:if>
335 </xsl:template>
336
337
338 <xsl:template name="bookshelfimg">
339 <xsl:param name="alt"/>
340 <xsl:param name="title"/>
341 <img border="0" width="20" height="16" src="interfaces/default/images/bshelf.gif" alt="{$alt}" title="{$title}"/>
342 </xsl:template>
343
344
345 <xsl:template match="/page/xsltparams">
346 <!-- suppress xsltparam block in page -->
347 </xsl:template>
348
349 <!-- is this ever used? copied from classifier tools and renamed xxxOld -->
350 <xsl:template match="documentNodeOld">
351 <xsl:param name="collName"/>
352 <xsl:param name="serviceName"/>
353 <a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@nodeID}&amp;dt={@docType}&amp;p.a=b&amp;p.s={$serviceName}"><xsl:apply-templates select="." mode="displayNodeIcon"/></a><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
354 </xsl:template>
355
356
357 <!-- icon + title template-->
358 <!-- is this ever used??? copied from classifier tools and renamed xxxOld??? -->
359 <xsl:template match="classifierNodeOld">
360 <xsl:param name="collName"/>
361 <xsl:param name="serviceName"/>
362 <a><xsl:attribute name='href'><xsl:value-of select='$library_name'/>?a=b&amp;rt=r&amp;s=<xsl:value-of select='$serviceName'/>&amp;c=<xsl:value-of select='$collName'/>&amp;cl=<xsl:value-of select='@nodeID'/><xsl:if test="classifierNode|documentNode">.pr</xsl:if></xsl:attribute><xsl:call-template name="bookshelfimg"/></a><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
363 </xsl:template>
364
365
366</xsl:stylesheet>
367
Note: See TracBrowser for help on using the repository browser.