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

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

Better handling of paged-images, still needs more work though. Also added the db flag (rename) that will show all the metadata of the current document

File size: 16.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
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 <xsl:if test="/page/pageRequest/paramList/param[@name = 'db']/@value = 'true'">
103 <table id="meta{@nodeID}">
104 <xsl:for-each select="metadataList/metadata">
105 <tr>
106 <td class="metaTableCellName"><xsl:value-of select="@name"/></td>
107 <td class="metaTableCellValue editable"><xsl:value-of select="."/></td>
108 </tr>
109 </xsl:for-each>
110 </table>
111 </xsl:if>
112 <div id="text{@nodeID}" class="sectionText"><!-- *** -->
113 <!-- Get the section content from the document template -->
114 <xsl:apply-templates select="." mode="document"/>
115 </div>
116 <xsl:if test="documentNode">
117 <xsl:call-template name="wrapDocumentNodes"/>
118 </xsl:if>
119 </div>
120 </xsl:for-each>
121 </xsl:template>
122
123 <!-- the page content -->
124 <xsl:template match="/page/pageResponse/document">
125 <xsl:if test="/page/pageRequest/paramList/param[@name = 'db']/@value = 'true'">
126 <gsf:metadata name="all"/>
127 </xsl:if>
128
129 <xsl:if test="$bookswitch = 'off'">
130 <div id="bookdiv" style="visibility:hidden; height:0px; display:inline;"><xsl:text> </xsl:text></div>
131
132 <script type="text/javascript" src="interfaces/{$interface_name}/js/document_scripts.js"><xsl:text> </xsl:text></script>
133
134 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
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:if>
144
145 <!-- show the little berries for this document -->
146 <xsl:call-template name="documentBerryForDocumentPage"/>
147
148 <xsl:if test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='sideBar']) or /page/pageResponse/format[@type='display']/gsf:option[@name='sideBar']/@value='true'">
149 <table id="rightSidebar">
150 <tr><td>
151 <xsl:call-template name="viewOptions"/>
152 </td></tr>
153 <tr><td>
154 <div id="contentsArea">
155 <!-- show the berry basket if it's turned on -->
156 <gslib:berryBasket/>
157
158 <!-- the book's cover image -->
159 <div id="coverImage">
160 <xsl:attribute name="class">
161 <xsl:choose>
162 <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'">visible</xsl:when>
163 <xsl:otherwise>hidden</xsl:otherwise>
164 </xsl:choose>
165 </xsl:attribute>
166 <gslib:coverImage/><xsl:text> </xsl:text>
167 </div>
168
169 <!-- the contents (if enabled) -->
170 <div id="tableOfContents">
171 <xsl:attribute name="class">
172 <xsl:choose>
173 <xsl:when test="count(//documentNode) > 1 and not(/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']) or /page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">visible</xsl:when>
174 <xsl:otherwise>hidden</xsl:otherwise>
175 </xsl:choose>
176 </xsl:attribute>
177 <xsl:apply-templates select="documentNode" mode="TOC"/>
178 </div>
179 </div>
180 </td></tr>
181 </table>
182 </xsl:if>
183 </xsl:if>
184
185 <!-- display the document -->
186 <xsl:choose>
187 <xsl:when test="@external != ''">
188 <xsl:call-template name="externalPage">
189 <xsl:with-param name="external" select="@external"/>
190 </xsl:call-template>
191 </xsl:when>
192 <xsl:when test="$bookswitch = 'flashxml'">
193 <xsl:apply-templates mode="flashxml"/>
194 </xsl:when>
195 <xsl:when test="$bookswitch = 'on'">
196 <div id="bookdiv" style="display:inline;"><xsl:text> </xsl:text></div>
197 <!-- *** in document-scripts.js *** -->
198 <script type="text/javascript">
199 <xsl:text disable-output-escaping="yes">
200 if(document.URL.indexOf("book=on") != -1)
201 {
202 loadBook();
203 }
204 </xsl:text>
205 </script>
206 </xsl:when>
207 <xsl:otherwise>
208 <table><tbody><tr><td>
209 <div id="gs-document-image" class="sectionImage">
210 <!-- Get the section content from the document template -->
211 <xsl:call-template name="documentImage"/>
212 </div>
213 </td>
214 <td>
215 <div id="gs-document-text" class="documenttext" collection="{/page/pageResponse/collection/@name}"><!-- *** -->
216 <xsl:call-template name="wrapDocumentNodes"/>
217 </div>
218 </td></tr></tbody></table>
219
220 </xsl:otherwise>
221 </xsl:choose>
222
223 <div class="clear"><xsl:text> </xsl:text></div>
224 </xsl:template>
225
226 <!-- Highlight annotations if requested -->
227 <xsl:template match="annotation">
228 <xsl:choose>
229 <xsl:when test="/page/pageRequest/paramList/param[@name='hl' and @value='on']">
230 <span class="termHighlight"><xsl:value-of select="."/></span>
231 </xsl:when>
232 <xsl:otherwise>
233 <span class="noTermHighlight"><xsl:value-of select="."/></span>
234 </xsl:otherwise>
235 </xsl:choose>
236 </xsl:template>
237
238 <xsl:template match="documentNode" mode="sectionTitleFormat">
239 <p>
240 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
241
242 <xsl:if test="util:hashToSectionId(@nodeID)">
243 <span class="sectionNumberSpan">
244 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
245 <xsl:text> </xsl:text>
246 </span>
247 </xsl:if>
248 <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
249 <span><xsl:apply-templates select="." mode="sectionTitle"/></span>
250 </p>
251 </xsl:template>
252
253 <!-- The default template for displaying section titles -->
254 <xsl:template match="documentNode" mode="sectionTitle">
255 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
256 </xsl:template>
257
258 <!-- The default template for displaying the document content -->
259 <xsl:template match="documentNode" mode="document">
260 <!-- Section text -->
261 <xsl:for-each select="nodeContent">
262 <xsl:for-each select="node()">
263 <xsl:choose>
264 <xsl:when test="not(name())">
265 <xsl:value-of select="." disable-output-escaping="yes"/>
266 </xsl:when>
267 <xsl:otherwise>
268 <xsl:apply-templates select="."/>
269 </xsl:otherwise>
270 </xsl:choose>
271 </xsl:for-each>
272 </xsl:for-each><xsl:text> </xsl:text>
273 </xsl:template>
274
275 <!-- The default template for displaying the document image -->
276 <xsl:template name="documentImage">
277 <xsl:variable name="imageTest"><gsf:metadata name="ScreenWidth"/></xsl:variable>
278 <xsl:if test="$imageTest != ''">
279 <h3>
280 <gsf:choose-metadata>
281 <gsf:metadata name="dc.Title"/>
282 <gsf:metadata name="ex.Title"/>
283 <gsf:default>Untitled</gsf:default>
284 </gsf:choose-metadata>
285 </h3>
286 <gsf:metadata name="screenicon"/>
287 </xsl:if>
288 </xsl:template>
289
290 <!-- This template is used to display the table of contents -->
291 <xsl:template match="documentNode" mode="TOC">
292
293 <!-- check if this is the currently selected table of contents item -->
294 <xsl:variable name="isCurrent" select="nodeContent"/>
295
296 <!-- formulate the link -->
297 <xsl:variable name="contentsLink">
298 <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
299 </xsl:variable>
300
301 <ul>
302 <table><tr>
303 <!-- The expand/collapse button (not displayed for the top level node) -->
304 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
305 <td>
306 <xsl:choose>
307 <xsl:when test="not(nodeContent and not(documentNode))">
308 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
309 <xsl:attribute name="src">
310 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
311 </xsl:attribute>
312 </img>
313 </xsl:when>
314 <xsl:otherwise>
315 <xsl:attribute name="class">emptyIcon</xsl:attribute>
316 </xsl:otherwise>
317 </xsl:choose>
318 </td>
319 </xsl:if>
320
321 <!-- The chapter/page icon -->
322 <td>
323 <img>
324 <xsl:if test="nodeContent and not(documentNode)">
325 <xsl:attribute name="class">leafNode</xsl:attribute>
326 </xsl:if>
327
328 <xsl:attribute name="src">
329 <xsl:choose>
330 <xsl:when test="nodeContent and not(documentNode)">
331 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
332 </xsl:when>
333 <xsl:otherwise>
334 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
335 </xsl:otherwise>
336 </xsl:choose>
337 </xsl:attribute>
338 </img>
339 </td>
340
341 <!-- The section name, links to the section in the document -->
342 <td>
343 <a>
344 <xsl:attribute name="href">#<xsl:value-of select="@nodeID"/></xsl:attribute>
345 <xsl:if test="util:hashToSectionId(@nodeID)">
346 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
347 <xsl:text> </xsl:text>
348 </xsl:if>
349 <xsl:apply-templates select="." mode="sectionTitle"/>
350 </a>
351 </td>
352 </tr></table>
353
354 <!-- display any child items -->
355 <xsl:if test="documentNode">
356 <li id="toc{@nodeID}" style="display:block;">
357 <xsl:apply-templates select="documentNode" mode="TOC"/>
358 </li>
359 </xsl:if>
360
361 </ul>
362 </xsl:template>
363
364 <!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
365 <xsl:template match="documentNode" mode="flashxml">
366 <xsl:text disable-output-escaping="yes">
367 &lt;Section&gt;
368 &lt;Description&gt;
369 &lt;Metadata name="Title"&gt;
370 </xsl:text>
371 <xsl:value-of select="normalize-space(metadataList/metadata[@name = 'Title'])"/>
372 <xsl:text disable-output-escaping="yes">
373 &lt;/Metadata&gt;
374 &lt;/Description&gt;
375 </xsl:text>
376
377 <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
378
379 <xsl:if test="documentNode">
380 <xsl:apply-templates select="documentNode" mode="flashxml"/>
381 </xsl:if>
382
383 <xsl:text disable-output-escaping="yes">
384 &lt;/Section&gt;
385 </xsl:text>
386 </xsl:template>
387
388 <xsl:template name="externalPage">
389 <xsl:param name="external"/>
390 <xsl:variable name="go_forward_link">
391 <a>
392 <xsl:attribute name="href">
393 <xsl:value-of select="$external"/>
394 </xsl:attribute>
395 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.go_forward')"/>
396 </a>
397 </xsl:variable>
398 <h2><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.title')"/></h2>
399 <p><xsl:value-of select="util:getInterfaceTextWithDOM($interface_name, /page/@lang, 'external.text', $go_forward_link)" disable-output-escaping="yes"/></p>
400 </xsl:template>
401
402 <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
403
404 <xsl:template name="viewOptions">
405 <table class="viewOptions"><tr>
406 <!-- Realistic books link -->
407 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
408 <td>
409 <img>
410 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/></xsl:attribute>
411 </img>
412 <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
413 </td>
414 </xsl:if>
415
416 <!-- Highlight on/off button -->
417 <xsl:if test="/page/pageRequest/paramList/param[@name = 'p.a']/@value = 'q' and count(//annotation) > 0">
418 <td>
419 <img>
420 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/></xsl:attribute>
421 </img>
422 <input id="highlightOption" type="checkbox" class="optionCheckBox">
423 <xsl:choose>
424 <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
425 <xsl:attribute name="onclick">
426 <xsl:text>removeHighlight();</xsl:text>
427 </xsl:attribute>
428 <xsl:attribute name="checked">true</xsl:attribute>
429 </xsl:when>
430 <xsl:otherwise>
431 <xsl:attribute name="onclick">
432 <xsl:text>addHighlight();</xsl:text>
433 </xsl:attribute>
434 </xsl:otherwise>
435 </xsl:choose>
436 </input>
437 </td>
438 </xsl:if>
439 <td class="tableOfContentsTitle">Table of Contents</td>
440 <td style="vertical-align:top;">
441 <a id="sidebarMinimizeButton" href="javascript:minimizeSidebar();" style="float: right; font-size:0.6em;">
442 <img class="icon">
443 <xsl:attribute name="src">
444 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
445 </xsl:attribute>
446 </img>
447 </a>
448 <a id="sidebarMaximizeButton" href="javascript:maximizeSidebar();" style="float: right; font-size:0.6em; display:none;">
449 <img class="icon">
450 <xsl:attribute name="src">
451 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
452 </xsl:attribute>
453 </img>
454 </a>
455 </td>
456 </tr></table>
457 </xsl:template>
458</xsl:stylesheet>
459
Note: See TracBrowser for help on using the repository browser.