1391 |
15 Sep 11 |
nicklas |
1 |
<%-- |
1391 |
15 Sep 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
1391 |
15 Sep 11 |
nicklas |
3 |
|
1391 |
15 Sep 11 |
nicklas |
4 |
This file is part of the Example Code Package for BASE. |
1391 |
15 Sep 11 |
nicklas |
5 |
Available at http://baseplugins.thep.lu.se/ |
1391 |
15 Sep 11 |
nicklas |
6 |
BASE main site: http://base.thep.lu.se/ |
1391 |
15 Sep 11 |
nicklas |
7 |
|
1391 |
15 Sep 11 |
nicklas |
8 |
This is free software; you can redistribute it and/or |
1391 |
15 Sep 11 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
1391 |
15 Sep 11 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
1391 |
15 Sep 11 |
nicklas |
11 |
of the License, or (at your option) any later version. |
1391 |
15 Sep 11 |
nicklas |
12 |
|
1391 |
15 Sep 11 |
nicklas |
13 |
The software is distributed in the hope that it will be useful, |
1391 |
15 Sep 11 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1391 |
15 Sep 11 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1391 |
15 Sep 11 |
nicklas |
16 |
GNU General Public License for more details. |
1391 |
15 Sep 11 |
nicklas |
17 |
|
1391 |
15 Sep 11 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
1391 |
15 Sep 11 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
1391 |
15 Sep 11 |
nicklas |
20 |
--%> |
1269 |
11 Nov 10 |
nicklas |
21 |
<%@ page |
1269 |
11 Nov 10 |
nicklas |
22 |
pageEncoding="UTF-8" |
1269 |
11 Nov 10 |
nicklas |
23 |
session="false" |
1269 |
11 Nov 10 |
nicklas |
24 |
import="net.sf.basedb.core.SessionControl" |
1269 |
11 Nov 10 |
nicklas |
25 |
import="net.sf.basedb.core.DbControl" |
1273 |
23 Nov 10 |
nicklas |
26 |
import="net.sf.basedb.core.BasicItem" |
1269 |
11 Nov 10 |
nicklas |
27 |
import="net.sf.basedb.core.ItemContext" |
1269 |
11 Nov 10 |
nicklas |
28 |
import="net.sf.basedb.core.Item" |
1269 |
11 Nov 10 |
nicklas |
29 |
import="net.sf.basedb.core.AnyToAny" |
1269 |
11 Nov 10 |
nicklas |
30 |
import="net.sf.basedb.core.File" |
1269 |
11 Nov 10 |
nicklas |
31 |
import="net.sf.basedb.core.ItemNotFoundException" |
1269 |
11 Nov 10 |
nicklas |
32 |
import="net.sf.basedb.core.PermissionDeniedException" |
2205 |
29 Jan 14 |
nicklas |
33 |
import="net.sf.basedb.util.extensions.Extension" |
1269 |
11 Nov 10 |
nicklas |
34 |
import="net.sf.basedb.clients.web.Base" |
1270 |
15 Nov 10 |
nicklas |
35 |
import="net.sf.basedb.clients.web.util.HTML" |
1269 |
11 Nov 10 |
nicklas |
36 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
1269 |
11 Nov 10 |
nicklas |
37 |
%> |
1269 |
11 Nov 10 |
nicklas |
38 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
1269 |
11 Nov 10 |
nicklas |
39 |
<% |
1269 |
11 Nov 10 |
nicklas |
40 |
// Get the JspContext that was created on the main edit page |
1269 |
11 Nov 10 |
nicklas |
41 |
final JspContext jspContext = (JspContext)request.getAttribute(JspContext.ATTRIBUTE_KEY); |
2205 |
29 Jan 14 |
nicklas |
42 |
final Extension extension = (Extension)request.getAttribute(JspContext.EXTENSION_KEY); |
1269 |
11 Nov 10 |
nicklas |
43 |
|
1273 |
23 Nov 10 |
nicklas |
44 |
// The current item is found in the context. NOTE! Can be null if a new item |
1273 |
23 Nov 10 |
nicklas |
45 |
final BasicItem item = (BasicItem)jspContext.getCurrentItem(); |
1269 |
11 Nov 10 |
nicklas |
46 |
|
1269 |
11 Nov 10 |
nicklas |
47 |
// Get the DbControl and SessionControl used to handle the request (do not close!) |
1269 |
11 Nov 10 |
nicklas |
48 |
final DbControl dc = jspContext.getDbControl(); |
1269 |
11 Nov 10 |
nicklas |
49 |
final SessionControl sc = dc.getSessionControl(); |
1269 |
11 Nov 10 |
nicklas |
50 |
final String ID = sc.getId(); |
1269 |
11 Nov 10 |
nicklas |
51 |
|
1270 |
15 Nov 10 |
nicklas |
52 |
AnyToAny any = null; |
1270 |
15 Nov 10 |
nicklas |
53 |
|
1269 |
11 Nov 10 |
nicklas |
54 |
// Try to get the currently attached history file |
1269 |
11 Nov 10 |
nicklas |
55 |
File currentFile = null; |
1269 |
11 Nov 10 |
nicklas |
56 |
boolean readCurrentFile = true; |
1273 |
23 Nov 10 |
nicklas |
57 |
if (item != null) |
1269 |
11 Nov 10 |
nicklas |
58 |
{ |
1269 |
11 Nov 10 |
nicklas |
59 |
try |
1269 |
11 Nov 10 |
nicklas |
60 |
{ |
1273 |
23 Nov 10 |
nicklas |
61 |
any = AnyToAny.getByName(dc, item, "history-file"); |
1269 |
11 Nov 10 |
nicklas |
62 |
if (any != null && any.getToType() == Item.FILE) |
1269 |
11 Nov 10 |
nicklas |
63 |
{ |
1269 |
11 Nov 10 |
nicklas |
64 |
currentFile = (File)any.getTo(); |
1269 |
11 Nov 10 |
nicklas |
65 |
} |
1269 |
11 Nov 10 |
nicklas |
66 |
} |
1269 |
11 Nov 10 |
nicklas |
67 |
catch (ItemNotFoundException ex) |
1269 |
11 Nov 10 |
nicklas |
68 |
{} // There is no file |
1269 |
11 Nov 10 |
nicklas |
69 |
catch (PermissionDeniedException ex) |
1269 |
11 Nov 10 |
nicklas |
70 |
{ |
1269 |
11 Nov 10 |
nicklas |
71 |
// There is a file but the user doesn't have permission to it |
1269 |
11 Nov 10 |
nicklas |
72 |
readCurrentFile = false; |
1269 |
11 Nov 10 |
nicklas |
73 |
} |
1269 |
11 Nov 10 |
nicklas |
74 |
} |
2205 |
29 Jan 14 |
nicklas |
75 |
|
2205 |
29 Jan 14 |
nicklas |
76 |
String HOME = jspContext.getHome(extension); |
1269 |
11 Nov 10 |
nicklas |
77 |
%> |
1269 |
11 Nov 10 |
nicklas |
78 |
<base:page type="include"> |
2205 |
29 Jan 14 |
nicklas |
79 |
<base:head scripts="<%=HOME + "/scripts/history-file.js"%>" /> |
1269 |
11 Nov 10 |
nicklas |
80 |
<base:body> |
1537 |
16 Feb 12 |
nicklas |
81 |
<table class="fullform input100"> |
1269 |
11 Nov 10 |
nicklas |
82 |
<tr> |
1537 |
16 Feb 12 |
nicklas |
83 |
<th>History file</th> |
1269 |
11 Nov 10 |
nicklas |
84 |
<td> |
1269 |
11 Nov 10 |
nicklas |
85 |
<base:select |
1273 |
23 Nov 10 |
nicklas |
86 |
id="history_file_id" |
1269 |
11 Nov 10 |
nicklas |
87 |
clazz="selectionlist" |
1269 |
11 Nov 10 |
nicklas |
88 |
required="false" |
1269 |
11 Nov 10 |
nicklas |
89 |
current="<%=currentFile%>" |
1269 |
11 Nov 10 |
nicklas |
90 |
denied="<%=!readCurrentFile%>" |
1273 |
23 Nov 10 |
nicklas |
91 |
newitem="<%=item == null%>" |
1269 |
11 Nov 10 |
nicklas |
92 |
/> |
1269 |
11 Nov 10 |
nicklas |
93 |
</td> |
1537 |
16 Feb 12 |
nicklas |
94 |
<td></td> |
1269 |
11 Nov 10 |
nicklas |
95 |
</tr> |
1537 |
16 Feb 12 |
nicklas |
96 |
<tr class="dynamic"> |
1537 |
16 Feb 12 |
nicklas |
97 |
<th>Description</th> |
1537 |
16 Feb 12 |
nicklas |
98 |
<td> |
2205 |
29 Jan 14 |
nicklas |
99 |
<textarea class="text" rows="6" name="history_description" id="history_description" |
1270 |
15 Nov 10 |
nicklas |
100 |
><%=HTML.encodeTags(any == null ? "" : any.getDescription())%></textarea> |
1270 |
15 Nov 10 |
nicklas |
101 |
</td> |
1537 |
16 Feb 12 |
nicklas |
102 |
<td style="width: 20px;"> |
2205 |
29 Jan 14 |
nicklas |
103 |
<base:zoom textarea="history_description" title="Description" /> |
1537 |
16 Feb 12 |
nicklas |
104 |
</td> |
1270 |
15 Nov 10 |
nicklas |
105 |
</tr> |
1269 |
11 Nov 10 |
nicklas |
106 |
</table> |
1269 |
11 Nov 10 |
nicklas |
107 |
</base:body> |
1269 |
11 Nov 10 |
nicklas |
108 |
</base:page> |
1269 |
11 Nov 10 |
nicklas |
109 |
|