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 16:04:27 -0700 (Wed, 24 Sep 2008) $'
11
* '$Revision: 4387 $'
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) {alert('Cart changes saved: ' + operation); window.document.getElementById("iframeheaderclass").src=window.document.getElementById("iframeheaderclass").src;}, 
104
						onFailure: function(transport) {alert('failure making ajax call');}
105
					 });
106
								
107
			}
108
			read = function(formId, docid, divId) {
109
			
110
				//alert("divId: " + divId);
111
				
112
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
113
				
114
				var submitFormObj = document.getElementById(formId);
115
				submitFormObj.qformat.value = 'first';
116
				submitFormObj.action.value = 'read';
117
				submitFormObj.docid.value = docid;
118
				submitFormObj.insertTemplate.value = '0';
119
				
120
				var myUpdate = new Ajax.Updater(
121
					divId,
122
					metacatURL,
123
					{	method: 'post',
124
						parameters: Form.serialize(submitFormObj),
125
						evalScripts: true,
126
						onSuccess: function(transport) {showDiv(divId); }, 
127
						onFailure: function(transport) {alert('failure making ajax call');}
128
					 });
129
								
130
			}
131
			areItemsSelected = function(checkBoxName) {
132
				var checkBoxes = document.getElementsByName(checkBoxName);
133
				
134
				for (var i=0; i< checkBoxes.length; i++) {
135
					if (checkBoxes[i].checked == true) {
136
						return true;
137
					}	
138
				}
139
				//alert("please select a checkbox: " + checkBoxName);
140
				return false;
141
				
142
			}
143
			hideDiv = function(divId) {
144
				Element.hide(divId);
145
			}
146
			showDiv = function(divId) {
147
				Element.show(divId);
148
			}
149
		 ]]>	
150
		</script>
151
        
152
		<p class="emphasis"><xsl:number value="count(resultset/document)" /> found</p>      
153
      
154
		<!-- This tests to see if there are returned documents,
155
            if there are not then don't show the query results -->
156

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

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

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

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

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

    
318
						</td>
319

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

    
353
				</xsl:for-each>
354
				
355
			</table>
356
			
357
			</form>
358

    
359
		</xsl:if>
360
	</xsl:template>
361

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