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

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

Committing a file I seemed to have missed in my previous commit, also document-scripts.xsl is now in a javascirpt file

File size: 13.6 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; display:inline;"><xsl:text> </xsl:text></div>
66
67 <script type="text/javascript" src="interfaces/{$interface_name}/js/document_scripts.js"><xsl:text> </xsl:text></script>
68
69 <!-- Adds the realistic books javascript if necessary ( *** in document-scripts.xsl *** ) -->
70 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
71 <script type="text/javascript">
72 <xsl:text disable-output-escaping="yes">
73 if(document.URL.indexOf("book=on") != -1)
74 {
75 loadBook();
76 }
77 </xsl:text>
78 </script>
79 </xsl:if>
80
81 <!-- show the little berries for this document -->
82 <xsl:call-template name="documentBerryForDocumentPage"/>
83
84 <table id="rightSidebar">
85 <tr><td>
86 <xsl:call-template name="viewOptions"/>
87 </td></tr>
88 <tr><td>
89 <!-- the sidebar -->
90 <div id="contentsArea">
91 <!-- show the berry basket if it's turned on -->
92 <gslib:berryBasket/>
93
94 <!-- the book's cover image -->
95 <xsl:choose>
96 <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
97 <div id="coverImage" class="visible"><gslib:coverImage/></div>
98 </xsl:when>
99 <xsl:otherwise>
100 <div id="coverImage" class="hidden"><gslib:coverImage/></div>
101 </xsl:otherwise>
102 </xsl:choose>
103
104 <!-- the contents (if enabled) -->
105 <xsl:choose>
106 <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
107 <div id="tableOfContents" class="visible">
108 <xsl:apply-templates select="documentNode" mode="TOC"/>
109 </div>
110 </xsl:when>
111 <xsl:otherwise>
112 <div id="tableOfContents" class="hidden">
113 <xsl:apply-templates select="documentNode" mode="TOC"/>
114 </div>
115 </xsl:otherwise>
116 </xsl:choose>
117 </div>
118 </td></tr>
119 </table>
120 </xsl:if>
121
122 <!-- display the document -->
123 <xsl:choose>
124 <xsl:when test="@external != ''">
125 <xsl:call-template name="externalPage">
126 <xsl:with-param name="external" select="@external"/>
127 </xsl:call-template>
128 </xsl:when>
129 <xsl:when test="$bookswitch = 'flashxml'">
130 <xsl:apply-templates mode="flashxml"/>
131 </xsl:when>
132 <xsl:when test="$bookswitch = 'on'">
133 <!-- *** in document-scripts.xsl *** -->
134 <div id="bookdiv" style="display:inline;"><xsl:text> </xsl:text></div>
135 <script type="text/javascript">
136 <xsl:text disable-output-escaping="yes">
137 if(document.URL.indexOf("book=on") != -1)
138 {
139 loadBook();
140 }
141 </xsl:text>
142 </script>
143 </xsl:when>
144 <xsl:otherwise>
145 <div id="gs-document-text" class="documenttext">
146 <xsl:apply-templates select="documentNode" mode="document"/>
147 </div>
148 </xsl:otherwise>
149 </xsl:choose>
150
151 <div class="clear"><xsl:text> </xsl:text></div>
152 </xsl:template>
153
154 <!-- Highlight annotations if requested -->
155 <xsl:template match="annotation">
156 <xsl:choose>
157 <xsl:when test="/page/pageRequest/paramList/param[@name='hl' and @value='on']">
158 <span class="termHighlight"><xsl:value-of select="."/></span>
159 </xsl:when>
160 <xsl:otherwise>
161 <span class="noTermHighlight"><xsl:value-of select="."/></span>
162 </xsl:otherwise>
163 </xsl:choose>
164 </xsl:template>
165
166 <!-- This template is used to display the document content -->
167 <xsl:template match="documentNode" mode="document">
168 <a name="{@nodeID}"><xsl:text> </xsl:text></a>
169 <!-- Section header -->
170 <table class="sectionHeader"><tr>
171 <!-- Expand/collapse button -->
172 <td class="headerTD">
173 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
174 <xsl:attribute name="src">
175 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
176 </xsl:attribute>
177 </img>
178 </td>
179
180 <!-- Automatic section number -->
181 <td class="headerTD">
182 <p>
183 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
184
185 <xsl:if test="util:hashToSectionId(@nodeID)">
186 <span class="sectionNumberSpan">
187 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
188 <xsl:text> </xsl:text>
189 </span>
190 </xsl:if>
191 <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
192 <span class="sectionTitle"><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/></span>
193 </p>
194 </td>
195
196 <!-- "back to top" link -->
197 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
198 <td class="backToTop headerTD">
199 <a href="#top">
200 <xsl:text disable-output-escaping="yes">&#9650;</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.back_to_top')"/>
201 </a>
202 </td>
203 </xsl:if>
204 </tr></table>
205
206 <!-- Section text -->
207 <div id="doc{@nodeID}" class="sectionContainer" style="display:block;">
208 <xsl:for-each select="nodeContent">
209 <xsl:for-each select="node()">
210 <xsl:choose>
211 <xsl:when test="not(name())">
212 <xsl:value-of select="." disable-output-escaping="yes"/>
213 </xsl:when>
214 <xsl:otherwise>
215 <xsl:apply-templates select="."/>
216 </xsl:otherwise>
217 </xsl:choose>
218 </xsl:for-each>
219 </xsl:for-each>
220 <xsl:if test="documentNode">
221 <xsl:apply-templates select="documentNode" mode="document"/>
222 </xsl:if>
223 </div>
224
225 </xsl:template>
226
227 <!-- This template is used to display the table of contents -->
228 <xsl:template match="documentNode" mode="TOC">
229
230 <!-- check if this is the currently selected table of contents item -->
231 <xsl:variable name="isCurrent" select="nodeContent"/>
232
233 <!-- formulate the link -->
234 <xsl:variable name="contentsLink">
235 <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
236 </xsl:variable>
237
238 <ul>
239 <table><tr>
240 <!-- The expand/collapse button (not displayed for the top level node) -->
241 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
242 <td>
243 <xsl:choose>
244 <xsl:when test="not(nodeContent and not(documentNode))">
245 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
246 <xsl:attribute name="src">
247 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
248 </xsl:attribute>
249 </img>
250 </xsl:when>
251 <xsl:otherwise>
252 <xsl:attribute name="class">emptyIcon</xsl:attribute>
253 </xsl:otherwise>
254 </xsl:choose>
255 </td>
256 </xsl:if>
257
258 <!-- The chapter/page icon -->
259 <td>
260 <img>
261 <xsl:if test="nodeContent and not(documentNode)">
262 <xsl:attribute name="class">leafNode</xsl:attribute>
263 </xsl:if>
264
265 <xsl:attribute name="src">
266 <xsl:choose>
267 <xsl:when test="nodeContent and not(documentNode)">
268 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
269 </xsl:when>
270 <xsl:otherwise>
271 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
272 </xsl:otherwise>
273 </xsl:choose>
274 </xsl:attribute>
275 </img>
276 </td>
277
278 <!-- The section name, links to the section in the document -->
279 <td>
280 <a>
281 <xsl:attribute name="href">#<xsl:value-of select="@nodeID"/></xsl:attribute>
282 <xsl:if test="util:hashToSectionId(@nodeID)">
283 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
284 <xsl:text> </xsl:text>
285 </xsl:if>
286 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
287 </a>
288 </td>
289 </tr></table>
290
291 <!-- display any child items -->
292 <xsl:if test="documentNode">
293 <li id="toc{@nodeID}" style="display:block;">
294 <xsl:apply-templates select="documentNode" mode="TOC"/>
295 </li>
296 </xsl:if>
297
298 </ul>
299 </xsl:template>
300
301 <!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
302 <xsl:template match="documentNode" mode="flashxml">
303 <xsl:text disable-output-escaping="yes">
304 &lt;Section&gt;
305 &lt;Description&gt;
306 &lt;Metadata name="Title"&gt;
307 </xsl:text>
308 <xsl:value-of select="normalize-space(metadataList/metadata[@name = 'Title'])"/>
309 <xsl:text disable-output-escaping="yes">
310 &lt;/Metadata&gt;
311 &lt;/Description&gt;
312 </xsl:text>
313
314 <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
315
316 <xsl:if test="documentNode">
317 <xsl:apply-templates select="documentNode" mode="flashxml"/>
318 </xsl:if>
319
320 <xsl:text disable-output-escaping="yes">
321 &lt;/Section&gt;
322 </xsl:text>
323 </xsl:template>
324
325 <xsl:template name="externalPage">
326 <xsl:param name="external"/>
327 <xsl:variable name="go_forward_link">
328 <a>
329 <xsl:attribute name="href">
330 <xsl:value-of select="$external"/>
331 </xsl:attribute>
332 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.go_forward')"/>
333 </a>
334 </xsl:variable>
335 <h2><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.title')"/></h2>
336 <p><xsl:value-of select="util:getInterfaceTextWithDOM($interface_name, /page/@lang, 'external.text', $go_forward_link)" disable-output-escaping="yes"/></p>
337 </xsl:template>
338
339 <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
340
341 <xsl:template name="viewOptions">
342 <table class="viewOptions"><tr>
343 <!-- Realistic books link -->
344 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
345 <td>
346 <img>
347 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/></xsl:attribute>
348 </img>
349 <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
350 </td>
351 </xsl:if>
352
353 <!-- Highlight on/off button -->
354 <xsl:if test="/page/pageRequest/paramList/param[@name = 'p.a']/@value = 'q' and count(//annotation) > 0">
355 <td>
356 <img>
357 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/></xsl:attribute>
358 </img>
359 <input id="highlightOption" type="checkbox" class="optionCheckBox">
360 <xsl:choose>
361 <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
362 <xsl:attribute name="onclick">
363 <xsl:text>removeHighlight();</xsl:text>
364 </xsl:attribute>
365 <xsl:attribute name="checked">true</xsl:attribute>
366 </xsl:when>
367 <xsl:otherwise>
368 <xsl:attribute name="onclick">
369 <xsl:text>addHighlight();</xsl:text>
370 </xsl:attribute>
371 </xsl:otherwise>
372 </xsl:choose>
373 </input>
374 </td>
375 </xsl:if>
376 </tr></table>
377 </xsl:template>
378</xsl:stylesheet>
379
Note: See TracBrowser for help on using the repository browser.