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

Last change on this file since 31752 was 31752, checked in by kjdon, 4 years ago

keep_editing_controls_visible is only defined when we are editing, so wrap in a test for that.

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