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

Last change on this file since 32836 was 32836, checked in by ak19, 5 years ago

Fixing annoying browser js error when classifier hfile attribute present but empty, then the full path constructed to the hfile only goes as far as up to the etc folder and a GET request on that etc folder fails. Now we don't bother doing a GET on any hfile that has an empty string value.

File size: 37.1 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 <span style="font-weight:bold; font-size: 120%;">
66 <xsl:call-template name="choose-title"/>
67 </span>
68 </xsl:template>
69
70 <!-- content of a simple document. Will not be used for editing mode -->
71 <xsl:template name="documentContent">
72 <div id="gs-document">
73 <xsl:call-template name="documentPre"/>
74 <xsl:call-template name="wrappedSectionImage"/>
75 <div id="gs-document-text">
76 <xsl:call-template name="documentNodeText"/>
77 </div>
78 </div>
79 </xsl:template>
80
81 <xsl:template name="sectionHeading">
82 <xsl:call-template name="sectionTitle"/>
83 </xsl:template>
84
85 <xsl:template name="topLevelSectionContent">
86 <xsl:call-template name="wrappedSectionImage"/>
87 <xsl:call-template name="wrappedSectionText"/>
88 </xsl:template>
89
90 <xsl:template name="sectionContent">
91 <xsl:call-template name="wrappedSectionImage"/>
92 <xsl:call-template name="wrappedSectionText"/>
93 </xsl:template>
94 <xsl:template name="sectionContentForEditing">
95 <xsl:call-template name="wrappedSectionImage"/>
96 <xsl:call-template name="wrappedSectionTextForEditing"/>
97 </xsl:template>
98
99 <xsl:template name="wrappedSectionTextForEditing">
100 <br /><br />
101 <div id="text{@nodeID}" class="sectionText" style="display:block;"><!-- *** -->
102 <xsl:attribute name="contenteditable">
103 <xsl:text>true</xsl:text>
104 </xsl:attribute>
105 <xsl:call-template name="documentNodeTextForEditing"/>
106 </div>
107 </xsl:template>
108
109 <xsl:template name="wrappedSectionText">
110 <br /><br />
111 <div id="text{@nodeID}" class="sectionText"><!-- *** -->
112 <xsl:attribute name="style">
113 <xsl:choose>
114 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'image'">
115 <xsl:text>display:none;</xsl:text>
116 </xsl:when>
117 <xsl:otherwise>
118 <xsl:text>display:block;</xsl:text>
119 </xsl:otherwise>
120 </xsl:choose>
121 </xsl:attribute>
122 <xsl:call-template name="documentNodeText"/>
123 </div>
124 </xsl:template>
125
126 <xsl:template name="sectionImage">
127 <gsf:image type="screen"/>
128 </xsl:template>
129
130 <!-- Used to make sure that regardless what the collection designer uses for the title and content we can wrap it properly -->
131 <!-- If editing, be aware that the Document Basket looks for specific classes that this template bakes in (key points marked with ***) -->
132 <xsl:template name="wrapDocumentNodes">
133 <xsl:variable name="nodeID" select="@nodeID"/>
134 <a name="{@nodeID}"><xsl:text> </xsl:text></a>
135
136 <!-- Section header -->
137 <table class="sectionHeader"><tr>
138
139 <!-- Expand/collapse button -->
140 <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'">
141 <td class="headerTD">
142 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
143 <xsl:attribute name="src">
144 <xsl:choose>
145 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or util:oidIsMatchOrParent($nodeID, /page/pageResponse/document/@selectedNode)">
146 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
147 </xsl:when>
148 <xsl:otherwise>
149 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
150 </xsl:otherwise>
151 </xsl:choose>
152 </xsl:attribute>
153 </img>
154 </td>
155 </xsl:if>
156
157 <!-- Title -->
158 <td id="header{@nodeID}" class="headerTD sectionTitle"><!-- *** -->
159 <p>
160 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
161
162 <xsl:if test="util:hashToSectionId(@nodeID)">
163 <span class="sectionNumberSpan">
164 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
165 <xsl:text> </xsl:text>
166 </span>
167 </xsl:if>
168 <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
169 <span><xsl:call-template name="sectionHeading"/></span>
170 </p>
171 </td>
172
173 <!-- "back to top" link -->
174 <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'">
175 <td class="backToTop headerTD">
176 <a href="javascript:scrollToTop();">
177 <xsl:text disable-output-escaping="yes">&#9650;</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.back_to_top')"/>
178 </a>
179 </td>
180 </xsl:if>
181 </tr></table>
182
183 <div id="doc{@nodeID}"><!-- *** -->
184 <xsl:choose>
185 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
186 <xsl:attribute name="class">
187 <xsl:text>sectionContainer hasText</xsl:text>
188 </xsl:attribute>
189 <xsl:attribute name="style">
190 <xsl:text>display:block;</xsl:text>
191 </xsl:attribute>
192 </xsl:when>
193 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or util:oidIsMatchOrParent(@nodeID, /page/pageResponse/document/@selectedNode)">
194 <xsl:attribute name="class">
195 <xsl:text>sectionContainer noText</xsl:text>
196 </xsl:attribute>
197 <xsl:attribute name="style">
198 <xsl:text>display:block;</xsl:text>
199 </xsl:attribute>
200 </xsl:when>
201 <xsl:otherwise>
202 <xsl:attribute name="class">
203 <xsl:text>sectionContainer noText</xsl:text>
204 </xsl:attribute>
205 <xsl:attribute name="style">
206 <xsl:text>display:none;</xsl:text>
207 </xsl:attribute>
208 </xsl:otherwise>
209 </xsl:choose>
210
211 <xsl:choose>
212 <xsl:when 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))">
213 <table id="meta{@nodeID}">
214 <xsl:attribute name="style">
215 <xsl:choose>
216 <xsl:when test="/page/pageRequest/paramList/param[@name = 'dmd']/@value = 'true'">
217 <xsl:text>display:block;</xsl:text>
218 </xsl:when>
219 <xsl:otherwise>
220 <xsl:text>display:none;</xsl:text>
221 </xsl:otherwise>
222 </xsl:choose>
223 </xsl:attribute>
224 <xsl:value-of select="util:clearMetadataStorage()"/>
225 <xsl:for-each select="metadataList/metadata">
226 <xsl:sort select="@name"/>
227 <tr>
228 <td class="metaTableCellName"><xsl:value-of select="@name"/></td>
229 <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>
230 </tr>
231 </xsl:for-each>
232 </table>
233 <div id="map-and-controls-{@nodeID}" tabindex="-1">
234 <div id="map-{@nodeID}" style="height: 300px;"><xsl:text> </xsl:text></div>
235
236
237 <div id="ControlPanel-{@nodeID}" class="ControlPanel" >
238 <div id="ControlButtons">
239
240 <button onclick="gsmap_store['map-{@nodeID}'].deleteAllShapes()" >Clear All</button>
241 <button onclick="gsmap_store['map-{@nodeID}'].deleteSelectedShapes()" >Delete Selected</button>
242 <button onclick="gsmap_store['map-{@nodeID}'].mapEditorHistory.undo()" >Undo</button>
243 <button onclick="gsmap_store['map-{@nodeID}'].mapEditorHistory.redo()" >Redo</button>
244 <input type="checkbox" name="draggableCB" id="draggableCB-{@nodeID}" value="false" /> Lock all shapes location <br/>
245 </div>
246
247 <div id="SecondRow">
248 <div id="LineThickness">
249 <p>Line thickness: <input type="range" min="20" max="100" value="1" class="slider" id="thicknessRange-{@nodeID}" /> </p>
250 <p>Value: <span id="thicknessRangeVal-{@nodeID}"></span></p>
251 </div>
252
253 <div id="ColourOpacity">
254 <p>Colour opacity: <input type="range" min="10" max="100" value="40" class="slider" id="colourOpacity-{@nodeID}" /> </p>
255 <p>Value: <span id="opacityRangeVal-{@nodeID}"></span></p>
256 </div>
257 </div>
258 <div id = "ThirdRow">
259 <div id="FillColour">
260 <p> Fill Colour:</p> <div id="color-palette1-{@nodeID}"><xsl:text> </xsl:text></div>
261 </div>
262 </div>
263 </div>
264 <div id="style-selector-control-{@nodeID}" class="map-control">
265 <select id="style-selector-{@nodeID}" class="selector-control">
266 <option value="default" selected="selected">Default</option>
267 <option value="silver">Silver</option>
268 <option value="night">Night mode</option>
269 <option value="retro">Retro</option>
270 <option value="paleDawn">Pale Dawn</option>
271 <option value="avocadoWorld">Avocado World</option>
272 <option value="bright">Bright</option>
273 <option value="turquoise">Turquoise</option>
274 <option value="hiding">Hide features</option>
275 </select>
276 </div>
277
278 </div>
279
280 <xsl:call-template name="sectionContentForEditing"/>
281 </xsl:when>
282 <xsl:otherwise>
283 <xsl:choose>
284 <xsl:when test="../../document">
285 <xsl:call-template name="topLevelSectionContent"/>
286 </xsl:when>
287 <xsl:otherwise>
288 <xsl:call-template name="sectionContent"/>
289 </xsl:otherwise>
290 </xsl:choose>
291 </xsl:otherwise>
292 </xsl:choose>
293 <xsl:if test="documentNode">
294 <xsl:for-each select="documentNode">
295 <xsl:call-template name="wrapDocumentNodes"/>
296 </xsl:for-each>
297 </xsl:if>
298 </div>
299 </xsl:template>
300
301 <xsl:template name="javascriptForDocumentView">
302 <script type="text/javascript" src="interfaces/{$interface_name}/js/document_scripts.js"><xsl:text> </xsl:text></script>
303 <gsf:metadata name="Thumb" hidden="true"/>
304 <script type="text/javascript">
305 <xsl:text disable-output-escaping="yes">
306 function goToAnchor(sectionID,anchor)
307 {
308 var docIdentifier = '</xsl:text><xsl:value-of select="//documentNode[@nodeType = 'root']/@nodeID"/><xsl:text disable-output-escaping="yes">';
309 focusAnchor(docIdentifier + "."+ sectionID,0,1,anchor);
310 }
311 </xsl:text>
312 </script>
313 <xsl:call-template name="customJavascriptForDocumentView"/>
314 </xsl:template>
315
316 <!-- Use this to add in extra javascript/files for an interface, site, collection -->
317 <xsl:template name="customJavascriptForDocumentView">
318 </xsl:template>
319
320 <xsl:template name="javascriptForDocumentEditing">
321 <!-- <script type="text/javascript" src="interfaces/{$interface_name}/js/documentmaker_scripts.js"><xsl:text> </xsl:text></script>-->
322 <script type="text/javascript" src="interfaces/{$interface_name}/js/documentedit_scripts.js"><xsl:text> </xsl:text></script>
323 <script type="text/javascript" src="interfaces/{$interface_name}/js/documentedit_scripts_util.js"><xsl:text> </xsl:text></script>
324 <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-shapes-util.js"><xsl:text> </xsl:text></script>
325 <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor-history.js"><xsl:text> </xsl:text></script>
326 <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor-themes.js"><xsl:text> </xsl:text></script>
327 <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor.js"><xsl:text> </xsl:text></script>
328 <script type="text/javascript" src="interfaces/{$interface_name}/js/hierarchy.js"><xsl:text> </xsl:text></script>
329
330 <link rel="stylesheet" href="interfaces/{$interface_name}/style/map-editors.css" type="text/css"/>
331
332 <script type="text/javascript">
333 <xsl:text disable-output-escaping="yes">
334
335 $(window).load(function()
336 {
337 if(gs.cgiParams.docEdit == "1")
338 {
339 readyPageForEditing();
340 }
341 });
342 </xsl:text>
343 <!-- download and process hierarchy files -->
344 <xsl:text disable-output-escaping="yes">$(document).ready(function(){</xsl:text>
345 <xsl:for-each select="//classifier[@hfile]">
346 <xsl:if test="@hfile != ''">
347 <xsl:text disable-output-escaping="yes">downloadAndProcessHierarchyFile('</xsl:text>
348 <xsl:text>sites/localsite/collect/</xsl:text><xsl:value-of select="$collName"/><xsl:text>/etc/</xsl:text><xsl:value-of select="@hfile"/>
349 <xsl:text disable-output-escaping="yes">','</xsl:text><xsl:value-of select="@metadata"/><xsl:text disable-output-escaping="yes">');</xsl:text>
350 </xsl:if>
351 </xsl:for-each>
352 <xsl:text disable-output-escaping="yes">});</xsl:text>
353
354 </script>
355 <xsl:call-template name="customJavascriptForDocumentEditing"/>
356 </xsl:template>
357
358 <!-- Use this to add in extra javascript/files for an interface, site, collection -->
359 <xsl:template name="customJavascriptForDocumentEditing">
360 </xsl:template>
361
362 <!-- the page content -->
363 <xsl:template match="/page/pageResponse/document">
364 <xsl:if test="$bookswitch = 'off'">
365 <xsl:call-template name="javascriptForDocumentView"/>
366 <gslib:langfrag name="doc"/>
367 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
368 <script type="text/javascript">
369 <xsl:text disable-output-escaping="yes">
370 if(document.URL.indexOf("book=on") != -1)
371 {
372 loadBook();
373 }
374 </xsl:text>
375 </script>
376 </xsl:if>
377 </xsl:if>
378 <xsl:variable name="canDoEditing">
379 <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>
380 </xsl:variable>
381 <xsl:if test="$canDoEditing = 'true'">
382 <xsl:call-template name="javascriptForDocumentEditing"/>
383 <gslib:langfrag name="dse"/>
384 <gslib:langfrag name="de"/>
385 </xsl:if>
386
387 <xsl:if test="$bookswitch = 'off'">
388 <div id="bookdiv" style="visibility:hidden; height:0px; display:inline;"><xsl:text> </xsl:text></div>
389
390 <div id="float-anchor" style="width: 30%; min-width:180px; float:right; margin: 0 0 10px 20px;">
391 <xsl:if test="$canDoEditing = 'true'">
392 <xsl:call-template name="editBar"/>
393 </xsl:if>
394 <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'">
395 <xsl:call-template name="rightSidebar"/>
396 </xsl:if>
397 <!-- add in some text just in case nothing has been added to this div-->
398 <xsl:text> </xsl:text>
399 </div>
400 <xsl:if test="$canDoEditing = 'true'">
401 <script type="text/javascript">
402 if (keep_editing_controls_visible) {
403 $(function() {
404 moveScroller();
405 });
406 }
407 </script>
408 </xsl:if>
409 </xsl:if>
410
411 <!-- display the document -->
412 <xsl:choose>
413 <xsl:when test="@external != ''">
414 <xsl:call-template name="externalPage">
415 <xsl:with-param name="external" select="@external"/>
416 </xsl:call-template>
417 </xsl:when>
418 <xsl:when test="$bookswitch = 'flashxml'">
419 <xsl:call-template name="documentNodeFlashXML"/>
420 </xsl:when>
421 <xsl:when test="$bookswitch = 'on'">
422 <div id="bookdiv" style="display:inline;"><xsl:text> </xsl:text></div>
423 <!-- *** in document-scripts.js *** -->
424 <script type="text/javascript">
425 <xsl:text disable-output-escaping="yes">
426 if(document.URL.indexOf("book=on") != -1)
427 {
428 loadBook();
429 }
430 </xsl:text>
431 </script>
432 </xsl:when>
433 <!-- 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-->
434 <!-- This is the first choice from wrappedDocument template-->
435 <xsl:when test="$canDoEditing = 'true' and /page/pageRequest/paramList/param[@name='docEdit']/@value = '1'">
436 <div id="gs-document" style="width: 67%">
437 <xsl:call-template name="documentPre"/>
438 <div id="gs-document-text" class="documenttext" collection="{/page/pageResponse/collection/@name}"><!-- *** -->
439 <xsl:choose>
440 <xsl:when test="@docType='simple'">
441 <xsl:call-template name="wrapDocumentNodes"/>
442 </xsl:when>
443 <xsl:otherwise>
444 <xsl:for-each select="documentNode">
445 <xsl:call-template name="wrapDocumentNodes"/>
446 </xsl:for-each>
447 </xsl:otherwise>
448 </xsl:choose>
449 </div>
450 </div>
451 </xsl:when>
452 <xsl:when test="@docType='simple'">
453 <xsl:call-template name="documentHeading"/><br/>
454 <xsl:call-template name="documentContent"/>
455 <br /><xsl:call-template name="userCommentsSection"/>
456 </xsl:when>
457 <xsl:otherwise> <!-- display the standard greenstone document -->
458 <xsl:call-template name="wrappedDocument"/>
459 <br /><xsl:call-template name="userCommentsSection"/>
460 </xsl:otherwise>
461 </xsl:choose>
462 </xsl:template>
463
464 <xsl:template name="wrappedDocument">
465 <xsl:choose>
466 <!-- NOTE: alb = ajax load bypass -->
467 <!--
468 If we have asked for expanded document, then do this.
469 OR If the docType is hierarchy and we want to bypass the ajax load then do this
470 OR If the docType is hierarchy and we have asked for the top level document then do this
471 -->
472 <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, '.')))))">
473 <div id="gs-document">
474 <xsl:call-template name="documentPre"/>
475 <div id="gs-document-text" class="documenttext" collection="{/page/pageResponse/collection/@name}"><!-- *** -->
476 <xsl:for-each select="documentNode">
477 <xsl:call-template name="wrapDocumentNodes"/>
478 </xsl:for-each>
479 </div>
480 </div>
481 </xsl:when>
482 <xsl:when test="/page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
483 <div id="gs-document">
484 <div id="tocLoadingImage" style="text-align:center;">
485 <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>
486 </div>
487 </div>
488 <script type="text/javascript">
489 <xsl:text disable-output-escaping="yes">
490 $(window).load(function()
491 {
492 var sectionID = gs.cgiParams.d;
493 var callbackFunction = null;
494 if(sectionID.indexOf(".") != -1)
495 {
496 callbackFunction = function()
497 {
498 focusSection(sectionID);
499 };
500 }
501 else {
502 callbackFunction = function()
503 {
504
505 expandAndExecute(sectionID+".1", null, null, null);
506 };
507 }
508 var docID = sectionID.replace(/([^.]*)\..*/, "$1");
509 var url = gs.xsltParams.library_name + "?a=d&amp;c=" + gs.cgiParams.c + "&amp;excerptid=gs-document&amp;dt=hierarchy&amp;d=" + docID;
510 if(gs.cgiParams.p_s) {
511 url += "&amp;p.s="+gs.cgiParams.p_s;
512 }
513 loadTopLevelPage(callbackFunction, url);
514 });
515 </xsl:text>
516 </script>
517 </xsl:when>
518 <xsl:otherwise>
519 <div id="gs-document">
520 <div id="tocLoadingImage" style="text-align:center;">
521 <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>
522 </div>
523 </div>
524 <script type="text/javascript">
525 <xsl:text disable-output-escaping="yes">
526 $(window).load(function()
527 {
528 loadTopLevelPage(function()
529 {
530 //Don't focus the section until the table of contents is loaded
531 var tocCheck = function()
532 {
533 if(gs.variables.tocLoaded)
534 {
535 focusSection("</xsl:text><xsl:value-of select="/page/pageResponse/document/@selectedNode"/><xsl:text disable-output-escaping="yes">");
536 }
537 else
538 {
539 setTimeout(tocCheck, 500);
540 }
541 }
542 tocCheck();
543 });
544 });
545 </xsl:text>
546 </script>
547 </xsl:otherwise>
548 </xsl:choose>
549
550 <div class="clear"><xsl:text> </xsl:text></div>
551 </xsl:template>
552
553 <xsl:template name="editBar">
554 <table style="width:100%; border:none;" id="editBar" class="ui-widget-content"><tr>
555 <td id="editBarLeft" style="width:70%"><xsl:text> </xsl:text></td>
556 <td id="editBarRight">
557 <div style="text-align:center;">
558 <!-- edit structure button -->
559 <!-- comment this out as its not working -->
560 <!-- <div style="margin:5px;" class="ui-state-default ui-corner-all">
561 <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>
562 </div>-->
563 <!-- edit content button -->
564 <div style="margin:5px;" class="ui-state-default ui-corner-all">
565 <a id="editContentButton" style="padding: 3px; text-decoration:none;">
566 <xsl:attribute name="href">
567 <xsl:value-of select="$library_name"/>
568 <xsl:text>/collection/</xsl:text>
569 <xsl:value-of select="$collName"/>
570 <xsl:text>/document/</xsl:text>
571 <xsl:choose>
572 <xsl:when test="count(//documentNode) > 0">
573 <xsl:value-of select="/page/pageResponse/document/documentNode/@nodeID"/>
574 </xsl:when>
575 <xsl:otherwise>
576 <xsl:value-of select="/page/pageResponse/document/@nodeID"/>
577 </xsl:otherwise>
578 </xsl:choose>
579 <xsl:if test="not(/page/pageRequest/paramList/param[@name = 'docEdit']/@value = '1')">
580 <xsl:text>?ed=1&amp;docEdit=1</xsl:text>
581 </xsl:if>
582 </xsl:attribute>
583 <xsl:choose>
584 <xsl:when test="/page/pageRequest/paramList/param[@name = 'docEdit']/@value = '1'">
585 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'de.hide_editor')"/>
586 </xsl:when>
587 <xsl:otherwise>
588 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'de.edit_content')"/>
589 </xsl:otherwise>
590 </xsl:choose>
591 </a>
592 </div>
593 </div>
594 </td>
595 </tr></table>
596 <gslib:langfrag name="dse"/>
597 </xsl:template>
598
599
600 <!-- The default template for displaying section titles -->
601 <xsl:template name="sectionTitle">
602 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
603 </xsl:template>
604
605 <xsl:template name="wrappedSectionImage">
606 <gsf:variable name="screenImageWidth"><gsf:metadata name="ScreenWidth"/></gsf:variable>
607 <gsf:variable name="screenImageHeight"><gsf:metadata name="ScreenHeight"/></gsf:variable>
608 <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable>
609 <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable>
610
611 <xsl:choose>
612 <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')">
613 <div id="tidyDiv"/>
614 <!-- adding a div with clear:both when the image doesn't nicely fit in beside the side bar. Otherwise, the divs stays up, but the image moves down and everything looks and acts weird. -->
615 <script type="text/javascript">
616 <xsl:text disable-output-escaping="yes">
617
618 var containerWidth = document.getElementById("container").offsetWidth;
619 var sidebarWidth = document.getElementById("rightSidebar").offsetWidth;
620 if (containerWidth - sidebarWidth &lt; </xsl:text><xsl:value-of select="$screenImageWidth"/><xsl:text disable-output-escaping="yes">) {
621 $("#tidyDiv").css("clear", "both");
622 }
623 </xsl:text>
624 </script>
625 <div id="image{@nodeID}">
626 <!-- when we ask for an individual section content we set ed=1. putting this test here prevents downloading all the screen and full images for each section of the document when we are just looking at the contents list. ed is not set for simple docs, so do this if doctype is simple -->
627 <xsl:if test="/page/pageResponse/document[@docType='simple'] or /page/pageRequest/paramList/param[@name = 'ed']/@value='1'">
628
629 <div id="wrap{util:replace(@nodeID, '.', '_')}" class="zoomImage" style="position:relative; width: {$screenImageWidth}px; height: {$screenImageHeight}px;">
630 <div id="small{util:replace(@nodeID, '.', '_')}" style="position:relative; width: {$screenImageWidth}px; height: {$screenImageHeight}px;">
631 <gsf:link type="source" target="_blank"><gsf:image type="screen"/></gsf:link>
632 </div>
633 <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;">
634 <div id="overlay{util:replace(@nodeID, '.', '_')}" style="width: 600px; height: 600px; position: absolute; top: 0; left: 0; z-index: 200;">
635 <xsl:text> </xsl:text>
636 </div>
637 <div id="large{util:replace(@nodeID, '.', '_')}" style="position: relative; width: {$imageWidth}px; height: {$imageHeight}px;">
638 <gsf:link type="source"><gsf:image type="source"/></gsf:link>
639 </div>
640 </div>
641 </div>
642 <script type="text/javascript">
643 <xsl:text disable-output-escaping="yes">
644 {
645 var nodeID = "</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">";
646 nodeID = nodeID.replace(/\./g, "_");
647
648 var bigHeight = </xsl:text><xsl:value-of select="$imageHeight"/><xsl:text disable-output-escaping="yes">;
649 var smallHeight = </xsl:text><xsl:value-of select="$screenImageHeight"/><xsl:text disable-output-escaping="yes">;
650
651 var multiplier = bigHeight / smallHeight;
652
653 $("#wrap" + nodeID).anythingZoomer({
654 smallArea: "#small" + nodeID,
655 largeArea: "#large" + nodeID,
656 zoomPort: "#overlay" + nodeID,
657 mover: "#mover" + nodeID,
658 expansionSize:50,
659 speedMultiplier:multiplier
660 });
661
662 $("#zoomOptions input").prop("checked", false);
663 $("#zoomOptions").css("display", "");
664 }
665 </xsl:text>
666 </script>
667 </xsl:if>
668 </div>
669 </xsl:when>
670 <xsl:otherwise>
671 <div id="image{@nodeID}">
672 <xsl:attribute name="style">
673 <xsl:choose>
674 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'text'">
675 <xsl:text>display:none;</xsl:text>
676 </xsl:when>
677 <xsl:otherwise>
678 <xsl:text>display:block;</xsl:text>
679 </xsl:otherwise>
680 </xsl:choose>
681 </xsl:attribute>
682 <xsl:call-template name="sectionImage"/><xsl:text> </xsl:text>
683 </div>
684 </xsl:otherwise>
685 </xsl:choose>
686 </xsl:template>
687
688 <!-- The default template for displaying the document node text -->
689 <!-- equivalent to gsf:text -->
690 <xsl:template name="documentNodeText">
691 <xsl:param name="force">0</xsl:param>
692 <!-- Hides the "This document has no text." message -->
693 <xsl:variable name="noText"><gsf:metadata name="NoText"/></xsl:variable>
694 <xsl:choose>
695 <xsl:when test="$force = '1' or not($noText = '1')">
696
697 <!-- Section text -->
698 <xsl:for-each select="nodeContent">
699 <xsl:call-template name="displayMarkedUpTextAndAnnotations"/>
700 </xsl:for-each>
701 </xsl:when>
702 <xsl:when test="$noText = '1' and not(metadataList/metadata[@name='ImageType'])">
703 <gsf:link type="source"><gsf:metadata name="Source"/></gsf:link>
704 </xsl:when>
705 </xsl:choose>
706 <xsl:text> </xsl:text>
707 </xsl:template>
708
709 <!-- display the text content of a node (content node or metadata node), marking up the annotations -->
710 <xsl:template name="displayMarkedUpTextAndAnnotations">
711 <xsl:variable name="annotation_class">
712 <xsl:choose>
713 <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'off' or /page/pageResponse/format[@type='display']/gsf:option[@name='disableSearchTermHighlighting']/@value='true'">noTermHighlight</xsl:when>
714 <xsl:otherwise>termHighlight</xsl:otherwise>
715 </xsl:choose>
716 </xsl:variable>
717 <xsl:for-each select="node()">
718 <xsl:choose>
719 <xsl:when test="not(name())">
720 <xsl:value-of select="." disable-output-escaping="yes"/>
721 </xsl:when>
722 <xsl:when test="name() = 'annotation'">
723 <span class="{$annotation_class}"><xsl:value-of select="."/></span>
724 </xsl:when>
725 <xsl:otherwise>
726 <xsl:apply-templates/>
727 </xsl:otherwise>
728 </xsl:choose>
729 </xsl:for-each>
730 </xsl:template>
731
732
733 <!-- The default template for displaying the document node text in
734 editing mode -->
735 <!-- Note: we need to put some content in if the nodeContent is empty, otherwise you end up with an empty div, it gets changed to <div> and the ckeditor ends up being attached to everything else afterwards. -->
736 <!-- equivalent to gsf:text -->
737 <xsl:template name="documentNodeTextForEditing">
738 <!-- Section text -->
739 <xsl:for-each select="nodeContent">
740 <xsl:if test="not(node())"><gsf:space/></xsl:if>
741 <xsl:for-each select="node()">
742 <xsl:choose>
743 <xsl:when test="not(name())">
744 <xsl:value-of select="." disable-output-escaping="yes"/>
745 </xsl:when>
746 <xsl:otherwise>
747 <xsl:apply-templates/>
748 </xsl:otherwise>
749 </xsl:choose>
750 </xsl:for-each>
751 </xsl:for-each>
752 </xsl:template>
753
754 <!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
755 <xsl:template name="documentNodeFlashXML">
756 <xsl:text disable-output-escaping="yes">
757 &lt;Section&gt;
758 &lt;Description&gt;
759 &lt;Metadata name="Title"&gt;
760 </xsl:text>
761 <xsl:value-of select="normalize-space(metadataList/metadata[@name = 'Title'])"/>
762 <xsl:text disable-output-escaping="yes">
763 &lt;/Metadata&gt;
764 &lt;/Description&gt;
765 </xsl:text>
766
767 <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
768
769 <xsl:for-each select="documentNode">
770 <xsl:call-template name="documentNodeFlashXML"/>
771 </xsl:for-each>
772
773 <xsl:text disable-output-escaping="yes">
774 &lt;/Section&gt;
775 </xsl:text>
776 </xsl:template>
777
778 <xsl:template name="externalPage">
779 <xsl:param name="external"/>
780 <xsl:variable name="go_forward_link">
781 <a>
782 <xsl:attribute name="href">
783 <xsl:value-of select="$external"/>
784 </xsl:attribute>
785 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.go_forward')"/>
786 </a>
787 </xsl:variable>
788 <h2><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.title')"/></h2>
789 <p><xsl:value-of select="util:getInterfaceTextWithDOM($interface_name, /page/@lang, 'external.text', $go_forward_link)" disable-output-escaping="yes"/></p>
790 </xsl:template>
791
792 <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
793
794 <xsl:template name="documentPre">
795 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
796 <xsl:call-template name="mapFeatures"/>
797 </xsl:if>
798 </xsl:template>
799
800 <xsl:template name="mapFeatures">
801 <div id="map_canvas" class="map_canvas_full"><xsl:text> </xsl:text></div>
802
803 <xsl:choose>
804 <!-- HIERARCHICAL DOCUMENTS -->
805 <xsl:when test="count(//documentNode) > 0">
806 <xsl:for-each select="documentNode">
807 <xsl:call-template name="mapPlacesNearHere"/>
808 </xsl:for-each>
809 </xsl:when>
810 <!-- SIMPLE DOCUMENTS -->
811 <xsl:otherwise>
812 <xsl:call-template name="mapPlacesNearHere"/>
813 </xsl:otherwise>
814 </xsl:choose>
815
816 <div id="jsonNodes" style="display:none;">
817 <xsl:text>[</xsl:text>
818 <xsl:choose>
819 <!-- HIERARCHICAL DOCUMENTS -->
820 <xsl:when test="count(//documentNode) > 0">
821 <xsl:for-each select="//documentNode">
822 <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
823 <xsl:text>{</xsl:text>
824 <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">",</xsl:text>
825 <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>
826 <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>
827 <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
828 <xsl:text>}</xsl:text>
829 <xsl:if test="not(position() = count(//documentNode))">
830 <xsl:text>,</xsl:text>
831 </xsl:if>
832 </xsl:if>
833 </xsl:for-each>
834 </xsl:when>
835 <!-- SIMPLE DOCUMENTS -->
836 <xsl:otherwise>
837 <xsl:for-each select="/page/pageResponse/document">
838 <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
839 <xsl:text>{</xsl:text>
840 <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@selectedNode"/><xsl:text disable-output-escaping="yes">",</xsl:text>
841 <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>
842 <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>
843 <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>
844 <xsl:text>}</xsl:text>
845 </xsl:if>
846 </xsl:for-each>
847 </xsl:otherwise>
848 </xsl:choose>
849 <xsl:text>]</xsl:text>
850 </div>
851 </xsl:template>
852
853 <xsl:template name="mapPlacesNearHere">
854 <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']">
855 <div style="background:#BBFFBB; padding: 5px; margin:0px auto; width:890px;">
856 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.map_nearby_docs')"/>
857 <img id="nearbyDocumentsToggle" style="margin-left:5px;" src="interfaces/{$interface_name}/images/expand.png">
858 <xsl:attribute name="onclick">
859 <xsl:text>performDistanceSearch('</xsl:text>
860 <xsl:value-of select="@nodeID"/>
861 <xsl:text>', '</xsl:text>
862 <gsf:metadata name="Latitude"/>
863 <xsl:text>', '</xsl:text>
864 <gsf:metadata name="Longitude"/>
865 <xsl:text>', 2);</xsl:text>
866 </xsl:attribute>
867 </img>
868 <div id="nearbyDocuments"><xsl:text> </xsl:text></div>
869 </div>
870 </xsl:if>
871 </xsl:template>
872</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.