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-03-24 16:36:03 -0700 (Tue, 24 Mar 2009) $'
11
* '$Revision: 4859 $'
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
				}
153
			}	
154
			isInCart = function(docid) {
155
		
156
				//look up the cart in the header
157
				var doc = getIframeDocument("iframeheaderclass");
158
				var objs = doc.getElementsByName("@packageId");
159
				
160
				if (objs.length == 0) {
161
					return false;
162
				}
163
				for (var i=0; i< objs.length; i++) {
164
					if (docid == objs[i].value) {
165
						return true;
166
					}
167
				}
168
				return false;
169
			}			
170
			hideDiv = function(divId) {
171
				new Effect.Puff(divId);
172
				//Element.hide(divId);
173
			}
174
			showDiv = function(divId) {
175
				new Effect.Appear(divId)
176
				//Element.show(divId);
177
			}
178
			setAllCartIcons = function() {
179
				var docids = document.getElementsByName('docid');
180
				for (var i=0; i< docids.length; i++) {
181
					var docid = docids[i].value;
182
					if (docid != "") {
183
						setCartIcon(docid);
184
					}	
185
				}
186
			}
187
			setCartIcon = function(docid) {
188
				//show or hide the div
189
				//alert("setting icon for: " + docid);
190
				if (isInCart(docid)) {
191
					hideDiv("ajaxDiv" + docid + "add");
192
					showDiv("ajaxDiv" + docid + "remove");
193
				}
194
				else {
195
					hideDiv("ajaxDiv" + docid + "remove");
196
					showDiv("ajaxDiv" + docid + "add");
197
				}
198
			}
199
			
200
		 ]]>	
201
		</script>
202
        
203
		<p class="emphasis">Assessments found: <xsl:number value="count(resultset/document)" /></p>      
204
      
205
		<!-- This tests to see if there are returned documents,
206
            if there are not then don't show the query results -->
207

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

    
256
			</form>	
257
			
258
			<!-- for downloading data -->				
259
			<form action="{$contextURL}/metacat" method="POST" id="assessmentForm" name="assessmentForm" >
260
				<input type="hidden" name="qformat" value="first" />
261
				<input type="hidden" name="sessionid">
262
					<xsl:attribute name="value">
263
						<xsl:value-of select="$sessid" />						
264
					</xsl:attribute>
265
				</input>
266
				<input type="hidden" name="action" value="read" />
267
				<input type="hidden" name="dataquery" />
268
				<input type="checkbox" name="transpose" value="true" />Transpose Data
269
				<input type="hidden" name="observation" value="3" />
270
				<input type="hidden" name="pivot" value="2" />
271
				<input type="hidden" name="operation" />
272
				
273
				<xsl:element name="input">
274
					<xsl:attribute name="type">hidden</xsl:attribute>
275
					<xsl:attribute name="id">questionId</xsl:attribute>
276
					<xsl:attribute name="name">questionId</xsl:attribute>
277
					<xsl:attribute name="value"></xsl:attribute>
278
				</xsl:element>
279
				
280
			<table width="95%" align="left" border="0" cellpadding="0"
281
				cellspacing="0">
282
				<tr>
283
					
284
					<th style="text-align: left" colspan="2">
285
						Assessment
286
					</th>
287
					<th style="text-align: left">
288
						Course Title
289
					</th>
290
					<th	style="text-align: left">
291
						Instructor[s]
292
					</th>
293
					<th	style="text-align: left">
294
						Organization[s]
295
					</th>
296
					<th	style="text-align: left">
297
						Keywords
298
					</th>
299
				</tr>
300

    
301
				<xsl:for-each select="resultset/document">
302
					<xsl:sort select="./param[@name='assessment/@id']" />
303
					<xsl:variable name="divId">
304
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
305
					</xsl:variable>
306
					<tr valign="top" class="subpanel">
307
						<xsl:attribute name="class">
308
			               <xsl:choose>
309
			                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
310
			                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
311
			               </xsl:choose>
312
			             </xsl:attribute>
313

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

    
368
							<input type="hidden" name="docid">
369
								<xsl:attribute name="value">
370
									<xsl:value-of select="./docid" />
371
								</xsl:attribute>
372
							</input>
373
							
374
							</xsl:if>
375
							<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) >= 2" >
376
								<!-- demographic data is present -->
377
								<img border="none">
378
									<xsl:attribute name="src">
379
										<xsl:value-of select="$contextURL" />
380
										<xsl:text>/style/skins/first/images/user.gif</xsl:text>
381
									</xsl:attribute>
382
								</img>
383
							</xsl:if>
384
							
385
						</td>
386
						<td>
387
							
388
							<a>
389
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.readForm)</xsl:attribute>
390
								<xsl:text>&#187;&#160;</xsl:text>
391
								<xsl:value-of select="./param[@name='assessment/title']" />
392
							</a>
393
							(<xsl:value-of select="./docid" />)
394
							
395
							<br />
396
							
397
							<!--include question ids here -->
398
							<xsl:for-each select="./param[@name='assessmentItems/assessmentItem/assessmentItemId']" >
399
								<input type="hidden">
400
									<xsl:attribute name="name">
401
										<xsl:value-of select="../docid" />
402
									</xsl:attribute>
403
									<xsl:attribute name="value">
404
										<xsl:value-of select="." />
405
									</xsl:attribute>
406
								</input>
407
							</xsl:for-each>
408
							
409
							<!-- demographic data - present or not? -->
410
							<input type="hidden">
411
								<xsl:attribute name="name">
412
									<xsl:value-of select="./docid" />
413
									<xsl:text>demographicData</xsl:text>
414
								</xsl:attribute>
415
								<xsl:attribute name="value">
416
									<xsl:choose>	
417
										<xsl:when test="count(./param[@name='dataset/dataTable/entityName']) >= 2" >
418
											<xsl:text>true</xsl:text>
419
										</xsl:when>
420
										<xsl:otherwise>
421
											<xsl:text></xsl:text>
422
										</xsl:otherwise>
423
									</xsl:choose>
424
								</xsl:attribute>
425
							</input>
426
							
427
							<br/>
428
														
429
						</td>
430

    
431
						<td class="text_plain">
432
							<xsl:for-each
433
								select="./param[@name='lom/general/title/string']">
434
								<xsl:value-of select="." />
435
								<br />
436
							</xsl:for-each>
437
						</td>
438
						<td class="text_plain">
439
							<xsl:for-each
440
								select="./param[@name='individualName/surName']">
441
								<xsl:value-of select="." />
442
								<br />
443
							</xsl:for-each>
444
						</td>
445
						<td class="text_plain">
446
							<xsl:for-each
447
								select="./param[@name='organizationName']">
448
								<xsl:value-of select="." />
449
								<br />
450
							</xsl:for-each>
451
						</td>
452

    
453
						<td class="text_plain">
454
							<xsl:for-each
455
								select="./param[@name='keyword']">
456
								<xsl:value-of select="." />
457
								<br />
458
							</xsl:for-each>
459
							<xsl:for-each
460
								select="./param[@name='lom/general/keyword/string']">
461
								<xsl:value-of select="." />
462
								<br />
463
							</xsl:for-each>
464

    
465
						</td>
466

    
467
					</tr>
468
					
469
					<tr>
470
						<td colspan="6">
471
							Details 
472
							<a>
473
								<xsl:attribute name="href">javascript:read('readForm', '<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
474
								<img border="none">
475
									<xsl:attribute name="src">
476
										<xsl:value-of select="$contextURL" />
477
										<xsl:text>/style/images/next.gif</xsl:text>
478
									</xsl:attribute>
479
								</img>
480
							</a>
481
							/
482
							<a>
483
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
484
								<img border="none">
485
									<xsl:attribute name="src">
486
										<xsl:value-of select="$contextURL" />
487
										<xsl:text>/style/images/previous.gif</xsl:text>
488
									</xsl:attribute>
489
								</img>
490
							</a>
491
							
492
						</td>	
493
					</tr>
494
					
495
					<tr>
496
						<td colspan="6">
497
							<div style="display:none;">
498
								<xsl:attribute name="id">
499
									<xsl:value-of select="$divId" />
500
								</xsl:attribute>
501
								Assessment details...
502
							</div>
503
						</td>	
504
					</tr>
505
					
506
					<tr class="searchresultsdivider">
507
						<td colspan="6">
508
							<img
509
								src="{$contextURL}/style/skins/default/images/transparent1x1.gif"
510
								width="1" height="1" />
511
						</td>
512
					</tr>
513

    
514
				</xsl:for-each>
515
				
516
			</table>
517
			
518
			</form>
519

    
520
		</xsl:if>
521
	</xsl:template>
522

    
523
</xsl:stylesheet>
(4-4/21)