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

Last change on this file since 33172 was 33148, checked in by wy59, 5 years ago
  1. Untested changes to Panorama viewer related xsl and js files to incorporate Coordinate meta wherever Latitude and Longitude meta was referred to. There's no way to test as we have no existing or tutorial collection making use of the Panorama Viewer to hand, however, a lot of the code added to deal with Coordinates is identical to other Coordinate insertions where Lat Long was used in classifier.xsl, document.xsl and map-tools.xsl and map-scripts.js. 2. Added new and removed finished TODOs.
File size: 13.4 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">
274 <td valign="top">
275 <gsf:link type="document">
276 <gsf:icon type="document"/>
277 </gsf:link>
278 </td>
279 <td valign="top">
280 <gsf:link type="source">
281 <gsf:choose-metadata>
282 <gsf:metadata name="thumbicon"/>
283 <gsf:metadata name="srcicon"/>
284 </gsf:choose-metadata>
285 </gsf:link>
286 </td>
287 <td valign="top">
288 <gsf:link type="document">
289 <!-- Defined in the global format statement -->
290 <xsl:call-template name="choose-title"/>
291 <gsf:switch>
292 <gsf:metadata name="Source"/>
293 <gsf:when test="exists"><br/><i>(<gsf:metadata name="Source"/>)</i></gsf:when>
294 </gsf:switch>
295 </gsf:link>
296 </td>
297 </xsl:template>
298
299
300 <xsl:template name="documentNodePost">
301 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
302 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude' or @name='Coordinate']">
303 <xsl:call-template name="mapFeaturesIcon"/>
304 </xsl:if>
305 </xsl:if>
306
307 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
308 <xsl:if test="metadataList/metadata[@name = 'PhotoType']='Panorama' and ( metadataList/metadata[@name = 'Coordinate'] or ( metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']))">
309 <xsl:call-template name="panoramaViewerFeaturesIcon"/>
310 </xsl:if>
311 </xsl:if>
312
313 </xsl:template>
314
315 <!--
316 TEMPLATE FOR GROUPS OF DOCUMENTS
317 -->
318 <xsl:template match="classifierNode[@classifierStyle = 'HList']" >
319 <gsf:link type="classifier" style="static">
320 <gsf:metadata name="Title"/>
321 </gsf:link>
322 </xsl:template>
323
324 <xsl:template match="classifierNode">
325 <td valign="top">
326 <gsf:link type="classifier" style="static">
327 <gsf:icon type="classifier"/>
328 </gsf:link>
329 </td>
330 <td valign="top">
331 <gsf:link type="classifier">
332 <gsf:metadata name="Title"/>
333 </gsf:link>
334 </td>
335 </xsl:template>
336
337
338 <xsl:template name="classifierPre">
339 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
340 <xsl:call-template name="mapFeaturesJSONNodes"/>
341 </xsl:if>
342
343 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
344 <xsl:call-template name="panoramaViewerFeaturesJSONNodes"/>
345 </xsl:if>
346
347 </xsl:template>
348
349 <xsl:template name="classifierResultsPre">
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="mapFeaturesMap"/>
352 </xsl:if>
353 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
354 <xsl:call-template name="panoramaViewerFeatures"/>
355 </xsl:if>
356 </xsl:template>
357
358 <xsl:template match="/page/xsltparams">
359 <!-- suppress xsltparam block in page -->
360 </xsl:template>
361
362</xsl:stylesheet>
363
Note: See TracBrowser for help on using the repository browser.