Project

General

Profile

« Previous | Next » 

Revision 4398

add login feature for first. integrates with existing metacat-skin-based login approach.
only show cart for authenticated users.

View differences:

lib/style/skins/first/header.jsp
75 75
						Search	
76 76
						</a>
77 77
					</td>
78
					<!--
79 78
					<td valign="top">
80
						<p><a href="http://www.first2.org" target=_top">FIRST Site</a></p>
81
					</td>
82
					-->
83
					<td valign="top">
84 79
						<p><a href="about.jsp" target="_top">About</a></p>
85 80
					</td>
86 81
					<td>
87 82
						<%
88
						String[] docids = 
89
							SessionService.getRegisteredSession(request.getSession().getId()).getDocumentCart().getDocids();
90
						Map fields = 
91
							SessionService.getRegisteredSession(request.getSession().getId()).getDocumentCart().getFields();
83
						boolean loggedIn = SessionService.isSessionRegistered(request.getSession().getId());
84
						String[] docids = null;
85
						Map fields = null;
86
						if (loggedIn) {
87
							docids = 
88
								SessionService.getRegisteredSession(request.getSession().getId()).getDocumentCart().getDocids();
89
							fields = 
90
								SessionService.getRegisteredSession(request.getSession().getId()).getDocumentCart().getFields();
91
							%>
92
							<div id="importantThings">
93
								<a href="cart.jsp" target="_top">
94
									Cart 
95
								</a>
96
								(Items: <%=docids.length %>, Fields: <%=fields.size() %>)
97
							</div>
98
							<!-- for use when downloading merged data -->
99
							<div style="display:none;">
100
								<form id='fieldForm'>
101
									<%
102
									if (loggedIn) {
103
										Iterator fieldIter =  fields.keySet().iterator();
104
										while (fieldIter.hasNext()) {
105
											String key = (String) fieldIter.next();
106
											String value = (String) fields.get(key);
107
										%>
108
											<input type="hidden" name="<%=key %>" value="<%=value %>" />
109
										<%	
110
										}
111
									}	
112
									%>
113
								</form>
114
							</div>
115
						<%	
116
						}
117
						else {
92 118
						%>
93
						<div id="importantThings">
94
							<a href="cart.jsp" target="_top">
95
								Cart 
96
							</a>	
97
							
98
							(Items: <%=docids.length %>, Fields: <%=fields.size() %>)
99
						</div>
119
							<a href="login.jsp" target="_top">Login</a>
120
						<%	
121
						}
122
						%>						
100 123
					</td>
101 124
				</tr>
102 125
				<tr>
103 126
					<td colspan="3">
104
						<!-- for use when downloading merged data -->
105
						<form id='fieldForm'>
106
						<%
107
						Iterator fieldIter =  fields.keySet().iterator();
108
						while (fieldIter.hasNext()) {
109
							String key = (String) fieldIter.next();
110
							String value = (String) fields.get(key);
111
						%>
112
							<input type="hidden" name="<%=key %>" value="<%=value %>" />
113
						<%	
114
						}
115
						%>	
116
						</form>
127
						
117 128
					</td>
118 129
				</tr>
119 130
			</table>
lib/style/skins/first/first.xml
17 17
    <target publicid="-//W3C//HTML//EN">/style/skins/first/xsl/qti-root.xsl</target>
18 18
  </doctype>
19 19

  
20
<!--
21
    ARE THESE STILL NEEDED????????????
22

  
20
  <!-- login -->
23 21
  <doctype publicid="-//NCEAS//login//EN">
24
    <target publicid="-//W3C//HTML//EN">@systemidserver@@style-common-path@/login.xsl</target>
22
    <target publicid="-//W3C//HTML//EN">/style/skins/first/login.xsl</target>
25 23
  </doctype>
26 24

  
25
<!--  
27 26
  <doctype publicid="-//NCEAS//eml-generic//EN">
28 27
    <target publicid="-//W3C//HTML//EN">@systemidserver@@style-common-path@/generic-morpho.xsl</target>
29 28
  </doctype>
lib/style/skins/first/login.jsp
1
<%@ page language="java"%>
2
<%
3
	 /**
4
	 * 
5
	 * '$RCSfile$'
6
	 * Copyright: 2008 Regents of the University of California and the
7
	 *             National Center for Ecological Analysis and Synthesis
8
	 *    '$Author: leinfelder $'
9
	 *      '$Date: 2008-09-25 16:11:55 -0700 (Thu, 25 Sep 2008) $'
10
	 * '$Revision: 4393 $'
11
	 * 
12
	 * This program is free software; you can redistribute it and/or modify
13
	 * it under the terms of the GNU General Public License as published by
14
	 * the Free Software Foundation; either version 2 of the License, or
15
	 * (at your option) any later version.
16
	 * 
17
	 * This program is distributed in the hope that it will be useful,
18
	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
	 * GNU General Public License for more details.
21
	
22
	 * You should have received a copy of the GNU General Public License
23
	 * along with this program; if not, write to the Free Software
24
	 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
	 */
26
%>
27

  
28
<%@ include file="../../common/common-settings.jsp"%>
29
<%@ include file="../../common/configure-check.jsp"%>
30

  
31
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
32
<html>
33
<head>
34
<title>FIRST Assessment Metadata Repository</title>
35
<link rel="stylesheet" type="text/css"
36
	href="<%=STYLE_SKINS_URL%>/first/first.css">
37
<script language="JavaScript" type="text/JavaScript"
38
	src="<%=STYLE_SKINS_URL%>/first/first.js"></script>
39
<script language="JavaScript" type="text/JavaScript"
40
	src="<%=STYLE_SKINS_URL%>/first/search.js"></script>
41
<script language="JavaScript" type="text/JavaScript"
42
	src="<%=STYLE_COMMON_URL%>/branding.js"></script>
43
<script language="Javascript" type="text/JavaScript"
44
	src="<%=STYLE_COMMON_URL%>/prototype-1.5.1.1/prototype.js">
45
</script>
46
<script language="Javascript" type="text/JavaScript"
47
	src="<%=STYLE_COMMON_URL%>/effects.js">
48
</script>
49
<script language="Javascript">
50
function submitform(formObj) {
51

  
52
	if (trim(formObj.elements["loginAction"].value)!="Login") {
53
		return true;
54
	}
55
	
56
	//trim username & passwd:
57
	var username = trim(formObj.elements["uid"].value);
58
	var organization  = trim(formObj.elements["organization"].value);
59
	var password      = trim(formObj.elements["password"].value);
60
	
61
	if (username=="") {
62
		alert("You must type a username. \n");
63
		formObj.elements["uid"].focus();
64
		return false;
65
	}
66
	
67
	if (organization=="") {
68
		alert("You must select an organization. \n");
69
		formObj.elements["organization"].focus();
70
		return false;
71
	}
72
	
73
	if (password=="") {
74
		alert("You must type a password. \n");
75
		formObj.elements["password"].focus();
76
		return false;
77
	}
78
	
79
	formObj.username.value="uid="+formObj.elements["uid"].value+",o="+formObj.elements["organization"].value+",dc=ecoinformatics,dc=org";
80
	return true;
81
}
82

  
83
function trim(stringToTrim) {
84
	return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
85
}
86
</script>
87
</head>
88
<body>
89
<script language="JavaScript">
90
          insertTemplateOpening("<%=CONTEXT_URL%>");
91
          insertSearchBox("<%=CONTEXT_URL%>");
92
      </script>
93

  
94
<table width="100%" border="0" cellspacing="20" cellpadding="0">
95
	<tr>
96
		<th colspan="2">Login</th>
97
	</tr>
98
	<tr>
99
		<td>
100
			<form name="loginform" id="loginform" method="post"
101
				action="<%=SERVLET_URL%>" target="_top"
102
				onsubmit="return submitform(this);">
103
				<input type="hidden" name="action" value="login" />
104
				<input type="hidden" name="username" value="" /> 
105
				<input type="hidden" name="qformat" value="first" />
106
	
107
			<table>
108
				<tr valign="middle">
109
					<td align="left" valign="middle" class="text_plain">Username:</td>
110
	
111
					<td width="173" align="right" class="text_plain"
112
						style="padding-top: 2px; padding-bottom: 2px;"><input
113
						name="uid" type="text" style="width: 140px;" value=""></td>
114
				</tr>
115
	
116
				<tr valign="middle">
117
					<td height="28" align="left" valign="middle" class="text_plain">Organization:</td>
118
	
119
					<td align="right" class="text_plain"
120
						style="padding-top: 2px; padding-bottom: 2px;">
121
						<select name="organization" style="width: 140px;">
122
							<option value="" selected>&#8212; choose one &#8212;</option>
123
							<option value="NCEAS">NCEAS</option>
124
							<option value="MSU">MSU</option>
125
							<option value="LTER">LTER</option>
126
							<option value="UCNRS">UCNRS</option>
127
							<option value="PISCO">PISCO</option>
128
							<option value="OBFS">OBFS</option>
129
							<option value="OSUBS">OSUBS</option>
130
							<option value="SAEON">SAEON</option>
131
							<option value="SANParks">SANParks</option>
132
							<option value="SDSC">SDSC</option>
133
							<option value="KU">KU</option>
134
							<option value="unaffiliated">unaffiliated</option>
135
						</select>
136
					</td>
137
				</tr>
138
	
139
				<tr valign="middle">
140
					<td width="85" align="left" valign="middle" class="text_plain">Password:</td>
141
	
142
					<td width="150" align="right">
143
						<input name="password" type="password" maxlength="50" style="width: 140px;" value="">
144
					</td>
145
				</tr>
146
				<tr>
147
					<td colspan="2" align=right class="buttonBG_login">
148
						<input type="submit" name="loginAction" value="Login" class="button_login">
149
					</td>
150
				</tr>
151
			</table>
152
			</form>
153
		</td>
154
		<td>
155
			<p>
156
				Blah blah blah...register for an account.....
157
			</p>
158
		</td>
159
	</tr>
160
</table>
161

  
162
<script language="JavaScript">          
163
    insertTemplateClosing("<%=CONTEXT_URL%>");
164
</script>
165
</body>
166
</html>
0 167

  
lib/style/skins/first/login.xsl
1
<?xml version="1.0"?>
2
<!--
3
	*  '$RCSfile$'
4
	*      Authors: Jivka Bojilova
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-06-17 13:29:31 -0700 (Tue, 17 Jun 2008) $'
11
	* '$Revision: 4007 $'
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 with information about login action
29
	* into an HTML format suitable for rendering with modern web browsers.
30
-->
31

  
32
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
33

  
34
	<xsl:output method="html" />
35
	<xsl:param name="qformat">default</xsl:param>
36
	<xsl:param name="contextURL" />
37
	<xsl:param name="cgi-prefix" />
38

  
39
	<xsl:template match="/">
40
		<html>
41
			<head>
42
				<link rel="stylesheet" type="text/css"
43
					href="{$contextURL}/style/skins/{$qformat}/{$qformat}.css" />
44
				<script language="Javascript" type="text/JavaScript"
45
					src="{$contextURL}/style/skins/{$qformat}/{$qformat}.js" />
46
				<script language="Javascript" type="text/JavaScript"
47
					src="{$contextURL}/style/common/branding.js" />
48
				<script language="JavaScript">
49
					<![CDATA[
50
					function search(url){
51
						location.href = url;
52
       				}]]>
53
				</script>
54
			</head>
55

  
56
			<script language="JavaScript">
57
				<![CDATA[
58
				insertTemplateOpening("]]><xsl:value-of select="$contextURL" /><![CDATA[");
59
          		insertSearchBox("]]><xsl:value-of select="$contextURL" /><![CDATA[");
60
          		]]>
61
			</script>
62
			
63
			<body>
64
				<table width="100%" border="0" cellspacing="20" cellpadding="0">					
65
					<tr>
66
						<th>
67
							Login
68
						</th>
69
					</tr>
70
					
71
					<xsl:choose>
72
						<xsl:when test="count(login) &gt; 0">
73
							<tr>
74
								<td>
75
									<script language="JavaScript">
76
										<![CDATA[timerId=setTimeout(search(']]><xsl:value-of select="$contextURL" /><![CDATA[/style/skins/]]><xsl:value-of select="$qformat" /><![CDATA['), 2000);]]>
77
									</script>
78
									<p class="text_plain">
79
										Welcome <xsl:value-of select="login/name" />. 
80
										You will be automatically redirected to the search page.
81
									</p>
82
								</td>
83
							</tr>		
84
						</xsl:when>
85
						<xsl:otherwise>
86
							<xsl:if test="count(unauth_login) &gt; 0">
87
								<tr>
88
									<td>
89
										<p class="text_plain">
90
											<xsl:value-of select="unauth_login/message" />
91
										</p>
92
									</td>
93
								</tr>	
94
							</xsl:if>
95
							<tr>
96
								<td>
97
									<p class="text_plain">
98
										Return to the
99
										<a href="{$contextURL}/style/skins/{$qformat}/login.jsp" target="_top">login page</a>.
100
									</p>
101
								</td>
102
							</tr>		
103
						</xsl:otherwise>
104
					</xsl:choose>	
105
				</table>
106
			</body>
107
			
108
			<script language="JavaScript">
109
				<![CDATA[
110
				insertTemplateClosing("]]><xsl:value-of select="$contextURL" /><![CDATA[");
111
				]]>
112
			</script>
113
		</html>
114
	</xsl:template>
115

  
116
</xsl:stylesheet>
0 117

  

Also available in: Unified diff