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

Last change on this file since 33140 was 33125, checked in by wy59, 5 years ago

First commit to do with adding support for the Coordinate metadata newly introduced. It doesn't yet replace Latitude and Longitude meta, but coexists with that. For docs that only contain lat and lng meta, the code will still behave as before. For docs that contain the new coord meta, the changes in this commit will be able to display markers on the map based on this. Updates include: doc.pm perl code now stores Coordinate and Coordshort meta when it encounters GPS.mapOverlay metadata created by the doc editor. Update to JS code: update to the rawquery search performed to get all docs whose coord info occur within the bounds of the displayed map, and updates to all the js and xsl code that used to only work with lat and lng before now ADDITIONALLY work with coord meta.

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 <!-- TODO: anything equivalent for Coordinate metadata? -->
308 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
309 <xsl:if test=" metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'] and metadataList/metadata[@name = 'PhotoType']='Panorama'">
310 <xsl:call-template name="panoramaViewerFeaturesIcon"/>
311 </xsl:if>
312 </xsl:if>
313
314 </xsl:template>
315
316 <!--
317 TEMPLATE FOR GROUPS OF DOCUMENTS
318 -->
319 <xsl:template match="classifierNode[@classifierStyle = 'HList']" >
320 <gsf:link type="classifier" style="static">
321 <gsf:metadata name="Title"/>
322 </gsf:link>
323 </xsl:template>
324
325 <xsl:template match="classifierNode">
326 <td valign="top">
327 <gsf:link type="classifier" style="static">
328 <gsf:icon type="classifier"/>
329 </gsf:link>
330 </td>
331 <td valign="top">
332 <gsf:link type="classifier">
333 <gsf:metadata name="Title"/>
334 </gsf:link>
335 </td>
336 </xsl:template>
337
338
339 <xsl:template name="classifierPre">
340 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
341 <xsl:call-template name="mapFeaturesJSONNodes"/>
342 </xsl:if>
343
344 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
345 <xsl:call-template name="panoramaViewerFeaturesJSONNodes"/>
346 </xsl:if>
347
348 </xsl:template>
349
350 <xsl:template name="classifierResultsPre">
351 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
352 <xsl:call-template name="mapFeaturesMap"/>
353 </xsl:if>
354 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
355 <xsl:call-template name="panoramaViewerFeatures"/>
356 </xsl:if>
357 </xsl:template>
358
359 <xsl:template match="/page/xsltparams">
360 <!-- suppress xsltparam block in page -->
361 </xsl:template>
362
363</xsl:stylesheet>
364
Note: See TracBrowser for help on using the repository browser.