source: main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl@ 26296

Last change on this file since 26296 was 26296, checked in by sjm84, 8 years ago

The document view will now correctly focus the subsection you have specified when in paged mode

File size: 26.7 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 <xsl:import href="layouts/toc.xsl"/>
14
15 <xsl:variable name="bookswitch">
16 <xsl:choose>
17 <xsl:when test="/page/pageRequest/paramList/param[@name='book']/@value">
18 <xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
19 </xsl:when>
20 <xsl:otherwise>off</xsl:otherwise>
21 </xsl:choose>
22 </xsl:variable>
23
24 <!-- set page title -->
25 <xsl:template name="pageTitle"><gslib:documentTitle/></xsl:template>
26
27 <!-- set page breadcrumbs -->
28 <xsl:template name="breadcrumbs">
29 <gslib:siteLink/><gslib:rightArrow/>
30 <gslib:collectionNameLinked/><gslib:rightArrow/>
31 <a>
32 <xsl:attribute name="href">
33 <xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collName"/>/document/<xsl:value-of select="/page/pageResponse/document/documentNode[1]/@nodeID"/>
34 </xsl:attribute>
35 <xsl:variable name="documentTitleVar">
36 <gslib:documentTitle/>
37 </xsl:variable>
38 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.document')"/>
39 </a>
40 </xsl:template>
41
42 <xsl:template match="/">
43 <xsl:choose>
44 <!-- if this is the realistic books version of the page -->
45 <xsl:when test="$bookswitch = 'flashxml'">
46 <html>
47 <body>
48 <xsl:apply-templates select="/page/pageResponse/document"/>
49 </body>
50 </html>
51 </xsl:when>
52 <!-- if this is the regular version of the page -->
53 <xsl:otherwise>
54 <xsl:call-template name="mainTemplate"/>
55 </xsl:otherwise>
56 </xsl:choose>
57 </xsl:template>
58
59 <xsl:template name="documentHeading">
60 <b><gsf:metadata name="Title"/></b><br/>
61 </xsl:template>
62
63 <xsl:template name="documentContent">
64 <xsl:choose>
65 <xsl:when test="@docType='simple'">
66 <div id="gs-document">
67 <xsl:call-template name="documentPre"/>
68 <xsl:call-template name="wrappedSectionImage"/>
69 <div id="gs-document-text">
70 <xsl:call-template name="documentNodeText"/>
71 </div>
72 </div>
73 </xsl:when>
74 <xsl:otherwise>
75 <xsl:call-template name="wrappedDocument"/>
76 </xsl:otherwise>
77 </xsl:choose>
78 </xsl:template>
79
80 <xsl:template name="sectionHeading">
81 <xsl:call-template name="sectionTitle"/>
82 </xsl:template>
83
84 <xsl:template name="topLevelSectionContent">
85 <xsl:call-template name="wrappedSectionImage"/>
86 <xsl:call-template name="wrappedSectionText"/>
87 </xsl:template>
88
89 <xsl:template name="sectionContent">
90 <xsl:call-template name="wrappedSectionImage"/>
91 <xsl:call-template name="wrappedSectionText"/>
92 </xsl:template>
93
94 <xsl:template name="wrappedSectionText">
95 <div id="text{@nodeID}" class="sectionText"><!-- *** -->
96 <xsl:attribute name="style">
97 <xsl:choose>
98 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'image'">
99 <xsl:text>display:none;</xsl:text>
100 </xsl:when>
101 <xsl:otherwise>
102 <xsl:text>display:block;</xsl:text>
103 </xsl:otherwise>
104 </xsl:choose>
105 </xsl:attribute>
106
107 <xsl:call-template name="documentNodeText"/>
108 </div>
109 </xsl:template>
110
111 <xsl:template name="sectionImage">
112 <gsf:image type="screen"/>
113 </xsl:template>
114
115 <!-- Used to make sure that regardless what the collection designer uses for the title and content we can wrap it properly -->
116 <!-- If editing, be aware that the Document Basket looks for specific classes that this template bakes in (key points marked with ***) -->
117 <xsl:template name="wrapDocumentNodes">
118 <a name="{@nodeID}"><xsl:text> </xsl:text></a>
119
120 <!-- Section header -->
121 <table class="sectionHeader"><tr>
122
123 <!-- Expand/collapse button -->
124 <xsl:if test="not(/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='sectionExpandCollapse']/@value) or /page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='sectionExpandCollapse']/@value = 'true'">
125 <td class="headerTD">
126 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
127 <xsl:attribute name="src">
128 <xsl:choose>
129 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or util:oidIsMatchOrParent(@nodeID, /page/pageResponse/document/@selectedNode)">
130 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
131 </xsl:when>
132 <xsl:otherwise>
133 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
134 </xsl:otherwise>
135 </xsl:choose>
136 </xsl:attribute>
137 </img>
138 </td>
139 </xsl:if>
140
141 <!-- Title -->
142 <td id="header{@nodeID}" class="headerTD sectionTitle"><!-- *** -->
143 <p>
144 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
145
146 <xsl:if test="util:hashToSectionId(@nodeID)">
147 <span class="sectionNumberSpan">
148 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
149 <xsl:text> </xsl:text>
150 </span>
151 </xsl:if>
152 <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
153 <span><xsl:call-template name="sectionHeading"/></span>
154 </p>
155 </td>
156
157 <!-- "back to top" link -->
158 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle' and not(/page/pageResponse/format[@type='display']/gsf:option[@name='backToTopLinks']) or /page/pageResponse/format[@type='display']/gsf:option[@name='backToTopLinks']/@value='true'">
159 <td class="backToTop headerTD">
160 <a href="javascript:scrollToTop();">
161 <xsl:text disable-output-escaping="yes">&#9650;</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.back_to_top')"/>
162 </a>
163 </td>
164 </xsl:if>
165 </tr></table>
166
167 <div id="doc{@nodeID}"><!-- *** -->
168 <xsl:choose>
169 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
170 <xsl:attribute name="class">
171 <xsl:text>sectionContainer hasText</xsl:text>
172 </xsl:attribute>
173 <xsl:attribute name="style">
174 <xsl:text>display:block;</xsl:text>
175 </xsl:attribute>
176 </xsl:when>
177 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or util:oidIsMatchOrParent(@nodeID, /page/pageResponse/document/@selectedNode)">
178 <xsl:attribute name="class">
179 <xsl:text>sectionContainer noText</xsl:text>
180 </xsl:attribute>
181 <xsl:attribute name="style">
182 <xsl:text>display:block;</xsl:text>
183 </xsl:attribute>
184 </xsl:when>
185 <xsl:otherwise>
186 <xsl:attribute name="class">
187 <xsl:text>sectionContainer noText</xsl:text>
188 </xsl:attribute>
189 <xsl:attribute name="style">
190 <xsl:text>display:none;</xsl:text>
191 </xsl:attribute>
192 </xsl:otherwise>
193 </xsl:choose>
194
195 <xsl:if test="/page/pageRequest/userInformation and (util:contains(/page/pageRequest/userInformation/@groups, 'administrator') or util:contains(/page/pageRequest/userInformation/@groups, 'all-collections-editor') or util:contains(/page/pageRequest/userInformation/@groups, $thisCollectionEditor))">
196 <table id="meta{@nodeID}">
197 <xsl:attribute name="style">
198 <xsl:choose>
199 <xsl:when test="/page/pageRequest/paramList/param[@name = 'dmd']/@value = 'true'">
200 <xsl:text>display:block;</xsl:text>
201 </xsl:when>
202 <xsl:otherwise>
203 <xsl:text>display:none;</xsl:text>
204 </xsl:otherwise>
205 </xsl:choose>
206 </xsl:attribute>
207 <xsl:value-of select="util:clearMetadataStorage()"/>
208 <xsl:for-each select="metadataList/metadata">
209 <xsl:sort select="@name"/>
210 <xsl:if test="util:checkMetadataNotDuplicate(@name, .)">
211 <tr>
212 <td class="metaTableCellName"><xsl:value-of select="@name"/></td>
213 <td class="metaTableCell"><xsl:value-of disable-output-escaping="yes" select="."/></td>
214 </tr>
215 </xsl:if>
216 </xsl:for-each>
217 </table>
218 </xsl:if>
219
220 <xsl:choose>
221 <xsl:when test="../../document">
222 <xsl:call-template name="topLevelSectionContent"/>
223 </xsl:when>
224 <xsl:otherwise>
225 <xsl:call-template name="sectionContent"/>
226 </xsl:otherwise>
227 </xsl:choose>
228
229 <xsl:if test="documentNode">
230 <xsl:for-each select="documentNode">
231 <xsl:call-template name="wrapDocumentNodes"/>
232 </xsl:for-each>
233 </xsl:if>
234 </div>
235 </xsl:template>
236
237 <!-- the page content -->
238 <xsl:template match="/page/pageResponse/document">
239 <xsl:if test="/page/pageRequest/userInformation and (util:contains(/page/pageRequest/userInformation/@groups, 'administrator') or util:contains(/page/pageRequest/userInformation/@groups, 'all-collections-editor') or util:contains(/page/pageRequest/userInformation/@groups, $thisCollectionEditor))">
240 <script type="text/javascript" src="interfaces/{$interface_name}/js/documentmaker_scripts.js"><xsl:text> </xsl:text></script>
241 <script type="text/javascript" src="interfaces/{$interface_name}/js/documentmaker_scripts_util.js"><xsl:text> </xsl:text></script>
242 <script type="text/javascript">
243 <xsl:text disable-output-escaping="yes">
244 $(window).load(function()
245 {
246 if(gs.cgiParams.docEdit == "1")
247 {
248 readyPageForEditing();
249 }
250 });
251 </xsl:text>
252 </script>
253 <gsf:metadata name="all"/>
254 </xsl:if>
255
256 <xsl:if test="$bookswitch = 'off'">
257 <div id="bookdiv" style="visibility:hidden; height:0px; display:inline;"><xsl:text> </xsl:text></div>
258
259 <script type="text/javascript" src="interfaces/{$interface_name}/js/document_scripts.js"><xsl:text> </xsl:text></script>
260
261 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
262 <script type="text/javascript">
263 <xsl:text disable-output-escaping="yes">
264 if(document.URL.indexOf("book=on") != -1)
265 {
266 loadBook();
267 }
268 </xsl:text>
269 </script>
270 </xsl:if>
271
272 <xsl:if test="/page/pageRequest/userInformation and (util:contains(/page/pageRequest/userInformation/@groups, 'administrator') or util:contains(/page/pageRequest/userInformation/@groups, 'all-collections-editor') or util:contains(/page/pageRequest/userInformation/@groups, $thisCollectionEditor))">
273 <xsl:call-template name="editBar"/>
274 </xsl:if>
275
276 <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'">
277 <xsl:call-template name="rightSidebar"/>
278 </xsl:if>
279 </xsl:if>
280
281 <!-- display the document -->
282 <xsl:choose>
283 <xsl:when test="@external != ''">
284 <xsl:call-template name="externalPage">
285 <xsl:with-param name="external" select="@external"/>
286 </xsl:call-template>
287 </xsl:when>
288 <xsl:when test="$bookswitch = 'flashxml'">
289 <xsl:call-template name="documentNodeFlashXML"/>
290 </xsl:when>
291 <xsl:when test="$bookswitch = 'on'">
292 <div id="bookdiv" style="display:inline;"><xsl:text> </xsl:text></div>
293 <!-- *** in document-scripts.js *** -->
294 <script type="text/javascript">
295 <xsl:text disable-output-escaping="yes">
296 if(document.URL.indexOf("book=on") != -1)
297 {
298 loadBook();
299 }
300 </xsl:text>
301 </script>
302 </xsl:when>
303 <xsl:when test="@docType='simple'">
304 <xsl:call-template name="documentHeading"/><br/>
305 <xsl:call-template name="documentContent"/>
306 </xsl:when>
307 <xsl:otherwise> <!-- display the standard greenstone document -->
308 <xsl:call-template name="documentContent"/>
309 </xsl:otherwise>
310 </xsl:choose>
311 </xsl:template>
312
313 <xsl:template name="wrappedDocument">
314 <xsl:choose>
315 <!-- NOTE: alb = ajax load bypass -->
316 <!--
317 If the docType is hierarchy and we want to bypass the ajax load then do this
318 OR If the docType is hierarchy and we have asked for the expanded document OR we have asked for the top level document then do this
319 -->
320 <xsl:when test="/page/pageResponse/document/@docType = 'hierarchy' and (/page/pageRequest/paramList/param[@name = 'alb']/@value = '1' or (string-length(/page/pageRequest/paramList/param[@name = 'd']/@value) > 0 and (/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or not(util:contains(/page/pageResponse/document/@selectedNode, '.')))))">
321 <div id="gs-document">
322 <xsl:call-template name="documentPre"/>
323 <div id="gs-document-text" class="documenttext" collection="{/page/pageResponse/collection/@name}"><!-- *** -->
324 <xsl:for-each select="documentNode">
325 <xsl:call-template name="wrapDocumentNodes"/>
326 </xsl:for-each>
327 </div>
328 </div>
329 </xsl:when>
330 <xsl:when test="/page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
331 <div id="gs-document">
332 <div id="tocLoadingImage" style="text-align:center;">
333 <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/><xsl:text>...</xsl:text>
334 </div>
335 </div>
336 <script type="text/javascript">
337 <xsl:text disable-output-escaping="yes">
338 $(window).load(function()
339 {
340 var sectionID = gs.cgiParams.d;
341 var callbackFunction = null;
342 if(sectionID.indexOf("\\.") == -1)
343 {
344 callbackFunction = function()
345 {
346 focusSection(sectionID);
347 };
348 }
349
350 var docID = sectionID.replace(/([^.]*)\..*/, "$1");
351 var url = gs.xsltParams.library_name + "?a=d&amp;c=" + gs.cgiParams.c + "&amp;excerptid=gs-document&amp;dt=hierarchy&amp;d=" + docID;
352 loadTopLevelPage(callbackFunction, url);
353 });
354 </xsl:text>
355 </script>
356 </xsl:when>
357 <xsl:otherwise>
358 <div id="gs-document">
359 <div id="tocLoadingImage" style="text-align:center;">
360 <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/><xsl:text>...</xsl:text>
361 </div>
362 </div>
363 <script type="text/javascript">
364 <xsl:text disable-output-escaping="yes">
365 $(window).load(function()
366 {
367 loadTopLevelPage(function()
368 {
369 //Don't focus the section until the table of contents is loaded
370 var tocCheck = function()
371 {
372 if(gs.variables.tocLoaded)
373 {
374 focusSection("</xsl:text><xsl:value-of select="/page/pageResponse/document/@selectedNode"/><xsl:text disable-output-escaping="yes">");
375 }
376 else
377 {
378 setTimeout(tocCheck, 500);
379 }
380 }
381 tocCheck();
382 });
383 });
384 </xsl:text>
385 </script>
386 </xsl:otherwise>
387 </xsl:choose>
388
389 <div class="clear"><xsl:text> </xsl:text></div>
390 </xsl:template>
391
392 <xsl:template name="editBar">
393 <table style="width:100%"><tr>
394 <td id="editBarLeft" style="width:70%"><xsl:text> </xsl:text></td>
395 <td id="editBarRight">
396 <div style="text-align:center;">
397 <div style="margin:5px;" class="ui-state-default ui-corner-all">
398 <a style="padding: 3px; text-decoration:none;" href="{$library_name}?a=g&amp;sa=documentbasket&amp;c=&amp;s=DisplayDocumentList&amp;rt=r&amp;p.c={/page/pageResponse/collection/@name}&amp;docToEdit={/page/pageResponse/document/documentNode/@nodeID}"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.edit_structure')"/></a>
399 </div>
400 <div style="margin:5px;" class="ui-state-default ui-corner-all">
401 <a id="editContentButton" style="padding: 3px; text-decoration:none;">
402 <xsl:attribute name="href">
403 <xsl:value-of select="$library_name"/>
404 <xsl:text>/collection/</xsl:text>
405 <xsl:value-of select="$collName"/>
406 <xsl:text>/document/</xsl:text>
407 <xsl:choose>
408 <xsl:when test="count(//documentNode) > 0">
409 <xsl:value-of select="/page/pageResponse/document/documentNode/@nodeID"/>
410 </xsl:when>
411 <xsl:otherwise>
412 <xsl:value-of select="/page/pageResponse/document/@nodeID"/>
413 </xsl:otherwise>
414 </xsl:choose>
415 <xsl:if test="not(/page/pageRequest/paramList/param[@name = 'docEdit']/@value = '1')">
416 <xsl:text>?ed=1&amp;docEdit=1&amp;dt=hierarchy</xsl:text>
417 </xsl:if>
418 </xsl:attribute>
419 <xsl:choose>
420 <xsl:when test="/page/pageRequest/paramList/param[@name = 'docEdit']/@value = '1'">
421 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.hide_editor')"/>
422 </xsl:when>
423 <xsl:otherwise>
424 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.edit_content')"/>
425 </xsl:otherwise>
426 </xsl:choose>
427 </a>
428 </div>
429 </div>
430 </td>
431 </tr></table>
432 <gslib:langfrag name="dse"/>
433 </xsl:template>
434
435 <!-- Highlight annotations if requested -->
436 <xsl:template name="displayAnnotation">
437 <xsl:choose>
438 <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
439 <span class="termHighlight"><xsl:value-of select="."/></span>
440 </xsl:when>
441 <xsl:otherwise>
442 <span class="noTermHighlight"><xsl:value-of select="."/></span>
443 </xsl:otherwise>
444 </xsl:choose>
445 </xsl:template>
446
447 <!-- The default template for displaying section titles -->
448 <xsl:template name="sectionTitle">
449 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
450 </xsl:template>
451
452 <xsl:template name="wrappedSectionImage">
453 <gsf:variable name="screenImageWidth"><gsf:metadata name="ScreenWidth"/></gsf:variable>
454 <gsf:variable name="screenImageHeight"><gsf:metadata name="ScreenHeight"/></gsf:variable>
455 <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable>
456 <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable>
457
458 <xsl:choose>
459 <xsl:when test="metadataList/metadata[@name = 'Screen'] and metadataList/metadata[@name = 'SourceFile'] and ($imageWidth div $screenImageWidth > 1.2)">
460 <div id="image{@nodeID}">
461 <div id="wrap{util:replace(@nodeID, '.', '_')}" class="zoomImage" style="position:relative; width: {$screenImageWidth}px; height: {$screenImageHeight}px;">
462 <div id="small{util:replace(@nodeID, '.', '_')}" style="position:relative; width: {$screenImageWidth}px; height: {$screenImageHeight}px;">
463 <gsf:image type="screen"/>
464 </div>
465 <div id="mover{util:replace(@nodeID, '.', '_')}" style="border: 1px solid green; position: absolute; top: 0; left: 0; width: 398px; height: 398px; overflow: hidden; z-index: 100; background: white; display: none;">
466 <div id="overlay{util:replace(@nodeID, '.', '_')}" style="width: 400px; height: 400px; position: absolute; top: 0; left: 0; z-index: 200;">
467 <xsl:text> </xsl:text>
468 </div>
469 <div id="large{util:replace(@nodeID, '.', '_')}" style="position: relative; width: {$imageWidth}px; height: {$imageHeight}px;">
470 <gsf:image type="source"/>
471 </div>
472 </div>
473 </div>
474 <script type="text/javascript">
475 <xsl:text disable-output-escaping="yes">
476 {
477 var nodeID = "</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">";
478 nodeID = nodeID.replace(/\./g, "_");
479
480 var bigHeight = </xsl:text><xsl:value-of select="$imageHeight"/><xsl:text disable-output-escaping="yes">;
481 var smallHeight = </xsl:text><xsl:value-of select="$screenImageHeight"/><xsl:text disable-output-escaping="yes">;
482
483 var multiplier = bigHeight / smallHeight;
484
485 $("#wrap" + nodeID).anythingZoomer({
486 smallArea: "#small" + nodeID,
487 largeArea: "#large" + nodeID,
488 zoomPort: "#overlay" + nodeID,
489 mover: "#mover" + nodeID,
490 expansionSize:50,
491 speedMultiplier:multiplier
492 });
493
494 $("#zoomOptions input").attr("checked", false);
495 $("#zoomOptions").css("display", null);
496 }
497 </xsl:text>
498 </script>
499 </div>
500 </xsl:when>
501 <xsl:otherwise>
502 <div id="image{@nodeID}">
503 <xsl:attribute name="style">
504 <xsl:choose>
505 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'text'">
506 <xsl:text>display:none;</xsl:text>
507 </xsl:when>
508 <xsl:otherwise>
509 <xsl:text>display:block;</xsl:text>
510 </xsl:otherwise>
511 </xsl:choose>
512 </xsl:attribute>
513 <xsl:call-template name="sectionImage"/><xsl:text> </xsl:text>
514 </div>
515 </xsl:otherwise>
516 </xsl:choose>
517 </xsl:template>
518
519 <!-- The default template for displaying the document node text -->
520 <!-- equivalent to gsf:text -->
521 <xsl:template name="documentNodeText">
522 <!-- Hides the "This document has no text." message -->
523 <xsl:variable name="noText"><gsf:metadata name="NoText"/></xsl:variable>
524 <xsl:if test="not($noText = '1')">
525 <!-- Section text -->
526 <xsl:for-each select="nodeContent">
527 <xsl:for-each select="node()">
528 <xsl:choose>
529 <xsl:when test="not(name())">
530 <xsl:value-of select="." disable-output-escaping="yes"/>
531 </xsl:when>
532 <xsl:when test="name() = 'annotation'">
533 <xsl:call-template name="displayAnnotation"/>
534 </xsl:when>
535 <xsl:otherwise>
536 <xsl:apply-templates/>
537 </xsl:otherwise>
538 </xsl:choose>
539 </xsl:for-each>
540 </xsl:for-each>
541 </xsl:if><xsl:text> </xsl:text>
542 </xsl:template>
543
544 <!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
545 <xsl:template name="documentNodeFlashXML">
546 <xsl:text disable-output-escaping="yes">
547 &lt;Section&gt;
548 &lt;Description&gt;
549 &lt;Metadata name="Title"&gt;
550 </xsl:text>
551 <xsl:value-of select="normalize-space(metadataList/metadata[@name = 'Title'])"/>
552 <xsl:text disable-output-escaping="yes">
553 &lt;/Metadata&gt;
554 &lt;/Description&gt;
555 </xsl:text>
556
557 <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
558
559 <xsl:for-each select="documentNode">
560 <xsl:call-template name="documentNodeFlashXML"/>
561 </xsl:for-each>
562
563 <xsl:text disable-output-escaping="yes">
564 &lt;/Section&gt;
565 </xsl:text>
566 </xsl:template>
567
568 <xsl:template name="externalPage">
569 <xsl:param name="external"/>
570 <xsl:variable name="go_forward_link">
571 <a>
572 <xsl:attribute name="href">
573 <xsl:value-of select="$external"/>
574 </xsl:attribute>
575 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.go_forward')"/>
576 </a>
577 </xsl:variable>
578 <h2><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.title')"/></h2>
579 <p><xsl:value-of select="util:getInterfaceTextWithDOM($interface_name, /page/@lang, 'external.text', $go_forward_link)" disable-output-escaping="yes"/></p>
580 </xsl:template>
581
582 <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
583
584 <xsl:template name="documentPre">
585 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
586 <xsl:call-template name="mapFeatures"/>
587 </xsl:if>
588 </xsl:template>
589
590 <xsl:template name="mapFeatures">
591 <div id="map_canvas" class="map_canvas_full"><xsl:text> </xsl:text></div>
592
593 <xsl:choose>
594 <!-- HIERARCHICAL DOCUMENTS -->
595 <xsl:when test="count(//documentNode) > 0">
596 <xsl:for-each select="documentNode">
597 <xsl:call-template name="mapPlacesNearHere"/>
598 </xsl:for-each>
599 </xsl:when>
600 <!-- SIMPLE DOCUMENTS -->
601 <xsl:otherwise>
602 <xsl:call-template name="mapPlacesNearHere"/>
603 </xsl:otherwise>
604 </xsl:choose>
605
606 <div id="jsonNodes" style="display:none;">
607 <xsl:text>[</xsl:text>
608 <xsl:choose>
609 <!-- HIERARCHICAL DOCUMENTS -->
610 <xsl:when test="count(//documentNode) > 0">
611 <xsl:for-each select="//documentNode">
612 <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
613 <xsl:text>{</xsl:text>
614 <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">",</xsl:text>
615 <xsl:text disable-output-escaping="yes">"title":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/><xsl:text disable-output-escaping="yes">",</xsl:text>
616 <xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>
617 <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
618 <xsl:text>}</xsl:text>
619 <xsl:if test="not(position() = count(//documentNode))">
620 <xsl:text>,</xsl:text>
621 </xsl:if>
622 </xsl:if>
623 </xsl:for-each>
624 </xsl:when>
625 <!-- SIMPLE DOCUMENTS -->
626 <xsl:otherwise>
627 <xsl:for-each select="/page/pageResponse/document">
628 <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
629 <xsl:text>{</xsl:text>
630 <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@selectedNode"/><xsl:text disable-output-escaping="yes">",</xsl:text>
631 <xsl:text disable-output-escaping="yes">"title":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/><xsl:text disable-output-escaping="yes">",</xsl:text>
632 <xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>
633 <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
634 <xsl:text>}</xsl:text>
635 </xsl:if>
636 </xsl:for-each>
637 </xsl:otherwise>
638 </xsl:choose>
639 <xsl:text>]</xsl:text>
640 </div>
641 </xsl:template>
642
643 <xsl:template name="mapPlacesNearHere">
644 <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
645 <div style="background:#BBFFBB; padding: 5px; margin:0px auto; width:890px;">
646 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.maps.nearby_docs')"/>
647 <img id="nearbyDocumentsToggle" style="margin-left:5px;" src="interfaces/{$interface_name}/images/expand.png">
648 <xsl:attribute name="onclick">
649 <xsl:text>performDistanceSearch('</xsl:text>
650 <xsl:value-of select="@nodeID"/>
651 <xsl:text>', '</xsl:text>
652 <gsf:metadata name="Latitude"/>
653 <xsl:text>', '</xsl:text>
654 <gsf:metadata name="Longitude"/>
655 <xsl:text>', 2);</xsl:text>
656 </xsl:attribute>
657 </img>
658 <div id="nearbyDocuments"><xsl:text> </xsl:text></div>
659 </div>
660 </xsl:if>
661 </xsl:template>
662</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.