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

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

Further interface updates

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