397 |
14 Apr 05 |
nicklas |
1 |
<%-- $Id$ |
397 |
14 Apr 05 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Nicklas Nordborg |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
397 |
14 Apr 05 |
nicklas |
5 |
|
2304 |
22 May 06 |
jari |
6 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
7 |
Available at http://base.thep.lu.se/ |
397 |
14 Apr 05 |
nicklas |
8 |
|
397 |
14 Apr 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
397 |
14 Apr 05 |
nicklas |
10 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
11 |
as published by the Free Software Foundation; either version 3 |
397 |
14 Apr 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
397 |
14 Apr 05 |
nicklas |
13 |
|
397 |
14 Apr 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
397 |
14 Apr 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
397 |
14 Apr 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
397 |
14 Apr 05 |
nicklas |
17 |
GNU General Public License for more details. |
397 |
14 Apr 05 |
nicklas |
18 |
|
397 |
14 Apr 05 |
nicklas |
19 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
20 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
397 |
14 Apr 05 |
nicklas |
21 |
------------------------------------------------------------------ |
397 |
14 Apr 05 |
nicklas |
22 |
|
397 |
14 Apr 05 |
nicklas |
23 |
|
397 |
14 Apr 05 |
nicklas |
24 |
@author Nicklas |
397 |
14 Apr 05 |
nicklas |
25 |
@version 2.0 |
397 |
14 Apr 05 |
nicklas |
26 |
--%> |
5426 |
24 Sep 10 |
nicklas |
27 |
<%@ page pageEncoding="UTF-8" session="false" |
397 |
14 Apr 05 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
397 |
14 Apr 05 |
nicklas |
29 |
import="net.sf.basedb.core.DbControl" |
397 |
14 Apr 05 |
nicklas |
30 |
import="net.sf.basedb.core.Item" |
1997 |
16 Feb 06 |
nicklas |
31 |
import="net.sf.basedb.core.ItemContext" |
397 |
14 Apr 05 |
nicklas |
32 |
import="net.sf.basedb.core.Permission" |
397 |
14 Apr 05 |
nicklas |
33 |
import="net.sf.basedb.core.News" |
1997 |
16 Feb 06 |
nicklas |
34 |
import="net.sf.basedb.core.PermissionDeniedException" |
397 |
14 Apr 05 |
nicklas |
35 |
import="net.sf.basedb.clients.web.Base" |
397 |
14 Apr 05 |
nicklas |
36 |
import="net.sf.basedb.clients.web.util.HTML" |
2942 |
22 Nov 06 |
nicklas |
37 |
import="net.sf.basedb.util.formatter.Formatter" |
2942 |
22 Nov 06 |
nicklas |
38 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
2942 |
22 Nov 06 |
nicklas |
39 |
import="net.sf.basedb.clients.web.formatter.FormatterSettings" |
2753 |
20 Oct 06 |
nicklas |
40 |
import="net.sf.basedb.util.Values" |
5506 |
19 Nov 10 |
nicklas |
41 |
import="net.sf.basedb.core.plugin.GuiContext" |
5506 |
19 Nov 10 |
nicklas |
42 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5506 |
19 Nov 10 |
nicklas |
43 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5506 |
19 Nov 10 |
nicklas |
44 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
45 |
import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction" |
5506 |
19 Nov 10 |
nicklas |
46 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
397 |
14 Apr 05 |
nicklas |
47 |
import="java.util.Date" |
397 |
14 Apr 05 |
nicklas |
48 |
%> |
397 |
14 Apr 05 |
nicklas |
49 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
397 |
14 Apr 05 |
nicklas |
50 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
6147 |
21 Sep 12 |
nicklas |
51 |
<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
397 |
14 Apr 05 |
nicklas |
52 |
<% |
1997 |
16 Feb 06 |
nicklas |
53 |
final Item itemType = Item.NEWS; |
1997 |
16 Feb 06 |
nicklas |
54 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
1997 |
16 Feb 06 |
nicklas |
55 |
final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
1997 |
16 Feb 06 |
nicklas |
56 |
final int itemId = cc.getId(); |
464 |
26 Apr 05 |
nicklas |
57 |
final String ID = sc.getId(); |
1997 |
16 Feb 06 |
nicklas |
58 |
final float scale = Base.getScale(sc); |
7954 |
12 May 21 |
nicklas |
59 |
final DbControl dc = sc.newDbControl(":Edit "+itemType); |
397 |
14 Apr 05 |
nicklas |
60 |
try |
397 |
14 Apr 05 |
nicklas |
61 |
{ |
397 |
14 Apr 05 |
nicklas |
62 |
String title = null; |
397 |
14 Apr 05 |
nicklas |
63 |
News news = null; |
2942 |
22 Nov 06 |
nicklas |
64 |
Date startDate = null; |
2942 |
22 Nov 06 |
nicklas |
65 |
Date newsDate = null; |
1997 |
16 Feb 06 |
nicklas |
66 |
|
1997 |
16 Feb 06 |
nicklas |
67 |
if (itemId == 0) |
397 |
14 Apr 05 |
nicklas |
68 |
{ |
397 |
14 Apr 05 |
nicklas |
69 |
title = "Create news"; |
1997 |
16 Feb 06 |
nicklas |
70 |
cc.removeObject("item"); |
7605 |
26 Feb 19 |
nicklas |
71 |
startDate = cc.getPropertyObject("startDate"); |
7605 |
26 Feb 19 |
nicklas |
72 |
newsDate = cc.getPropertyObject("newsDate"); |
397 |
14 Apr 05 |
nicklas |
73 |
} |
397 |
14 Apr 05 |
nicklas |
74 |
else |
397 |
14 Apr 05 |
nicklas |
75 |
{ |
1997 |
16 Feb 06 |
nicklas |
76 |
news = News.getById(dc, itemId); |
1997 |
16 Feb 06 |
nicklas |
77 |
cc.setObject("item", news); |
1997 |
16 Feb 06 |
nicklas |
78 |
title = "Edit news -- " + HTML.encodeTags(news.getName()); |
2942 |
22 Nov 06 |
nicklas |
79 |
startDate = news.getStartDate(); |
2942 |
22 Nov 06 |
nicklas |
80 |
newsDate = news.getNewsDate(); |
6218 |
19 Dec 12 |
nicklas |
81 |
news.checkPermission(Permission.WRITE); |
397 |
14 Apr 05 |
nicklas |
82 |
} |
1997 |
16 Feb 06 |
nicklas |
83 |
|
2942 |
22 Nov 06 |
nicklas |
84 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
2942 |
22 Nov 06 |
nicklas |
85 |
String dateFormat = FormatterSettings.getDateFormat(sc); |
2942 |
22 Nov 06 |
nicklas |
86 |
String htmlDateFormat = HTML.encodeTags(dateFormat); |
5506 |
19 Nov 10 |
nicklas |
87 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), news); |
7604 |
25 Feb 19 |
nicklas |
88 |
ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext); |
397 |
14 Apr 05 |
nicklas |
89 |
%> |
6218 |
19 Dec 12 |
nicklas |
90 |
<base:page type="popup" title="<%=title%>" id="edit-page"> |
6218 |
19 Dec 12 |
nicklas |
91 |
<base:head scripts="tabcontrol-2.js,~news.js" styles="tabcontrol.css"> |
5506 |
19 Nov 10 |
nicklas |
92 |
<ext:scripts context="<%=jspContext%>" /> |
5506 |
19 Nov 10 |
nicklas |
93 |
<ext:stylesheets context="<%=jspContext%>" /> |
415 |
18 Apr 05 |
nicklas |
94 |
</base:head> |
6218 |
19 Dec 12 |
nicklas |
95 |
<base:body > |
5921 |
10 Jan 12 |
nicklas |
96 |
<h1><%=title%> <base:help tabcontrol="settings" /></h1> |
6218 |
19 Dec 12 |
nicklas |
97 |
|
6218 |
19 Dec 12 |
nicklas |
98 |
<div id="page-data" class="datacontainer" |
6218 |
19 Dec 12 |
nicklas |
99 |
data-date-format="<%=htmlDateFormat%>" |
6218 |
19 Dec 12 |
nicklas |
100 |
></div> |
6218 |
19 Dec 12 |
nicklas |
101 |
|
6162 |
10 Oct 12 |
nicklas |
102 |
<form action="index.jsp?ID=<%=ID%>" method="post" name="news"> |
1997 |
16 Feb 06 |
nicklas |
103 |
<input type="hidden" name="cmd" value="UpdateItem"> |
1997 |
16 Feb 06 |
nicklas |
104 |
|
5921 |
10 Jan 12 |
nicklas |
105 |
<t:tabcontrol id="settings" |
5921 |
10 Jan 12 |
nicklas |
106 |
subclass="content dialogtabcontrol" |
5506 |
19 Nov 10 |
nicklas |
107 |
position="bottom" remember="<%=news != null%>" |
5506 |
19 Nov 10 |
nicklas |
108 |
extensions="<%=invoker%>"> |
6218 |
19 Dec 12 |
nicklas |
109 |
<t:tab id="info" title="News" helpid="news.edit"> |
5921 |
10 Jan 12 |
nicklas |
110 |
<table class="fullform input100 smaller"> |
415 |
18 Apr 05 |
nicklas |
111 |
<tr> |
5921 |
10 Jan 12 |
nicklas |
112 |
<th>Title</th> |
6218 |
19 Dec 12 |
nicklas |
113 |
<td><input class="text required auto-init" data-auto-init="<%=news == null ? "focus-select" : "focus" %>" |
6218 |
19 Dec 12 |
nicklas |
114 |
type="text" name="title" |
1997 |
16 Feb 06 |
nicklas |
115 |
value="<%=HTML.encodeTags(news == null ? Values.getString(cc.getPropertyValue("name"), "New news") : news.getName())%>" |
5921 |
10 Jan 12 |
nicklas |
116 |
maxlength="<%=News.MAX_NAME_LENGTH%>"></td> |
5921 |
10 Jan 12 |
nicklas |
117 |
<td></td> |
415 |
18 Apr 05 |
nicklas |
118 |
</tr> |
415 |
18 Apr 05 |
nicklas |
119 |
<tr> |
7393 |
09 Jun 17 |
nicklas |
120 |
<th class="prompt"><label for="sticky">Sticky</label></th> |
7393 |
09 Jun 17 |
nicklas |
121 |
<td><input type="checkbox" name="sticky" id="sticky" value="1" |
7393 |
09 Jun 17 |
nicklas |
122 |
<%=(news != null && news.isSticky()) || (news == null && Values.getBoolean(cc.getPropertyValue("sticky"))) ? "checked" : ""%>> |
7393 |
09 Jun 17 |
nicklas |
123 |
<i>Sticky news are sorted before non-sticky news!</i> |
7393 |
09 Jun 17 |
nicklas |
124 |
</td> |
7393 |
09 Jun 17 |
nicklas |
125 |
<td></td> |
7393 |
09 Jun 17 |
nicklas |
126 |
</tr> |
7393 |
09 Jun 17 |
nicklas |
127 |
<tr> |
5921 |
10 Jan 12 |
nicklas |
128 |
<th>Start date</th> |
415 |
18 Apr 05 |
nicklas |
129 |
<td> |
5921 |
10 Jan 12 |
nicklas |
130 |
<table> |
5921 |
10 Jan 12 |
nicklas |
131 |
<tr> |
5921 |
10 Jan 12 |
nicklas |
132 |
<td> |
6217 |
14 Dec 12 |
nicklas |
133 |
<input class="text required" type="text" name="start_date" id="start_date" style="width: 15em;" |
5921 |
10 Jan 12 |
nicklas |
134 |
value="<%=HTML.encodeTags(dateFormatter.format(startDate == null ? new Date() : startDate))%>" |
5921 |
10 Jan 12 |
nicklas |
135 |
maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> |
5921 |
10 Jan 12 |
nicklas |
136 |
</td> |
5921 |
10 Jan 12 |
nicklas |
137 |
<td> |
6216 |
14 Dec 12 |
nicklas |
138 |
<base:calendar textarea="start_date" title="Start date" /> |
5921 |
10 Jan 12 |
nicklas |
139 |
</td> |
5921 |
10 Jan 12 |
nicklas |
140 |
</tr> |
5921 |
10 Jan 12 |
nicklas |
141 |
</table> |
540 |
10 May 05 |
nicklas |
142 |
</td> |
5921 |
10 Jan 12 |
nicklas |
143 |
<td></td> |
5921 |
10 Jan 12 |
nicklas |
144 |
</tr> |
5921 |
10 Jan 12 |
nicklas |
145 |
<tr> |
5921 |
10 Jan 12 |
nicklas |
146 |
<th>News date</th> |
540 |
10 May 05 |
nicklas |
147 |
<td> |
5921 |
10 Jan 12 |
nicklas |
148 |
<table> |
5921 |
10 Jan 12 |
nicklas |
149 |
<tr> |
5921 |
10 Jan 12 |
nicklas |
150 |
<td> |
6217 |
14 Dec 12 |
nicklas |
151 |
<input class="text required" type="text" name="news_date" id="news_date" style="width: 15em;" |
5921 |
10 Jan 12 |
nicklas |
152 |
value="<%=HTML.encodeTags(dateFormatter.format(newsDate == null ? new Date() : newsDate))%>" |
5921 |
10 Jan 12 |
nicklas |
153 |
maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> |
5921 |
10 Jan 12 |
nicklas |
154 |
</td> |
5921 |
10 Jan 12 |
nicklas |
155 |
<td> |
6216 |
14 Dec 12 |
nicklas |
156 |
<base:calendar textarea="news_date" title="News date" /> |
5921 |
10 Jan 12 |
nicklas |
157 |
</td> |
5921 |
10 Jan 12 |
nicklas |
158 |
</tr> |
5921 |
10 Jan 12 |
nicklas |
159 |
</table> |
415 |
18 Apr 05 |
nicklas |
160 |
</td> |
5921 |
10 Jan 12 |
nicklas |
161 |
<td></td> |
415 |
18 Apr 05 |
nicklas |
162 |
</tr> |
415 |
18 Apr 05 |
nicklas |
163 |
<tr> |
5921 |
10 Jan 12 |
nicklas |
164 |
<th>End date</th> |
415 |
18 Apr 05 |
nicklas |
165 |
<td> |
5921 |
10 Jan 12 |
nicklas |
166 |
<table> |
5921 |
10 Jan 12 |
nicklas |
167 |
<tr> |
5921 |
10 Jan 12 |
nicklas |
168 |
<td> |
6217 |
14 Dec 12 |
nicklas |
169 |
<input class="text" type="text" name="end_date" style="width: 15em;" id="end_date" |
5921 |
10 Jan 12 |
nicklas |
170 |
value="<%=dateFormatter.format(news == null ? |
7605 |
26 Feb 19 |
nicklas |
171 |
cc.getPropertyObject("endDate") : news.getEndDate())%>" |
5921 |
10 Jan 12 |
nicklas |
172 |
maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> |
5921 |
10 Jan 12 |
nicklas |
173 |
</td> |
5921 |
10 Jan 12 |
nicklas |
174 |
<td> |
6216 |
14 Dec 12 |
nicklas |
175 |
<base:calendar textarea="end_date" title="End date" /> |
5921 |
10 Jan 12 |
nicklas |
176 |
</td> |
5921 |
10 Jan 12 |
nicklas |
177 |
</tr> |
5921 |
10 Jan 12 |
nicklas |
178 |
</table> |
540 |
10 May 05 |
nicklas |
179 |
</td> |
5921 |
10 Jan 12 |
nicklas |
180 |
<td></td> |
415 |
18 Apr 05 |
nicklas |
181 |
</tr> |
5921 |
10 Jan 12 |
nicklas |
182 |
<tr class="dynamic"> |
5921 |
10 Jan 12 |
nicklas |
183 |
<th>Description</th> |
415 |
18 Apr 05 |
nicklas |
184 |
<td> |
6215 |
13 Dec 12 |
nicklas |
185 |
<textarea class="text" rows="6" name="description" id="description" |
5921 |
10 Jan 12 |
nicklas |
186 |
><%=HTML.encodeTags(news == null ? cc.getPropertyValue("description") : news.getDescription())%></textarea> |
540 |
10 May 05 |
nicklas |
187 |
</td> |
5921 |
10 Jan 12 |
nicklas |
188 |
<td style="width: 20px;"> |
6215 |
13 Dec 12 |
nicklas |
189 |
<base:zoom textarea="description" title="Description" /> |
415 |
18 Apr 05 |
nicklas |
190 |
</td> |
415 |
18 Apr 05 |
nicklas |
191 |
</tr> |
415 |
18 Apr 05 |
nicklas |
192 |
</table> |
1997 |
16 Feb 06 |
nicklas |
193 |
</t:tab> |
1997 |
16 Feb 06 |
nicklas |
194 |
</t:tabcontrol> |
5921 |
10 Jan 12 |
nicklas |
195 |
</form> |
5921 |
10 Jan 12 |
nicklas |
196 |
|
5921 |
10 Jan 12 |
nicklas |
197 |
<div class="legend"> |
5946 |
03 Feb 12 |
nicklas |
198 |
<base:icon image="required.png" />= required information |
5921 |
10 Jan 12 |
nicklas |
199 |
</div> |
1997 |
16 Feb 06 |
nicklas |
200 |
|
5921 |
10 Jan 12 |
nicklas |
201 |
<base:buttongroup subclass="dialogbuttons"> |
6218 |
19 Dec 12 |
nicklas |
202 |
<base:button id="btnSave" title="Save" /> |
6218 |
19 Dec 12 |
nicklas |
203 |
<base:button id="close" title="Cancel" /> |
5921 |
10 Jan 12 |
nicklas |
204 |
</base:buttongroup> |
415 |
18 Apr 05 |
nicklas |
205 |
</base:body> |
397 |
14 Apr 05 |
nicklas |
206 |
</base:page> |
397 |
14 Apr 05 |
nicklas |
207 |
<% |
397 |
14 Apr 05 |
nicklas |
208 |
} |
397 |
14 Apr 05 |
nicklas |
209 |
finally |
397 |
14 Apr 05 |
nicklas |
210 |
{ |
397 |
14 Apr 05 |
nicklas |
211 |
if (dc != null) dc.close(); |
397 |
14 Apr 05 |
nicklas |
212 |
} |
397 |
14 Apr 05 |
nicklas |
213 |
%> |