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

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

Some major changes to document.xsl to make it easier to modify more specific parts to be modified in the collectionConfig.xml files

File size: 15.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: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
17 <xsl:variable name="bookswitch">
18 <xsl:choose>
19 <xsl:when test="/page/pageRequest/paramList/param[@name='book']/@value">
20 <xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
21 </xsl:when>
22 <xsl:otherwise>off</xsl:otherwise>
23 </xsl:choose>
24 </xsl:variable>
25
26 <!-- set page title -->
27 <xsl:template name="pageTitle"><gslib:documentTitle/></xsl:template>
28
29 <!-- set page breadcrumbs -->
30 <xsl:template name="breadcrumbs">
31 <gslib:siteLink/><gslib:rightArrow/>
32 <gslib:collectionNameLinked/><gslib:rightArrow/>
33 <a>
34 <xsl:attribute name="href">
35 <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"/>
36 </xsl:attribute>
37 <xsl:variable name="documentTitleVar">
38 <gslib:documentTitle/>
39 </xsl:variable>
40 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.document')"/>
41 </a>
42 </xsl:template>
43
44 <xsl:template match="/">
45 <xsl:choose>
46 <!-- if this is the realistic books version of the page -->
47 <xsl:when test="$bookswitch = 'flashxml'">
48 <html>
49 <body>
50 <xsl:apply-templates select="/page/pageResponse/document"/>
51 </body>
52 </html>
53 </xsl:when>
54 <!-- if this is the regular version of the page -->
55 <xsl:otherwise>
56 <xsl:apply-imports/>
57 </xsl:otherwise>
58 </xsl:choose>
59 </xsl:template>
60
61 <!-- Used to make sure that regardless what the collection designer uses for the title and content we can wrap it properly -->
62 <!-- If editing, be aware that the Document Basket looks for specific classes that this template bakes in (key points marked with ***) -->
63 <xsl:template name="wrapDocumentNodes">
64 <xsl:for-each select="documentNode">
65 <a name="{@nodeID}"><xsl:text> </xsl:text></a>
66 <!-- Section header -->
67 <table class="sectionHeader"><tr>
68
69 <!-- Expand/collapse button -->
70 <td class="headerTD">
71 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
72 <xsl:attribute name="src">
73 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
74 </xsl:attribute>
75 </img>
76 </td>
77
78 <!-- Title -->
79 <td id="header{@nodeID}" class="headerTD sectionTitle"><!-- *** -->
80 <!-- Get the title from the title sectionTitle template -->
81 <xsl:choose>
82 <xsl:when test="not(/page/pageRequest/paramList/param[@name = 'db']) or /page/pageRequest/paramList/param[@name = 'db']/@value = 'false'">
83 <xsl:apply-templates select="." mode="sectionTitleFormat"/>
84 </xsl:when>
85 <xsl:otherwise>
86 <xsl:apply-templates select="." mode="sectionTitle"/>
87 </xsl:otherwise>
88 </xsl:choose>
89 </td>
90
91 <!-- "back to top" link -->
92 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
93 <td class="backToTop headerTD">
94 <a href="#top">
95 <xsl:text disable-output-escaping="yes">&#9650;</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.back_to_top')"/>
96 </a>
97 </td>
98 </xsl:if>
99 </tr></table>
100
101 <div id="doc{@nodeID}" class="sectionContainer" style="display:block;"><!-- *** -->
102 <div id="text{@nodeID}" class="sectionText"><!-- *** -->
103 <!-- Get the section content from the document template -->
104 <xsl:apply-templates select="." mode="document"/>
105 </div>
106 <xsl:if test="documentNode">
107 <xsl:call-template name="wrapDocumentNodes"/>
108 </xsl:if>
109 </div>
110 </xsl:for-each>
111 </xsl:template>
112
113 <!-- the page content -->
114 <xsl:template match="/page/pageResponse/document">
115 <xsl:if test="$bookswitch = 'off'">
116 <div id="bookdiv" style="visibility:hidden; height:0px; display:inline;"><xsl:text> </xsl:text></div>
117
118 <script type="text/javascript" src="interfaces/{$interface_name}/js/document_scripts.js"><xsl:text> </xsl:text></script>
119
120 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
121 <script type="text/javascript">
122 <xsl:text disable-output-escaping="yes">
123 if(document.URL.indexOf("book=on") != -1)
124 {
125 loadBook();
126 }
127 </xsl:text>
128 </script>
129 </xsl:if>
130
131 <!-- show the little berries for this document -->
132 <xsl:call-template name="documentBerryForDocumentPage"/>
133
134 <xsl:if test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']) or /page/pageResponse/format[@type='display']/gsf:option[@name='sideBar']/@value='true'">
135 <table id="rightSidebar">
136 <tr><td>
137 <xsl:call-template name="viewOptions"/>
138 </td></tr>
139 <tr><td>
140 <div id="contentsArea">
141
142 <!-- show the berry basket if it's turned on -->
143 <gslib:berryBasket/>
144
145 <!-- the book's cover image -->
146 <xsl:choose>
147 <xsl:when test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']) or /page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
148 <div id="coverImage" class="visible"><gslib:coverImage/></div>
149 </xsl:when>
150 <xsl:otherwise>
151 <div id="coverImage" class="hidden"><gslib:coverImage/></div>
152 </xsl:otherwise>
153 </xsl:choose>
154
155 <!-- the contents (if enabled) -->
156 <xsl:choose>
157 <xsl:when test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']) or /page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
158 <div id="tableOfContents" class="visible">
159 <xsl:apply-templates select="documentNode" mode="TOC"/>
160 </div>
161 </xsl:when>
162 <xsl:otherwise>
163 <div id="tableOfContents" class="hidden">
164 <xsl:apply-templates select="documentNode" mode="TOC"/>
165 </div>
166 </xsl:otherwise>
167 </xsl:choose>
168 </div>
169 </td></tr>
170 </table>
171 </xsl:if>
172 </xsl:if>
173
174 <!-- display the document -->
175 <xsl:choose>
176 <xsl:when test="@external != ''">
177 <xsl:call-template name="externalPage">
178 <xsl:with-param name="external" select="@external"/>
179 </xsl:call-template>
180 </xsl:when>
181 <xsl:when test="$bookswitch = 'flashxml'">
182 <xsl:apply-templates mode="flashxml"/>
183 </xsl:when>
184 <xsl:when test="$bookswitch = 'on'">
185 <!-- *** in document-scripts.xsl *** -->
186 <div id="bookdiv" style="display:inline;"><xsl:text> </xsl:text></div>
187 <script type="text/javascript">
188 <xsl:text disable-output-escaping="yes">
189 if(document.URL.indexOf("book=on") != -1)
190 {
191 loadBook();
192 }
193 </xsl:text>
194 </script>
195 </xsl:when>
196 <xsl:otherwise>
197 <div id="gs-document-text" class="documenttext">
198 <xsl:call-template name="wrapDocumentNodes"/>
199 </div>
200 </xsl:otherwise>
201 </xsl:choose>
202
203 <div class="clear"><xsl:text> </xsl:text></div>
204 </xsl:template>
205
206 <!-- Highlight annotations if requested -->
207 <xsl:template match="annotation">
208 <xsl:choose>
209 <xsl:when test="/page/pageRequest/paramList/param[@name='hl' and @value='on']">
210 <span class="termHighlight"><xsl:value-of select="."/></span>
211 </xsl:when>
212 <xsl:otherwise>
213 <span class="noTermHighlight"><xsl:value-of select="."/></span>
214 </xsl:otherwise>
215 </xsl:choose>
216 </xsl:template>
217
218 <xsl:template match="documentNode" mode="sectionTitleFormat">
219 <p>
220 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
221
222 <xsl:if test="util:hashToSectionId(@nodeID)">
223 <span class="sectionNumberSpan">
224 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
225 <xsl:text> </xsl:text>
226 </span>
227 </xsl:if>
228 <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
229 <span><xsl:apply-templates select="." mode="sectionTitle"/></span>
230 </p>
231 </xsl:template>
232
233 <!-- The default template for displaying section titles -->
234 <xsl:template match="documentNode" mode="sectionTitle">
235 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
236 </xsl:template>
237
238 <!-- The default template for displaying the document content -->
239 <xsl:template match="documentNode" mode="document">
240 <!-- Section text -->
241 <xsl:for-each select="nodeContent">
242 <xsl:for-each select="node()">
243 <xsl:choose>
244 <xsl:when test="not(name())">
245 <xsl:value-of select="." disable-output-escaping="yes"/>
246 </xsl:when>
247 <xsl:otherwise>
248 <xsl:apply-templates select="."/>
249 </xsl:otherwise>
250 </xsl:choose>
251 </xsl:for-each>
252 </xsl:for-each><xsl:text> </xsl:text>
253 </xsl:template>
254
255 <!-- This template is used to display the table of contents -->
256 <xsl:template match="documentNode" mode="TOC">
257
258 <!-- check if this is the currently selected table of contents item -->
259 <xsl:variable name="isCurrent" select="nodeContent"/>
260
261 <!-- formulate the link -->
262 <xsl:variable name="contentsLink">
263 <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
264 </xsl:variable>
265
266 <ul>
267 <table><tr>
268 <!-- The expand/collapse button (not displayed for the top level node) -->
269 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
270 <td>
271 <xsl:choose>
272 <xsl:when test="not(nodeContent and not(documentNode))">
273 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
274 <xsl:attribute name="src">
275 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
276 </xsl:attribute>
277 </img>
278 </xsl:when>
279 <xsl:otherwise>
280 <xsl:attribute name="class">emptyIcon</xsl:attribute>
281 </xsl:otherwise>
282 </xsl:choose>
283 </td>
284 </xsl:if>
285
286 <!-- The chapter/page icon -->
287 <td>
288 <img>
289 <xsl:if test="nodeContent and not(documentNode)">
290 <xsl:attribute name="class">leafNode</xsl:attribute>
291 </xsl:if>
292
293 <xsl:attribute name="src">
294 <xsl:choose>
295 <xsl:when test="nodeContent and not(documentNode)">
296 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
297 </xsl:when>
298 <xsl:otherwise>
299 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
300 </xsl:otherwise>
301 </xsl:choose>
302 </xsl:attribute>
303 </img>
304 </td>
305
306 <!-- The section name, links to the section in the document -->
307 <td>
308 <a>
309 <xsl:attribute name="href">#<xsl:value-of select="@nodeID"/></xsl:attribute>
310 <xsl:if test="util:hashToSectionId(@nodeID)">
311 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
312 <xsl:text> </xsl:text>
313 </xsl:if>
314 <xsl:apply-templates select="." mode="sectionTitle"/>
315 </a>
316 </td>
317 </tr></table>
318
319 <!-- display any child items -->
320 <xsl:if test="documentNode">
321 <li id="toc{@nodeID}" style="display:block;">
322 <xsl:apply-templates select="documentNode" mode="TOC"/>
323 </li>
324 </xsl:if>
325
326 </ul>
327 </xsl:template>
328
329 <!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
330 <xsl:template match="documentNode" mode="flashxml">
331 <xsl:text disable-output-escaping="yes">
332 &lt;Section&gt;
333 &lt;Description&gt;
334 &lt;Metadata name="Title"&gt;
335 </xsl:text>
336 <xsl:value-of select="normalize-space(metadataList/metadata[@name = 'Title'])"/>
337 <xsl:text disable-output-escaping="yes">
338 &lt;/Metadata&gt;
339 &lt;/Description&gt;
340 </xsl:text>
341
342 <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
343
344 <xsl:if test="documentNode">
345 <xsl:apply-templates select="documentNode" mode="flashxml"/>
346 </xsl:if>
347
348 <xsl:text disable-output-escaping="yes">
349 &lt;/Section&gt;
350 </xsl:text>
351 </xsl:template>
352
353 <xsl:template name="externalPage">
354 <xsl:param name="external"/>
355 <xsl:variable name="go_forward_link">
356 <a>
357 <xsl:attribute name="href">
358 <xsl:value-of select="$external"/>
359 </xsl:attribute>
360 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.go_forward')"/>
361 </a>
362 </xsl:variable>
363 <h2><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.title')"/></h2>
364 <p><xsl:value-of select="util:getInterfaceTextWithDOM($interface_name, /page/@lang, 'external.text', $go_forward_link)" disable-output-escaping="yes"/></p>
365 </xsl:template>
366
367 <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
368
369 <xsl:template name="viewOptions">
370 <table class="viewOptions"><tr>
371 <!-- Realistic books link -->
372 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
373 <td>
374 <img>
375 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/></xsl:attribute>
376 </img>
377 <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
378 </td>
379 </xsl:if>
380
381 <!-- Highlight on/off button -->
382 <xsl:if test="/page/pageRequest/paramList/param[@name = 'p.a']/@value = 'q' and count(//annotation) > 0">
383 <td>
384 <img>
385 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/></xsl:attribute>
386 </img>
387 <input id="highlightOption" type="checkbox" class="optionCheckBox">
388 <xsl:choose>
389 <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
390 <xsl:attribute name="onclick">
391 <xsl:text>removeHighlight();</xsl:text>
392 </xsl:attribute>
393 <xsl:attribute name="checked">true</xsl:attribute>
394 </xsl:when>
395 <xsl:otherwise>
396 <xsl:attribute name="onclick">
397 <xsl:text>addHighlight();</xsl:text>
398 </xsl:attribute>
399 </xsl:otherwise>
400 </xsl:choose>
401 </input>
402 </td>
403 </xsl:if>
404 <td style="vertical-align:top;">
405 <a id="sidebarMinimizeButton" href="javascript:minimizeSidebar();" style="float: right; font-size:0.6em;">
406 <img class="icon">
407 <xsl:attribute name="src">
408 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
409 </xsl:attribute>
410 </img>
411 </a>
412 <a id="sidebarMaximizeButton" href="javascript:maximizeSidebar();" style="float: right; font-size:0.6em; display:none;">
413 <img class="icon">
414 <xsl:attribute name="src">
415 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
416 </xsl:attribute>
417 </img>
418 </a>
419 </td>
420 </tr></table>
421 </xsl:template>
422</xsl:stylesheet>
423
Note: See TracBrowser for help on using the repository browser.