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
	<xsl:template match="/">
38
		<script language="JavaScript">
39
          <![CDATA[
40 3542 leinfelder
          submitform = function(action,docid,form_ref) {
41 3531 leinfelder
              form_ref.action.value=action;
42 3542 leinfelder
              form_ref.docid.value=docid;
43 3531 leinfelder
              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 3542 leinfelder
          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 3531 leinfelder
          ]]>
57
        </script>
58 3542 leinfelder
        <script type="text/javascript" language="Javascript">
59
			<![CDATA[
60 3551 leinfelder
			//reusable function to get the URL since I know this could change....
61
			getResponseDataURL = function() {
62 3542 leinfelder
				var styleURL = "/knb/style/skins/first";
63
				styleURL += "/assessmentQuery.jsp";
64 3551 leinfelder
				return styleURL;
65
			}
66 3669 leinfelder
			getResponseData = function(docid, divId, questionId) {
67 3551 leinfelder
				var styleURL = getResponseDataURL();
68 3542 leinfelder
69
				//alert("calling ajax: " + styleURL);
70
				//alert("docid: " + docid);
71 3669 leinfelder
				//alert("questionId: " + questionId);
72 3542 leinfelder
73
				var myUpdate = new Ajax.Updater(
74
					divId,
75
					styleURL,
76
					{	method: 'post',
77 3669 leinfelder
						parameters: { docids: docid, questionId: questionId },
78 3542 leinfelder
						//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 3551 leinfelder
				if (!areItemsSelected('docids')) {
89
					alert("Please select at least one dataset to view");
90
					return false;
91
				}
92
				var styleURL = getResponseDataURL();
93 3542 leinfelder
94
				//alert("calling ajax: " + styleURL);
95
				//alert("docid: " + docid);
96
97 3669 leinfelder
				//transfer the assessmentItemId to this form
98
				document.getElementById("questionId").value = document.getElementById("assessmentItemId").value;
99
				//alert("questionId: " + document.getElementById("questionId").value);
100
101 3542 leinfelder
				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 3551 leinfelder
			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 3669 leinfelder
				//transfer the assessmentItemId to this form
125
				document.getElementById("questionId").value = document.getElementById("assessmentItemId").value;
126
				//alert("questionId: " + document.getElementById("questionId").value);
127
128 3551 leinfelder
				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 3542 leinfelder
			hideDiv = function(divId) {
150
				Element.hide(divId);
151
			}
152
		 ]]>
153
		</script>
154 3531 leinfelder
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 3669 leinfelder
			<form action="/knb/metacat" method="POST" id="assessmentForm" name="assessmentForm" >
163 3542 leinfelder
				<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 3669 leinfelder
				<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 3542 leinfelder
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 3551 leinfelder
				View:
187 3542 leinfelder
				<a>
188 3551 leinfelder
					<xsl:attribute name="href">#</xsl:attribute>
189
					<xsl:attribute name="onClick">javascript:getMergedResponseData('assessmentForm','mergedResponseData')</xsl:attribute>
190
					<xsl:text>Selected</xsl:text>
191 3542 leinfelder
				</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 3551 leinfelder
				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 3542 leinfelder
				<div id="mergedResponseData"/>
211
				<br/>
212
213 3531 leinfelder
			<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/@assessmentId']" />
235 3542 leinfelder
					<xsl:variable name="divId">
236
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
237
					</xsl:variable>
238 3531 leinfelder
					<tr valign="top" class="subpanel">
239
						<xsl:attribute name="class">
240 3542 leinfelder
			               <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 3531 leinfelder
246
						<td class="text_plain">
247 3542 leinfelder
							<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/@assessmentTitle']" />
251
								<!-- <xsl:value-of select="./param[@name='assessment/@assessmentId']" />) -->
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 3669 leinfelder
								<xsl:attribute name="href">javascript:getResponseData('<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />', document.getElementById("assessmentItemId").value )</xsl:attribute>
264 3542 leinfelder
								<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 3531 leinfelder
						</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 3542 leinfelder
332 3531 leinfelder
			</table>
333 3542 leinfelder
334
			</form>
335
336 3531 leinfelder
337
		</xsl:if>
338
	</xsl:template>
339
340
</xsl:stylesheet>