source: main/trunk/model-cols-dev/peijones/transform/pages/document.xsl@ 24616

Last change on this file since 24616 was 24616, checked in by papitha, 13 years ago

Pei Jones - Collage included and Photo Notes included

File size: 17.2 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 xmlns:gslib="http://www.greenstone.org/skinning"
7 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
8 extension-element-prefixes="java util"
9 exclude-result-prefixes="java util gsf">
10
11 <!-- use the 'main' layout -->
12 <xsl:import href="layouts/main.xsl"/>
13
14 <!-- style includes global params interface_name, library_name -->
15 <xsl:include href=".old/berrytools.xsl"/>
16
17 <xsl:variable name="bookswitch">
18 <xsl:choose>
19 <xsl:when test="/page/pageRequest/paramList/param[@name='book']/@value">
20 <xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
21 </xsl:when>
22 <xsl:otherwise>off</xsl:otherwise>
23 </xsl:choose>
24 </xsl:variable>
25
26 <!-- set page title -->
27 <xsl:template name="pageTitle"><gslib:documentTitle/></xsl:template>
28
29 <!-- set page breadcrumbs -->
30 <xsl:template name="breadcrumbs">
31 <gslib:siteLink/><gslib:rightArrow/>
32 <gslib:collectionNameLinked/><gslib:rightArrow/>
33 <a>
34 <xsl:attribute name="href">
35 <xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="$collName"/>&amp;d=<xsl:value-of select="/page/pageResponse/document/documentNode[1]/@nodeID"/>&amp;dt=<xsl:value-of select="/page/pageResponse/document/documentNode/@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>
36 </xsl:attribute>
37 <xsl:variable name="documentTitleVar">
38 <gslib:documentTitle/>
39 </xsl:variable>
40 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.document')"/>
41 </a>
42 </xsl:template>
43
44 <xsl:template match="/">
45 <xsl:choose>
46 <!-- if this is the realistic books version of the page -->
47 <xsl:when test="$bookswitch = 'flashxml'">
48 <html>
49 <body>
50 <xsl:apply-templates select="/page/pageResponse/document"/>
51 </body>
52 </html>
53 </xsl:when>
54 <!-- if this is the regular version of the page -->
55 <xsl:otherwise>
56 <xsl:apply-imports/>
57 </xsl:otherwise>
58 </xsl:choose>
59 </xsl:template>
60
61 <!-- the page content -->
62 <xsl:template match="/page/pageResponse/document">
63
64 <xsl:if test="$bookswitch = 'off'">
65 <div id="bookdiv" style="visibility:hidden; height:0px; display:inline;"><xsl:text> </xsl:text></div>
66
67 <script type="text/javascript" src="interfaces/{$interface_name}/js/document_scripts.js"><xsl:text> </xsl:text></script>
68
69 <script type="text/javascript" src="sites/localsite/collect/peijones/js/documentmaker/BrowserDetect.js"><xsl:text> </xsl:text></script>
70 <script type="text/javascript" src="sites/localsite/collect/peijones/js/documentmaker/PhotoNotes-1.5.js"><xsl:text> </xsl:text></script>
71 <link rel="stylesheet" type="text/css" href="sites/localsite/collect/peijones/style/PhotoNotes-1.5.css"/>
72 <div class="Photo fn-container" id="PhotoContainer">
73 <img src="sites/localsite/collect/peijones/images/photo/0_PAColl-0671-01korokijones.jpg" />
74 </div>
75
76 <input type="button" value="Add a Note!" style="margin-left:30px;" onclick="AddNote();" />
77 <script type="text/javascript">
78 <xsl:text disable-output-escaping="yes">
79 /* create the Photo Note Container */
80 var notes = new PhotoNoteContainer(document.getElementById('PhotoContainer'));
81 var posCount = 0;
82
83 function deleteFunction(note)
84 {
85 var callback =
86 {
87 success: function(response){},
88 failed: function(){},
89 timeout: 5000
90 };
91
92 var url = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=remove-metadata&amp;site=localsite&amp;c=" + gs.cgiParams.c + "&amp;d=" + gs.cgiParams.d + "&amp;metaname=dc.Creator&amp;metapos=" + note.id;
93 YAHOO.util.Connect.asyncRequest("GET", url, callback);
94 return true;
95 }
96
97 function saveFunction(note)
98 {
99 var callback =
100 {
101 success: function(response){},
102 failed: function(){},
103 timeout: 5000
104 };
105
106 var jsonVal = '{"caption":"' + note.text + '", "area":{"x":' + note.rect.left + ', "y":' + note.rect.top + ', "width":' + note.rect.width + ', "height":' + note.rect.height + '}}';
107 var url = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=set-metadata&amp;site=localsite&amp;c=" + gs.cgiParams.c + "&amp;d=" + gs.cgiParams.d + "&amp;metaname=dc.Creator&amp;metavalue=" + jsonVal + "&amp;metapos=" + note.id;
108 YAHOO.util.Connect.asyncRequest("GET", url, callback);
109 return 1;
110 }
111
112 function getNotes(count)
113 {
114 var callback =
115 {
116 success: function(response)
117 {
118 if(response.responseText.search(/\w/) == -1)
119 {
120 return;
121 }
122 posCount++;
123
124 var jsonObj = eval("(" + response.responseText + ")");
125 var newNote = new PhotoNote(jsonObj.caption, this.count, new PhotoNoteRect(jsonObj.area.x,jsonObj.area.y,jsonObj.area.width,jsonObj.area.height));
126 newNote.onsave = saveFunction;
127 newNote.ondelete = deleteFunction;
128 notes.AddNote(newNote);
129 getNotes(this.count + 1);
130 },
131 failed: function(){},
132 timeout: 5000
133 };
134
135 var url = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=get-metadata&amp;site=localsite&amp;c=" + gs.cgiParams.c + "&amp;d=" + gs.cgiParams.d + "&amp;metaname=dc.Creator&amp;metapos=" + count;
136 //var url = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=get-metadata&amp;site=localsite&amp;c=" + gs.cgiParams.c + "&amp;d=" + gs.cgiParams.d + "&amp;metaname=[dc.Title]";
137 callback.count = count;
138 YAHOO.util.Connect.asyncRequest("GET", url, callback);
139 }
140
141 function AddNote()
142 {
143 var newNote = new PhotoNote('Add note text here...',posCount++,new PhotoNoteRect(10,10,50,50));
144 newNote.onsave = saveFunction;
145 newNote.ondelete = deleteFunction;
146 notes.AddNote(newNote);
147 newNote.Select();
148 }
149 getNotes(0);
150 </xsl:text>
151 </script>
152
153 <!-- Adds the realistic books javascript if necessary ( *** in document-scripts.xsl *** ) -->
154 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
155 <script type="text/javascript">
156 <xsl:text disable-output-escaping="yes">
157 if(document.URL.indexOf("book=on") != -1)
158 {
159 loadBook();
160 }
161 </xsl:text>
162 </script>
163 </xsl:if>
164
165 <!-- show the little berries for this document -->
166 <xsl:call-template name="documentBerryForDocumentPage"/>
167
168 <table id="rightSidebar">
169 <tr><td>
170 <xsl:call-template name="viewOptions"/>
171 </td></tr>
172 <tr><td>
173 <!-- the sidebar -->
174 <div id="contentsArea">
175 <!-- show the berry basket if it's turned on -->
176 <gslib:berryBasket/>
177
178 <!-- the book's cover image -->
179 <xsl:choose>
180 <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
181 <div id="coverImage" class="visible"><gslib:coverImage/></div>
182 </xsl:when>
183 <xsl:otherwise>
184 <div id="coverImage" class="hidden"><gslib:coverImage/></div>
185 </xsl:otherwise>
186 </xsl:choose>
187
188 <!-- the contents (if enabled) -->
189 <xsl:choose>
190 <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
191 <div id="tableOfContents" class="visible">
192 <xsl:apply-templates select="documentNode" mode="TOC"/>
193 </div>
194 </xsl:when>
195 <xsl:otherwise>
196 <div id="tableOfContents" class="hidden">
197 <xsl:apply-templates select="documentNode" mode="TOC"/>
198 </div>
199 </xsl:otherwise>
200 </xsl:choose>
201 </div>
202 </td></tr>
203 </table>
204 </xsl:if>
205
206 <!-- display the document -->
207 <xsl:choose>
208 <xsl:when test="@external != ''">
209 <xsl:call-template name="externalPage">
210 <xsl:with-param name="external" select="@external"/>
211 </xsl:call-template>
212 </xsl:when>
213 <xsl:when test="$bookswitch = 'flashxml'">
214 <xsl:apply-templates mode="flashxml"/>
215 </xsl:when>
216 <xsl:when test="$bookswitch = 'on'">
217 <!-- *** in document-scripts.xsl *** -->
218 <div id="bookdiv" style="display:inline;"><xsl:text> </xsl:text></div>
219 <script type="text/javascript">
220 <xsl:text disable-output-escaping="yes">
221 if(document.URL.indexOf("book=on") != -1)
222 {
223 loadBook();
224 }
225 </xsl:text>
226 </script>
227 </xsl:when>
228 <xsl:otherwise>
229 <div id="gs-document-text" class="documenttext">
230 <xsl:apply-templates select="documentNode" mode="document"/>
231 </div>
232 </xsl:otherwise>
233 </xsl:choose>
234
235 <div class="clear"><xsl:text> </xsl:text></div>
236 </xsl:template>
237
238 <!-- Highlight annotations if requested -->
239 <xsl:template match="annotation">
240 <xsl:choose>
241 <xsl:when test="/page/pageRequest/paramList/param[@name='hl' and @value='on']">
242 <span class="termHighlight"><xsl:value-of select="."/></span>
243 </xsl:when>
244 <xsl:otherwise>
245 <span class="noTermHighlight"><xsl:value-of select="."/></span>
246 </xsl:otherwise>
247 </xsl:choose>
248 </xsl:template>
249
250 <!-- This template is used to display the document content -->
251 <xsl:template match="documentNode" mode="document">
252 <a name="{@nodeID}"><xsl:text> </xsl:text></a>
253 <!-- Section header -->
254 <table class="sectionHeader"><tr>
255 <!-- Expand/collapse button -->
256 <td class="headerTD">
257 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
258 <xsl:attribute name="src">
259 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
260 </xsl:attribute>
261 </img>
262 </td>
263
264 <!-- Automatic section number -->
265 <td class="headerTD">
266 <p>
267 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
268
269 <xsl:if test="util:hashToSectionId(@nodeID)">
270 <span class="sectionNumberSpan">
271 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
272 <xsl:text> </xsl:text>
273 </span>
274 </xsl:if>
275 <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
276 <span class="sectionTitle"><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/></span>
277 </p>
278 </td>
279
280 <!-- "back to top" link -->
281 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
282 <td class="backToTop headerTD">
283 <a href="#top">
284 <xsl:text disable-output-escaping="yes">&#9650;</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.back_to_top')"/>
285 </a>
286 </td>
287 </xsl:if>
288 </tr></table>
289
290 <!-- Section text -->
291 <div id="doc{@nodeID}" class="sectionContainer" style="display:block;">
292 <xsl:for-each select="nodeContent">
293 <xsl:for-each select="node()">
294 <xsl:choose>
295 <xsl:when test="not(name())">
296 <xsl:value-of select="." disable-output-escaping="yes"/>
297 </xsl:when>
298 <xsl:otherwise>
299 <xsl:apply-templates select="."/>
300 </xsl:otherwise>
301 </xsl:choose>
302 </xsl:for-each>
303 </xsl:for-each>
304 <xsl:if test="documentNode">
305 <xsl:apply-templates select="documentNode" mode="document"/>
306 </xsl:if>
307 </div>
308
309 </xsl:template>
310
311 <!-- This template is used to display the table of contents -->
312 <xsl:template match="documentNode" mode="TOC">
313
314 <!-- check if this is the currently selected table of contents item -->
315 <xsl:variable name="isCurrent" select="nodeContent"/>
316
317 <!-- formulate the link -->
318 <xsl:variable name="contentsLink">
319 <xsl:value-of select='$library_name'/>?a=d&amp;c=<gslib:collectionNameShort/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="documentNode">.pr</xsl:if>&amp;sib=1
320 </xsl:variable>
321
322 <ul>
323 <table><tr>
324 <!-- The expand/collapse button (not displayed for the top level node) -->
325 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
326 <td>
327 <xsl:choose>
328 <xsl:when test="not(nodeContent and not(documentNode))">
329 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
330 <xsl:attribute name="src">
331 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
332 </xsl:attribute>
333 </img>
334 </xsl:when>
335 <xsl:otherwise>
336 <xsl:attribute name="class">emptyIcon</xsl:attribute>
337 </xsl:otherwise>
338 </xsl:choose>
339 </td>
340 </xsl:if>
341
342 <!-- The chapter/page icon -->
343 <td>
344 <img>
345 <xsl:if test="nodeContent and not(documentNode)">
346 <xsl:attribute name="class">leafNode</xsl:attribute>
347 </xsl:if>
348
349 <xsl:attribute name="src">
350 <xsl:choose>
351 <xsl:when test="nodeContent and not(documentNode)">
352 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
353 </xsl:when>
354 <xsl:otherwise>
355 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
356 </xsl:otherwise>
357 </xsl:choose>
358 </xsl:attribute>
359 </img>
360 </td>
361
362 <!-- The section name, links to the section in the document -->
363 <td>
364 <a>
365 <xsl:attribute name="href">#<xsl:value-of select="@nodeID"/></xsl:attribute>
366 <xsl:if test="util:hashToSectionId(@nodeID)">
367 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
368 <xsl:text> </xsl:text>
369 </xsl:if>
370 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
371 </a>
372 </td>
373 </tr></table>
374
375 <!-- display any child items -->
376 <xsl:if test="documentNode">
377 <li id="toc{@nodeID}" style="display:block;">
378 <xsl:apply-templates select="documentNode" mode="TOC"/>
379 </li>
380 </xsl:if>
381
382 </ul>
383 </xsl:template>
384
385 <!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
386 <xsl:template match="documentNode" mode="flashxml">
387 <xsl:text disable-output-escaping="yes">
388 &lt;Section&gt;
389 &lt;Description&gt;
390 &lt;Metadata name="Title"&gt;
391 </xsl:text>
392 <xsl:value-of select="normalize-space(metadataList/metadata[@name = 'Title'])"/>
393 <xsl:text disable-output-escaping="yes">
394 &lt;/Metadata&gt;
395 &lt;/Description&gt;
396 </xsl:text>
397
398 <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
399
400 <xsl:if test="documentNode">
401 <xsl:apply-templates select="documentNode" mode="flashxml"/>
402 </xsl:if>
403
404 <xsl:text disable-output-escaping="yes">
405 &lt;/Section&gt;
406 </xsl:text>
407 </xsl:template>
408
409 <xsl:template name="externalPage">
410 <xsl:param name="external"/>
411 <xsl:variable name="go_forward_link">
412 <a>
413 <xsl:attribute name="href">
414 <xsl:value-of select="$external"/>
415 </xsl:attribute>
416 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.go_forward')"/>
417 </a>
418 </xsl:variable>
419 <h2><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'external.title')"/></h2>
420 <p><xsl:value-of select="util:getInterfaceTextWithDOM($interface_name, /page/@lang, 'external.text', $go_forward_link)" disable-output-escaping="yes"/></p>
421 </xsl:template>
422
423 <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
424
425 <xsl:template name="viewOptions">
426 <table class="viewOptions"><tr>
427 <!-- Realistic books link -->
428 <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
429 <td>
430 <img>
431 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/></xsl:attribute>
432 </img>
433 <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
434 </td>
435 </xsl:if>
436
437 <!-- Highlight on/off button -->
438 <xsl:if test="/page/pageRequest/paramList/param[@name = 'p.a']/@value = 'q' and count(//annotation) > 0">
439 <td>
440 <img>
441 <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/></xsl:attribute>
442 </img>
443 <input id="highlightOption" type="checkbox" class="optionCheckBox">
444 <xsl:choose>
445 <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
446 <xsl:attribute name="onclick">
447 <xsl:text>removeHighlight();</xsl:text>
448 </xsl:attribute>
449 <xsl:attribute name="checked">true</xsl:attribute>
450 </xsl:when>
451 <xsl:otherwise>
452 <xsl:attribute name="onclick">
453 <xsl:text>addHighlight();</xsl:text>
454 </xsl:attribute>
455 </xsl:otherwise>
456 </xsl:choose>
457 </input>
458 </td>
459 </xsl:if>
460 </tr></table>
461 </xsl:template>
462</xsl:stylesheet>
463
Note: See TracBrowser for help on using the repository browser.