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

Last change on this file since 24202 was 24202, checked in by sjb48, 13 years ago

Working on document-level format editting

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