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-09-30 11:19:05 -0700 (Tue, 30 Sep 2008) $'
11
* '$Revision: 4410 $'
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) {
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
						evalScripts: true,
104
						onSuccess: function(transport) {
105
							//alert('Cart changes saved: ' + operation); 
106
							//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
						onFailure: function(transport) {alert('failure making ajax call');}
115
					 });
116
								
117
			}
118
			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
			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
			hideDiv = function(divId) {
154
				new Effect.Fade(divId);
155
				//Element.hide(divId);
156
			}
157
			showDiv = function(divId) {
158
				new Effect.Appear(divId)
159
				//Element.show(divId);
160
			}
161
		 ]]>	
162
		</script>
163
        
164
		<p class="emphasis">Assessments found: <xsl:number value="count(resultset/document)" /></p>      
165
      
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
			<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
					<img border="none">
189
						<xsl:attribute name="src">
190
							<xsl:value-of select="$contextURL" />
191
							<xsl:text>/style/images/fav.gif</xsl:text>
192
						</xsl:attribute>
193
					</img>
194
					<xsl:text> Add to Cart</xsl:text>
195
				</a>
196
				/
197
				<a>
198
					<xsl:attribute name="href">javascript:{}</xsl:attribute>
199
					<xsl:attribute name="onclick">javascript:editCart('assessmentForm', 'remove')</xsl:attribute>
200
					<!--  <xsl:text>Remove </xsl:text> -->
201
					<img border="none">
202
						<xsl:attribute name="src">
203
							<xsl:value-of select="$contextURL" />
204
							<xsl:text>/style/images/delete.gif</xsl:text>
205
						</xsl:attribute>
206
					</img>
207
					<xsl:text> Remove from Cart</xsl:text>
208
				</a>
209
			</p>
210
						
211
			<!-- for reading the assessment details -->
212
			<form action="{$contextURL}/metacat" method="POST" id="readForm" name="readForm" >
213
				<input type="hidden" name="qformat" value="first" />
214
				<input type="hidden" name="sessionid">
215
					<xsl:attribute name="value">
216
						<xsl:value-of select="$sessid" />						
217
					</xsl:attribute>
218
				</input>
219
				<input type="hidden" name="action" value="read" />
220
				<input type="hidden" name="docid" />
221
				<input type="hidden" name="insertTemplate" value="1"/>
222
			</form>
223
			
224
			<!-- for managing the ajax actions -->				
225
			<form action="{$contextURL}/metacat" method="POST" id="assessmentForm" name="assessmentForm" >
226
				<input type="hidden" name="qformat" value="first" />
227
				<input type="hidden" name="sessionid">
228
					<xsl:attribute name="value">
229
						<xsl:value-of select="$sessid" />						
230
					</xsl:attribute>
231
				</input>
232
				<input type="hidden" name="action" value="read" />
233
				<input type="hidden" name="dataquery" />
234
				<input type="hidden" name="operation" />
235
				<xsl:element name="input">
236
					<xsl:attribute name="type">hidden</xsl:attribute>
237
					<xsl:attribute name="id">questionId</xsl:attribute>
238
					<xsl:attribute name="name">questionId</xsl:attribute>
239
					<xsl:attribute name="value"></xsl:attribute>
240
				</xsl:element>
241
				
242
			<table width="95%" align="left" border="0" cellpadding="0"
243
				cellspacing="0">
244
				<tr>
245
					<th style="text-align: left">
246
						<input type="checkbox">
247
							<xsl:attribute name="onclick">setSelect(document.assessmentForm, 'docid', this.checked)</xsl:attribute>
248
						</input>
249
					</th>
250
					<th style="text-align: left">
251
						Assessment Title
252
					</th>
253
					<th style="text-align: left">
254
						Course Title
255
					</th>
256
					<th	style="text-align: left">
257
						Instructor[s]
258
					</th>
259
					<th	style="text-align: left">
260
						Organization[s]
261
					</th>
262
					<th	style="text-align: left">
263
						Keywords
264
					</th>
265
				</tr>
266

    
267
				<xsl:for-each select="resultset/document">
268
					<xsl:sort select="./param[@name='assessment/@id']" />
269
					<xsl:variable name="divId">
270
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
271
					</xsl:variable>
272
					<tr valign="top" class="subpanel">
273
						<xsl:attribute name="class">
274
			               <xsl:choose>
275
			                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
276
			                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
277
			               </xsl:choose>
278
			             </xsl:attribute>
279

    
280
						<td class="text_plain">
281
							<input type="checkbox" name="docid">
282
								<xsl:attribute name="value">
283
									<xsl:value-of select="./docid" />
284
								</xsl:attribute>
285
							</input>
286
						</td>
287
						<td>
288
							
289
							<a>
290
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.readForm)</xsl:attribute>
291
								<xsl:text>&#187;&#160;</xsl:text>
292
								<xsl:value-of select="./param[@name='assessment/@title']" />
293
							</a>
294
							(<xsl:value-of select="./docid" />)
295
							
296
							<br />
297
							
298
							<!--include question ids here -->
299
							<xsl:for-each select="./param[@name='assessmentItems/assessmentItem/assessmentItemId']" >
300
								<input type="hidden">
301
									<xsl:attribute name="name">
302
										<xsl:value-of select="../docid" />
303
									</xsl:attribute>
304
									<xsl:attribute name="value">
305
										<xsl:value-of select="." />
306
									</xsl:attribute>
307
								</input>
308
							</xsl:for-each>
309
							
310
							<br/>
311
														
312
						</td>
313

    
314
						<td class="text_plain">
315
							<xsl:for-each
316
								select="./param[@name='lom/general/title/string']">
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='individualName/surName']">
324
								<xsl:value-of select="." />
325
								<br />
326
							</xsl:for-each>
327
						</td>
328
						<td class="text_plain">
329
							<xsl:for-each
330
								select="./param[@name='organizationName']">
331
								<xsl:value-of select="." />
332
								<br />
333
							</xsl:for-each>
334
						</td>
335

    
336
						<td class="text_plain">
337
							<xsl:for-each
338
								select="./param[@name='keyword']">
339
								<xsl:value-of select="." />
340
								<br />
341
							</xsl:for-each>
342
							<xsl:for-each
343
								select="./param[@name='lom/general/keyword/string']">
344
								<xsl:value-of select="." />
345
								<br />
346
							</xsl:for-each>
347

    
348
						</td>
349

    
350
					</tr>
351
					
352
					<tr>
353
						<td width="30">&#160;</td>
354
						<td colspan="5">
355
							Details 
356
							<a>
357
								<xsl:attribute name="href">javascript:read('readForm', '<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
358
								<img border="none">
359
									<xsl:attribute name="src">
360
										<xsl:value-of select="$contextURL" />
361
										<xsl:text>/style/images/next.gif</xsl:text>
362
									</xsl:attribute>
363
								</img>
364
							</a>
365
							/
366
							<a>
367
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
368
								<img border="none">
369
									<xsl:attribute name="src">
370
										<xsl:value-of select="$contextURL" />
371
										<xsl:text>/style/images/previous.gif</xsl:text>
372
									</xsl:attribute>
373
								</img>
374
							</a>
375
							
376
						</td>	
377
					</tr>
378
					
379
					<tr>
380
						<td>&#160;</td>
381
						<td colspan="5">
382
							<div style="display:none;">
383
								<xsl:attribute name="id">
384
									<xsl:value-of select="$divId" />
385
								</xsl:attribute>
386
								Assessment details...
387
							</div>
388
						</td>	
389
					</tr>
390
					
391
					<tr class="searchresultsdivider">
392
						<td colspan="6">
393
							<img
394
								src="{$contextURL}/style/skins/default/images/transparent1x1.gif"
395
								width="1" height="1" />
396
						</td>
397
					</tr>
398

    
399
				</xsl:for-each>
400
				
401
			</table>
402
			
403
			</form>
404

    
405
		</xsl:if>
406
	</xsl:template>
407

    
408
</xsl:stylesheet>
(4-4/16)