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