370 |
05 Apr 05 |
nicklas |
1 |
<%-- $Id$ |
370 |
05 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 |
370 |
05 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/ |
370 |
05 Apr 05 |
nicklas |
8 |
|
370 |
05 Apr 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
370 |
05 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 |
370 |
05 Apr 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
370 |
05 Apr 05 |
nicklas |
13 |
|
370 |
05 Apr 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
370 |
05 Apr 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
370 |
05 Apr 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
370 |
05 Apr 05 |
nicklas |
17 |
GNU General Public License for more details. |
370 |
05 Apr 05 |
nicklas |
18 |
|
370 |
05 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/>. |
370 |
05 Apr 05 |
nicklas |
21 |
------------------------------------------------------------------ |
1997 |
16 Feb 06 |
nicklas |
22 |
|
370 |
05 Apr 05 |
nicklas |
23 |
@author Nicklas |
370 |
05 Apr 05 |
nicklas |
24 |
@version 2.0 |
370 |
05 Apr 05 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
397 |
14 Apr 05 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
397 |
14 Apr 05 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
397 |
14 Apr 05 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
1997 |
16 Feb 06 |
nicklas |
30 |
import="net.sf.basedb.core.Include" |
397 |
14 Apr 05 |
nicklas |
31 |
import="net.sf.basedb.core.News" |
1418 |
07 Oct 05 |
nicklas |
32 |
import="net.sf.basedb.core.ItemQuery" |
397 |
14 Apr 05 |
nicklas |
33 |
import="net.sf.basedb.core.Permission" |
1997 |
16 Feb 06 |
nicklas |
34 |
import="net.sf.basedb.core.ItemContext" |
1997 |
16 Feb 06 |
nicklas |
35 |
import="net.sf.basedb.core.MultiPermissions" |
1997 |
16 Feb 06 |
nicklas |
36 |
import="net.sf.basedb.core.PermissionDeniedException" |
1997 |
16 Feb 06 |
nicklas |
37 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
1997 |
16 Feb 06 |
nicklas |
38 |
import="net.sf.basedb.util.RemovableUtil" |
370 |
05 Apr 05 |
nicklas |
39 |
import="net.sf.basedb.clients.web.Base" |
1997 |
16 Feb 06 |
nicklas |
40 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
41 |
import="net.sf.basedb.util.Values" |
370 |
05 Apr 05 |
nicklas |
42 |
import="net.sf.basedb.clients.web.util.HTML" |
2942 |
22 Nov 06 |
nicklas |
43 |
import="net.sf.basedb.util.formatter.Formatter" |
2942 |
22 Nov 06 |
nicklas |
44 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
5478 |
05 Nov 10 |
nicklas |
45 |
import="net.sf.basedb.clients.web.servlet.RssNewsFeed" |
5506 |
19 Nov 10 |
nicklas |
46 |
import="net.sf.basedb.core.plugin.GuiContext" |
5506 |
19 Nov 10 |
nicklas |
47 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5506 |
19 Nov 10 |
nicklas |
48 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5506 |
19 Nov 10 |
nicklas |
49 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5506 |
19 Nov 10 |
nicklas |
50 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
51 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5506 |
19 Nov 10 |
nicklas |
52 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6045 |
03 Apr 12 |
nicklas |
53 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
54 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6045 |
03 Apr 12 |
nicklas |
55 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
1997 |
16 Feb 06 |
nicklas |
56 |
import="java.util.Date" |
1997 |
16 Feb 06 |
nicklas |
57 |
import="java.util.Set" |
1997 |
16 Feb 06 |
nicklas |
58 |
import="java.util.HashSet" |
1997 |
16 Feb 06 |
nicklas |
59 |
import="java.util.List" |
1997 |
16 Feb 06 |
nicklas |
60 |
import="java.util.ArrayList" |
1997 |
16 Feb 06 |
nicklas |
61 |
import="java.util.Collections" |
370 |
05 Apr 05 |
nicklas |
62 |
%> |
374 |
07 Apr 05 |
nicklas |
63 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
374 |
07 Apr 05 |
nicklas |
64 |
<%! |
4576 |
13 Oct 08 |
nicklas |
65 |
private static final ItemContext defaultContext = Base.createDefaultContext("newsDate,id", "all"); |
1997 |
16 Feb 06 |
nicklas |
66 |
static |
1997 |
16 Feb 06 |
nicklas |
67 |
{ |
1997 |
16 Feb 06 |
nicklas |
68 |
defaultContext.setSortDirection(ItemContext.SortDirection.DESC); |
1997 |
16 Feb 06 |
nicklas |
69 |
} |
1997 |
16 Feb 06 |
nicklas |
70 |
private static final Item itemType = Item.NEWS; |
370 |
05 Apr 05 |
nicklas |
71 |
%> |
370 |
05 Apr 05 |
nicklas |
72 |
<% |
1997 |
16 Feb 06 |
nicklas |
73 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
401 |
15 Apr 05 |
nicklas |
74 |
final String ID = sc.getId(); |
1997 |
16 Feb 06 |
nicklas |
75 |
final String cmd = request.getParameter("cmd"); |
1997 |
16 Feb 06 |
nicklas |
76 |
final String root = request.getContextPath()+"/"; |
1997 |
16 Feb 06 |
nicklas |
77 |
final String mode = request.getParameter("mode"); |
1997 |
16 Feb 06 |
nicklas |
78 |
final String callback = request.getParameter("callback"); |
1997 |
16 Feb 06 |
nicklas |
79 |
final String itemId = request.getParameter("item_id"); |
1997 |
16 Feb 06 |
nicklas |
80 |
final String listPage = "list_news.jsp?ID="+ID |
1997 |
16 Feb 06 |
nicklas |
81 |
+(mode == null ? "" : "&mode="+mode) |
1997 |
16 Feb 06 |
nicklas |
82 |
+(callback == null ? "" : "&callback="+callback) |
1997 |
16 Feb 06 |
nicklas |
83 |
+(itemId == null ? "" : "&item_id="+itemId); |
1997 |
16 Feb 06 |
nicklas |
84 |
final String viewPage = "view_news.jsp?ID="+ID; |
1997 |
16 Feb 06 |
nicklas |
85 |
final String editPage = "edit_news.jsp?ID="+ID; |
395 |
14 Apr 05 |
nicklas |
86 |
|
1997 |
16 Feb 06 |
nicklas |
87 |
String forward = null; |
1997 |
16 Feb 06 |
nicklas |
88 |
String redirect = null; |
1997 |
16 Feb 06 |
nicklas |
89 |
String message = null; |
1997 |
16 Feb 06 |
nicklas |
90 |
DbControl dc = null; |
1997 |
16 Feb 06 |
nicklas |
91 |
|
370 |
05 Apr 05 |
nicklas |
92 |
try |
370 |
05 Apr 05 |
nicklas |
93 |
{ |
1997 |
16 Feb 06 |
nicklas |
94 |
if (cmd == null || "List".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
95 |
{ |
1997 |
16 Feb 06 |
nicklas |
96 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
97 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
1997 |
16 Feb 06 |
nicklas |
98 |
redirect = listPage; |
1997 |
16 Feb 06 |
nicklas |
99 |
} |
1997 |
16 Feb 06 |
nicklas |
100 |
else if ("UpdateContext".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
101 |
{ |
1997 |
16 Feb 06 |
nicklas |
102 |
// Display the list page after updating the current context from the request parameters |
1997 |
16 Feb 06 |
nicklas |
103 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
104 |
redirect = listPage; |
1997 |
16 Feb 06 |
nicklas |
105 |
} |
1997 |
16 Feb 06 |
nicklas |
106 |
else if ("LoadContext".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
107 |
{ |
1997 |
16 Feb 06 |
nicklas |
108 |
// Display the list page after loading a saved context |
1997 |
16 Feb 06 |
nicklas |
109 |
int contextId = Values.getInt(request.getParameter("context")); |
1997 |
16 Feb 06 |
nicklas |
110 |
Base.loadContext(sc, contextId, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
111 |
redirect = listPage; |
1997 |
16 Feb 06 |
nicklas |
112 |
} |
1997 |
16 Feb 06 |
nicklas |
113 |
|
1997 |
16 Feb 06 |
nicklas |
114 |
else if ("ViewItem".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
115 |
{ |
1997 |
16 Feb 06 |
nicklas |
116 |
// Display the view page for a single item |
1997 |
16 Feb 06 |
nicklas |
117 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
118 |
forward = viewPage; |
1997 |
16 Feb 06 |
nicklas |
119 |
} |
1997 |
16 Feb 06 |
nicklas |
120 |
else if ("EditItem".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
121 |
{ |
1997 |
16 Feb 06 |
nicklas |
122 |
// Display the edit page for a single item (should be opened in a popup) |
1997 |
16 Feb 06 |
nicklas |
123 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
124 |
redirect = editPage; |
1997 |
16 Feb 06 |
nicklas |
125 |
} |
1997 |
16 Feb 06 |
nicklas |
126 |
else if ("NewItem".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
127 |
{ |
1997 |
16 Feb 06 |
nicklas |
128 |
// Display the edit page for a new item (should be opened in a popup) |
1997 |
16 Feb 06 |
nicklas |
129 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
401 |
15 Apr 05 |
nicklas |
130 |
{ |
1997 |
16 Feb 06 |
nicklas |
131 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
401 |
15 Apr 05 |
nicklas |
132 |
} |
1997 |
16 Feb 06 |
nicklas |
133 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
134 |
cc.setId(0); |
1997 |
16 Feb 06 |
nicklas |
135 |
redirect = editPage; |
1997 |
16 Feb 06 |
nicklas |
136 |
} |
1997 |
16 Feb 06 |
nicklas |
137 |
else if ("UpdateItem".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
138 |
{ |
1997 |
16 Feb 06 |
nicklas |
139 |
// Update the properties on an item (will close the popup) |
1997 |
16 Feb 06 |
nicklas |
140 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
7954 |
12 May 21 |
nicklas |
141 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
142 |
News news = cc.getObject("item"); |
2942 |
22 Nov 06 |
nicklas |
143 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
2999 |
04 Dec 06 |
nicklas |
144 |
Date startDate = dateFormatter.parseString(Values.getStringOrNull(request.getParameter("start_date"))); |
2999 |
04 Dec 06 |
nicklas |
145 |
Date newsDate = dateFormatter.parseString(Values.getStringOrNull(request.getParameter("news_date"))); |
1997 |
16 Feb 06 |
nicklas |
146 |
if (news == null) |
401 |
15 Apr 05 |
nicklas |
147 |
{ |
1997 |
16 Feb 06 |
nicklas |
148 |
news = News.getNew(dc, startDate, newsDate); |
1997 |
16 Feb 06 |
nicklas |
149 |
message = "News created"; |
1997 |
16 Feb 06 |
nicklas |
150 |
dc.saveItem(news); |
464 |
26 Apr 05 |
nicklas |
151 |
} |
1997 |
16 Feb 06 |
nicklas |
152 |
else |
464 |
26 Apr 05 |
nicklas |
153 |
{ |
7393 |
09 Jun 17 |
nicklas |
154 |
dc.reattachItem(news, false); |
1997 |
16 Feb 06 |
nicklas |
155 |
news.setStartDate(startDate); |
1997 |
16 Feb 06 |
nicklas |
156 |
news.setNewsDate(newsDate); |
1997 |
16 Feb 06 |
nicklas |
157 |
message = "News updated"; |
401 |
15 Apr 05 |
nicklas |
158 |
} |
5506 |
19 Nov 10 |
nicklas |
159 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.NEWS), news); |
7604 |
25 Feb 19 |
nicklas |
160 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5506 |
19 Nov 10 |
nicklas |
161 |
try |
5506 |
19 Nov 10 |
nicklas |
162 |
{ |
5506 |
19 Nov 10 |
nicklas |
163 |
news.setName(Values.getStringOrNull(request.getParameter("title"))); |
5506 |
19 Nov 10 |
nicklas |
164 |
news.setEndDate(dateFormatter.parseString(Values.getStringOrNull(request.getParameter("end_date")))); |
5506 |
19 Nov 10 |
nicklas |
165 |
news.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
7393 |
09 Jun 17 |
nicklas |
166 |
news.setSticky(Values.getBoolean(request.getParameter("sticky"))); |
5506 |
19 Nov 10 |
nicklas |
167 |
|
5506 |
19 Nov 10 |
nicklas |
168 |
// OnSave extensions |
5506 |
19 Nov 10 |
nicklas |
169 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5506 |
19 Nov 10 |
nicklas |
170 |
dc.commit(); |
5506 |
19 Nov 10 |
nicklas |
171 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
5506 |
19 Nov 10 |
nicklas |
172 |
if (RssNewsFeed.isEnabled()) RssNewsFeed.reset(); |
5506 |
19 Nov 10 |
nicklas |
173 |
} |
5506 |
19 Nov 10 |
nicklas |
174 |
catch (Exception ex) |
5506 |
19 Nov 10 |
nicklas |
175 |
{ |
5506 |
19 Nov 10 |
nicklas |
176 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5506 |
19 Nov 10 |
nicklas |
177 |
throw ex; |
5506 |
19 Nov 10 |
nicklas |
178 |
} |
5506 |
19 Nov 10 |
nicklas |
179 |
finally |
5506 |
19 Nov 10 |
nicklas |
180 |
{ |
5506 |
19 Nov 10 |
nicklas |
181 |
cc.removeObject("item"); |
5506 |
19 Nov 10 |
nicklas |
182 |
} |
1997 |
16 Feb 06 |
nicklas |
183 |
} |
1997 |
16 Feb 06 |
nicklas |
184 |
else if ("DeleteItem".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
185 |
{ |
1997 |
16 Feb 06 |
nicklas |
186 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
187 |
dc = sc.newDbControl(":Delete "+itemType); |
1997 |
16 Feb 06 |
nicklas |
188 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
189 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
1997 |
16 Feb 06 |
nicklas |
190 |
dc.commit(); |
5478 |
05 Nov 10 |
nicklas |
191 |
RssNewsFeed.reset(); |
1997 |
16 Feb 06 |
nicklas |
192 |
redirect = viewPage; |
1997 |
16 Feb 06 |
nicklas |
193 |
} |
1997 |
16 Feb 06 |
nicklas |
194 |
else if ("DeleteItems".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
195 |
{ |
1997 |
16 Feb 06 |
nicklas |
196 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
197 |
dc = sc.newDbControl(":Delete "+itemType); |
1997 |
16 Feb 06 |
nicklas |
198 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
199 |
int numTotal = cc.getSelected().size(); |
1997 |
16 Feb 06 |
nicklas |
200 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
1997 |
16 Feb 06 |
nicklas |
201 |
dc.commit(); |
5478 |
05 Nov 10 |
nicklas |
202 |
RssNewsFeed.reset(); |
1997 |
16 Feb 06 |
nicklas |
203 |
if (numTotal != numRemoved) |
415 |
18 Apr 05 |
nicklas |
204 |
{ |
1997 |
16 Feb 06 |
nicklas |
205 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
415 |
18 Apr 05 |
nicklas |
206 |
} |
6192 |
31 Oct 12 |
nicklas |
207 |
redirect = listPage; |
1997 |
16 Feb 06 |
nicklas |
208 |
} |
1997 |
16 Feb 06 |
nicklas |
209 |
else if ("RestoreItem".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
210 |
{ |
1997 |
16 Feb 06 |
nicklas |
211 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
212 |
dc = sc.newDbControl(":Restore "+itemType); |
1997 |
16 Feb 06 |
nicklas |
213 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
214 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
1997 |
16 Feb 06 |
nicklas |
215 |
dc.commit(); |
5478 |
05 Nov 10 |
nicklas |
216 |
RssNewsFeed.reset(); |
1997 |
16 Feb 06 |
nicklas |
217 |
redirect = viewPage; |
1997 |
16 Feb 06 |
nicklas |
218 |
} |
1997 |
16 Feb 06 |
nicklas |
219 |
else if ("RestoreItems".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
220 |
{ |
1997 |
16 Feb 06 |
nicklas |
221 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
222 |
dc = sc.newDbControl(":Restore "+itemType); |
1997 |
16 Feb 06 |
nicklas |
223 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
224 |
int numTotal = cc.getSelected().size(); |
1997 |
16 Feb 06 |
nicklas |
225 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
1997 |
16 Feb 06 |
nicklas |
226 |
dc.commit(); |
5478 |
05 Nov 10 |
nicklas |
227 |
RssNewsFeed.reset(); |
1997 |
16 Feb 06 |
nicklas |
228 |
if (numTotal != numRemoved) |
415 |
18 Apr 05 |
nicklas |
229 |
{ |
2528 |
15 Aug 06 |
martin |
230 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
415 |
18 Apr 05 |
nicklas |
231 |
} |
6192 |
31 Oct 12 |
nicklas |
232 |
redirect = listPage; |
1997 |
16 Feb 06 |
nicklas |
233 |
} |
1997 |
16 Feb 06 |
nicklas |
234 |
else if ("ExportItems".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
235 |
{ |
1997 |
16 Feb 06 |
nicklas |
236 |
// Run an export plugin in a list context |
1997 |
16 Feb 06 |
nicklas |
237 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
238 |
final ItemQuery<News> query = News.getQuery(); |
7954 |
12 May 21 |
nicklas |
239 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
240 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
241 |
cc.configureQuery(dc, query, jspContext, true); |
6045 |
03 Apr 12 |
nicklas |
242 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
243 |
ExtensionsInvoker<ListColumnAction<News,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
244 |
listInvoker.render(new ListColumnExportRenderer<News>(cc)); |
5590 |
16 Mar 11 |
nicklas |
245 |
dc.close(); |
1997 |
16 Feb 06 |
nicklas |
246 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+news"; |
1997 |
16 Feb 06 |
nicklas |
247 |
} |
1997 |
16 Feb 06 |
nicklas |
248 |
else if ("ExportItem".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
249 |
{ |
1997 |
16 Feb 06 |
nicklas |
250 |
// Run an export plugin in single-item context |
1997 |
16 Feb 06 |
nicklas |
251 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
252 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+news"; |
1997 |
16 Feb 06 |
nicklas |
253 |
} |
1997 |
16 Feb 06 |
nicklas |
254 |
else if ("ImportItems".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
255 |
{ |
1997 |
16 Feb 06 |
nicklas |
256 |
// Run an import plugin in a list context |
1997 |
16 Feb 06 |
nicklas |
257 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
258 |
final ItemQuery<News> query = News.getQuery(); |
7954 |
12 May 21 |
nicklas |
259 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
260 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
261 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
262 |
dc.close(); |
1997 |
16 Feb 06 |
nicklas |
263 |
cc.setQuery(query); |
1997 |
16 Feb 06 |
nicklas |
264 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+news"; |
1997 |
16 Feb 06 |
nicklas |
265 |
} |
1997 |
16 Feb 06 |
nicklas |
266 |
else if ("ImportItem".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
267 |
{ |
1997 |
16 Feb 06 |
nicklas |
268 |
// Run an import plugin in single-item context |
1997 |
16 Feb 06 |
nicklas |
269 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
270 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+news"; |
1997 |
16 Feb 06 |
nicklas |
271 |
} |
1997 |
16 Feb 06 |
nicklas |
272 |
else if ("RunListPlugin".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
273 |
{ |
1997 |
16 Feb 06 |
nicklas |
274 |
// Run another plugin in a list context |
1997 |
16 Feb 06 |
nicklas |
275 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
276 |
final ItemQuery<News> query = News.getQuery(); |
7954 |
12 May 21 |
nicklas |
277 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
278 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
279 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
280 |
dc.close(); |
1997 |
16 Feb 06 |
nicklas |
281 |
cc.setQuery(query); |
1997 |
16 Feb 06 |
nicklas |
282 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
1997 |
16 Feb 06 |
nicklas |
283 |
} |
1997 |
16 Feb 06 |
nicklas |
284 |
else if ("RunPlugin".equals(cmd)) |
1997 |
16 Feb 06 |
nicklas |
285 |
{ |
1997 |
16 Feb 06 |
nicklas |
286 |
// Run another plugin in single-item context |
1997 |
16 Feb 06 |
nicklas |
287 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1997 |
16 Feb 06 |
nicklas |
288 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
1997 |
16 Feb 06 |
nicklas |
289 |
} |
1997 |
16 Feb 06 |
nicklas |
290 |
else |
1997 |
16 Feb 06 |
nicklas |
291 |
{ |
1997 |
16 Feb 06 |
nicklas |
292 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1997 |
16 Feb 06 |
nicklas |
293 |
} |
370 |
05 Apr 05 |
nicklas |
294 |
} |
370 |
05 Apr 05 |
nicklas |
295 |
finally |
370 |
05 Apr 05 |
nicklas |
296 |
{ |
370 |
05 Apr 05 |
nicklas |
297 |
if (dc != null) dc.close(); |
370 |
05 Apr 05 |
nicklas |
298 |
} |
1997 |
16 Feb 06 |
nicklas |
299 |
|
1997 |
16 Feb 06 |
nicklas |
300 |
if (forward != null) |
1997 |
16 Feb 06 |
nicklas |
301 |
{ |
6192 |
31 Oct 12 |
nicklas |
302 |
sc.setSessionSetting("alert-message", message); |
1997 |
16 Feb 06 |
nicklas |
303 |
pageContext.forward(forward); |
1997 |
16 Feb 06 |
nicklas |
304 |
} |
1997 |
16 Feb 06 |
nicklas |
305 |
else if (redirect != null) |
1997 |
16 Feb 06 |
nicklas |
306 |
{ |
6192 |
31 Oct 12 |
nicklas |
307 |
sc.setSessionSetting("alert-message", message); |
1997 |
16 Feb 06 |
nicklas |
308 |
response.sendRedirect(redirect); |
1997 |
16 Feb 06 |
nicklas |
309 |
} |
1997 |
16 Feb 06 |
nicklas |
310 |
else if (message == null) |
1997 |
16 Feb 06 |
nicklas |
311 |
{ |
1997 |
16 Feb 06 |
nicklas |
312 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1997 |
16 Feb 06 |
nicklas |
313 |
} |
1997 |
16 Feb 06 |
nicklas |
314 |
else |
1997 |
16 Feb 06 |
nicklas |
315 |
{ |
1997 |
16 Feb 06 |
nicklas |
316 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1997 |
16 Feb 06 |
nicklas |
317 |
} |
1997 |
16 Feb 06 |
nicklas |
318 |
%> |
1997 |
16 Feb 06 |
nicklas |
319 |
|