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

Last change on this file since 24473 was 24473, checked in by sjm84, 9 years ago

Removed the reference to document-scripts.xsl from document.xsl

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