2129 |
30 Mar 06 |
martin |
1 |
<%-- $Id$ |
2129 |
30 Mar 06 |
martin |
2 |
------------------------------------------------------------------ |
2129 |
30 Mar 06 |
martin |
3 |
BioArray Software Environment (BASE) - http://base.thep.lu.se/ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006 Nicklas Nordborg, Martin Svensson |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg |
2129 |
30 Mar 06 |
martin |
6 |
|
2129 |
30 Mar 06 |
martin |
7 |
This file is part of BASE. |
2129 |
30 Mar 06 |
martin |
8 |
|
2129 |
30 Mar 06 |
martin |
9 |
BASE is free software; you can redistribute it and/or |
2129 |
30 Mar 06 |
martin |
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 |
2129 |
30 Mar 06 |
martin |
12 |
of the License, or (at your option) any later version. |
2129 |
30 Mar 06 |
martin |
13 |
|
2129 |
30 Mar 06 |
martin |
14 |
BASE is distributed in the hope that it will be useful, |
2129 |
30 Mar 06 |
martin |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2129 |
30 Mar 06 |
martin |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2129 |
30 Mar 06 |
martin |
17 |
GNU General Public License for more details. |
2129 |
30 Mar 06 |
martin |
18 |
|
2129 |
30 Mar 06 |
martin |
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/>. |
2129 |
30 Mar 06 |
martin |
21 |
------------------------------------------------------------------ |
2129 |
30 Mar 06 |
martin |
22 |
|
2129 |
30 Mar 06 |
martin |
23 |
Open a popupwindow viewing a particular helpsection. |
2129 |
30 Mar 06 |
martin |
24 |
|
2129 |
30 Mar 06 |
martin |
25 |
@param helpid The externalid of the helpsection to display. |
2129 |
30 Mar 06 |
martin |
26 |
|
2129 |
30 Mar 06 |
martin |
27 |
@author Martin |
2129 |
30 Mar 06 |
martin |
28 |
@version 2.0 |
2129 |
30 Mar 06 |
martin |
29 |
--%> |
5426 |
24 Sep 10 |
nicklas |
30 |
<%@ page pageEncoding="UTF-8" session="false" |
2129 |
30 Mar 06 |
martin |
31 |
import="net.sf.basedb.core.Client" |
2129 |
30 Mar 06 |
martin |
32 |
import="net.sf.basedb.core.DbControl" |
2129 |
30 Mar 06 |
martin |
33 |
import="net.sf.basedb.core.Help" |
2129 |
30 Mar 06 |
martin |
34 |
import="net.sf.basedb.core.Permission" |
2129 |
30 Mar 06 |
martin |
35 |
import="net.sf.basedb.core.SessionControl" |
2405 |
21 Jun 06 |
nicklas |
36 |
import="net.sf.basedb.core.ItemNotFoundException" |
2129 |
30 Mar 06 |
martin |
37 |
import="net.sf.basedb.clients.web.Base" |
2753 |
20 Oct 06 |
nicklas |
38 |
import="net.sf.basedb.util.Values" |
2422 |
26 Jun 06 |
nicklas |
39 |
import="net.sf.basedb.clients.web.util.HTML" |
2422 |
26 Jun 06 |
nicklas |
40 |
import="java.util.regex.Pattern" |
2422 |
26 Jun 06 |
nicklas |
41 |
import="java.util.regex.Matcher" |
2129 |
30 Mar 06 |
martin |
42 |
%> |
2129 |
30 Mar 06 |
martin |
43 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2422 |
26 Jun 06 |
nicklas |
44 |
<%! |
5708 |
25 Aug 11 |
nicklas |
45 |
private static final Pattern findTag = Pattern.compile("\\{\\@(\\w+)\\s([^\\s]+)\\s*(.+?)\\}"); |
2422 |
26 Jun 06 |
nicklas |
46 |
private String parseTags(String ID, Help help, int includeLevel) |
2422 |
26 Jun 06 |
nicklas |
47 |
{ |
2422 |
26 Jun 06 |
nicklas |
48 |
StringBuffer sb = new StringBuffer(); |
6181 |
22 Oct 12 |
nicklas |
49 |
Matcher m = findTag.matcher(Values.getString(help.getDescription())); |
2422 |
26 Jun 06 |
nicklas |
50 |
while (m.find()) |
2422 |
26 Jun 06 |
nicklas |
51 |
{ |
2422 |
26 Jun 06 |
nicklas |
52 |
String cmd = m.group(1); |
2422 |
26 Jun 06 |
nicklas |
53 |
if ("link".equals(cmd)) |
2422 |
26 Jun 06 |
nicklas |
54 |
{ |
2422 |
26 Jun 06 |
nicklas |
55 |
m.appendReplacement(sb, "<a href=\"view_help.jsp?ID="+ID+"&external_id=$2\">$3</a>"); |
2422 |
26 Jun 06 |
nicklas |
56 |
} |
2422 |
26 Jun 06 |
nicklas |
57 |
else if ("include".equals(cmd)) |
2422 |
26 Jun 06 |
nicklas |
58 |
{ |
2422 |
26 Jun 06 |
nicklas |
59 |
if (includeLevel >= 10) |
2422 |
26 Jun 06 |
nicklas |
60 |
{ |
2422 |
26 Jun 06 |
nicklas |
61 |
m.appendReplacement(sb, "[<a href=\"view_help.jsp?ID="+ID+"&external_id=$2\">$2</a>]"); |
2422 |
26 Jun 06 |
nicklas |
62 |
} |
2422 |
26 Jun 06 |
nicklas |
63 |
else |
2422 |
26 Jun 06 |
nicklas |
64 |
{ |
2422 |
26 Jun 06 |
nicklas |
65 |
String externalId = m.group(2); |
2422 |
26 Jun 06 |
nicklas |
66 |
Help included = null; |
2422 |
26 Jun 06 |
nicklas |
67 |
try |
2422 |
26 Jun 06 |
nicklas |
68 |
{ |
2422 |
26 Jun 06 |
nicklas |
69 |
Client c = help.getClient(); |
2422 |
26 Jun 06 |
nicklas |
70 |
DbControl dc = help.getDbControl(); |
2422 |
26 Jun 06 |
nicklas |
71 |
included = c.getHelpByExternalId(dc, externalId, false); |
2422 |
26 Jun 06 |
nicklas |
72 |
} |
2422 |
26 Jun 06 |
nicklas |
73 |
catch (Throwable t) |
2422 |
26 Jun 06 |
nicklas |
74 |
{} |
2422 |
26 Jun 06 |
nicklas |
75 |
if (included != null) |
2422 |
26 Jun 06 |
nicklas |
76 |
{ |
2422 |
26 Jun 06 |
nicklas |
77 |
String includedHelp = parseTags(ID, included, includeLevel+1); |
2422 |
26 Jun 06 |
nicklas |
78 |
m.appendReplacement(sb, includedHelp); |
2422 |
26 Jun 06 |
nicklas |
79 |
} |
2422 |
26 Jun 06 |
nicklas |
80 |
} |
2422 |
26 Jun 06 |
nicklas |
81 |
} |
2422 |
26 Jun 06 |
nicklas |
82 |
else |
2422 |
26 Jun 06 |
nicklas |
83 |
{ |
2422 |
26 Jun 06 |
nicklas |
84 |
m.appendReplacement(sb, "cmd=$1, id=$2, rest=$3"); |
2422 |
26 Jun 06 |
nicklas |
85 |
} |
2422 |
26 Jun 06 |
nicklas |
86 |
} |
2422 |
26 Jun 06 |
nicklas |
87 |
m.appendTail(sb); |
2422 |
26 Jun 06 |
nicklas |
88 |
return sb.toString(); |
2422 |
26 Jun 06 |
nicklas |
89 |
} |
2422 |
26 Jun 06 |
nicklas |
90 |
%> |
2129 |
30 Mar 06 |
martin |
91 |
<% |
2129 |
30 Mar 06 |
martin |
92 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2405 |
21 Jun 06 |
nicklas |
93 |
final String ID = sc.getId(); |
2405 |
21 Jun 06 |
nicklas |
94 |
final float scale = Base.getScale(sc); |
7954 |
12 May 21 |
nicklas |
95 |
final DbControl dc = sc.newDbControl(":View help text"); |
2129 |
30 Mar 06 |
martin |
96 |
final int clientId = sc.getClientId(); |
2129 |
30 Mar 06 |
martin |
97 |
|
2129 |
30 Mar 06 |
martin |
98 |
String externalId = request.getParameter("external_id"); |
2129 |
30 Mar 06 |
martin |
99 |
|
2129 |
30 Mar 06 |
martin |
100 |
try |
2129 |
30 Mar 06 |
martin |
101 |
{ |
2129 |
30 Mar 06 |
martin |
102 |
Client c = Client.getById(dc, clientId); |
2405 |
21 Jun 06 |
nicklas |
103 |
Help help = null; |
2405 |
21 Jun 06 |
nicklas |
104 |
String title = "Help is not available"; |
2405 |
21 Jun 06 |
nicklas |
105 |
String description = null; |
2405 |
21 Jun 06 |
nicklas |
106 |
boolean writePermission = c.hasPermission(Permission.WRITE); |
2405 |
21 Jun 06 |
nicklas |
107 |
|
2405 |
21 Jun 06 |
nicklas |
108 |
try |
2405 |
21 Jun 06 |
nicklas |
109 |
{ |
2405 |
21 Jun 06 |
nicklas |
110 |
help = c.getHelpByExternalId(dc, externalId, false); |
2405 |
21 Jun 06 |
nicklas |
111 |
title = help.getName(); |
2422 |
26 Jun 06 |
nicklas |
112 |
description = parseTags(ID, help, 0); |
2405 |
21 Jun 06 |
nicklas |
113 |
writePermission = help.hasPermission(Permission.WRITE); |
2405 |
21 Jun 06 |
nicklas |
114 |
} |
2405 |
21 Jun 06 |
nicklas |
115 |
catch (ItemNotFoundException ex) |
2405 |
21 Jun 06 |
nicklas |
116 |
{} |
2129 |
30 Mar 06 |
martin |
117 |
%> |
2129 |
30 Mar 06 |
martin |
118 |
<base:page type="popup" title="Help"> |
6181 |
22 Oct 12 |
nicklas |
119 |
<base:head styles="help.css" scripts="~help.js" /> |
6520 |
18 Aug 14 |
nicklas |
120 |
<base:body data-read-only="1"> |
5907 |
13 Dec 11 |
nicklas |
121 |
<h1><%=title%></h1> |
6181 |
22 Oct 12 |
nicklas |
122 |
|
6181 |
22 Oct 12 |
nicklas |
123 |
<div id="page-data" class="datacontainer" |
6181 |
22 Oct 12 |
nicklas |
124 |
data-help-id="<%=help == null ? 0 : help.getId() %>" |
6181 |
22 Oct 12 |
nicklas |
125 |
data-external-id="<%=externalId%>" |
6181 |
22 Oct 12 |
nicklas |
126 |
data-client-id="<%=clientId%>" |
6181 |
22 Oct 12 |
nicklas |
127 |
></div> |
6181 |
22 Oct 12 |
nicklas |
128 |
|
5907 |
13 Dec 11 |
nicklas |
129 |
<div class="content bottomborder"> |
2405 |
21 Jun 06 |
nicklas |
130 |
<% |
2405 |
21 Jun 06 |
nicklas |
131 |
if (help == null || description == null) |
2405 |
21 Jun 06 |
nicklas |
132 |
{ |
2405 |
21 Jun 06 |
nicklas |
133 |
%> |
6607 |
19 Nov 14 |
nicklas |
134 |
<table class="fullcc bg-filled-50" style="border-bottom: 0px;"><tr><td> |
5907 |
13 Dec 11 |
nicklas |
135 |
<b>The help text for the section <b><%=externalId%></b> is not |
5907 |
13 Dec 11 |
nicklas |
136 |
written yet.</b> |
5907 |
13 Dec 11 |
nicklas |
137 |
</td></tr></table> |
2405 |
21 Jun 06 |
nicklas |
138 |
<% |
2405 |
21 Jun 06 |
nicklas |
139 |
} |
2405 |
21 Jun 06 |
nicklas |
140 |
else |
2405 |
21 Jun 06 |
nicklas |
141 |
{ |
2405 |
21 Jun 06 |
nicklas |
142 |
%> |
3273 |
26 Apr 07 |
nicklas |
143 |
<div class="helptext"> |
2405 |
21 Jun 06 |
nicklas |
144 |
<%=description%> |
3273 |
26 Apr 07 |
nicklas |
145 |
</div> |
2405 |
21 Jun 06 |
nicklas |
146 |
<% |
2405 |
21 Jun 06 |
nicklas |
147 |
} |
2405 |
21 Jun 06 |
nicklas |
148 |
%> |
2405 |
21 Jun 06 |
nicklas |
149 |
</div> |
5799 |
12 Oct 11 |
nicklas |
150 |
|
5907 |
13 Dec 11 |
nicklas |
151 |
<base:buttongroup subclass="dialogbuttons" > |
6181 |
22 Oct 12 |
nicklas |
152 |
<base:button |
6181 |
22 Oct 12 |
nicklas |
153 |
id="btnEdit" image="edit.png" title="Edit…" |
6181 |
22 Oct 12 |
nicklas |
154 |
visible="<%=writePermission && description != null%>" |
2405 |
21 Jun 06 |
nicklas |
155 |
tooltip="Edit this help text" /> |
6181 |
22 Oct 12 |
nicklas |
156 |
<base:button |
6400 |
27 Jan 14 |
nicklas |
157 |
id="btnNew" image="new.png" title="Create…" |
6181 |
22 Oct 12 |
nicklas |
158 |
visible="<%=writePermission && description == null%>" |
2405 |
21 Jun 06 |
nicklas |
159 |
tooltip="Create this help text" /> |
6181 |
22 Oct 12 |
nicklas |
160 |
<base:button id="btnBack" image="goback.png" title="Back" /> |
6181 |
22 Oct 12 |
nicklas |
161 |
<base:button id="close" title="Close" /> |
2405 |
21 Jun 06 |
nicklas |
162 |
</base:buttongroup> |
2129 |
30 Mar 06 |
martin |
163 |
</base:body> |
2129 |
30 Mar 06 |
martin |
164 |
</base:page> |
2129 |
30 Mar 06 |
martin |
165 |
<% |
2129 |
30 Mar 06 |
martin |
166 |
} |
2129 |
30 Mar 06 |
martin |
167 |
finally |
2129 |
30 Mar 06 |
martin |
168 |
{ |
2129 |
30 Mar 06 |
martin |
169 |
if (dc != null) dc.close(); |
2129 |
30 Mar 06 |
martin |
170 |
} |
3675 |
16 Aug 07 |
jari |
171 |
%> |