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 11:12:28 -0700 (Thu, 30 Oct 2008) $'
11
* '$Revision: 4493 $'
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 objs = window.document.getElementById("iframeheaderclass").contentDocument.getElementsByName("@packageId");
166
				//var objs = document.getElementsByName("@packageId");
167
				if (objs.length == 0) {
168
					return false;
169
				}
170
				for (var i=0; i< objs.length; i++) {
171
					if (docid == objs[i].value) {
172
						return true;
173
					}
174
				}
175
				return false;
176
			}			
177
			hideDiv = function(divId) {
178
				new Effect.Puff(divId);
179
				//Element.hide(divId);
180
			}
181
			showDiv = function(divId) {
182
				new Effect.Appear(divId)
183
				//Element.show(divId);
184
			}
185
			setAllCartIcons = function() {
186
				var docids = document.getElementsByName('docid');
187
				for (var i=0; i< docids.length; i++) {
188
					var docid = docids[i].value;
189
					if (docid != "") {
190
						setCartIcon(docid);
191
					}	
192
				}
193
			}
194
			setCartIcon = function(docid) {
195
				//show or hide the div
196
				//alert("setting icon for: " + docid);
197
				if (isInCart(docid)) {
198
					hideDiv("ajaxDiv" + docid + "add");
199
					showDiv("ajaxDiv" + docid + "remove");
200
				}
201
				else {
202
					hideDiv("ajaxDiv" + docid + "remove");
203
					showDiv("ajaxDiv" + docid + "add");
204
				}
205
			}	
206
		 ]]>	
207
		</script>
208
        
209
		<p class="emphasis">Assessments found: <xsl:number value="count(resultset/document)" /></p>      
210
      
211
		<!-- This tests to see if there are returned documents,
212
            if there are not then don't show the query results -->
213

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

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

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

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

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

    
400
						<td class="text_plain">
401
							<xsl:for-each
402
								select="./param[@name='lom/general/title/string']">
403
								<xsl:value-of select="." />
404
								<br />
405
							</xsl:for-each>
406
						</td>
407
						<td class="text_plain">
408
							<xsl:for-each
409
								select="./param[@name='individualName/surName']">
410
								<xsl:value-of select="." />
411
								<br />
412
							</xsl:for-each>
413
						</td>
414
						<td class="text_plain">
415
							<xsl:for-each
416
								select="./param[@name='organizationName']">
417
								<xsl:value-of select="." />
418
								<br />
419
							</xsl:for-each>
420
						</td>
421

    
422
						<td class="text_plain">
423
							<xsl:for-each
424
								select="./param[@name='keyword']">
425
								<xsl:value-of select="." />
426
								<br />
427
							</xsl:for-each>
428
							<xsl:for-each
429
								select="./param[@name='lom/general/keyword/string']">
430
								<xsl:value-of select="." />
431
								<br />
432
							</xsl:for-each>
433

    
434
						</td>
435

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

    
483
				</xsl:for-each>
484
				
485
			</table>
486
			
487
			</form>
488

    
489
		</xsl:if>
490
	</xsl:template>
491

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