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 4484 leinfelder
				//if (!areItemsSelected('docid')) {
65
				//	alert("Please select at least one dataset");
66
				//	return false;
67
				//}
68 4289 leinfelder
69 3669 leinfelder
				//transfer the assessmentItemId to this form
70 4290 leinfelder
				//document.getElementById("questionId").value = document.getElementById("assessmentItemId").value;
71 3669 leinfelder
				//alert("questionId: " + document.getElementById("questionId").value);
72
73 3551 leinfelder
				var submitFormObj = document.getElementById(formId);
74
				submitFormObj.qformat.value = 'csv';
75 4289 leinfelder
				submitFormObj.action.value = 'dataquery';
76 3551 leinfelder
77 4387 leinfelder
				//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 4289 leinfelder
82 4387 leinfelder
				multipleAssessmentSearch(submitFormObj, fieldFormObj);
83
84 3551 leinfelder
				submitFormObj.submit();
85
			}
86 4484 leinfelder
			editCart = function(formId, operation, docid) {
87 4361 leinfelder
88
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
89 4484 leinfelder
				//if (!areItemsSelected('docid') && docid) {
90
				//	alert("Please select at least one dataset");
91
				//	return false;
92
				//}
93 4361 leinfelder
94
				var submitFormObj = document.getElementById(formId);
95
				submitFormObj.qformat.value = 'first';
96
				submitFormObj.action.value = 'editcart';
97
				submitFormObj.operation.value = operation;
98 4484 leinfelder
				if (docid) {
99
					submitFormObj.docid.value = docid;
100
				}
101 4361 leinfelder
102
				var myUpdate = new Ajax.Request(
103
					metacatURL,
104
					{	method: 'post',
105
						parameters: Form.serialize(submitFormObj),
106 4379 leinfelder
						evalScripts: true,
107 4388 leinfelder
						onSuccess: function(transport) {
108
							//alert('Cart changes saved: ' + operation);
109 4390 leinfelder
							//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
							}
116
						},
117 4361 leinfelder
						onFailure: function(transport) {alert('failure making ajax call');}
118
					 });
119
120
			}
121 4379 leinfelder
			read = function(formId, docid, divId) {
122
123
				//alert("divId: " + divId);
124
125
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
126
127
				var submitFormObj = document.getElementById(formId);
128
				submitFormObj.qformat.value = 'first';
129
				submitFormObj.action.value = 'read';
130
				submitFormObj.docid.value = docid;
131
				submitFormObj.insertTemplate.value = '0';
132
133
				var myUpdate = new Ajax.Updater(
134
					divId,
135
					metacatURL,
136
					{	method: 'post',
137
						parameters: Form.serialize(submitFormObj),
138
						evalScripts: true,
139
						onSuccess: function(transport) {showDiv(divId); },
140
						onFailure: function(transport) {alert('failure making ajax call');}
141
					 });
142
143
			}
144 3551 leinfelder
			areItemsSelected = function(checkBoxName) {
145
				var checkBoxes = document.getElementsByName(checkBoxName);
146
147
				for (var i=0; i< checkBoxes.length; i++) {
148
					if (checkBoxes[i].checked == true) {
149
						return true;
150
					}
151
				}
152
				//alert("please select a checkbox: " + checkBoxName);
153
				return false;
154
155
			}
156 4411 leinfelder
			setControlVisibility = function() {
157
				if (document.getElementById("ajaxCartResults")) {
158 4484 leinfelder
					new Effect.Appear("download");
159 4411 leinfelder
				}
160 4484 leinfelder
			}
161
162
			isInCart = function(docid) {
163
164
				var objs = window.document.getElementById("iframeheaderclass").contentDocument.getElementsByName("@packageId");
165
				//var objs = document.getElementsByName("@packageId");
166
				if (objs.length == 0) {
167
					return false;
168 4411 leinfelder
				}
169 4484 leinfelder
				for (var i=0; i< objs.length; i++) {
170
					if (docid == objs[i].value) {
171
						return true;
172
					}
173
				}
174
				return false;
175 4411 leinfelder
			}
176
177 3542 leinfelder
			hideDiv = function(divId) {
178 4390 leinfelder
				new Effect.Fade(divId);
179 4388 leinfelder
				//Element.hide(divId);
180 3542 leinfelder
			}
181 4379 leinfelder
			showDiv = function(divId) {
182 4390 leinfelder
				new Effect.Appear(divId)
183 4388 leinfelder
				//Element.show(divId);
184 4379 leinfelder
			}
185 3542 leinfelder
		 ]]>
186
		</script>
187 3531 leinfelder
188 4390 leinfelder
		<p class="emphasis">Assessments found: <xsl:number value="count(resultset/document)" /></p>
189 3531 leinfelder
190
		<!-- This tests to see if there are returned documents,
191
            if there are not then don't show the query results -->
192
193
		<xsl:if test="count(resultset/document) &gt; 0">
194 4411 leinfelder
			<script type="text/javascript" language="Javascript">
195
				<![CDATA[
196
					//call on load
197
					setControlVisibility();
198
				]]>
199
			</script>
200 4484 leinfelder
			<div id="download" style="display:none;">
201 4411 leinfelder
				<p>
202
					<a>
203
						<xsl:attribute name="href">javascript:{}</xsl:attribute>
204 4484 leinfelder
						<xsl:attribute name="onclick">javascript:downloadMergedResponseData('assessmentForm', 'fieldForm')</xsl:attribute>
205 4411 leinfelder
						<img border="none">
206
							<xsl:attribute name="src">
207
								<xsl:value-of select="$contextURL" />
208 4484 leinfelder
								<xsl:text>/style/images/page_white_put.png</xsl:text>
209 4411 leinfelder
							</xsl:attribute>
210
						</img>
211 4484 leinfelder
						<xsl:text> Download (.csv)</xsl:text>
212 4411 leinfelder
					</a>
213
				</p>
214
			</div>
215 4390 leinfelder
216 4361 leinfelder
			<!-- for reading the assessment details -->
217
			<form action="{$contextURL}/metacat" method="POST" id="readForm" name="readForm" >
218
				<input type="hidden" name="qformat" value="first" />
219
				<input type="hidden" name="sessionid">
220
					<xsl:attribute name="value">
221
						<xsl:value-of select="$sessid" />
222
					</xsl:attribute>
223
				</input>
224
				<input type="hidden" name="action" value="read" />
225
				<input type="hidden" name="docid" />
226 4379 leinfelder
				<input type="hidden" name="insertTemplate" value="1"/>
227 4361 leinfelder
			</form>
228
229 4484 leinfelder
			<!-- for editing cart -->
230
			<form action="{$contextURL}/metacat" method="POST" id="cartForm" name="cartForm" >
231
				<input type="hidden" name="qformat" value="first" />
232
				<input type="hidden" name="sessionid">
233
					<xsl:attribute name="value">
234
						<xsl:value-of select="$sessid" />
235
					</xsl:attribute>
236
				</input>
237
				<input type="hidden" name="action" value="editcart" />
238
				<input type="hidden" name="operation" />
239
				<input type="hidden" name="docid" />
240
241
			</form>
242
243
			<!-- for downloading data -->
244 4289 leinfelder
			<form action="{$contextURL}/metacat" method="POST" id="assessmentForm" name="assessmentForm" >
245 3542 leinfelder
				<input type="hidden" name="qformat" value="first" />
246 4289 leinfelder
				<input type="hidden" name="sessionid">
247
					<xsl:attribute name="value">
248
						<xsl:value-of select="$sessid" />
249
					</xsl:attribute>
250
				</input>
251 3542 leinfelder
				<input type="hidden" name="action" value="read" />
252 4289 leinfelder
				<input type="hidden" name="dataquery" />
253 4361 leinfelder
				<input type="hidden" name="operation" />
254 4484 leinfelder
255 3669 leinfelder
				<xsl:element name="input">
256
					<xsl:attribute name="type">hidden</xsl:attribute>
257
					<xsl:attribute name="id">questionId</xsl:attribute>
258
					<xsl:attribute name="name">questionId</xsl:attribute>
259
					<xsl:attribute name="value"></xsl:attribute>
260
				</xsl:element>
261 3542 leinfelder
262 3531 leinfelder
			<table width="95%" align="left" border="0" cellpadding="0"
263
				cellspacing="0">
264
				<tr>
265 4484 leinfelder
266
					<th style="text-align: left" colspan="2">
267
						Assessment
268 4289 leinfelder
					</th>
269
					<th style="text-align: left">
270 3531 leinfelder
						Course Title
271
					</th>
272
					<th	style="text-align: left">
273
						Instructor[s]
274
					</th>
275
					<th	style="text-align: left">
276
						Organization[s]
277
					</th>
278
					<th	style="text-align: left">
279
						Keywords
280
					</th>
281
				</tr>
282
283
				<xsl:for-each select="resultset/document">
284 3918 leinfelder
					<xsl:sort select="./param[@name='assessment/@id']" />
285 3542 leinfelder
					<xsl:variable name="divId">
286
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
287
					</xsl:variable>
288 3531 leinfelder
					<tr valign="top" class="subpanel">
289
						<xsl:attribute name="class">
290 3542 leinfelder
			               <xsl:choose>
291
			                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
292
			                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
293
			               </xsl:choose>
294
			             </xsl:attribute>
295 3531 leinfelder
296 4484 leinfelder
						<td class="text_plain" nowrap="nowrap">
297
298
							<script type="text/javascript" language="Javascript">
299
								<![CDATA[
300
									//what are our options?
301
									if (isInCart("]]><xsl:value-of select="./docid" /><![CDATA[")) {
302
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
303
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
304
									}
305
									else {
306
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
307
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
308
									}
309
								]]>
310
							</script>
311
							<div style="display:none;">
312
								<xsl:attribute name="id">
313
									<xsl:value-of select="$divId" />
314
									<xsl:text>add</xsl:text>
315
								</xsl:attribute>
316
								<a>
317
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
318
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'add',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
319
									<img border="none">
320
										<xsl:attribute name="src">
321
											<xsl:value-of select="$contextURL" />
322
											<xsl:text>/style/skins/first/images/add.png</xsl:text>
323
										</xsl:attribute>
324
									</img>
325
								</a>
326
							</div>
327
							<div style="display:none;">
328
								<xsl:attribute name="id">
329
									<xsl:value-of select="$divId" />
330
									<xsl:text>remove</xsl:text>
331
								</xsl:attribute>
332
								<a>
333
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
334
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'remove',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
335
									<!--  <xsl:text>Remove </xsl:text> -->
336
									<img border="none">
337
										<xsl:attribute name="src">
338
											<xsl:value-of select="$contextURL" />
339
											<xsl:text>/style/images/delete.gif</xsl:text>
340
										</xsl:attribute>
341
									</img>
342
									<xsl:text> Remove</xsl:text>
343
								</a>
344
							</div>
345
346
							<input type="hidden" name="docid">
347 4289 leinfelder
								<xsl:attribute name="value">
348
									<xsl:value-of select="./docid" />
349
								</xsl:attribute>
350
							</input>
351 4484 leinfelder
352 4289 leinfelder
						</td>
353
						<td>
354
355 3542 leinfelder
							<a>
356 4361 leinfelder
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.readForm)</xsl:attribute>
357 3542 leinfelder
								<xsl:text>&#187;&#160;</xsl:text>
358 3918 leinfelder
								<xsl:value-of select="./param[@name='assessment/@title']" />
359 3542 leinfelder
							</a>
360
							(<xsl:value-of select="./docid" />)
361 4289 leinfelder
362 3542 leinfelder
							<br />
363 4289 leinfelder
364
							<!--include question ids here -->
365
							<xsl:for-each select="./param[@name='assessmentItems/assessmentItem/assessmentItemId']" >
366
								<input type="hidden">
367
									<xsl:attribute name="name">
368
										<xsl:value-of select="../docid" />
369
									</xsl:attribute>
370
									<xsl:attribute name="value">
371
										<xsl:value-of select="." />
372
									</xsl:attribute>
373
								</input>
374
							</xsl:for-each>
375
376 3542 leinfelder
							<br/>
377 4379 leinfelder
378 3531 leinfelder
						</td>
379
380
						<td class="text_plain">
381
							<xsl:for-each
382
								select="./param[@name='lom/general/title/string']">
383
								<xsl:value-of select="." />
384
								<br />
385
							</xsl:for-each>
386
						</td>
387
						<td class="text_plain">
388
							<xsl:for-each
389
								select="./param[@name='individualName/surName']">
390
								<xsl:value-of select="." />
391
								<br />
392
							</xsl:for-each>
393
						</td>
394
						<td class="text_plain">
395
							<xsl:for-each
396
								select="./param[@name='organizationName']">
397
								<xsl:value-of select="." />
398
								<br />
399
							</xsl:for-each>
400
						</td>
401
402
						<td class="text_plain">
403
							<xsl:for-each
404
								select="./param[@name='keyword']">
405
								<xsl:value-of select="." />
406
								<br />
407
							</xsl:for-each>
408
							<xsl:for-each
409
								select="./param[@name='lom/general/keyword/string']">
410
								<xsl:value-of select="." />
411
								<br />
412
							</xsl:for-each>
413
414
						</td>
415
416
					</tr>
417 4379 leinfelder
418
					<tr>
419 4484 leinfelder
						<td colspan="6">
420 4390 leinfelder
							Details
421 4379 leinfelder
							<a>
422 4388 leinfelder
								<xsl:attribute name="href">javascript:read('readForm', '<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
423 4390 leinfelder
								<img border="none">
424
									<xsl:attribute name="src">
425
										<xsl:value-of select="$contextURL" />
426
										<xsl:text>/style/images/next.gif</xsl:text>
427
									</xsl:attribute>
428
								</img>
429 4379 leinfelder
							</a>
430
							/
431
							<a>
432 4388 leinfelder
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
433 4390 leinfelder
								<img border="none">
434
									<xsl:attribute name="src">
435
										<xsl:value-of select="$contextURL" />
436
										<xsl:text>/style/images/previous.gif</xsl:text>
437
									</xsl:attribute>
438
								</img>
439 4379 leinfelder
							</a>
440 4390 leinfelder
441 4388 leinfelder
						</td>
442
					</tr>
443
444
					<tr>
445 4484 leinfelder
						<td colspan="6">
446 4388 leinfelder
							<div style="display:none;">
447 4379 leinfelder
								<xsl:attribute name="id">
448
									<xsl:value-of select="$divId" />
449
								</xsl:attribute>
450
								Assessment details...
451
							</div>
452
						</td>
453
					</tr>
454
455 3531 leinfelder
					<tr class="searchresultsdivider">
456 4289 leinfelder
						<td colspan="6">
457 3531 leinfelder
							<img
458 4289 leinfelder
								src="{$contextURL}/style/skins/default/images/transparent1x1.gif"
459 3531 leinfelder
								width="1" height="1" />
460
						</td>
461
					</tr>
462
463
				</xsl:for-each>
464 3542 leinfelder
465 3531 leinfelder
			</table>
466 3542 leinfelder
467
			</form>
468 3531 leinfelder
469
		</xsl:if>
470
	</xsl:template>
471
472
</xsl:stylesheet>