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-05-28 15:34:27 -0700 (Wed, 28 May 2008) $'
11
* '$Revision: 3918 $'
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:template match="/">
38
		<script language="JavaScript">
39
          <![CDATA[
40
          submitform = function(action,docid,form_ref) {
41
              form_ref.action.value=action;
42
              form_ref.docid.value=docid;
43
              form_ref.sessionid.value="]]><xsl:value-of select="$sessid" /><![CDATA[";
44
              //form_ref.qformat.value="]]><xsl:value-of select="$qformat" /><![CDATA[";
45
              form_ref.submit();
46
          }
47
          setSelect = function(form_ref, checkBoxName, checked) {
48
              var formElements = form_ref.elements;
49
              for (var i=0; i<formElements.length; i++) {
50
              	var myElement = formElements[i];
51
              	if (myElement.name == checkBoxName) {
52
              		myElement.checked = checked;
53
              	}
54
              }
55
          }    
56
          ]]>
57
        </script>
58
        <script type="text/javascript" language="Javascript">
59
			<![CDATA[
60
			//reusable function to get the URL since I know this could change....
61
			getResponseDataURL = function() {
62
				var styleURL = "/knb/style/skins/first";
63
				styleURL += "/assessmentQuery.jsp";
64
				return styleURL;
65
			}	
66
			getResponseData = function(docid, divId, questionId) {
67
				var styleURL = getResponseDataURL();
68
																				
69
				//alert("calling ajax: " + styleURL);
70
				//alert("docid: " + docid);
71
				//alert("questionId: " + questionId);
72
				
73
				var myUpdate = new Ajax.Updater(
74
					divId,
75
					styleURL,
76
					{	method: 'post',
77
						parameters: { docids: docid, questionId: questionId },
78
						//parameters: $('responseDataSearch').serialize(true),
79
						evalScripts: true, 
80
						//onSuccess: function(transport) {alert('success: ' + transport.status);},
81
						onFailure: function(transport) {alert('failure making ajax call');}
82
					 });
83
					 
84
				Element.show(divId);					
85
				//alert("done calling response ajax");
86
			}
87
			getMergedResponseData = function(formId,divId) {
88
				if (!areItemsSelected('docids')) {
89
					alert("Please select at least one dataset to view");
90
					return false;
91
				}
92
				var styleURL = getResponseDataURL();
93
																				
94
				//alert("calling ajax: " + styleURL);
95
				//alert("docid: " + docid);
96
				
97
				//transfer the assessmentItemId to this form
98
				document.getElementById("questionId").value = document.getElementById("assessmentItemId").value;
99
				//alert("questionId: " + document.getElementById("questionId").value);
100
				
101
				var myUpdate = new Ajax.Updater(
102
					divId,
103
					styleURL,
104
					{	method: 'post',
105
						//parameters: { docid: docid},
106
						parameters: $(formId).serialize(true),
107
						evalScripts: true, 
108
						//onSuccess: function(transport) {alert('success: ' + transport.status);},
109
						onFailure: function(transport) {alert('failure making ajax call');}
110
					 });
111
					 
112
				Element.show(divId);					
113
				//alert("done calling response ajax");
114
			}
115
			downloadMergedResponseData = function(formId) {
116
			
117
				if (!areItemsSelected('docids')) {
118
					alert("Please select at least one dataset to download");
119
					return false;
120
				}
121
				
122
				var styleURL = getResponseDataURL();
123
				
124
				//transfer the assessmentItemId to this form
125
				document.getElementById("questionId").value = document.getElementById("assessmentItemId").value;
126
				//alert("questionId: " + document.getElementById("questionId").value);
127
				
128
				var submitFormObj = document.getElementById(formId);
129
				submitFormObj.qformat.value = 'csv';
130
				submitFormObj.action = styleURL;
131
																				
132
				//alert("downloading response data from: " + submitFormObj.action);
133
				//alert("format=" + submitFormObj.qformat.value);
134
				
135
				submitFormObj.submit();
136
			}
137
			areItemsSelected = function(checkBoxName) {
138
				var checkBoxes = document.getElementsByName(checkBoxName);
139
				
140
				for (var i=0; i< checkBoxes.length; i++) {
141
					if (checkBoxes[i].checked == true) {
142
						return true;
143
					}	
144
				}
145
				//alert("please select a checkbox: " + checkBoxName);
146
				return false;
147
				
148
			}
149
			hideDiv = function(divId) {
150
				Element.hide(divId);
151
			}
152
		 ]]>	
153
		</script>
154
        
155
		<p class="emphasis"><xsl:number value="count(resultset/document)" /> found</p>      
156
      
157
		<!-- This tests to see if there are returned documents,
158
            if there are not then don't show the query results -->
159

    
160
		<xsl:if test="count(resultset/document) &gt; 0">
161

    
162
			<form action="/knb/metacat" method="POST" id="assessmentForm" name="assessmentForm" >
163
				<input type="hidden" name="qformat" value="first" />
164
				<input type="hidden" name="sessionid" />
165
				<input type="hidden" name="action" value="read" />
166
				<input type="hidden" name="docid" />
167
				<xsl:element name="input">
168
					<xsl:attribute name="type">hidden</xsl:attribute>
169
					<xsl:attribute name="id">questionId</xsl:attribute>
170
					<xsl:attribute name="name">questionId</xsl:attribute>
171
					<xsl:attribute name="value"></xsl:attribute>
172
				</xsl:element>
173
				
174
				<br/>
175
				Select:
176
				<a>
177
					<xsl:attribute name="href">javascript:setSelect(document.assessmentForm, 'docids', true)</xsl:attribute>
178
					<xsl:text>All</xsl:text>
179
				</a>
180
				/
181
				<a>
182
					<xsl:attribute name="href">javascript:setSelect(document.assessmentForm, 'docids', false)</xsl:attribute>
183
					<xsl:text>None</xsl:text>
184
				</a>
185
				<br/>
186
				View:
187
				<a>
188
					<xsl:attribute name="href">#</xsl:attribute>
189
					<xsl:attribute name="onClick">javascript:getMergedResponseData('assessmentForm','mergedResponseData')</xsl:attribute>
190
					<xsl:text>Selected</xsl:text>
191
				</a>
192
				/
193
				<a>
194
					<xsl:attribute name="href">javascript:hideDiv('mergedResponseData')</xsl:attribute>
195
					<xsl:text>Hide</xsl:text>
196
				</a>
197
				<br/>
198
				Download Selected as:
199
				<a>
200
					<xsl:attribute name="href">#</xsl:attribute>
201
					<xsl:attribute name="onClick">javascript:downloadMergedResponseData('assessmentForm')</xsl:attribute>
202
					<xsl:text>Datafile (.csv)</xsl:text>
203
				</a>
204
				/
205
				<a>
206
					<xsl:attribute name="href">#doNothing</xsl:attribute>
207
					<xsl:text>Metadata Package (.zip)</xsl:text>
208
				</a>
209
				<br/>
210
				<div id="mergedResponseData"/>
211
				<br/>
212
				
213
			<table width="95%" align="left" border="0" cellpadding="0"
214
				cellspacing="0">
215
				<tr>
216
					<th style="text-align: left">
217
						Assessment Title
218
					</th>
219
					<th style="text-align: left">
220
						Course Title
221
					</th>
222
					<th	style="text-align: left">
223
						Instructor[s]
224
					</th>
225
					<th	style="text-align: left">
226
						Organization[s]
227
					</th>
228
					<th	style="text-align: left">
229
						Keywords
230
					</th>
231
				</tr>
232

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

    
246
						<td class="text_plain">
247
							<a>
248
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.assessmentForm)</xsl:attribute>
249
								<xsl:text>&#187;&#160;</xsl:text>
250
								<xsl:value-of select="./param[@name='assessment/@title']" />
251
								<!-- <xsl:value-of select="./param[@name='assessment/@id']" />) -->
252
							</a>
253
							(<xsl:value-of select="./docid" />)
254
							<br />
255
							Response Data...
256
							<input type="checkbox" name="docids">
257
								<xsl:attribute name="value">
258
									<xsl:value-of select="./docid" />
259
								</xsl:attribute>
260
							</input>
261
							<br/>
262
							<a>
263
								<xsl:attribute name="href">javascript:getResponseData('<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />', document.getElementById("assessmentItemId").value )</xsl:attribute>
264
								<xsl:text>View</xsl:text>
265
							</a>
266
							/
267
							<a>
268
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
269
								<xsl:text>Hide</xsl:text>
270
							</a>
271
							<!-- 
272
							/
273
							<a>
274
								<xsl:attribute name="href">javascript:getMergedResponseData('assessmentForm','mergedResponseData')</xsl:attribute>
275
								<xsl:text>Merge Selected</xsl:text>
276
							</a>
277
							 -->
278
							<div>
279
								<xsl:attribute name="id">
280
									<xsl:value-of select="$divId" />
281
								</xsl:attribute>
282
							</div>							
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
					<tr class="searchresultsdivider">
323
						<td colspan="5">
324
							<img
325
								src="/knb/style/skins/default/images/transparent1x1.gif"
326
								width="1" height="1" />
327
						</td>
328
					</tr>
329

    
330
				</xsl:for-each>
331
				
332
			</table>
333
			
334
			</form>
335
			
336

    
337
		</xsl:if>
338
	</xsl:template>
339

    
340
</xsl:stylesheet>
(2-2/10)