source: main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl@ 24009

Last change on this file since 24009 was 24009, checked in by sjm84, 13 years ago

Another round of improvements to the oran skin including a tree view of the classifiers

File size: 12.0 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
14 <!-- style includes global params interface_name, library_name -->
15 <xsl:include href=".old/berrytools.xsl"/>
16 <xsl:include href="document-scripts.xsl"/>
17
18 <xsl:variable name="bookswitch">
19 <xsl:choose>
20 <xsl:when test="/page/pageRequest/paramList/param[@name='book']/@value">
21 <xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
22 </xsl:when>
23 <xsl:otherwise>off</xsl:otherwise>
24 </xsl:choose>
25 </xsl:variable>
26
27 <!-- set page title -->
28 <xsl:template name="pageTitle"><gslib:documentTitle/></xsl:template>
29
30 <!-- set page breadcrumbs -->
31 <xsl:template name="breadcrumbs">
32 <gslib:siteLink/><gslib:rightArrow/>
33 <gslib:collectionNameLinked/><gslib:rightArrow/>
34 <a>
35 <xsl:attribute name="href">
36 <xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="$collName"/>&amp;d=<xsl:value-of select="/page/pageResponse/document/documentNode[1]/@nodeID"/>&amp;dt=<xsl:value-of select="/page/pageResponse/document/documentNode/@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>
37 </xsl:attribute>
38 <xsl:variable name="documentTitleVar">
39 <gslib:documentTitle/>
40 </xsl:variable>
41 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.document')"/>
42 </a>
43 </xsl:template>
44
45 <xsl:template match="/">
46 <xsl:choose>
47 <!-- if this is the realistic books version of the page -->
48 <xsl:when test="$bookswitch = 'flashxml'">
49 <html>
50 <body>
51 <xsl:apply-templates select="/page/pageResponse/document"/>
52 </body>
53 </html>
54 </xsl:when>
55 <!-- if this is the regular version of the page -->
56 <xsl:otherwise>
57 <xsl:apply-imports/>
58 </xsl:otherwise>
59 </xsl:choose>
60 </xsl:template>
61
62 <!-- the page content -->
63 <xsl:template match="/page/pageResponse/document">
64 <xsl:if test="$bookswitch = 'off'">
65 <div id="bookdiv" style="visibility:hidden; height:0px;"><xsl:text> </xsl:text></div>
66 <!-- Add the Javascript that adds and removes highlighting ( *** in document-scripts.xsl *** ) -->
67 <xsl:call-template name="highlightingScript"/>
68
69 <!-- Add the Javascript that expands and collapses sections ( *** in document-scripts.xsl *** ) -->
70 <xsl:call-template name="expansionScript"/>
71
72 <!-- show the little berries for this document -->
73 <xsl:call-template name="documentBerryForDocumentPage"/>
74
75 <table id="rightSidebar">
76 <tr><td>
77 <xsl:call-template name="viewOptions"/>
78 </td></tr>
79 <tr><td>
80 <!-- the sidebar -->
81 <div id="contentsArea">
82 <!-- show the berry basket if it's turned on -->
83 <gslib:berryBasket/>
84
85 <!-- the book's cover image -->
86 <div id="coverImage"><gslib:coverImage/></div>
87
88 <!-- the contents -->
89 <div id="tableOfContents">
90 <xsl:apply-templates select="documentNode" mode="TOC"/>
91 </div>
92 </div>
93 </td></tr>
94 </table>
95 </xsl:if>
96
97 <!-- display the document -->
98 <xsl:choose>
99 <xsl:when test="@external != ''">
100 <xsl:call-template name="externalPage">
101 <xsl:with-param name="external" select="@external"/>
102 </xsl:call-template>
103 </xsl:when>
104 <xsl:when test="$bookswitch = 'flashxml'">
105 <xsl:apply-templates mode="flashxml"/>
106 </xsl:when>
107 <xsl:when test="$bookswitch = 'on'">
108 <!-- *** in document-scripts.xsl *** -->
109 <xsl:call-template name="realisticBooksScript"/>
110 </xsl:when>
111 <xsl:otherwise>
112 <div id="gs-document-text" class="documenttext">
113 <xsl:apply-templates select="documentNode" mode="document"/>
114 </div>
115 </xsl:otherwise>
116 </xsl:choose>
117
118 <div class="clear"><xsl:text> </xsl:text></div>
119 </xsl:template>
120
121 <!-- Highlight annotations if requested -->
122 <xsl:template match="annotation">
123 <xsl:choose>
124 <xsl:when test="/page/pageRequest/paramList/param[@name='hl' and @value='on']">
125 <span class="termHighlight"><xsl:value-of select="."/></span>
126 </xsl:when>
127 <xsl:otherwise>
128 <span class="noTermHighlight"><xsl:value-of select="."/></span>
129 </xsl:otherwise>
130 </xsl:choose>
131 </xsl:template>
132
133 <!-- This template is used to display the document content -->
134 <xsl:template match="documentNode" mode="document">
135 <a name="{@nodeID}"><xsl:text> </xsl:text></a>
136 <!-- Section header -->
137 <table><tr>
138 <!-- Expand/collapse button -->
139 <td class="headerTD">
140 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
141 <xsl:attribute name="src">
142 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
143 </xsl:attribute>
144 </img>
145 </td>
146
147 <!-- Automatic section number -->
148 <td class="headerTD">
149 <p>
150 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
151
152 <xsl:if test="util:hashToSectionId(@nodeID)">
153 <span class="sectionNumberSpan">
154 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
155 <xsl:text> </xsl:text>
156 </span>
157 </xsl:if>
158 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
159 </p>
160 </td>
161
162 <!-- "back to top" link -->
163 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
164 <td class="backToTop headerTD">
165 <a href="#top">
166 <xsl:text disable-output-escaping="yes">&#9650;</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.back_to_top')"/>
167 </a>
168 </td>
169 </xsl:if>
170 </tr></table>
171
172 <!-- Section text -->
173 <div id="doc{@nodeID}" class="sectionContainer" style="display:block;">
174 <xsl:for-each select="nodeContent">
175 <xsl:for-each select="node()">
176 <xsl:choose>
177 <xsl:when test="not(name())">
178 <xsl:value-of select="." disable-output-escaping="yes"/>
179 </xsl:when>
180 <xsl:otherwise>
181 <xsl:apply-templates select="."/>
182 </xsl:otherwise>
183 </xsl:choose>
184 </xsl:for-each>
185 </xsl:for-each>
186 <xsl:if test="documentNode">
187 <xsl:apply-templates select="documentNode" mode="document"/>
188 </xsl:if>
189 </div>
190
191 </xsl:template>
192
193 <!-- This template is used to display the table of contents -->
194 <xsl:template match="documentNode" mode="TOC">
195
196 <!-- check if this is the currently selected table of contents item -->
197 <xsl:variable name="isCurrent" select="nodeContent"/>
198
199 <!-- formulate the link -->
200 <xsl:variable name="contentsLink">
201 <xsl:value-of select='$library_name'/>?a=d&amp;c=<gslib:collectionNameShort/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="documentNode">.pr</xsl:if>&amp;sib=1
202 </xsl:variable>
203
204 <ul>
205 <table><tr>
206 <!-- The expand/collapse button (not displayed for the top level node) -->
207 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
208 <td>
209 <xsl:choose>
210 <xsl:when test="not(nodeContent and not(documentNode))">
211 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
212 <xsl:attribute name="src">
213 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
214 </xsl:attribute>
215 </img>
216 </xsl:when>
217 <xsl:otherwise>
218 <xsl:attribute name="class">emptyIcon</xsl:attribute>
219 </xsl:otherwise>
220 </xsl:choose>
221 </td>
222 </xsl:if>
223
224 <!-- The chapter/page icon -->
225 <td>
226 <img>
227 <xsl:if test="nodeContent and not(documentNode)">
228 <xsl:attribute name="class">leafNode</xsl:attribute>
229 </xsl:if>
230
231 <xsl:attribute name="src">
232 <xsl:choose>
233 <xsl:when test="nodeContent and not(documentNode)">
234 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
235 </xsl:when>
236 <xsl:otherwise>
237 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
238 </xsl:otherwise>
239 </xsl:choose>
240 </xsl:attribute>
241 </img>
242 </td>
243
244 <!-- The section name, links to the section in the document -->
245 <td>
246 <a>
247 <xsl:attribute name="href">#<xsl:value-of select="@nodeID"/></xsl:attribute>
248 <xsl:if test="util:hashToSectionId(@nodeID)">
249 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
250 <xsl:text> </xsl:text>
251 </xsl:if>
252 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
253 </a>
254 </td>
255 </tr></table>
256
257 <!-- display any child items -->
258 <xsl:if test="documentNode">
259 <li id="toc{@nodeID}" style="display:block;">
260 <xsl:apply-templates select="documentNode" mode="TOC"/>
261 </li>
262 </xsl:if>
263
264 </ul>
265 </xsl:template>
266
267 <!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
268 <xsl:template match="documentNode" mode="flashxml">
269 <xsl:text disable-output-escaping="yes">
270 &lt;Section&gt;
271 &lt;Description&gt;
272 &lt;Metadata name="Title"&gt;
273 </xsl:text>
274 <xsl:value-of select="normalize-space(metadataList/metadata[@name = 'Title'])"/>
275 <xsl:text disable-output-escaping="yes">
276 &lt;/Metadata&gt;
277 &lt;/Description&gt;
278 </xsl:text>
279
280 <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
281
282 <xsl:if test="documentNode">
283 <xsl:apply-templates select="documentNode" mode="flashxml"/>
284 </xsl:if>
285
286 <xsl:text disable-output-escaping="yes">
287 &lt;/Section&gt;
288 </xsl:text>
289 </xsl:template>
290
291 <xsl:template name="externalPage">
292 <xsl:param name="external"/>
293 <xsl:variable name="go_forward_link">
294 <a>
295 <xsl:attribute name="href">
296 <xsl:value-of select="$external"/>
297 </xsl:attribute>
298 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.go_forward')"/>
299 </a>
300 </xsl:variable>
301 <h2><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.title')"/></h2>
302 <p><xsl:value-of select="util:getInterfaceTextWithDOM($interface_name, /page/@lang, 'external.text', $go_forward_link)" disable-output-escaping="yes"/></p>
303 </xsl:template>
304
305 <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
306
307 <xsl:template name="viewOptions">
308 <xsl:call-template name="realisticBooksScript"/>
309 <table class="viewOptions"><tr>
310 <!-- Realistic books link -->
311 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
312 <td>
313 <!-- old url = {$library_name}?a=d&amp;c={$collName}&amp;d={/page/pageResponse/document/documentNode[1]/@nodeID}&amp;dt={/page/pageResponse/document/documentNode/@docType}&amp;p.a=b&amp;p.s={/page/pageResponse/service/@name}&amp;book=on&amp;ed=1 -->
314 <div title="Realistic book view" id="rbOptionDiv"><input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/></div>
315 </td>
316 </xsl:if>
317
318 <!-- Highlight on/off button -->
319 <xsl:if test="/page/pageRequest/paramList/param[@name = 'p.a']/@value = 'q'">
320 <td>
321 <div id="highlightOptionDiv" title="Search term highlighting">
322 <input id="highlightOption" type="checkbox" class="optionCheckBox">
323 <xsl:choose>
324 <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
325 <xsl:attribute name="onclick">
326 <xsl:text>removeHighlight();</xsl:text>
327 </xsl:attribute>
328 <xsl:attribute name="checked">true</xsl:attribute>
329 </xsl:when>
330 <xsl:otherwise>
331 <xsl:attribute name="onclick">
332 <xsl:text>addHighlight();</xsl:text>
333 </xsl:attribute>
334 </xsl:otherwise>
335 </xsl:choose>
336 </input>
337 </div>
338 </td>
339 </xsl:if>
340 </tr></table>
341 </xsl:template>
342</xsl:stylesheet>
343
Note: See TracBrowser for help on using the repository browser.