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

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

tidied up default templates for classifiers. added a new template classifierNodeLink to handle the logic of choosing which type or link the bookshelf should use - static, which opens a new page for that bookshelf, or javascript - uses the toggleSection method to open/close the section inplace. we are leaving bookshelves as static links to allow google to traverse the classifier and index all the documents

File size: 13.9 KB
RevLine 
[19856]1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
[31554]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"/>
[19856]15
[31554]16 <!-- set page title -->
17 <xsl:template name="pageTitle"><gslib:serviceName/></xsl:template>
[19856]18
[31554]19 <!-- set page breadcrumbs -->
20 <xsl:template name="breadcrumbs"><gslib:siteLink/><gslib:rightArrow/><gslib:collectionNameLinked/><gslib:rightArrow/></xsl:template>
[19988]21
[31554]22 <!-- optional cgi-params for links to document pages -->
23 <xsl:variable name="opt-doc-link-args"></xsl:variable>
[31563]24
[31554]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>
[24510]40
[31554]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>
[24340]56
[31554]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>
[24997]64
[31554]65 <div class="clear"><xsl:text> </xsl:text></div>
66 </xsl:template>
[19856]67
[31554]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>
[31552]92
[31554]93 <xsl:template name="HList">
94 <xsl:param name="collName"/>
95 <xsl:param name="serviceName"/>
96 <ul class="horizontalContainer">
97 <xsl:for-each select='classifierNode'>
98 <li>
99 <xsl:attribute name="class">
100 <xsl:if test="@nodeID = /page/pageRequest/paramList/param[@name = 'cl']/@value">selectedHorizontalClassifierNode </xsl:if>
101 <xsl:text>horizontalClassifierNode</xsl:text>
102 </xsl:attribute>
103 <xsl:apply-templates select='.'>
104 <xsl:with-param name='collName' select='$collName'/>
105 <xsl:with-param name='serviceName' select='$serviceName'/>
106 </xsl:apply-templates>
107 </li>
108 </xsl:for-each>
109 </ul>
110 <table id="classifiernodelist">
111 <xsl:for-each select='classifierNode'>
112 <xsl:call-template name="processNodeChildren">
113 <xsl:with-param name='collName' select='$collName'/>
114 <xsl:with-param name='serviceName' select='$serviceName'/>
115 </xsl:call-template>
116 </xsl:for-each>
117 </table>
118 </xsl:template>
[31552]119
[31554]120 <xsl:template name="processNodeChildren">
121 <xsl:param name="collName"/>
122 <xsl:param name="serviceName"/>
[31552]123
[31554]124 <xsl:choose>
125 <xsl:when test="@childType = 'VList' or @childType = 'DateList'">
126 <xsl:value-of select="util:storeString('prevMonth', '')"/>
127 <xsl:for-each select='classifierNode|documentNode'>
128 <tr>
129 <xsl:choose>
130 <xsl:when test="name()='documentNode'">
131 <xsl:if test="../@childType = 'DateList'">
132 <xsl:variable name="prevMonth"><xsl:value-of select="util:getString('prevMonth')"/></xsl:variable>
133 <xsl:variable name="currentDate"><gsf:metadata name="Date"/></xsl:variable>
134 <xsl:variable name="currentMonth"><xsl:value-of select="util:getDetailFromDate($currentDate, 'month', /page/@lang)"/></xsl:variable>
135 <xsl:value-of select="util:storeString('prevMonth', $currentMonth)"/>
136 <td>
137 <xsl:if test="not($currentMonth = $prevMonth)">
138 <xsl:value-of select="$currentMonth"/>
139 </xsl:if>
140 <xsl:text> </xsl:text>
141 </td>
142 </xsl:if>
143 <td>
144 <table id="div{@nodeID}"><tr>
145 <xsl:call-template name="documentNodeWrapper">
146 <xsl:with-param name='collName' select='$collName'/>
147 <xsl:with-param name='serviceName' select='$serviceName'/>
148 </xsl:call-template>
149 </tr></table>
150 </td>
151 </xsl:when>
152 <xsl:when test="name()='classifierNode' and @childType = 'VList'">
153 <td>
154 <table id="title{@nodeID}"><tr>
155 <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'">
156 <td class="headerTD">
[31563]157 <img id="toggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon turnstyleicon">
[31554]158 <xsl:attribute name="src">
159 <xsl:choose>
160 <xsl:when test="classifierNode or documentNode">
161 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
162 </xsl:when>
163 <xsl:otherwise>
164 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
165 </xsl:otherwise>
166 </xsl:choose>
167 </xsl:attribute>
168 </img>
169 </td>
170 </xsl:if>
171 <xsl:apply-templates select='.'>
172 <xsl:with-param name='collName' select='$collName'/>
173 <xsl:with-param name='serviceName' select='$serviceName'/>
174 </xsl:apply-templates>
175 </tr></table>
176 </td>
177 <xsl:if test="child::classifierNode or child::documentNode">
178 <!--recurse into the children-->
179 <tr><td><table class="childrenlist" id="div{@nodeID}">
180 <xsl:apply-templates select='.' mode='process-all-children'>
181 <xsl:with-param name='collName' select='$collName'/>
182 <xsl:with-param name='serviceName' select='$serviceName'/>
183 </xsl:apply-templates>
184 </table></td></tr>
185 </xsl:if>
186 </xsl:when>
187 <xsl:otherwise>Unknown classifier style specified</xsl:otherwise>
188 </xsl:choose>
189 </tr>
190 </xsl:for-each>
191 </xsl:when>
192 <xsl:when test="@childType = 'HTML'">
193 <xsl:variable name="URL"><xsl:value-of select="documentNode/@nodeID"/></xsl:variable>
194 <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>
195 </xsl:when>
196 <xsl:otherwise>
197 we are in the other wise
198 </xsl:otherwise>
199 </xsl:choose>
200 </xsl:template>
[31552]201
202
[31554]203 <!-- processing for the recursive bit -->
204 <xsl:template match="classifierNode" mode="process-all-children">
205 <xsl:param name="collName"/>
206 <xsl:param name="serviceName"/>
207 <xsl:call-template name="processNodeChildren">
208 <xsl:with-param name='collName' select='$collName'/>
209 <xsl:with-param name='serviceName' select='$serviceName'/>
210 </xsl:call-template>
211 </xsl:template>
[31552]212
213
214
[31554]215 <!-- 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 -->
216 <xsl:template name="documentNodeWrapper">
217 <xsl:param name="collName"/>
218 <xsl:param name="serviceName"/>
219 <xsl:apply-templates select=".">
220 <xsl:with-param name="collName" select="$collName"/>
221 <xsl:with-param name="serviceName" select="$serviceName"/>
222 </xsl:apply-templates>
223 <!-- The berry (optional) -->
224 <td>
225 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
226 </td>
227 <xsl:call-template name="documentNodePost"/>
228 </xsl:template>
[31552]229
[31554]230 <!--
231 TEMPLATE FOR DOCUMENTS
232 -->
233 <xsl:template match="documentNode"><!-- priority="3"-->
234 <!-- The book icon -->
235 <td>
236 <img>
237 <xsl:attribute name="src">
238 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/>
239 </xsl:attribute>
240 </img>
241 </td>
242 <!-- The document link -->
243 <td>
244 <a>
245 <xsl:choose>
246 <xsl:when test="@docType = 'paged'">
247 <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>
248 </xsl:when>
249 <xsl:otherwise>
250 <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>
251 </xsl:otherwise>
252 </xsl:choose>
253 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
254 </a>
255 </td>
256 <!-- The berry (optional) -->
257 <td>
258 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
259 </td>
260 </xsl:template>
[19856]261
[31554]262 <xsl:template name="documentNodePost">
263 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
264 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude']">
265 <xsl:call-template name="mapFeaturesIcon"/>
266 </xsl:if>
267 </xsl:if>
[31552]268
269
[31554]270 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
271 <xsl:if test=" metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'] and metadataList/metadata[@name = 'PhotoType']='Panorama'">
272 <xsl:call-template name="panoramaViewerFeaturesIcon"/>
273 </xsl:if>
274 </xsl:if>
[31552]275
[31554]276 </xsl:template>
[31552]277
[31554]278 <!--
279 TEMPLATE FOR GROUPS OF DOCUMENTS
280 -->
281 <xsl:template match="classifierNode[@classifierStyle = 'HList']" >
[31563]282 <gsf:link type="classifier" style="static">
[31554]283 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
284 </gsf:link>
285 </xsl:template>
[31548]286
[31563]287 <xsl:template match="classifierNode">
[31554]288 <!-- Bookshelf icon -->
289 <td>
[31563]290 <gsf:link type="classifier" style="static">
[31554]291 <img>
292 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute>
293 </img>
[31563]294 </gsf:link>
[31554]295 </td>
296 <!-- Link title -->
297 <td>
[31563]298 <gsf:link type="classifier">
[31554]299 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
[31563]300 </gsf:link>
[31554]301 </td>
302 </xsl:template>
303
[31563]304 <xsl:template name="classifierNodeLink">
305 <xsl:param name="link-type">dynamic</xsl:param>
306 <xsl:param name="node-id"></xsl:param>
307 <xsl:variable name="final-link-type">
308 <xsl:choose>
309 <xsl:when test="$link-type='static'">static</xsl:when>
310 <xsl:when test="$link-type='javascript'">javascript</xsl:when>
311 <xsl:when test="@classifierStyle = 'HList'">static</xsl:when>
312 <xsl:when test="not(/page/pageResponse/format[@type='browse']/gsf:option[@name='turnstyleClassifiers']) or /page/pageResponse/format[@type='browse']/gsf:option[@name='turnstyleClassifiers']/@value='true'">javascript</xsl:when>
313 <xsl:otherwise>static</xsl:otherwise>
314 </xsl:choose>
315 </xsl:variable>
316 <xsl:choose>
317 <xsl:when test="$final-link-type='static'">
318 <xsl:value-of select='$library_name'/>/collection/<xsl:value-of select='/page/pageResponse/collection/@name'/>/browse/<xsl:choose><xsl:when test="$node-id"><xsl:value-of select="$node-id"/></xsl:when><xsl:otherwise><xsl:value-of select='util:replace(@nodeID, ".", "/")'/></xsl:otherwise></xsl:choose>
319 </xsl:when>
320 <xsl:otherwise>javascript:toggleSection('<xsl:value-of select="@nodeID"/>');</xsl:otherwise>
321 </xsl:choose>
322 </xsl:template>
323
324
[31554]325 <xsl:template name="classifierPre">
326 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
327 <xsl:call-template name="mapFeaturesJSONNodes"/>
328 </xsl:if>
329
330 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
331 <xsl:call-template name="panoramaViewerFeaturesJSONNodes"/>
332 </xsl:if>
333
334 </xsl:template>
335
336 <xsl:template name="classifierResultsPre">
337 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
338 <xsl:call-template name="mapFeaturesMap"/>
339 </xsl:if>
340 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
341 <xsl:call-template name="panoramaViewerFeatures"/>
342 </xsl:if>
343 </xsl:template>
344
345 <xsl:template match="/page/xsltparams">
346 <!-- suppress xsltparam block in page -->
347 </xsl:template>
[31552]348
[19856]349</xsl:stylesheet>
350
Note: See TracBrowser for help on using the repository browser.