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 3542 leinfelder
			hideDiv = function(divId) {
154 4390 leinfelder
				new Effect.Fade(divId);
155 4388 leinfelder
				//Element.hide(divId);
156 3542 leinfelder
			}
157 4379 leinfelder
			showDiv = function(divId) {
158 4390 leinfelder
				new Effect.Appear(divId)
159 4388 leinfelder
				//Element.show(divId);
160 4379 leinfelder
			}
161 3542 leinfelder
		 ]]>
162
		</script>
163 3531 leinfelder
164 4390 leinfelder
		<p class="emphasis">Assessments found: <xsl:number value="count(resultset/document)" /></p>
165 3531 leinfelder
166
		<!-- This tests to see if there are returned documents,
167
            if there are not then don't show the query results -->
168
169
		<xsl:if test="count(resultset/document) &gt; 0">
170 4390 leinfelder
			<p>
171
				Download Selected (.csv):
172
				<a>
173
					<xsl:attribute name="href">javascript:{}</xsl:attribute>
174
					<xsl:attribute name="onclick">javascript:downloadMergedResponseData('assessmentForm', 'fieldForm')</xsl:attribute>
175
					<img border="none">
176
						<xsl:attribute name="src">
177
							<xsl:value-of select="$contextURL" />
178
							<xsl:text>/style/images/page_white_put.png</xsl:text>
179
						</xsl:attribute>
180
					</img>
181
				</a>
182
			</p>
183
			<p>
184
				Edit Selected:
185
				<a>
186
					<xsl:attribute name="href">javascript:{}</xsl:attribute>
187
					<xsl:attribute name="onclick">javascript:editCart('assessmentForm', 'add')</xsl:attribute>
188
					<xsl:text>+</xsl:text>
189
				</a>
190
				/
191
				<a>
192
					<xsl:attribute name="href">javascript:{}</xsl:attribute>
193
					<xsl:attribute name="onclick">javascript:editCart('assessmentForm', 'remove')</xsl:attribute>
194
					<!--  <xsl:text>Remove </xsl:text> -->
195
					<img border="none">
196
						<xsl:attribute name="src">
197
							<xsl:value-of select="$contextURL" />
198
							<xsl:text>/style/images/delete.gif</xsl:text>
199
						</xsl:attribute>
200
					</img>
201
				</a>
202
			</p>
203
204 4361 leinfelder
			<!-- for reading the assessment details -->
205
			<form action="{$contextURL}/metacat" method="POST" id="readForm" name="readForm" >
206
				<input type="hidden" name="qformat" value="first" />
207
				<input type="hidden" name="sessionid">
208
					<xsl:attribute name="value">
209
						<xsl:value-of select="$sessid" />
210
					</xsl:attribute>
211
				</input>
212
				<input type="hidden" name="action" value="read" />
213
				<input type="hidden" name="docid" />
214 4379 leinfelder
				<input type="hidden" name="insertTemplate" value="1"/>
215 4361 leinfelder
			</form>
216
217
			<!-- for managing the ajax actions -->
218 4289 leinfelder
			<form action="{$contextURL}/metacat" method="POST" id="assessmentForm" name="assessmentForm" >
219 3542 leinfelder
				<input type="hidden" name="qformat" value="first" />
220 4289 leinfelder
				<input type="hidden" name="sessionid">
221
					<xsl:attribute name="value">
222
						<xsl:value-of select="$sessid" />
223
					</xsl:attribute>
224
				</input>
225 3542 leinfelder
				<input type="hidden" name="action" value="read" />
226 4289 leinfelder
				<input type="hidden" name="dataquery" />
227 4361 leinfelder
				<input type="hidden" name="operation" />
228 3669 leinfelder
				<xsl:element name="input">
229
					<xsl:attribute name="type">hidden</xsl:attribute>
230
					<xsl:attribute name="id">questionId</xsl:attribute>
231
					<xsl:attribute name="name">questionId</xsl:attribute>
232
					<xsl:attribute name="value"></xsl:attribute>
233
				</xsl:element>
234 3542 leinfelder
235 3531 leinfelder
			<table width="95%" align="left" border="0" cellpadding="0"
236
				cellspacing="0">
237
				<tr>
238
					<th style="text-align: left">
239 4289 leinfelder
						<input type="checkbox">
240 4361 leinfelder
							<xsl:attribute name="onclick">setSelect(document.assessmentForm, 'docid', this.checked)</xsl:attribute>
241 4289 leinfelder
						</input>
242
					</th>
243
					<th style="text-align: left">
244 3531 leinfelder
						Assessment Title
245
					</th>
246
					<th style="text-align: left">
247
						Course Title
248
					</th>
249
					<th	style="text-align: left">
250
						Instructor[s]
251
					</th>
252
					<th	style="text-align: left">
253
						Organization[s]
254
					</th>
255
					<th	style="text-align: left">
256
						Keywords
257
					</th>
258
				</tr>
259
260
				<xsl:for-each select="resultset/document">
261 3918 leinfelder
					<xsl:sort select="./param[@name='assessment/@id']" />
262 3542 leinfelder
					<xsl:variable name="divId">
263
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
264
					</xsl:variable>
265 3531 leinfelder
					<tr valign="top" class="subpanel">
266
						<xsl:attribute name="class">
267 3542 leinfelder
			               <xsl:choose>
268
			                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
269
			                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
270
			               </xsl:choose>
271
			             </xsl:attribute>
272 3531 leinfelder
273
						<td class="text_plain">
274 4361 leinfelder
							<input type="checkbox" name="docid">
275 4289 leinfelder
								<xsl:attribute name="value">
276
									<xsl:value-of select="./docid" />
277
								</xsl:attribute>
278
							</input>
279
						</td>
280
						<td>
281
282 3542 leinfelder
							<a>
283 4361 leinfelder
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.readForm)</xsl:attribute>
284 3542 leinfelder
								<xsl:text>&#187;&#160;</xsl:text>
285 3918 leinfelder
								<xsl:value-of select="./param[@name='assessment/@title']" />
286 3542 leinfelder
							</a>
287
							(<xsl:value-of select="./docid" />)
288 4289 leinfelder
289 3542 leinfelder
							<br />
290 4289 leinfelder
291
							<!--include question ids here -->
292
							<xsl:for-each select="./param[@name='assessmentItems/assessmentItem/assessmentItemId']" >
293
								<input type="hidden">
294
									<xsl:attribute name="name">
295
										<xsl:value-of select="../docid" />
296
									</xsl:attribute>
297
									<xsl:attribute name="value">
298
										<xsl:value-of select="." />
299
									</xsl:attribute>
300
								</input>
301
							</xsl:for-each>
302
303 3542 leinfelder
							<br/>
304 4379 leinfelder
305 3531 leinfelder
						</td>
306
307
						<td class="text_plain">
308
							<xsl:for-each
309
								select="./param[@name='lom/general/title/string']">
310
								<xsl:value-of select="." />
311
								<br />
312
							</xsl:for-each>
313
						</td>
314
						<td class="text_plain">
315
							<xsl:for-each
316
								select="./param[@name='individualName/surName']">
317
								<xsl:value-of select="." />
318
								<br />
319
							</xsl:for-each>
320
						</td>
321
						<td class="text_plain">
322
							<xsl:for-each
323
								select="./param[@name='organizationName']">
324
								<xsl:value-of select="." />
325
								<br />
326
							</xsl:for-each>
327
						</td>
328
329
						<td class="text_plain">
330
							<xsl:for-each
331
								select="./param[@name='keyword']">
332
								<xsl:value-of select="." />
333
								<br />
334
							</xsl:for-each>
335
							<xsl:for-each
336
								select="./param[@name='lom/general/keyword/string']">
337
								<xsl:value-of select="." />
338
								<br />
339
							</xsl:for-each>
340
341
						</td>
342
343
					</tr>
344 4379 leinfelder
345
					<tr>
346 4390 leinfelder
						<td width="30">&#160;</td>
347 4388 leinfelder
						<td colspan="5">
348 4390 leinfelder
							Details
349 4379 leinfelder
							<a>
350 4388 leinfelder
								<xsl:attribute name="href">javascript:read('readForm', '<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
351 4390 leinfelder
								<img border="none">
352
									<xsl:attribute name="src">
353
										<xsl:value-of select="$contextURL" />
354
										<xsl:text>/style/images/next.gif</xsl:text>
355
									</xsl:attribute>
356
								</img>
357 4379 leinfelder
							</a>
358
							/
359
							<a>
360 4388 leinfelder
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
361 4390 leinfelder
								<img border="none">
362
									<xsl:attribute name="src">
363
										<xsl:value-of select="$contextURL" />
364
										<xsl:text>/style/images/previous.gif</xsl:text>
365
									</xsl:attribute>
366
								</img>
367 4379 leinfelder
							</a>
368 4390 leinfelder
369 4388 leinfelder
						</td>
370
					</tr>
371
372
					<tr>
373 4390 leinfelder
						<td>&#160;</td>
374
						<td colspan="5">
375 4388 leinfelder
							<div style="display:none;">
376 4379 leinfelder
								<xsl:attribute name="id">
377
									<xsl:value-of select="$divId" />
378
								</xsl:attribute>
379
								Assessment details...
380
							</div>
381
						</td>
382
					</tr>
383
384 3531 leinfelder
					<tr class="searchresultsdivider">
385 4289 leinfelder
						<td colspan="6">
386 3531 leinfelder
							<img
387 4289 leinfelder
								src="{$contextURL}/style/skins/default/images/transparent1x1.gif"
388 3531 leinfelder
								width="1" height="1" />
389
						</td>
390
					</tr>
391
392
				</xsl:for-each>
393 3542 leinfelder
394 3531 leinfelder
			</table>
395 3542 leinfelder
396
			</form>
397 3531 leinfelder
398
		</xsl:if>
399
	</xsl:template>
400
401
</xsl:stylesheet>