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

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

want to bold the selected node in each horizintal row. for displaying the month down the side in a datelist, assume have classified on the first date

File size: 13.5 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 <xsl:when test="@childType = 'VList' or @childType = 'DateList'">
140 <xsl:value-of select="util:storeString('prevMonth', '')"/>
141 <xsl:for-each select='classifierNode|documentNode'>
142 <tr>
143 <xsl:choose>
144 <xsl:when test="name()='documentNode'">
145 <xsl:if test="../@childType = 'DateList'">
146 <xsl:variable name="prevMonth"><xsl:value-of select="util:getString('prevMonth')"/></xsl:variable>
147 <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...-->
148 <xsl:variable name="currentMonth"><xsl:value-of select="util:getDetailFromDate($currentDate, 'month', /page/@lang)"/></xsl:variable>
149 <xsl:value-of select="util:storeString('prevMonth', $currentMonth)"/>
150 <td>
151 <xsl:if test="not($currentMonth = $prevMonth)">
152 <xsl:value-of select="$currentMonth"/>
153 </xsl:if>
154 <xsl:text> </xsl:text>
155 </td>
156 </xsl:if>
157 <td>
158 <table id="div{@nodeID}"><tr>
159 <xsl:call-template name="documentNodeWrapper">
160 <xsl:with-param name='collName' select='$collName'/>
161 <xsl:with-param name='serviceName' select='$serviceName'/>
162 </xsl:call-template>
163 </tr></table>
164 </td>
165 </xsl:when>
166 <xsl:when test="name()='classifierNode' and @childType = 'VList'">
167 <td>
168 <table id="title{@nodeID}"><tr>
169 <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'">
170 <td class="headerTD">
171 <img id="toggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon turnstyleicon">
172 <xsl:attribute name="src">
173 <xsl:choose>
174 <xsl:when test="classifierNode or documentNode">
175 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
176 </xsl:when>
177 <xsl:otherwise>
178 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
179 </xsl:otherwise>
180 </xsl:choose>
181 </xsl:attribute>
182 </img>
183 </td>
184 </xsl:if>
185 <xsl:apply-templates select='.'>
186 <xsl:with-param name='collName' select='$collName'/>
187 <xsl:with-param name='serviceName' select='$serviceName'/>
188 </xsl:apply-templates>
189 </tr></table>
190 </td>
191 <xsl:if test="child::classifierNode or child::documentNode">
192 <!--recurse into the children-->
193 <tr><td><table class="childrenlist" id="div{@nodeID}">
194 <xsl:apply-templates select='.' mode='process-all-children'>
195 <xsl:with-param name='collName' select='$collName'/>
196 <xsl:with-param name='serviceName' select='$serviceName'/>
197 </xsl:apply-templates>
198 </table></td></tr>
199 </xsl:if>
200 </xsl:when>
201 <xsl:otherwise>Unknown classifier style specified</xsl:otherwise>
202 </xsl:choose>
203 </tr>
204 </xsl:for-each>
205 </xsl:when>
206 <xsl:when test="@childType = 'HTML'">
207 <xsl:variable name="URL"><xsl:value-of select="documentNode/@nodeID"/></xsl:variable>
208 <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>
209 </xsl:when>
210 <xsl:otherwise>
211 we are in the other wise
212 </xsl:otherwise>
213 </xsl:choose>
214 </xsl:template>
215
216
217 <!-- processing for the recursive bit -->
218 <xsl:template match="classifierNode" mode="process-all-children">
219 <xsl:param name="collName"/>
220 <xsl:param name="serviceName"/>
221 <xsl:call-template name="processNodeChildren">
222 <xsl:with-param name='collName' select='$collName'/>
223 <xsl:with-param name='serviceName' select='$serviceName'/>
224 </xsl:call-template>
225 </xsl:template>
226
227
228
229 <!-- 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 -->
230 <xsl:template name="documentNodeWrapper">
231 <xsl:param name="collName"/>
232 <xsl:param name="serviceName"/>
233 <xsl:apply-templates select=".">
234 <xsl:with-param name="collName" select="$collName"/>
235 <xsl:with-param name="serviceName" select="$serviceName"/>
236 </xsl:apply-templates>
237 <!-- The berry (optional) -->
238 <td>
239 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
240 </td>
241 <xsl:call-template name="documentNodePost"/>
242 </xsl:template>
243
244 <!--
245 TEMPLATE FOR DOCUMENTS
246 -->
247 <xsl:template match="documentNode"><!-- priority="3"-->
248 <!-- The book icon -->
249 <td>
250 <img>
251 <xsl:attribute name="src">
252 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/>
253 </xsl:attribute>
254 </img>
255 </td>
256 <!-- The document link -->
257 <td>
258 <a>
259 <xsl:choose>
260 <xsl:when test="@docType = 'paged'">
261 <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>
262 </xsl:when>
263 <xsl:otherwise>
264 <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>
265 </xsl:otherwise>
266 </xsl:choose>
267 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
268 </a>
269 </td>
270 <!-- The berry (optional) -->
271 <td>
272 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
273 </td>
274 </xsl:template>
275
276 <xsl:template name="documentNodePost">
277 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
278 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude']">
279 <xsl:call-template name="mapFeaturesIcon"/>
280 </xsl:if>
281 </xsl:if>
282
283
284 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
285 <xsl:if test=" metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'] and metadataList/metadata[@name = 'PhotoType']='Panorama'">
286 <xsl:call-template name="panoramaViewerFeaturesIcon"/>
287 </xsl:if>
288 </xsl:if>
289
290 </xsl:template>
291
292 <!--
293 TEMPLATE FOR GROUPS OF DOCUMENTS
294 -->
295 <xsl:template match="classifierNode[@classifierStyle = 'HList']" >
296 <gsf:link type="classifier" style="static">
297 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
298 </gsf:link>
299 </xsl:template>
300
301 <xsl:template match="classifierNode">
302 <!-- Bookshelf icon -->
303 <td>
304 <gsf:link type="classifier" style="static">
305 <img>
306 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute>
307 </img>
308 </gsf:link>
309 </td>
310 <!-- Link title -->
311 <td>
312 <gsf:link type="classifier">
313 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
314 </gsf:link>
315 </td>
316 </xsl:template>
317
318
319 <xsl:template name="classifierPre">
320 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
321 <xsl:call-template name="mapFeaturesJSONNodes"/>
322 </xsl:if>
323
324 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
325 <xsl:call-template name="panoramaViewerFeaturesJSONNodes"/>
326 </xsl:if>
327
328 </xsl:template>
329
330 <xsl:template name="classifierResultsPre">
331 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
332 <xsl:call-template name="mapFeaturesMap"/>
333 </xsl:if>
334 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
335 <xsl:call-template name="panoramaViewerFeatures"/>
336 </xsl:if>
337 </xsl:template>
338
339 <xsl:template match="/page/xsltparams">
340 <!-- suppress xsltparam block in page -->
341 </xsl:template>
342
343</xsl:stylesheet>
344
Note: See TracBrowser for help on using the repository browser.