source: main/trunk/greenstone3/web/interfaces/default/transform/classifiertools.xsl@ 30868

Last change on this file since 30868 was 30560, checked in by kjdon, 8 years ago

added in basic handling for HTML type classifiers

File size: 9.3 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:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
7 extension-element-prefixes="java util"
8 exclude-result-prefixes="java util gsf">
9
10
11 <xsl:template match="classifier">
12 <xsl:param name="collName"/>
13 <xsl:param name="serviceName"/>
14 <div id="classifiers">
15 <xsl:variable name="cl_name"><xsl:value-of select="@name"/></xsl:variable>
16 <xsl:choose>
17 <xsl:when test="@childType = 'HList'">
18 <xsl:call-template name="HList">
19 <xsl:with-param name='collName' select='$collName'/>
20 <xsl:with-param name='serviceName' select='$serviceName'/>
21 </xsl:call-template>
22 </xsl:when>
23 <xsl:otherwise>
24 <table id="classifiernodelist">
25 <xsl:call-template name="processNodeChildren">
26 <xsl:with-param name='collName' select='$collName'/>
27 <xsl:with-param name='serviceName' select='$serviceName'/>
28 </xsl:call-template>
29 </table>
30 </xsl:otherwise>
31 </xsl:choose>
32 </div>
33 </xsl:template>
34
35 <!-- 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 -->
36 <xsl:template name="documentNodeWrapper">
37 <xsl:param name="collName"/>
38 <xsl:param name="serviceName"/>
39 <xsl:apply-templates select=".">
40 <xsl:with-param name="collName" select="$collName"/>
41 <xsl:with-param name="serviceName" select="$serviceName"/>
42 </xsl:apply-templates>
43 <!-- The berry (optional) -->
44 <td>
45 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
46 </td>
47 <xsl:call-template name="documentNodePost"/>
48 </xsl:template>
49
50
51 <xsl:template match="documentNode">
52 <xsl:param name="collName"/>
53 <xsl:param name="serviceName"/>
54 <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']"/>
55 </xsl:template>
56
57
58 <!-- icon + title template-->
59 <xsl:template match="classifierNode">
60 <xsl:param name="collName"/>
61 <xsl:param name="serviceName"/>
62 <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']"/>
63 </xsl:template>
64
65
66 <!-- processing for the recursive bit -->
67 <xsl:template match="classifierNode" mode="process-all-children">
68 <xsl:param name="collName"/>
69 <xsl:param name="serviceName"/>
70 <xsl:call-template name="processNodeChildren">
71 <xsl:with-param name='collName' select='$collName'/>
72 <xsl:with-param name='serviceName' select='$serviceName'/>
73 </xsl:call-template>
74 </xsl:template>
75
76 <xsl:template name="HList">
77 <xsl:param name="collName"/>
78 <xsl:param name="serviceName"/>
79 <ul class="horizontalContainer">
80 <xsl:for-each select='classifierNode'>
81 <li>
82 <xsl:attribute name="class">
83 <xsl:if test="@nodeID = /page/pageRequest/paramList/param[@name = 'cl']/@value">selectedHorizontalClassifierNode </xsl:if>
84 <xsl:text>horizontalClassifierNode</xsl:text>
85 </xsl:attribute>
86 <xsl:apply-templates select='.'>
87 <xsl:with-param name='collName' select='$collName'/>
88 <xsl:with-param name='serviceName' select='$serviceName'/>
89 </xsl:apply-templates>
90 </li>
91 </xsl:for-each>
92 </ul>
93 <table id="classifiernodelist">
94 <xsl:for-each select='classifierNode'>
95 <xsl:call-template name="processNodeChildren">
96 <xsl:with-param name='collName' select='$collName'/>
97 <xsl:with-param name='serviceName' select='$serviceName'/>
98 </xsl:call-template>
99 </xsl:for-each>
100 </table>
101 </xsl:template>
102
103 <xsl:template name="processNodeChildren">
104 <xsl:param name="collName"/>
105 <xsl:param name="serviceName"/>
106
107 <xsl:choose>
108 <xsl:when test="@childType = 'VList' or @childType = 'DateList'">
109 <xsl:value-of select="util:storeString('prevMonth', '')"/>
110 <xsl:for-each select='classifierNode|documentNode'>
111 <tr>
112 <xsl:choose>
113 <xsl:when test="name()='documentNode'">
114 <xsl:if test="../@childType = 'DateList'">
115 <xsl:variable name="prevMonth"><xsl:value-of select="util:getString('prevMonth')"/></xsl:variable>
116 <xsl:variable name="currentDate"><gsf:metadata name="Date"/></xsl:variable>
117 <xsl:variable name="currentMonth"><xsl:value-of select="util:getDetailFromDate($currentDate, 'month', /page/@lang)"/></xsl:variable>
118 <xsl:value-of select="util:storeString('prevMonth', $currentMonth)"/>
119 <td>
120 <xsl:if test="not($currentMonth = $prevMonth)">
121 <xsl:value-of select="$currentMonth"/>
122 </xsl:if>
123 <xsl:text> </xsl:text>
124 </td>
125 </xsl:if>
126 <td>
127 <table id="div{@nodeID}"><tr>
128 <xsl:call-template name="documentNodeWrapper">
129 <xsl:with-param name='collName' select='$collName'/>
130 <xsl:with-param name='serviceName' select='$serviceName'/>
131 </xsl:call-template>
132 </tr></table>
133 </td>
134 </xsl:when>
135 <xsl:when test="name()='classifierNode' and @childType = 'VList'">
136 <td>
137 <table id="title{@nodeID}"><tr>
138 <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'">
139 <td class="headerTD">
140 <img id="toggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
141 <xsl:attribute name="src">
142 <xsl:choose>
143 <xsl:when test="classifierNode or documentNode">
144 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
145 </xsl:when>
146 <xsl:otherwise>
147 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
148 </xsl:otherwise>
149 </xsl:choose>
150 </xsl:attribute>
151 </img>
152 </td>
153 </xsl:if>
154 <xsl:apply-templates select='.'>
155 <xsl:with-param name='collName' select='$collName'/>
156 <xsl:with-param name='serviceName' select='$serviceName'/>
157 </xsl:apply-templates>
158 </tr></table>
159 </td>
160 <xsl:if test="child::classifierNode or child::documentNode">
161 <!--recurse into the children-->
162 <tr><td><table class="childrenlist" id="div{@nodeID}">
163 <xsl:apply-templates select='.' mode='process-all-children'>
164 <xsl:with-param name='collName' select='$collName'/>
165 <xsl:with-param name='serviceName' select='$serviceName'/>
166 </xsl:apply-templates>
167 </table></td></tr>
168 </xsl:if>
169 </xsl:when>
170 <xsl:otherwise>Unknown classifier style specified</xsl:otherwise>
171 </xsl:choose>
172 </tr>
173 </xsl:for-each>
174 </xsl:when>
175 <xsl:when test="@childType = 'HTML'">
176 <xsl:variable name="URL"><xsl:value-of select="documentNode/@nodeID"/></xsl:variable>
177 <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>
178 </xsl:when>
179 <xsl:otherwise>
180 we are in the other wise
181 </xsl:otherwise>
182 </xsl:choose>
183 </xsl:template>
184
185 <xsl:template name="bookshelfimg">
186 <xsl:param name="alt"/>
187 <xsl:param name="title"/>
188 <img border="0" width="20" height="16" src="interfaces/default/images/bshelf.gif" alt="{$alt}" title="{$title}"/>
189 </xsl:template>
190
191 <xsl:template name="documentNodePost">
192 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
193 <xsl:if test="metadataList/metadata[@name='Latitude' or @name='Longitude']">
194 <xsl:call-template name="mapFeaturesIcon"/>
195 </xsl:if>
196 </xsl:if>
197
198
199 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
200 <xsl:if test=" metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'] and metadataList/metadata[@name = 'PhotoType']='Panorama'">
201 <xsl:call-template name="panoramaViewerFeaturesIcon"/>
202 </xsl:if>
203 </xsl:if>
204
205 </xsl:template>
206
207 <xsl:template name="mapFeaturesIcon">
208 <td style="padding-left:5px; padding-right:5px;" valign="top">
209 <a href="javascript:focusDocument('{@nodeID}');"><img src="interfaces/{$interface_name}/images/map_marker.png"/></a>
210 </td>
211 </xsl:template>
212
213
214 <xsl:template name="panoramaViewerFeaturesIcon">
215 <td style="padding-left:5px; padding-right:5px;" valign="top">
216 <a href="javascript:switchPanorama('{@nodeID}');">
217 <img src="interfaces/default/images/map_marker.png"/>
218 </a>
219 </td>
220 </xsl:template>
221
222</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.