Project

General

Profile

1 3531 leinfelder
<?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$'
10
*     '$Date$'
11
* '$Revision$'
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 4289 leinfelder
	<xsl:param name="contextURL"/>
38 3531 leinfelder
	<xsl:template match="/">
39
		<script language="JavaScript">
40
          <![CDATA[
41 3542 leinfelder
          submitform = function(action,docid,form_ref) {
42 3531 leinfelder
              form_ref.action.value=action;
43 3542 leinfelder
              form_ref.docid.value=docid;
44 3531 leinfelder
              form_ref.sessionid.value="]]><xsl:value-of select="$sessid" /><![CDATA[";
45 4290 leinfelder
              form_ref.qformat.value="first";
46 4390 leinfelder
              form_ref.insertTemplate.value="1";
47 3531 leinfelder
              form_ref.submit();
48
          }
49 3542 leinfelder
          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 3531 leinfelder
          ]]>
59
        </script>
60 3542 leinfelder
        <script type="text/javascript" language="Javascript">
61
			<![CDATA[
62 4387 leinfelder
			downloadMergedResponseData = function(formId, fieldFormId) {
63 3551 leinfelder
64
				var submitFormObj = document.getElementById(formId);
65
				submitFormObj.qformat.value = 'csv';
66 4289 leinfelder
				submitFormObj.action.value = 'dataquery';
67 3551 leinfelder
68 4387 leinfelder
				//the form that holds the metadata field mappings - but in the header!
69
				var fieldFormObj =
70 4495 leinfelder
					getIframeDocument("iframeheaderclass").getElementById(fieldFormId);
71 4387 leinfelder
				//alert("fieldFormObj: " + fieldFormObj);
72 4289 leinfelder
73 4387 leinfelder
				multipleAssessmentSearch(submitFormObj, fieldFormObj);
74
75 3551 leinfelder
				submitFormObj.submit();
76
			}
77 4484 leinfelder
			editCart = function(formId, operation, docid) {
78 4361 leinfelder
79
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
80 4484 leinfelder
				//if (!areItemsSelected('docid') && docid) {
81
				//	alert("Please select at least one dataset");
82
				//	return false;
83
				//}
84 4361 leinfelder
85
				var submitFormObj = document.getElementById(formId);
86
				submitFormObj.qformat.value = 'first';
87
				submitFormObj.action.value = 'editcart';
88
				submitFormObj.operation.value = operation;
89 4484 leinfelder
				if (docid) {
90
					submitFormObj.docid.value = docid;
91
				}
92 4361 leinfelder
93
				var myUpdate = new Ajax.Request(
94
					metacatURL,
95
					{	method: 'post',
96
						parameters: Form.serialize(submitFormObj),
97 4379 leinfelder
						evalScripts: true,
98 4388 leinfelder
						onSuccess: function(transport) {
99
							//alert('Cart changes saved: ' + operation);
100 4390 leinfelder
							//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 4493 leinfelder
								//now check the cart contents and update those icons (but wait a second)
107
								setTimeout("setAllCartIcons()", 1000);
108 4390 leinfelder
							}
109
						},
110 4361 leinfelder
						onFailure: function(transport) {alert('failure making ajax call');}
111
					 });
112
113
			}
114 4379 leinfelder
			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 3551 leinfelder
			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 4411 leinfelder
			setControlVisibility = function() {
150
				if (document.getElementById("ajaxCartResults")) {
151 4484 leinfelder
					new Effect.Appear("download");
152 4880 leinfelder
					new Effect.Appear("transposeDiv");
153 4411 leinfelder
				}
154 4493 leinfelder
			}
155 4484 leinfelder
			isInCart = function(docid) {
156
157 4495 leinfelder
				//look up the cart in the header
158
				var doc = getIframeDocument("iframeheaderclass");
159 4494 leinfelder
				var objs = doc.getElementsByName("@packageId");
160
161 4484 leinfelder
				if (objs.length == 0) {
162
					return false;
163 4411 leinfelder
				}
164 4484 leinfelder
				for (var i=0; i< objs.length; i++) {
165
					if (docid == objs[i].value) {
166
						return true;
167
					}
168
				}
169
				return false;
170 4493 leinfelder
			}
171 3542 leinfelder
			hideDiv = function(divId) {
172 4493 leinfelder
				new Effect.Puff(divId);
173 4388 leinfelder
				//Element.hide(divId);
174 3542 leinfelder
			}
175 4379 leinfelder
			showDiv = function(divId) {
176 4390 leinfelder
				new Effect.Appear(divId)
177 4388 leinfelder
				//Element.show(divId);
178 4379 leinfelder
			}
179 4493 leinfelder
			setAllCartIcons = function() {
180
				var docids = document.getElementsByName('docid');
181
				for (var i=0; i< docids.length; i++) {
182
					var docid = docids[i].value;
183
					if (docid != "") {
184
						setCartIcon(docid);
185
					}
186
				}
187
			}
188
			setCartIcon = function(docid) {
189
				//show or hide the div
190
				//alert("setting icon for: " + docid);
191
				if (isInCart(docid)) {
192
					hideDiv("ajaxDiv" + docid + "add");
193
					showDiv("ajaxDiv" + docid + "remove");
194
				}
195
				else {
196
					hideDiv("ajaxDiv" + docid + "remove");
197
					showDiv("ajaxDiv" + docid + "add");
198
				}
199 4495 leinfelder
			}
200
201 3542 leinfelder
		 ]]>
202
		</script>
203 3531 leinfelder
204 4390 leinfelder
		<p class="emphasis">Assessments found: <xsl:number value="count(resultset/document)" /></p>
205 3531 leinfelder
206
		<!-- This tests to see if there are returned documents,
207
            if there are not then don't show the query results -->
208
209
		<xsl:if test="count(resultset/document) &gt; 0">
210 4411 leinfelder
			<script type="text/javascript" language="Javascript">
211
				<![CDATA[
212
					//call on load
213
					setControlVisibility();
214
				]]>
215
			</script>
216 4484 leinfelder
			<div id="download" style="display:none;">
217 4411 leinfelder
				<p>
218
					<a>
219
						<xsl:attribute name="href">javascript:{}</xsl:attribute>
220 4484 leinfelder
						<xsl:attribute name="onclick">javascript:downloadMergedResponseData('assessmentForm', 'fieldForm')</xsl:attribute>
221 4411 leinfelder
						<img border="none">
222
							<xsl:attribute name="src">
223
								<xsl:value-of select="$contextURL" />
224 4484 leinfelder
								<xsl:text>/style/images/page_white_put.png</xsl:text>
225 4411 leinfelder
							</xsl:attribute>
226
						</img>
227 4484 leinfelder
						<xsl:text> Download (.csv)</xsl:text>
228 4411 leinfelder
					</a>
229
				</p>
230
			</div>
231 4390 leinfelder
232 4361 leinfelder
			<!-- for reading the assessment details -->
233
			<form action="{$contextURL}/metacat" method="POST" id="readForm" name="readForm" >
234
				<input type="hidden" name="qformat" value="first" />
235
				<input type="hidden" name="sessionid">
236
					<xsl:attribute name="value">
237
						<xsl:value-of select="$sessid" />
238
					</xsl:attribute>
239
				</input>
240
				<input type="hidden" name="action" value="read" />
241
				<input type="hidden" name="docid" />
242 4379 leinfelder
				<input type="hidden" name="insertTemplate" value="1"/>
243 4361 leinfelder
			</form>
244
245 4484 leinfelder
			<!-- for editing cart -->
246
			<form action="{$contextURL}/metacat" method="POST" id="cartForm" name="cartForm" >
247
				<input type="hidden" name="qformat" value="first" />
248
				<input type="hidden" name="sessionid">
249
					<xsl:attribute name="value">
250
						<xsl:value-of select="$sessid" />
251
					</xsl:attribute>
252
				</input>
253
				<input type="hidden" name="action" value="editcart" />
254
				<input type="hidden" name="operation" />
255
				<input type="hidden" name="docid" />
256
257
			</form>
258
259
			<!-- for downloading data -->
260 4872 leinfelder
			<form action="{$contextURL}/style/skins/first/download.jsp" method="POST" id="assessmentForm" name="assessmentForm" >
261 3542 leinfelder
				<input type="hidden" name="qformat" value="first" />
262 4289 leinfelder
				<input type="hidden" name="sessionid">
263
					<xsl:attribute name="value">
264
						<xsl:value-of select="$sessid" />
265
					</xsl:attribute>
266
				</input>
267 3542 leinfelder
				<input type="hidden" name="action" value="read" />
268 4289 leinfelder
				<input type="hidden" name="dataquery" />
269 4880 leinfelder
				<div id="transposeDiv" style="display:none;">
270
					<input type="checkbox" name="transpose" value="true" />Transpose Data
271
				</div>
272 4859 leinfelder
				<input type="hidden" name="observation" value="3" />
273
				<input type="hidden" name="pivot" value="2" />
274 4361 leinfelder
				<input type="hidden" name="operation" />
275 4484 leinfelder
276 3669 leinfelder
				<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 3542 leinfelder
283 3531 leinfelder
			<table width="95%" align="left" border="0" cellpadding="0"
284
				cellspacing="0">
285
				<tr>
286 4484 leinfelder
287
					<th style="text-align: left" colspan="2">
288
						Assessment
289 4289 leinfelder
					</th>
290
					<th style="text-align: left">
291 3531 leinfelder
						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 3918 leinfelder
					<xsl:sort select="./param[@name='assessment/@id']" />
306 3542 leinfelder
					<xsl:variable name="divId">
307
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
308
					</xsl:variable>
309 3531 leinfelder
					<tr valign="top" class="subpanel">
310
						<xsl:attribute name="class">
311 3542 leinfelder
			               <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 3531 leinfelder
317 4484 leinfelder
						<td class="text_plain" nowrap="nowrap">
318
319 4650 leinfelder
						<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) = 0" >
320
							No Data
321
						</xsl:if>
322
						<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) >= 1" >
323
324 4484 leinfelder
							<script type="text/javascript" language="Javascript">
325
								<![CDATA[
326
									//what are our options?
327
									if (isInCart("]]><xsl:value-of select="./docid" /><![CDATA[")) {
328
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
329
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
330
									}
331
									else {
332
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
333
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
334
									}
335
								]]>
336
							</script>
337
							<div style="display:none;">
338
								<xsl:attribute name="id">
339
									<xsl:value-of select="$divId" />
340
									<xsl:text>add</xsl:text>
341
								</xsl:attribute>
342
								<a>
343
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
344
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'add',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
345
									<img border="none">
346
										<xsl:attribute name="src">
347
											<xsl:value-of select="$contextURL" />
348 4492 leinfelder
											<xsl:text>/style/skins/first/images/cart_plus_sm.png</xsl:text>
349 4484 leinfelder
										</xsl:attribute>
350
									</img>
351
								</a>
352
							</div>
353
							<div style="display:none;">
354
								<xsl:attribute name="id">
355
									<xsl:value-of select="$divId" />
356
									<xsl:text>remove</xsl:text>
357
								</xsl:attribute>
358
								<a>
359
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
360
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'remove',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
361
									<!--  <xsl:text>Remove </xsl:text> -->
362
									<img border="none">
363
										<xsl:attribute name="src">
364
											<xsl:value-of select="$contextURL" />
365 4492 leinfelder
											<xsl:text>/style/skins/first/images/cart_minus_sm.png</xsl:text>
366 4484 leinfelder
										</xsl:attribute>
367
									</img>
368
								</a>
369
							</div>
370
371
							<input type="hidden" name="docid">
372 4289 leinfelder
								<xsl:attribute name="value">
373
									<xsl:value-of select="./docid" />
374
								</xsl:attribute>
375
							</input>
376 4484 leinfelder
377 4650 leinfelder
							</xsl:if>
378
							<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) >= 2" >
379
								<!-- demographic data is present -->
380
								<img border="none">
381
									<xsl:attribute name="src">
382
										<xsl:value-of select="$contextURL" />
383
										<xsl:text>/style/skins/first/images/user.gif</xsl:text>
384
									</xsl:attribute>
385
								</img>
386
							</xsl:if>
387
388 4289 leinfelder
						</td>
389
						<td>
390
391 3542 leinfelder
							<a>
392 4361 leinfelder
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.readForm)</xsl:attribute>
393 3542 leinfelder
								<xsl:text>&#187;&#160;</xsl:text>
394 4636 leinfelder
								<xsl:value-of select="./param[@name='assessment/title']" />
395 3542 leinfelder
							</a>
396
							(<xsl:value-of select="./docid" />)
397 4289 leinfelder
398 3542 leinfelder
							<br />
399 4289 leinfelder
400
							<!--include question ids here -->
401
							<xsl:for-each select="./param[@name='assessmentItems/assessmentItem/assessmentItemId']" >
402
								<input type="hidden">
403
									<xsl:attribute name="name">
404
										<xsl:value-of select="../docid" />
405
									</xsl:attribute>
406
									<xsl:attribute name="value">
407
										<xsl:value-of select="." />
408
									</xsl:attribute>
409
								</input>
410
							</xsl:for-each>
411
412 4650 leinfelder
							<!-- demographic data - present or not? -->
413
							<input type="hidden">
414
								<xsl:attribute name="name">
415
									<xsl:value-of select="./docid" />
416
									<xsl:text>demographicData</xsl:text>
417
								</xsl:attribute>
418
								<xsl:attribute name="value">
419
									<xsl:choose>
420
										<xsl:when test="count(./param[@name='dataset/dataTable/entityName']) >= 2" >
421
											<xsl:text>true</xsl:text>
422
										</xsl:when>
423
										<xsl:otherwise>
424 4653 leinfelder
											<xsl:text></xsl:text>
425 4650 leinfelder
										</xsl:otherwise>
426
									</xsl:choose>
427
								</xsl:attribute>
428
							</input>
429
430 3542 leinfelder
							<br/>
431 4379 leinfelder
432 3531 leinfelder
						</td>
433
434
						<td class="text_plain">
435
							<xsl:for-each
436
								select="./param[@name='lom/general/title/string']">
437
								<xsl:value-of select="." />
438
								<br />
439
							</xsl:for-each>
440
						</td>
441
						<td class="text_plain">
442
							<xsl:for-each
443
								select="./param[@name='individualName/surName']">
444
								<xsl:value-of select="." />
445
								<br />
446
							</xsl:for-each>
447
						</td>
448
						<td class="text_plain">
449
							<xsl:for-each
450
								select="./param[@name='organizationName']">
451
								<xsl:value-of select="." />
452
								<br />
453
							</xsl:for-each>
454
						</td>
455
456
						<td class="text_plain">
457
							<xsl:for-each
458
								select="./param[@name='keyword']">
459
								<xsl:value-of select="." />
460
								<br />
461
							</xsl:for-each>
462
							<xsl:for-each
463
								select="./param[@name='lom/general/keyword/string']">
464
								<xsl:value-of select="." />
465
								<br />
466
							</xsl:for-each>
467
468
						</td>
469
470
					</tr>
471 4379 leinfelder
472
					<tr>
473 4484 leinfelder
						<td colspan="6">
474 4390 leinfelder
							Details
475 4379 leinfelder
							<a>
476 4388 leinfelder
								<xsl:attribute name="href">javascript:read('readForm', '<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
477 4390 leinfelder
								<img border="none">
478
									<xsl:attribute name="src">
479
										<xsl:value-of select="$contextURL" />
480
										<xsl:text>/style/images/next.gif</xsl:text>
481
									</xsl:attribute>
482
								</img>
483 4379 leinfelder
							</a>
484
							/
485
							<a>
486 4388 leinfelder
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
487 4390 leinfelder
								<img border="none">
488
									<xsl:attribute name="src">
489
										<xsl:value-of select="$contextURL" />
490
										<xsl:text>/style/images/previous.gif</xsl:text>
491
									</xsl:attribute>
492
								</img>
493 4379 leinfelder
							</a>
494 4390 leinfelder
495 4388 leinfelder
						</td>
496
					</tr>
497
498
					<tr>
499 4484 leinfelder
						<td colspan="6">
500 4388 leinfelder
							<div style="display:none;">
501 4379 leinfelder
								<xsl:attribute name="id">
502
									<xsl:value-of select="$divId" />
503
								</xsl:attribute>
504
								Assessment details...
505
							</div>
506
						</td>
507
					</tr>
508
509 3531 leinfelder
					<tr class="searchresultsdivider">
510 4289 leinfelder
						<td colspan="6">
511 3531 leinfelder
							<img
512 4289 leinfelder
								src="{$contextURL}/style/skins/default/images/transparent1x1.gif"
513 3531 leinfelder
								width="1" height="1" />
514
						</td>
515
					</tr>
516
517
				</xsl:for-each>
518 3542 leinfelder
519 3531 leinfelder
			</table>
520 3542 leinfelder
521
			</form>
522 3531 leinfelder
523
		</xsl:if>
524
	</xsl:template>
525
526
</xsl:stylesheet>