source: trunk/gsdl3/web/interfaces/default/transform/berry.xsl@ 13264

Last change on this file since 13264 was 13264, checked in by shaoqun, 17 years ago

added the body style for berry basket page

  • Property svn:keywords set to Author Date Id Revision
File size: 25.9 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 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9 <!--<xsl:include href="style.xsl"/>-->
10 <xsl:include href="service-params.xsl"/>
11 <xsl:include href="berrytools.xsl"/>
12
13 <xsl:output method="html"/>
14
15 <xsl:param name="library_name"/>
16
17 <!-- the main page layout template is here -->
18 <xsl:template match="page">
19 <html>
20 <xsl:call-template name="pageHead"/>
21 <body class="bgimage">
22 <div class='globalwrapper'>
23 <xsl:apply-templates select="pageResponse"/>
24 </div>
25 </body>
26 </html>
27 </xsl:template>
28
29 <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
30 <xsl:template name="pageHead">
31 <head>
32 <title>
33 <xsl:call-template name="pageTitle"/>
34 </title>
35 <xsl:call-template name="pageStyle"/>
36 </head>
37 </xsl:template>
38
39 <xsl:template name="pageTitle">
40 <xsl:value-of select="/page/pageResponse/serviceCluster/metadataList/metadata[@name='Title']"/>
41 Berry Basket
42 </xsl:template>
43
44 <!-- page specific style goes here -->
45 <xsl:template name="pageStyle" >
46 <xsl:call-template name="styleSheet" />
47 <xsl:call-template name="loadLibrary" />
48 <xsl:call-template name="buildContent" />
49 <!-- <xsl:call-template name="showMailBox" />-->
50 </xsl:template>
51
52 <xsl:template match="pageResponse">
53 <xsl:variable name="clusterName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
54 <xsl:call-template name="berryPageBanner" />
55 <xsl:apply-templates select="paramList"/>
56 <div id="content" ><span></span></div>
57 <xsl:call-template name="footBanner" />
58 </xsl:template>
59
60
61 <xsl:template match="collection">
62 <xsl:for-each select="item">
63 <xsl:text disable-output-escaping="yes">
64 var doc = new Array();
65 </xsl:text>
66 <xsl:for-each select="@*">
67 <xsl:text disable-output-escaping="yes">
68 doc["</xsl:text><xsl:value-of select="name()" /><xsl:text disable-output-escaping="yes">"]='</xsl:text><xsl:value-of select="." /><xsl:text disable-output-escaping="yes">'; </xsl:text>
69 </xsl:for-each>
70 <xsl:text disable-output-escaping="yes">
71 docList[docList.length] = doc;
72 </xsl:text>
73 </xsl:for-each>
74 </xsl:template>
75
76
77 <xsl:template name="buildContent">
78 <script type="text/javascript">
79 <xsl:text disable-output-escaping="yes">
80 var previousView;
81 var docList = new Array();
82 var urlonly = false;
83 var mailinfo = new Array();
84 mailinfo['address'] = "To: ";
85 mailinfo['cc'] = "CC: ";
86 mailinfo['bcc'] = "Bcc: ";
87 mailinfo['subject'] = "Subject: ";
88 var textwin;
89 var mailwin;
90 </xsl:text>
91 <xsl:apply-templates select="/page/pageResponse/collection" />
92
93 <xsl:text disable-output-escaping="yes">
94
95 function navigate(e){
96 var target = e.target;
97
98 if (target.id.toLowerCase() == 'fullview'){
99 showFullView();
100 }
101
102 if (target.id.toLowerCase() == 'textview'){
103 showTextView();
104 }
105
106 if (target.id.toLowerCase() == 'email'){
107 showEmail();
108 }
109
110 if (target.id.toLowerCase() == 'sendmail'){
111 sendMail();
112 }
113
114
115
116 if (target.id.toLowerCase() == 'urlcheck' &amp;&amp; urlonly){
117 var urlcheck = YAHOO.util.Dom.get('urlcheck');
118 urlcheck.src = 'interfaces/default/images/check3.gif';
119 var parea =YAHOO.util.Dom.get('pretextarea');
120 urlonly = false;
121 populateUrlsAndMetadata(parea);
122 return;
123
124 }
125
126 if (target.id.toLowerCase() == 'urlcheck' &amp;&amp; !urlonly ){
127 var urlcheck = YAHOO.util.Dom.get('urlcheck');
128 urlcheck.src = 'interfaces/default/images/check4.gif';
129 var parea =YAHOO.util.Dom.get('pretextarea');
130 populateUrls(parea);
131 urlonly = true;
132 return;
133 }
134
135 if (target.id.toLowerCase() == 'extextview' ){
136 if (textwin != null){
137 textwin.close();
138 }
139
140 textwin = window.open("","Berry basket plain text view","status=1,width=450,height=300");
141 textwin.moveTo(0,0);
142 var content = document.createElement('div');
143 buildPreview(content);
144 var body = textwin.document.getElementsByTagName('body')[0];
145 body.appendChild(content);
146 var prearea = textwin.document.getElementsByTagName('textarea')[0];
147 prearea.cols = '55';
148 prearea.rows = '15';
149 }
150
151 if (target.id.toLowerCase() == 'exemail' ){
152 if (mailwin != null){
153 mailwin.close();
154 }
155 mailwin = window.open("","Berry basket mail to a friend","status=1,width=450,height=350");
156 mailwin.moveTo(0,0);
157 var content = document.createElement('div');
158 getEmailContent(content);
159 var body = mailwin.document.getElementsByTagName('body')[0];
160 body.appendChild(content);
161 var prearea = mailwin.document.getElementsByTagName('textarea')[0];
162 prearea.cols = '50';
163 prearea.rows = '11';
164 }
165
166 }
167
168 function showFullView(){
169
170 var content = YAHOO.util.Dom.get('content');
171 var fullview = YAHOO.util.Dom.get('fullview');
172
173 if (previousView != null){
174 previousView.style.backgroundImage = 'url("interfaces/default/images/bg_on.png")';
175 }
176 previousView = fullview;
177 previousView.style.backgroundImage = 'url("interfaces/default/images/bg_green.png")';
178
179 while (content.hasChildNodes()) {
180 content.removeChild(content.firstChild);
181 }
182
183 if (docList.length == 0){
184 content.appendChild(document.createTextNode("Your berry basket is empty."));
185 return;
186 }
187
188
189 var trashbin = document.createElement('div');
190 trashbin.id ='trashbin';
191 var binhandle = document.createElement('div');
192 binhandle.id = 'binhandle';
193 binhandle.appendChild(document.createElement('span'));
194 trashbin.appendChild(binhandle)
195
196 content.appendChild(trashbin);
197
198 var dd = new ygDDOnTop('trashbin');
199 dd.setHandleElId('binhandle');
200 new YAHOO.util.DDTarget('trashbin','trash');
201
202 var dlist = document.createElement('div');
203 content.appendChild(dlist);
204 var ol = document.createElement('ol');
205 dlist.appendChild(ol);
206
207 for (var i in docList){
208 var doc = docList[i];
209 var li = document.createElement('li');
210 var a = document.createElement('a');
211 var text ="";
212 a.href ="?a=d&amp;c="+doc['collection']+"&amp;d="+doc['name'];
213 a.appendChild(document.createTextNode(doc['title']));
214 if (doc['root_title'] != ""){
215 li.appendChild(document.createTextNode(doc['root_title']+": "));
216 }
217 li.appendChild(a);
218 var metadata = "";
219 for (var metaItem in doc &amp;&amp; metaItem != 'title'){
220 metadata = "\n"+metaItem+": "+ doc[metaItem]+"\n";
221 }
222 text +=metadata+"\n";
223 li.appendChild(document.createTextNode(text));
224 li.id = doc['collection']+":"+ doc['name'];
225 li.className = 'berrydoc';
226 ol.appendChild(li);
227 new ygDDPlayer(li.id,'trash',docList);
228 }
229
230 /**
231 var extra = document.createElement('div');
232 var textview = document.createElement('span');
233 textview.id = 'extextview';
234 textview.className = 'extralink';
235 textview.appendChild(document.createTextNode("plain text version"));
236 var email = document.createElement('span');
237 email.appendChild(document.createTextNode("email to a friend"));
238 email.id = 'exemail';
239 email.className = 'extralink';
240 extra.appendChild(textview);
241 extra.appendChild(email);
242 content.appendChild(extra);
243 **/
244 }
245
246 function showTextView(){
247 var content = YAHOO.util.Dom.get('content');
248 var textview = YAHOO.util.Dom.get('textview');
249
250 if (previousView != null &amp;&amp; textview !=null){
251 previousView.style.backgroundImage = 'url("interfaces/default/images/bg_on.png")';
252 }
253
254 if (textview !=null){
255 previousView = textview;
256 previousView.style.backgroundImage = 'url("interfaces/default/images/bg_green.png")';
257 }
258
259 while (content.hasChildNodes()) {
260 content.removeChild(content.firstChild);
261 }
262
263 if (docList.length == 0){
264 content.appendChild(document.createTextNode("Your berry basket is empty."));
265 return;
266 }
267
268 buildPreview(content);
269
270
271 }
272
273 function getEmailContent(content){
274 var item ;
275 var tr;
276 var td;
277 var input;
278
279 table = document.createElement('table');
280 table.setAttribute("class","mailtable");
281
282 for (item in mailinfo){
283 tr = document.createElement('tr');
284 td = document.createElement('td');
285 td.setAttribute("class","mailitem");
286 td.appendChild(document.createTextNode(mailinfo[item]));
287 tr.appendChild(td);
288
289 td = document.createElement('td');
290 input = document.createElement('input');
291 input.setAttribute("id", item);
292 input.setAttribute("class", "mailinput");
293 input.setAttribute("type", "text");
294 td.appendChild(input);
295 tr.appendChild(td);
296 table.appendChild(tr);
297
298 }
299
300 // an empty line
301 tr = document.createElement('tr');
302 td = document.createElement('td');
303 td.appendChild(document.createElement('br'));
304 tr.appendChild(td);
305 table.appendChild(tr);
306
307 content.appendChild(table);
308
309 buildPreview(content);
310
311 //send button
312 input = document.createElement('input');
313 input.setAttribute("id", 'sendmail');
314 input.setAttribute("class", "sendbutton");
315 input.setAttribute("type", "button");
316 input.setAttribute("value", "send");
317 content.appendChild(input);
318
319 }
320
321
322 function showEmail(){
323
324 var content = YAHOO.util.Dom.get('content');
325 var email = YAHOO.util.Dom.get('email');
326
327 if (previousView != null &amp;&amp; email !=null ){
328 previousView.style.backgroundImage = 'url("interfaces/default/images/bg_on.png")';
329 }
330
331 if (email != null){
332 previousView = email;
333 previousView.style.backgroundImage = 'url("interfaces/default/images/bg_green.png")';
334 }
335 while (content.hasChildNodes()) {
336 content.removeChild(content.firstChild);
337 }
338
339 if (docList.length == 0){
340 content.appendChild(document.createTextNode("Your berry basket is empty."));
341 return;
342 }
343
344
345 var item ;
346 var tr;
347 var td;
348 var input;
349
350 table = document.createElement('table');
351 table.setAttribute("class","mailtable");
352
353 for (item in mailinfo){
354 tr = document.createElement('tr');
355 td = document.createElement('td');
356 td.setAttribute("class","mailitem");
357 td.appendChild(document.createTextNode(mailinfo[item]));
358 tr.appendChild(td);
359
360 td = document.createElement('td');
361 input = document.createElement('input');
362 input.setAttribute("id", item);
363 input.setAttribute("class", "mailinput");
364 input.setAttribute("type", "text");
365 td.appendChild(input);
366 tr.appendChild(td);
367 table.appendChild(tr);
368
369 }
370
371 // an empty line
372 tr = document.createElement('tr');
373 td = document.createElement('td');
374 td.appendChild(document.createElement('br'));
375 tr.appendChild(td);
376 table.appendChild(tr);
377
378 content.appendChild(table);
379
380 buildPreview(content);
381
382 //send button
383 input = document.createElement('input');
384 input.setAttribute("id", 'sendmail');
385 input.setAttribute("class", "sendbutton");
386 input.setAttribute("type", "button");
387 input.setAttribute("value", "send");
388 content.appendChild(input);
389
390 }
391
392
393 function buildPreview(parent){
394 var div = document.createElement('div');
395
396
397 var img = document.createElement('img');
398 img.src = 'interfaces/default/images/check3.gif';
399 img.id = 'urlcheck';
400 div.appendChild(img);
401
402 var urls = document.createElement('span');
403 urls.id = 'urls';
404 urls.className = 'berrycheck';
405 urls.appendChild(document.createTextNode('URL only'));
406 div.appendChild(urls);
407
408 // var urlsmetadata = document.createElement('span');
409 // urlsmetadata.id = 'urlsmetadata'
410 // urlsmetadata.className = 'berryradio';
411 // urlsmetadata.appendChild(document.createTextNode('URLs and Metadata'));
412
413 // div.appendChild(urlsmetadata);
414
415
416 parent.appendChild(div);
417
418
419 var parea = document.createElement('textarea');
420 parea.id = 'pretextarea';
421
422 parent.appendChild(parea);
423
424
425 populateUrlsAndMetadata(parea);
426
427
428 }
429
430
431 function populateUrls(parea){
432 var urls="";
433 var doc_url = document.URL;
434 var root_url = doc_url.substring(0,doc_url.indexOf('?'));
435
436 for (var i in docList){
437 var doc = docList[i];
438 urls +=root_url+"?a=d&amp;c="+doc["collection"]+"&amp;d="+doc["name"]+"\n\n";
439
440 }
441
442 parea.value = urls;
443
444 }
445
446 function populateUrlsAndMetadata(parea){
447
448 var doc_url = document.URL;
449 var root_url = doc_url.substring(0,doc_url.indexOf('?'));
450 var fulltext="";
451
452 for (var i in docList){
453 var doc = docList[i];
454 var url =root_url+"?a=d&amp;c="+doc['collection']+"&amp;d="+doc['name']+"\n";
455 for (var metaItem in doc){
456 var metadata = metaItem+": "+ doc[metaItem]+"\n";
457 }
458 fulltext +=url+metadata+"\n";
459
460 }
461
462 parea.value = fulltext;
463
464 }
465
466 function sendMail(){
467 var url = "?a=pr&amp;rt=r&amp;ro=1&amp;s=SendMail&amp;c=";
468 var request_type = "POST";
469 var postdata = "";
470 var i;
471 //get checked items
472 for (i in mailinfo)
473 {
474
475 var input = YAHOO.util.Dom.get(i);
476 var value = input.value;
477 postdata +="&amp;s1."+i+"="+value;
478 }
479
480
481 var content = YAHOO.util.Dom.get('pretextarea').value;
482
483 content = content.replace(/&amp;/g,'-------');
484 postdata +="&amp;s1.content="+content;
485
486
487 var callback = {
488 success:function(o){
489 var result = o.responseText;
490 alert(result);
491
492 } ,
493 failure:function(o){
494 alert("Sending mail falied");
495 }
496 }
497
498
499 YAHOO.util.Connect.asyncRequest(request_type , url , callback, postdata);
500 }
501
502 YAHOO.util.Event.addListener(window,'click', navigate);
503 YAHOO.util.Event.addListener(window,'load', showFullView);
504 </xsl:text>
505 </script>
506 </xsl:template>
507
508 <xsl:template name="styleSheet">
509 <link rel="stylesheet" href="interfaces/default/style/core.css" type="text/css"/>
510 <link rel="stylesheet" href="interfaces/default/style/berry.css" type="text/css"/>
511 </xsl:template>
512
513 <xsl:template name="showMailBox">
514 <script type="text/javascript">
515 <xsl:text disable-output-escaping="yes">
516 var show = false;
517 var table;
518 var mailserver = new Array();
519 mailserver['host'] = "Mail Server: ";
520 mailserver['user'] = "User Name: ";
521 mailserver['password'] = "Password: ";
522
523 var mailinfo = new Array();
524 mailinfo['address'] = "To: ";
525 mailinfo['cc'] = "CC: ";
526 mailinfo['bcc'] = "Bcc: ";
527 mailinfo['subject'] = "Subject: ";
528
529 function mailBoxUpdate(e) {
530 var target = e.target;
531 if (target.id.toLowerCase() == 'sendasemail' &amp;&amp; !show){
532 showMailBox();
533 show = true;
534 }
535 else{
536 if (target.id.toLowerCase() == 'sendasemail' &amp;&amp; show){
537 hideMailBox();
538 show = false;
539 }
540
541 if (target.id.toLowerCase() == 'sendmail'){
542 sendMail();
543 }
544 }
545
546
547
548 }
549
550 function showMailBox(){
551 var mailbox = YAHOO.util.Dom.get('mailbox');
552 if (table != null &amp;&amp; !show){
553 mailbox.appendChild(table);
554 return;
555 }
556
557 var item ;
558 var tr;
559 var td;
560 var input;
561
562 table = document.createElement('table');
563 table.setAttribute("class","mailtable");
564
565 // mail server
566 tr = document.createElement('tr');
567 td = document.createElement('td');
568 td.setAttribute("class","mailitem");
569 td.appendChild(document.createTextNode(mailserver['host']));
570 tr.appendChild(td);
571
572 td = document.createElement('td');
573 input = document.createElement('input');
574 input.setAttribute("id", 'host');
575 input.setAttribute("class", "mailinput");
576 input.setAttribute("type", "text");
577 td.appendChild(input);
578 td.appendChild(document.createTextNode(' e.g. webmail.cs.waikato.ac.nz'));
579 tr.appendChild(td);
580 table.appendChild(tr);
581
582 //user name
583 tr = document.createElement('tr');
584 td = document.createElement('td');
585 td.setAttribute("class","mailitem");
586 td.appendChild(document.createTextNode(mailserver['user']));
587 tr.appendChild(td);
588 td = document.createElement('td');
589 input = document.createElement('input');
590 input.setAttribute("id", 'user');
591 input.setAttribute("class", "mailinput");
592 input.setAttribute("type", "text");
593 td.appendChild(input);
594 tr.appendChild(td);
595 table.appendChild(tr);
596
597 //password
598 tr = document.createElement('tr');
599 td = document.createElement('td');
600 td.setAttribute("class","mailitem");
601 td.appendChild(document.createTextNode(mailserver['password']));
602 tr.appendChild(td);
603 td = document.createElement('td');
604 input = document.createElement('input');
605 input.setAttribute("id", 'password');
606 input.setAttribute("class", "mailinput");
607 input.setAttribute("type", "password");
608 td.appendChild(input);
609 tr.appendChild(td);
610 table.appendChild(tr);
611
612 // an empty line
613 tr = document.createElement('tr');
614 td = document.createElement('td');
615 td.appendChild(document.createElement('br'));
616 tr.appendChild(td);
617 table.appendChild(tr);
618
619 for (item in mailinfo){
620 tr = document.createElement('tr');
621 td = document.createElement('td');
622 td.setAttribute("class","mailitem");
623 td.appendChild(document.createTextNode(mailinfo[item]));
624 tr.appendChild(td);
625
626 td = document.createElement('td');
627 input = document.createElement('input');
628 input.setAttribute("id", item);
629 input.setAttribute("class", "mailinput");
630 input.setAttribute("type", "text");
631 td.appendChild(input);
632 tr.appendChild(td);
633 table.appendChild(tr);
634
635 }
636
637 // an empty line
638 tr = document.createElement('tr');
639 td = document.createElement('td');
640 td.appendChild(document.createElement('br'));
641 tr.appendChild(td);
642 table.appendChild(tr);
643
644 //send button
645 tr = document.createElement('tr');
646 td = document.createElement('td');
647 td.setAttribute("class","mailitem");
648 input = document.createElement('input');
649 input.setAttribute("id", 'sendmail');
650 input.setAttribute("class", "sendbutton");
651 input.setAttribute("type", "button");
652 input.setAttribute("value", "send");
653 td.appendChild(input);
654 tr.appendChild(td);
655 table.appendChild(tr);
656
657
658 mailbox.appendChild(table);
659 }
660
661
662 function hideMailBox(){
663 var mailbox = YAHOO.util.Dom.get('mailbox');
664 while (mailbox.hasChildNodes()) {
665 mailbox.removeChild(mailbox.firstChild);
666 }
667 }
668
669 function sendMail(){
670 var url = "?a=pr&amp;rt=r&amp;ro=1&amp;s=SendMail&amp;c=";
671 var request_type = "POST";
672 var postdata = "";
673 var i;
674 //get checked items
675 for (i in mailinfo)
676 {
677
678 var input = YAHOO.util.Dom.get(i);
679 var value = input.value;
680 postdata +="&amp;s1."+i+"="+value;
681 }
682
683
684 for (i in mailserver){
685 var input = YAHOO.util.Dom.get(i);
686 var value = input.value;
687 postdata +="&amp;s1."+i+"="+value;
688 }
689
690 var content = YAHOO.util.Dom.get('pretextarea').value;
691
692 content = content.replace(/&amp;/g,'-------');
693 postdata +="&amp;s1.content="+content;
694
695
696 var callback = {
697 success:function(o){
698 var response = o.responseXML;
699
700 alert(response.getAttribute('status'));
701 } ,
702 failure:function(o){
703 alert("Sending mail falied");
704 }
705 }
706
707
708 YAHOO.util.Connect.asyncRequest(request_type , url , callback, postdata);
709 }
710
711
712 YAHOO.util.Event.addListener(window,'click',mailBoxUpdate );
713
714 </xsl:text>
715 </script>
716 </xsl:template>
717
718 <xsl:template name="berryPageBanner">
719 <div class='banner'>
720 <div class='pageinfo'>
721 <p class='bannerlinks'>
722 <a class='navlink' href='{$library_name}?a=p&amp;sa=home' title='Library home page' >HOME</a>
723 <a class='navlink' href='{$library_name}?a=p&amp;sa=help&amp;c=' title='Help pages' >HELP</a>
724 <a class='navlink' href='{$library_name}?a=p&amp;sa=pref&amp;c=' title='Change your interface preferences'>PREFERENCES</a>
725 </p>
726 </div>
727 <div class='basketimage'><p class='bannertitle'>Berry Basket</p></div>
728 </div>
729 <div class="bannerextra"></div>
730
731 <div >
732 <p class='navbar'><span id='fullview' class='navlink'>full view</span><span id='textview' class='navlink'>plain text version</span><span id='email' class='navlink'>email to a friend</span></p>
733 </div>
734 </xsl:template>
735
736 <xsl:template name="footBanner">
737 <div >
738 <p class='navbar'><span >powered by greenstone3</span></p>
739 </div>
740 </xsl:template>
741
742</xsl:stylesheet>
743
Note: See TracBrowser for help on using the repository browser.