Project

General

Profile

1
<?xml version="1.0"?>
2
<!--
3
*  '$RCSfile$'
4
*      Authors: Matt Jones, CHad Berkley
5
*    Copyright: 2000 Regents of the University of California and the
6
*               National Center for Ecological Analysis and Synthesis
7
*  For Details: http://www.nceas.ucsb.edu/
8
*
9
*   '$Author: leinfelder $'
10
*     '$Date: 2008-10-30 12:42:35 -0700 (Thu, 30 Oct 2008) $'
11
* '$Revision: 4494 $'
12
*
13
* This program is free software; you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation; either version 2 of the License, or
16
* (at your option) any later version.
17
*
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
* GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License
24
* along with this program; if not, write to the Free Software
25
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
*
27
* This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
28
* convert an XML file showing the resultset of a query
29
* into an HTML format suitable for rendering with modern web browsers.
30
-->
31
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
32

    
33
	<xsl:output method="html"/>
34
	<xsl:param name="sessid"/>
35
	<xsl:param name="qformat">default</xsl:param>
36
	<xsl:param name="enableediting">false</xsl:param>
37
	<xsl:param name="contextURL"/>
38
	<xsl:template match="/">
39
		<script language="JavaScript">
40
          <![CDATA[
41
          submitform = function(action,docid,form_ref) {
42
              form_ref.action.value=action;
43
              form_ref.docid.value=docid;
44
              form_ref.sessionid.value="]]><xsl:value-of select="$sessid" /><![CDATA[";
45
              form_ref.qformat.value="first";
46
              form_ref.insertTemplate.value="1";
47
              form_ref.submit();
48
          }
49
          setSelect = function(form_ref, checkBoxName, checked) {
50
              var formElements = form_ref.elements;
51
              for (var i=0; i<formElements.length; i++) {
52
              	var myElement = formElements[i];
53
              	if (myElement.name == checkBoxName) {
54
              		myElement.checked = checked;
55
              	}
56
              }
57
          }    
58
          ]]>
59
        </script>
60
        <script type="text/javascript" language="Javascript">
61
			<![CDATA[
62
			downloadMergedResponseData = function(formId, fieldFormId) {
63
			
64
				//if (!areItemsSelected('docid')) {
65
				//	alert("Please select at least one dataset");
66
				//	return false;
67
				//}
68
								
69
				//transfer the assessmentItemId to this form
70
				//document.getElementById("questionId").value = document.getElementById("assessmentItemId").value;
71
				//alert("questionId: " + document.getElementById("questionId").value);
72
				
73
				var submitFormObj = document.getElementById(formId);
74
				submitFormObj.qformat.value = 'csv';
75
				submitFormObj.action.value = 'dataquery';
76
				
77
				//the form that holds the metadata field mappings - but in the header!
78
				var fieldFormObj = 
79
					window.document.getElementById("iframeheaderclass").contentDocument.getElementById(fieldFormId);
80
				//alert("fieldFormObj: " + fieldFormObj);
81
				
82
				multipleAssessmentSearch(submitFormObj, fieldFormObj);
83
				
84
				submitFormObj.submit();
85
			}
86
			editCart = function(formId, operation, docid) {
87
			
88
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
89
				//if (!areItemsSelected('docid') && docid) {
90
				//	alert("Please select at least one dataset");
91
				//	return false;
92
				//}
93
				
94
				var submitFormObj = document.getElementById(formId);
95
				submitFormObj.qformat.value = 'first';
96
				submitFormObj.action.value = 'editcart';
97
				submitFormObj.operation.value = operation;
98
				if (docid) {
99
					submitFormObj.docid.value = docid;
100
				}
101
				
102
				var myUpdate = new Ajax.Request(
103
					metacatURL,
104
					{	method: 'post',
105
						parameters: Form.serialize(submitFormObj),
106
						evalScripts: true,
107
						onSuccess: function(transport) {
108
							//alert('Cart changes saved: ' + operation); 
109
							//if we are in the cart, we should refresh the entire page
110
							if (document.getElementById("ajaxCartResults")) {
111
								window.location.reload();
112
							}
113
							else {
114
								window.document.getElementById("iframeheaderclass").src=window.document.getElementById("iframeheaderclass").src;
115
								//now check the cart contents and update those icons (but wait a second)
116
								setTimeout("setAllCartIcons()", 1000);
117
							}
118
						}, 
119
						onFailure: function(transport) {alert('failure making ajax call');}
120
					 });
121
								
122
			}
123
			read = function(formId, docid, divId) {
124
			
125
				//alert("divId: " + divId);
126
				
127
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
128
				
129
				var submitFormObj = document.getElementById(formId);
130
				submitFormObj.qformat.value = 'first';
131
				submitFormObj.action.value = 'read';
132
				submitFormObj.docid.value = docid;
133
				submitFormObj.insertTemplate.value = '0';
134
				
135
				var myUpdate = new Ajax.Updater(
136
					divId,
137
					metacatURL,
138
					{	method: 'post',
139
						parameters: Form.serialize(submitFormObj),
140
						evalScripts: true,
141
						onSuccess: function(transport) {showDiv(divId); }, 
142
						onFailure: function(transport) {alert('failure making ajax call');}
143
					 });
144
								
145
			}
146
			areItemsSelected = function(checkBoxName) {
147
				var checkBoxes = document.getElementsByName(checkBoxName);
148
				
149
				for (var i=0; i< checkBoxes.length; i++) {
150
					if (checkBoxes[i].checked == true) {
151
						return true;
152
					}	
153
				}
154
				//alert("please select a checkbox: " + checkBoxName);
155
				return false;
156
				
157
			}
158
			setControlVisibility = function() {
159
				if (document.getElementById("ajaxCartResults")) {
160
					new Effect.Appear("download");
161
				}
162
			}	
163
			isInCart = function(docid) {
164
		
165
				var iframe = window.document.getElementById("iframeheaderclass").contentDocument;
166
				var doc = iframe.contentDocument;
167
				if (!doc) {
168
					doc = iframe.contentWindow.document;
169
				}
170
				var objs = doc.getElementsByName("@packageId");
171
				
172
				//var objs = document.getElementsByName("@packageId");
173
				if (objs.length == 0) {
174
					return false;
175
				}
176
				for (var i=0; i< objs.length; i++) {
177
					if (docid == objs[i].value) {
178
						return true;
179
					}
180
				}
181
				return false;
182
			}			
183
			hideDiv = function(divId) {
184
				new Effect.Puff(divId);
185
				//Element.hide(divId);
186
			}
187
			showDiv = function(divId) {
188
				new Effect.Appear(divId)
189
				//Element.show(divId);
190
			}
191
			setAllCartIcons = function() {
192
				var docids = document.getElementsByName('docid');
193
				for (var i=0; i< docids.length; i++) {
194
					var docid = docids[i].value;
195
					if (docid != "") {
196
						setCartIcon(docid);
197
					}	
198
				}
199
			}
200
			setCartIcon = function(docid) {
201
				//show or hide the div
202
				//alert("setting icon for: " + docid);
203
				if (isInCart(docid)) {
204
					hideDiv("ajaxDiv" + docid + "add");
205
					showDiv("ajaxDiv" + docid + "remove");
206
				}
207
				else {
208
					hideDiv("ajaxDiv" + docid + "remove");
209
					showDiv("ajaxDiv" + docid + "add");
210
				}
211
			}	
212
		 ]]>	
213
		</script>
214
        
215
		<p class="emphasis">Assessments found: <xsl:number value="count(resultset/document)" /></p>      
216
      
217
		<!-- This tests to see if there are returned documents,
218
            if there are not then don't show the query results -->
219

    
220
		<xsl:if test="count(resultset/document) &gt; 0">
221
			<script type="text/javascript" language="Javascript">
222
				<![CDATA[
223
					//call on load
224
					setControlVisibility();
225
				]]>	
226
			</script>
227
			<div id="download" style="display:none;">
228
				<p>
229
					<a>
230
						<xsl:attribute name="href">javascript:{}</xsl:attribute>
231
						<xsl:attribute name="onclick">javascript:downloadMergedResponseData('assessmentForm', 'fieldForm')</xsl:attribute>
232
						<img border="none">
233
							<xsl:attribute name="src">
234
								<xsl:value-of select="$contextURL" />
235
								<xsl:text>/style/images/page_white_put.png</xsl:text>
236
							</xsl:attribute>
237
						</img>
238
						<xsl:text> Download (.csv)</xsl:text>
239
					</a>
240
				</p>
241
			</div>
242
						
243
			<!-- for reading the assessment details -->
244
			<form action="{$contextURL}/metacat" method="POST" id="readForm" name="readForm" >
245
				<input type="hidden" name="qformat" value="first" />
246
				<input type="hidden" name="sessionid">
247
					<xsl:attribute name="value">
248
						<xsl:value-of select="$sessid" />						
249
					</xsl:attribute>
250
				</input>
251
				<input type="hidden" name="action" value="read" />
252
				<input type="hidden" name="docid" />
253
				<input type="hidden" name="insertTemplate" value="1"/>
254
			</form>
255
			
256
			<!-- for editing cart -->				
257
			<form action="{$contextURL}/metacat" method="POST" id="cartForm" name="cartForm" >
258
				<input type="hidden" name="qformat" value="first" />
259
				<input type="hidden" name="sessionid">
260
					<xsl:attribute name="value">
261
						<xsl:value-of select="$sessid" />						
262
					</xsl:attribute>
263
				</input>
264
				<input type="hidden" name="action" value="editcart" />
265
				<input type="hidden" name="operation" />
266
				<input type="hidden" name="docid" />
267

    
268
			</form>	
269
			
270
			<!-- for downloading data -->				
271
			<form action="{$contextURL}/metacat" method="POST" id="assessmentForm" name="assessmentForm" >
272
				<input type="hidden" name="qformat" value="first" />
273
				<input type="hidden" name="sessionid">
274
					<xsl:attribute name="value">
275
						<xsl:value-of select="$sessid" />						
276
					</xsl:attribute>
277
				</input>
278
				<input type="hidden" name="action" value="read" />
279
				<input type="hidden" name="dataquery" />
280
				<input type="hidden" name="operation" />
281
				
282
				<xsl:element name="input">
283
					<xsl:attribute name="type">hidden</xsl:attribute>
284
					<xsl:attribute name="id">questionId</xsl:attribute>
285
					<xsl:attribute name="name">questionId</xsl:attribute>
286
					<xsl:attribute name="value"></xsl:attribute>
287
				</xsl:element>
288
				
289
			<table width="95%" align="left" border="0" cellpadding="0"
290
				cellspacing="0">
291
				<tr>
292
					
293
					<th style="text-align: left" colspan="2">
294
						Assessment
295
					</th>
296
					<th style="text-align: left">
297
						Course Title
298
					</th>
299
					<th	style="text-align: left">
300
						Instructor[s]
301
					</th>
302
					<th	style="text-align: left">
303
						Organization[s]
304
					</th>
305
					<th	style="text-align: left">
306
						Keywords
307
					</th>
308
				</tr>
309

    
310
				<xsl:for-each select="resultset/document">
311
					<xsl:sort select="./param[@name='assessment/@id']" />
312
					<xsl:variable name="divId">
313
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
314
					</xsl:variable>
315
					<tr valign="top" class="subpanel">
316
						<xsl:attribute name="class">
317
			               <xsl:choose>
318
			                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
319
			                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
320
			               </xsl:choose>
321
			             </xsl:attribute>
322

    
323
						<td class="text_plain" nowrap="nowrap">
324
						
325
							<script type="text/javascript" language="Javascript">
326
								<![CDATA[
327
									//what are our options?
328
									if (isInCart("]]><xsl:value-of select="./docid" /><![CDATA[")) {
329
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
330
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
331
									}
332
									else {
333
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
334
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
335
									}
336
								]]>	
337
							</script>
338
							<div style="display:none;">
339
								<xsl:attribute name="id">
340
									<xsl:value-of select="$divId" />
341
									<xsl:text>add</xsl:text>
342
								</xsl:attribute>
343
								<a>
344
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
345
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'add',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
346
									<img border="none">
347
										<xsl:attribute name="src">
348
											<xsl:value-of select="$contextURL" />
349
											<xsl:text>/style/skins/first/images/cart_plus_sm.png</xsl:text>
350
										</xsl:attribute>
351
									</img>
352
								</a>
353
							</div>
354
							<div style="display:none;">
355
								<xsl:attribute name="id">
356
									<xsl:value-of select="$divId" />
357
									<xsl:text>remove</xsl:text>
358
								</xsl:attribute>
359
								<a>
360
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
361
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'remove',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
362
									<!--  <xsl:text>Remove </xsl:text> -->
363
									<img border="none">
364
										<xsl:attribute name="src">
365
											<xsl:value-of select="$contextURL" />
366
											<xsl:text>/style/skins/first/images/cart_minus_sm.png</xsl:text>
367
										</xsl:attribute>
368
									</img>
369
								</a>
370
							</div>
371

    
372
							<input type="hidden" name="docid">
373
								<xsl:attribute name="value">
374
									<xsl:value-of select="./docid" />
375
								</xsl:attribute>
376
							</input>
377
							
378
						</td>
379
						<td>
380
							
381
							<a>
382
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.readForm)</xsl:attribute>
383
								<xsl:text>&#187;&#160;</xsl:text>
384
								<xsl:value-of select="./param[@name='assessment/@title']" />
385
							</a>
386
							(<xsl:value-of select="./docid" />)
387
							
388
							<br />
389
							
390
							<!--include question ids here -->
391
							<xsl:for-each select="./param[@name='assessmentItems/assessmentItem/assessmentItemId']" >
392
								<input type="hidden">
393
									<xsl:attribute name="name">
394
										<xsl:value-of select="../docid" />
395
									</xsl:attribute>
396
									<xsl:attribute name="value">
397
										<xsl:value-of select="." />
398
									</xsl:attribute>
399
								</input>
400
							</xsl:for-each>
401
							
402
							<br/>
403
														
404
						</td>
405

    
406
						<td class="text_plain">
407
							<xsl:for-each
408
								select="./param[@name='lom/general/title/string']">
409
								<xsl:value-of select="." />
410
								<br />
411
							</xsl:for-each>
412
						</td>
413
						<td class="text_plain">
414
							<xsl:for-each
415
								select="./param[@name='individualName/surName']">
416
								<xsl:value-of select="." />
417
								<br />
418
							</xsl:for-each>
419
						</td>
420
						<td class="text_plain">
421
							<xsl:for-each
422
								select="./param[@name='organizationName']">
423
								<xsl:value-of select="." />
424
								<br />
425
							</xsl:for-each>
426
						</td>
427

    
428
						<td class="text_plain">
429
							<xsl:for-each
430
								select="./param[@name='keyword']">
431
								<xsl:value-of select="." />
432
								<br />
433
							</xsl:for-each>
434
							<xsl:for-each
435
								select="./param[@name='lom/general/keyword/string']">
436
								<xsl:value-of select="." />
437
								<br />
438
							</xsl:for-each>
439

    
440
						</td>
441

    
442
					</tr>
443
					
444
					<tr>
445
						<td colspan="6">
446
							Details 
447
							<a>
448
								<xsl:attribute name="href">javascript:read('readForm', '<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
449
								<img border="none">
450
									<xsl:attribute name="src">
451
										<xsl:value-of select="$contextURL" />
452
										<xsl:text>/style/images/next.gif</xsl:text>
453
									</xsl:attribute>
454
								</img>
455
							</a>
456
							/
457
							<a>
458
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
459
								<img border="none">
460
									<xsl:attribute name="src">
461
										<xsl:value-of select="$contextURL" />
462
										<xsl:text>/style/images/previous.gif</xsl:text>
463
									</xsl:attribute>
464
								</img>
465
							</a>
466
							
467
						</td>	
468
					</tr>
469
					
470
					<tr>
471
						<td colspan="6">
472
							<div style="display:none;">
473
								<xsl:attribute name="id">
474
									<xsl:value-of select="$divId" />
475
								</xsl:attribute>
476
								Assessment details...
477
							</div>
478
						</td>	
479
					</tr>
480
					
481
					<tr class="searchresultsdivider">
482
						<td colspan="6">
483
							<img
484
								src="{$contextURL}/style/skins/default/images/transparent1x1.gif"
485
								width="1" height="1" />
486
						</td>
487
					</tr>
488

    
489
				</xsl:for-each>
490
				
491
			</table>
492
			
493
			</form>
494

    
495
		</xsl:if>
496
	</xsl:template>
497

    
498
</xsl:stylesheet>
(4-4/19)