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: 2009-10-01 15:04:14 -0700 (Thu, 01 Oct 2009) $'
11
* '$Revision: 5068 $'
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
				var submitFormObj = document.getElementById(formId);
65
				submitFormObj.qformat.value = 'csv';
66
				submitFormObj.action.value = 'dataquery';
67
				
68
				//the form that holds the metadata field mappings - but in the header!
69
				var fieldFormObj = 
70
					getIframeDocument("iframeheaderclass").getElementById(fieldFormId);
71
				//alert("fieldFormObj: " + fieldFormObj);
72
				
73
				multipleAssessmentSearch(submitFormObj, fieldFormObj);
74
				
75
				submitFormObj.submit();
76
			}
77
			editCart = function(formId, operation, docid) {
78
			
79
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
80
				//if (!areItemsSelected('docid') && docid) {
81
				//	alert("Please select at least one dataset");
82
				//	return false;
83
				//}
84
				
85
				var submitFormObj = document.getElementById(formId);
86
				submitFormObj.qformat.value = 'first';
87
				submitFormObj.action.value = 'editcart';
88
				submitFormObj.operation.value = operation;
89
				if (docid) {
90
					submitFormObj.docid.value = docid;
91
				}
92
				
93
				var myUpdate = new Ajax.Request(
94
					metacatURL,
95
					{	method: 'post',
96
						parameters: Form.serialize(submitFormObj),
97
						evalScripts: true,
98
						onSuccess: function(transport) {
99
							//alert('Cart changes saved: ' + operation); 
100
							//if we are in the cart, we should refresh the entire page
101
							if (document.getElementById("ajaxCartResults")) {
102
								window.location.reload();
103
							}
104
							else {
105
								window.document.getElementById("iframeheaderclass").src=window.document.getElementById("iframeheaderclass").src;
106
								//now check the cart contents and update those icons (but wait a second)
107
								setTimeout("setAllCartIcons()", 1000);
108
							}
109
						}, 
110
						onFailure: function(transport) {alert('failure making ajax call');}
111
					 });
112
								
113
			}
114
			read = function(formId, docid, divId) {
115
			
116
				//alert("divId: " + divId);
117
				
118
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
119
				
120
				var submitFormObj = document.getElementById(formId);
121
				submitFormObj.qformat.value = 'first';
122
				submitFormObj.action.value = 'read';
123
				submitFormObj.docid.value = docid;
124
				submitFormObj.insertTemplate.value = '0';
125
				
126
				var myUpdate = new Ajax.Updater(
127
					divId,
128
					metacatURL,
129
					{	method: 'post',
130
						parameters: Form.serialize(submitFormObj),
131
						evalScripts: true,
132
						onSuccess: function(transport) {showDiv(divId); }, 
133
						onFailure: function(transport) {alert('failure making ajax call');}
134
					 });
135
								
136
			}
137
			areItemsSelected = function(checkBoxName) {
138
				var checkBoxes = document.getElementsByName(checkBoxName);
139
				
140
				for (var i=0; i< checkBoxes.length; i++) {
141
					if (checkBoxes[i].checked == true) {
142
						return true;
143
					}	
144
				}
145
				//alert("please select a checkbox: " + checkBoxName);
146
				return false;
147
				
148
			}
149
			setControlVisibility = function() {
150
				if (document.getElementById("ajaxCartResults")) {
151
					new Effect.Appear("download");
152
					new Effect.Appear("transposeDiv");
153
					new Effect.Appear("metadataCountDiv");
154
				}
155
			}	
156
			isInCart = function(docid) {
157
		
158
				//look up the cart in the header
159
				var doc = getIframeDocument("iframeheaderclass");
160
				var objs = doc.getElementsByName("@packageId");
161
				
162
				if (objs.length == 0) {
163
					return false;
164
				}
165
				for (var i=0; i< objs.length; i++) {
166
					if (docid == objs[i].value) {
167
						return true;
168
					}
169
				}
170
				return false;
171
			}			
172
			hideDiv = function(divId) {
173
				new Effect.Puff(divId);
174
				//Element.hide(divId);
175
			}
176
			showDiv = function(divId) {
177
				new Effect.Appear(divId)
178
				//Element.show(divId);
179
			}
180
			setAllCartIcons = function() {
181
				var docids = document.getElementsByName('docid');
182
				for (var i=0; i< docids.length; i++) {
183
					var docid = docids[i].value;
184
					if (docid != "") {
185
						setCartIcon(docid);
186
					}	
187
				}
188
			}
189
			setCartIcon = function(docid) {
190
				//show or hide the div
191
				//alert("setting icon for: " + docid);
192
				if (isInCart(docid)) {
193
					hideDiv("ajaxDiv" + docid + "add");
194
					showDiv("ajaxDiv" + docid + "remove");
195
				}
196
				else {
197
					hideDiv("ajaxDiv" + docid + "remove");
198
					showDiv("ajaxDiv" + docid + "add");
199
				}
200
			}
201
			
202
		 ]]>	
203
		</script>
204
        
205
		<p class="emphasis">Assessments found: <xsl:number value="count(resultset/document)" /></p>      
206
      
207
		<!-- This tests to see if there are returned documents,
208
            if there are not then don't show the query results -->
209

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

    
258
			</form>	
259
			
260
			<!-- for downloading data -->				
261
			<form action="{$contextURL}/style/skins/first/download.jsp" method="POST" id="assessmentForm" name="assessmentForm" >
262
				<input type="hidden" name="qformat" value="first" />
263
				<input type="hidden" name="sessionid">
264
					<xsl:attribute name="value">
265
						<xsl:value-of select="$sessid" />						
266
					</xsl:attribute>
267
				</input>
268
				<input type="hidden" name="action" value="read" />
269
				<input type="hidden" name="dataquery" />
270
				<div id="metadataCountDiv" style="display:none;">
271
					<select name="metadataCount" id="metadataCount" width="2" >
272
						<option>1</option>
273
						<option>2</option>
274
						<option>3</option>
275
						<option>4</option>
276
						<option>5</option>
277
						<option>6</option>
278
						<option>7</option>
279
						<option>8</option>
280
						<option>9</option>
281
						<option>10</option>
282
						<option>20</option>
283
						<option>30</option>
284
						<option>40</option>
285
						<option>50</option>
286
					</select>
287
					item metadata fields included
288
				</div>
289
				<div id="transposeDiv" style="display:none;">
290
					<input type="checkbox" name="transpose" value="true" />Transpose Data
291
				</div>
292
				<input type="hidden" name="observation" value="3" />
293
				<input type="hidden" name="pivot" value="2" />
294
				<input type="hidden" name="operation" />
295
				
296
				<xsl:element name="input">
297
					<xsl:attribute name="type">hidden</xsl:attribute>
298
					<xsl:attribute name="id">questionId</xsl:attribute>
299
					<xsl:attribute name="name">questionId</xsl:attribute>
300
					<xsl:attribute name="value"></xsl:attribute>
301
				</xsl:element>
302
				
303
			<table width="95%" align="left" border="0" cellpadding="0"
304
				cellspacing="0">
305
				<tr>
306
					
307
					<th style="text-align: left" colspan="2">
308
						Assessment
309
					</th>
310
					<th style="text-align: left">
311
						Course Title
312
					</th>
313
					<th	style="text-align: left">
314
						Instructor[s]
315
					</th>
316
					<th	style="text-align: left">
317
						Organization[s]
318
					</th>
319
					<th	style="text-align: left">
320
						Keywords
321
					</th>
322
				</tr>
323

    
324
				<xsl:for-each select="resultset/document">
325
					<xsl:sort select="./param[@name='assessment/@id']" />
326
					<xsl:variable name="divId">
327
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
328
					</xsl:variable>
329
					<tr valign="top" class="subpanel">
330
						<xsl:attribute name="class">
331
			               <xsl:choose>
332
			                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
333
			                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
334
			               </xsl:choose>
335
			             </xsl:attribute>
336

    
337
						<td class="text_plain" nowrap="nowrap">
338
						
339
						<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) = 0" >
340
							No Data
341
						</xsl:if>	
342
						<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) >= 1" >
343
						
344
							<script type="text/javascript" language="Javascript">
345
								<![CDATA[
346
									//what are our options?
347
									if (isInCart("]]><xsl:value-of select="./docid" /><![CDATA[")) {
348
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
349
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
350
									}
351
									else {
352
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
353
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
354
									}
355
								]]>	
356
							</script>
357
							<div style="display:none;">
358
								<xsl:attribute name="id">
359
									<xsl:value-of select="$divId" />
360
									<xsl:text>add</xsl:text>
361
								</xsl:attribute>
362
								<a>
363
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
364
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'add',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
365
									<img border="none">
366
										<xsl:attribute name="src">
367
											<xsl:value-of select="$contextURL" />
368
											<xsl:text>/style/skins/first/images/cart_plus_sm.png</xsl:text>
369
										</xsl:attribute>
370
									</img>
371
								</a>
372
							</div>
373
							<div style="display:none;">
374
								<xsl:attribute name="id">
375
									<xsl:value-of select="$divId" />
376
									<xsl:text>remove</xsl:text>
377
								</xsl:attribute>
378
								<a>
379
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
380
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'remove',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
381
									<!--  <xsl:text>Remove </xsl:text> -->
382
									<img border="none">
383
										<xsl:attribute name="src">
384
											<xsl:value-of select="$contextURL" />
385
											<xsl:text>/style/skins/first/images/cart_minus_sm.png</xsl:text>
386
										</xsl:attribute>
387
									</img>
388
								</a>
389
							</div>
390

    
391
							<input type="hidden" name="docid">
392
								<xsl:attribute name="value">
393
									<xsl:value-of select="./docid" />
394
								</xsl:attribute>
395
							</input>
396
							
397
							</xsl:if>
398
							<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) >= 2" >
399
								<!-- demographic data is present -->
400
								<img border="none">
401
									<xsl:attribute name="src">
402
										<xsl:value-of select="$contextURL" />
403
										<xsl:text>/style/skins/first/images/user.gif</xsl:text>
404
									</xsl:attribute>
405
								</img>
406
							</xsl:if>
407
							
408
						</td>
409
						<td>
410
							
411
							<a>
412
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.readForm)</xsl:attribute>
413
								<xsl:text>&#187;&#160;</xsl:text>
414
								<xsl:value-of select="./param[@name='assessment/title']" />
415
							</a>
416
							(<xsl:value-of select="./docid" />)
417
							
418
							<br />
419
							
420
							<!--include question ids here -->
421
							<xsl:for-each select="./param[@name='assessmentItems/assessmentItem/assessmentItemId']" >
422
								<input type="hidden">
423
									<xsl:attribute name="name">
424
										<xsl:value-of select="../docid" />
425
									</xsl:attribute>
426
									<xsl:attribute name="value">
427
										<xsl:value-of select="." />
428
									</xsl:attribute>
429
								</input>
430
							</xsl:for-each>
431
							
432
							<!-- demographic data - present or not? -->
433
							<input type="hidden">
434
								<xsl:attribute name="name">
435
									<xsl:value-of select="./docid" />
436
									<xsl:text>demographicData</xsl:text>
437
								</xsl:attribute>
438
								<xsl:attribute name="value">
439
									<xsl:choose>	
440
										<xsl:when test="count(./param[@name='dataset/dataTable/entityName']) >= 2" >
441
											<xsl:text>true</xsl:text>
442
										</xsl:when>
443
										<xsl:otherwise>
444
											<xsl:text></xsl:text>
445
										</xsl:otherwise>
446
									</xsl:choose>
447
								</xsl:attribute>
448
							</input>
449
							
450
							<br/>
451
														
452
						</td>
453

    
454
						<td class="text_plain">
455
							<xsl:for-each
456
								select="./param[@name='lom/general/title/string']">
457
								<xsl:value-of select="." />
458
								<br />
459
							</xsl:for-each>
460
						</td>
461
						<td class="text_plain">
462
							<xsl:for-each
463
								select="./param[@name='individualName/surName']">
464
								<xsl:value-of select="." />
465
								<br />
466
							</xsl:for-each>
467
						</td>
468
						<td class="text_plain">
469
							<xsl:for-each
470
								select="./param[@name='organizationName']">
471
								<xsl:value-of select="." />
472
								<br />
473
							</xsl:for-each>
474
						</td>
475

    
476
						<td class="text_plain">
477
							<xsl:for-each
478
								select="./param[@name='keyword']">
479
								<xsl:value-of select="." />
480
								<br />
481
							</xsl:for-each>
482
							<xsl:for-each
483
								select="./param[@name='lom/general/keyword/string']">
484
								<xsl:value-of select="." />
485
								<br />
486
							</xsl:for-each>
487

    
488
						</td>
489

    
490
					</tr>
491
					
492
					<tr>
493
						<td colspan="6">
494
							Details 
495
							<a>
496
								<xsl:attribute name="href">javascript:read('readForm', '<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
497
								<img border="none">
498
									<xsl:attribute name="src">
499
										<xsl:value-of select="$contextURL" />
500
										<xsl:text>/style/images/next.gif</xsl:text>
501
									</xsl:attribute>
502
								</img>
503
							</a>
504
							/
505
							<a>
506
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
507
								<img border="none">
508
									<xsl:attribute name="src">
509
										<xsl:value-of select="$contextURL" />
510
										<xsl:text>/style/images/previous.gif</xsl:text>
511
									</xsl:attribute>
512
								</img>
513
							</a>
514
							
515
						</td>	
516
					</tr>
517
					
518
					<tr>
519
						<td colspan="6">
520
							<div style="display:none;">
521
								<xsl:attribute name="id">
522
									<xsl:value-of select="$divId" />
523
								</xsl:attribute>
524
								Assessment details...
525
							</div>
526
						</td>	
527
					</tr>
528
					
529
					<tr class="searchresultsdivider">
530
						<td colspan="6">
531
							<img
532
								src="{$contextURL}/style/skins/default/images/transparent1x1.gif"
533
								width="1" height="1" />
534
						</td>
535
					</tr>
536

    
537
				</xsl:for-each>
538
				
539
			</table>
540
			
541
			</form>
542

    
543
		</xsl:if>
544
	</xsl:template>
545

    
546
</xsl:stylesheet>
(5-5/22)