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-24 17:41:55 -0700 (Wed, 24 Sep 2008) $'
11
* '$Revision: 4388 $'
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.submit();
47
          }
48
          setSelect = function(form_ref, checkBoxName, checked) {
49
              var formElements = form_ref.elements;
50
              for (var i=0; i<formElements.length; i++) {
51
              	var myElement = formElements[i];
52
              	if (myElement.name == checkBoxName) {
53
              		myElement.checked = checked;
54
              	}
55
              }
56
          }    
57
          ]]>
58
        </script>
59
        <script type="text/javascript" language="Javascript">
60
			<![CDATA[
61
			downloadMergedResponseData = function(formId, fieldFormId) {
62
			
63
				if (!areItemsSelected('docid')) {
64
					alert("Please select at least one dataset");
65
					return false;
66
				}
67
								
68
				//transfer the assessmentItemId to this form
69
				//document.getElementById("questionId").value = document.getElementById("assessmentItemId").value;
70
				//alert("questionId: " + document.getElementById("questionId").value);
71
				
72
				var submitFormObj = document.getElementById(formId);
73
				submitFormObj.qformat.value = 'csv';
74
				submitFormObj.action.value = 'dataquery';
75
				
76
				//the form that holds the metadata field mappings - but in the header!
77
				var fieldFormObj = 
78
					window.document.getElementById("iframeheaderclass").contentDocument.getElementById(fieldFormId);
79
				//alert("fieldFormObj: " + fieldFormObj);
80
				
81
				multipleAssessmentSearch(submitFormObj, fieldFormObj);
82
				
83
				submitFormObj.submit();
84
			}
85
			editCart = function(formId, operation) {
86
			
87
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
88
				if (!areItemsSelected('docid')) {
89
					alert("Please select at least one dataset");
90
					return false;
91
				}
92
				
93
				var submitFormObj = document.getElementById(formId);
94
				submitFormObj.qformat.value = 'first';
95
				submitFormObj.action.value = 'editcart';
96
				submitFormObj.operation.value = operation;
97
				
98
				var myUpdate = new Ajax.Request(
99
					metacatURL,
100
					{	method: 'post',
101
						parameters: Form.serialize(submitFormObj),
102
						evalScripts: true,
103
						onSuccess: function(transport) {
104
							//alert('Cart changes saved: ' + operation); 
105
							window.document.getElementById("iframeheaderclass").src=window.document.getElementById("iframeheaderclass").src;}, 
106
						onFailure: function(transport) {alert('failure making ajax call');}
107
					 });
108
								
109
			}
110
			read = function(formId, docid, divId) {
111
			
112
				//alert("divId: " + divId);
113
				
114
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
115
				
116
				var submitFormObj = document.getElementById(formId);
117
				submitFormObj.qformat.value = 'first';
118
				submitFormObj.action.value = 'read';
119
				submitFormObj.docid.value = docid;
120
				submitFormObj.insertTemplate.value = '0';
121
				
122
				var myUpdate = new Ajax.Updater(
123
					divId,
124
					metacatURL,
125
					{	method: 'post',
126
						parameters: Form.serialize(submitFormObj),
127
						evalScripts: true,
128
						onSuccess: function(transport) {showDiv(divId); }, 
129
						onFailure: function(transport) {alert('failure making ajax call');}
130
					 });
131
								
132
			}
133
			areItemsSelected = function(checkBoxName) {
134
				var checkBoxes = document.getElementsByName(checkBoxName);
135
				
136
				for (var i=0; i< checkBoxes.length; i++) {
137
					if (checkBoxes[i].checked == true) {
138
						return true;
139
					}	
140
				}
141
				//alert("please select a checkbox: " + checkBoxName);
142
				return false;
143
				
144
			}
145
			hideDiv = function(divId) {
146
				Effect.Fade(divId);
147
				//Element.hide(divId);
148
			}
149
			showDiv = function(divId) {
150
				Effect.Appear(divId)
151
				//Element.show(divId);
152
			}
153
		 ]]>	
154
		</script>
155
        
156
		<p class="emphasis"><xsl:number value="count(resultset/document)" /> found</p>      
157
      
158
		<!-- This tests to see if there are returned documents,
159
            if there are not then don't show the query results -->
160

    
161
		<xsl:if test="count(resultset/document) &gt; 0">
162
				
163
			Download Selected as:
164
			<a>
165
				<xsl:attribute name="href">javascript:downloadMergedResponseData('assessmentForm', 'fieldForm')</xsl:attribute>
166
				<xsl:text>Datafile (.csv)</xsl:text>
167
			</a>
168
			<br/>
169
			Edit Cart:
170
			<a>
171
				<xsl:attribute name="href">javascript:editCart('assessmentForm', 'add')</xsl:attribute>
172
				<xsl:text>Add Selected</xsl:text>
173
			</a>
174
			/
175
			<a>
176
				<xsl:attribute name="href">javascript:editCart('assessmentForm', 'remove')</xsl:attribute>
177
				<xsl:text>Remove Selected</xsl:text>
178
			</a>
179
			
180
			<br/>
181
			
182
			<!-- for reading the assessment details -->
183
			<form action="{$contextURL}/metacat" method="POST" id="readForm" name="readForm" >
184
				<input type="hidden" name="qformat" value="first" />
185
				<input type="hidden" name="sessionid">
186
					<xsl:attribute name="value">
187
						<xsl:value-of select="$sessid" />						
188
					</xsl:attribute>
189
				</input>
190
				<input type="hidden" name="action" value="read" />
191
				<input type="hidden" name="docid" />
192
				<input type="hidden" name="insertTemplate" value="1"/>
193
			</form>
194
			
195
			<!-- for managing the ajax actions -->				
196
			<form action="{$contextURL}/metacat" method="POST" id="assessmentForm" name="assessmentForm" >
197
				<input type="hidden" name="qformat" value="first" />
198
				<input type="hidden" name="sessionid">
199
					<xsl:attribute name="value">
200
						<xsl:value-of select="$sessid" />						
201
					</xsl:attribute>
202
				</input>
203
				<input type="hidden" name="action" value="read" />
204
				<input type="hidden" name="dataquery" />
205
				<input type="hidden" name="operation" />
206
				<xsl:element name="input">
207
					<xsl:attribute name="type">hidden</xsl:attribute>
208
					<xsl:attribute name="id">questionId</xsl:attribute>
209
					<xsl:attribute name="name">questionId</xsl:attribute>
210
					<xsl:attribute name="value"></xsl:attribute>
211
				</xsl:element>
212
				
213
			<table width="95%" align="left" border="0" cellpadding="0"
214
				cellspacing="0">
215
				<tr>
216
					<th style="text-align: left">
217
						<input type="checkbox">
218
							<xsl:attribute name="onclick">setSelect(document.assessmentForm, 'docid', this.checked)</xsl:attribute>
219
						</input>
220
					</th>
221
					<th style="text-align: left">
222
						Assessment Title
223
					</th>
224
					<th style="text-align: left">
225
						Course Title
226
					</th>
227
					<th	style="text-align: left">
228
						Instructor[s]
229
					</th>
230
					<th	style="text-align: left">
231
						Organization[s]
232
					</th>
233
					<th	style="text-align: left">
234
						Keywords
235
					</th>
236
				</tr>
237

    
238
				<xsl:for-each select="resultset/document">
239
					<xsl:sort select="./param[@name='assessment/@id']" />
240
					<xsl:variable name="divId">
241
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
242
					</xsl:variable>
243
					<tr valign="top" class="subpanel">
244
						<xsl:attribute name="class">
245
			               <xsl:choose>
246
			                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
247
			                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
248
			               </xsl:choose>
249
			             </xsl:attribute>
250

    
251
						<td class="text_plain">
252
							<input type="checkbox" name="docid">
253
								<xsl:attribute name="value">
254
									<xsl:value-of select="./docid" />
255
								</xsl:attribute>
256
							</input>
257
						</td>
258
						<td>
259
							
260
							<a>
261
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.readForm)</xsl:attribute>
262
								<xsl:text>&#187;&#160;</xsl:text>
263
								<xsl:value-of select="./param[@name='assessment/@title']" />
264
							</a>
265
							(<xsl:value-of select="./docid" />)
266
							
267
							<br />
268
							
269
							<!--include question ids here -->
270
							<xsl:for-each select="./param[@name='assessmentItems/assessmentItem/assessmentItemId']" >
271
								<input type="hidden">
272
									<xsl:attribute name="name">
273
										<xsl:value-of select="../docid" />
274
									</xsl:attribute>
275
									<xsl:attribute name="value">
276
										<xsl:value-of select="." />
277
									</xsl:attribute>
278
								</input>
279
							</xsl:for-each>
280
							
281
							<br/>
282
														
283
						</td>
284

    
285
						<td class="text_plain">
286
							<xsl:for-each
287
								select="./param[@name='lom/general/title/string']">
288
								<xsl:value-of select="." />
289
								<br />
290
							</xsl:for-each>
291
						</td>
292
						<td class="text_plain">
293
							<xsl:for-each
294
								select="./param[@name='individualName/surName']">
295
								<xsl:value-of select="." />
296
								<br />
297
							</xsl:for-each>
298
						</td>
299
						<td class="text_plain">
300
							<xsl:for-each
301
								select="./param[@name='organizationName']">
302
								<xsl:value-of select="." />
303
								<br />
304
							</xsl:for-each>
305
						</td>
306

    
307
						<td class="text_plain">
308
							<xsl:for-each
309
								select="./param[@name='keyword']">
310
								<xsl:value-of select="." />
311
								<br />
312
							</xsl:for-each>
313
							<xsl:for-each
314
								select="./param[@name='lom/general/keyword/string']">
315
								<xsl:value-of select="." />
316
								<br />
317
							</xsl:for-each>
318

    
319
						</td>
320

    
321
					</tr>
322
					
323
					<tr>
324
						<td>
325
						</td>
326
						<td colspan="5">
327
							Details (
328
							<a>
329
								<xsl:attribute name="href">javascript:read('readForm', '<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
330
								<xsl:text>+</xsl:text>
331
							</a>
332
							/
333
							<a>
334
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
335
								<xsl:text>-</xsl:text>
336
							</a>
337
							)
338
						</td>	
339
					</tr>
340
					
341
					<tr>
342
						<td colspan="6">
343
							<div style="display:none;">
344
								<xsl:attribute name="id">
345
									<xsl:value-of select="$divId" />
346
								</xsl:attribute>
347
								Assessment details...
348
							</div>
349
						</td>	
350
					</tr>
351
					
352
					<tr class="searchresultsdivider">
353
						<td colspan="6">
354
							<img
355
								src="{$contextURL}/style/skins/default/images/transparent1x1.gif"
356
								width="1" height="1" />
357
						</td>
358
					</tr>
359

    
360
				</xsl:for-each>
361
				
362
			</table>
363
			
364
			</form>
365

    
366
		</xsl:if>
367
	</xsl:template>
368

    
369
</xsl:stylesheet>
(4-4/14)