source: trunk/www/admin/news/view_news.jsp @ 5937

Last change on this file since 5937 was 5937, checked in by Nicklas Nordborg, 10 years ago

References #1655: GUI improvements

  • Fixes rest of view pages in biomaterials menu.
  • Use SVG filter to make disabled button images grayscale.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.5 KB
Line 
1<%-- $Id: view_news.jsp 5937 2012-01-27 11:00:26Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.0
24--%>
25<%@ page pageEncoding="UTF-8" session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.SystemItems"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.ItemContext"
31  import="net.sf.basedb.core.Permission"
32  import="net.sf.basedb.core.News"
33  import="net.sf.basedb.core.PermissionDeniedException"
34  import="net.sf.basedb.core.PluginDefinition"
35  import="net.sf.basedb.core.plugin.GuiContext"
36  import="net.sf.basedb.core.plugin.Plugin"
37  import="net.sf.basedb.clients.web.Base"
38  import="net.sf.basedb.clients.web.PermissionUtil"
39  import="net.sf.basedb.clients.web.util.HTML"
40  import="net.sf.basedb.util.formatter.Formatter"
41  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
42  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
43  import="net.sf.basedb.clients.web.extensions.JspContext"
44  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
45  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
46  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
47  import="net.sf.basedb.util.Values"
48  import="java.util.Map"
49  import="java.util.Date"
50%>
51<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
52<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
53<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
54<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
55<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
56<%!
57  private static final Item itemType = Item.NEWS;
58  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
59%>
60<%
61final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
62final String ID = sc.getId();
63final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
64final int itemId = cc.getId();
65final float scale = Base.getScale(sc);
66final DbControl dc = sc.newDbControl();
67try
68{
69  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
70
71  String title = null;
72  News news = News.getById(dc, itemId);
73 
74  final boolean writePermission = news.hasPermission(Permission.WRITE);
75  final boolean deletePermission = news.hasPermission(Permission.DELETE);
76  final boolean isRemoved = news.isRemoved();
77  final boolean isUsed = isRemoved && news.isUsed();
78  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
79  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
80  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, news);
81  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
82  %>
83  <base:page title="<%=title%>">
84  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
85    <ext:scripts context="<%=jspContext%>" />
86    <ext:stylesheets context="<%=jspContext%>" />
87    <script language="JavaScript">
88    function editItem()
89    {
90      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
91    }
92    function deleteItem()
93    {
94      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
95    }
96    function restoreItem()
97    {
98      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
99    }
100    function deleteItemPermanently()
101    {
102      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
103    }
104    function itemDeleted()
105    {
106      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
107    }
108    function showUsingItems()
109    {
110      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
111    }
112    function runPlugin(cmd)
113    {
114      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
115    }
116    </script>
117  </base:head>
118  <base:body>
119    <p>
120    <p:path>
121      <p:pathelement title="News" href="<%="index.jsp?ID="+ID%>" />
122      <p:pathelement title="<%=HTML.encodeTags(news.getName())%>" />
123    </p:path>
124   
125    <t:tabcontrol id="main" active="properties">
126    <t:tab id="properties" title="Properties">
127   
128    <tbl:toolbar
129      >
130      <tbl:button 
131        disabled="<%=writePermission ? false : true%>" 
132        image="edit.gif" 
133        onclick="editItem()" 
134        title="Edit&hellip;" 
135        tooltip="<%=writePermission ? "Edit this news" : "You do not have permission to edit news"%>" 
136      />
137      <tbl:button 
138        disabled="<%=deletePermission ? false : true%>" 
139        image="delete.gif" 
140        onclick="deleteItem()" 
141        title="Delete"
142        visible="<%=!news.isRemoved()%>"
143        tooltip="<%=deletePermission ? "Delete this news" : "You do not have permission to delete this news"%>" 
144      />
145      <tbl:button 
146        disabled="<%=writePermission ? false : true%>" 
147        image="restore.gif" 
148        onclick="restoreItem()" 
149        title="Restore"
150        visible="<%=news.isRemoved()%>"
151        tooltip="<%=writePermission ? "Restore this news" : "You do not have permission to restore this news"%>" 
152      />
153      <tbl:button 
154        image="import.gif" 
155        onclick="runPlugin('ImportItem')" 
156        title="Import&hellip;" 
157        tooltip="Import data" 
158        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
159      />
160      <tbl:button 
161        image="export.gif" 
162        onclick="runPlugin('ExportItem')" 
163        title="Export&hellip;" 
164        tooltip="Export data" 
165        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
166      />
167      <tbl:button 
168        image="runplugin.gif" 
169        onclick="runPlugin('RunPlugin')" 
170        title="Run plugin&hellip;" 
171        tooltip="Run a plugin" 
172        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
173      />
174      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
175        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
176      <tbl:button
177        image="help.png"
178        onclick="<%="Main.openHelp('" + ID +"', 'news.view.properties')"%>"
179        title="Help&hellip;"
180        tooltip="Get help about this page"
181      />
182      </tbl:toolbar>
183    <div class="boxedbottom">
184      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(news)%></i></div>
185      <%
186      if (news.isRemoved())
187      {
188        %>
189        <div class="itemstatus">
190          <base:icon 
191            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
192            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
193            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
194            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
195          <base:icon image="used.gif" 
196            onclick="showUsingItems()"
197            tooltip="Show the items that are using this one"
198            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
199        </div>
200        <%
201      }
202      %>
203      <table class="form" cellspacing=0>
204      <tr>
205        <td class="prompt">Name</td>
206        <td><%=HTML.encodeTags(news.getName())%></td>
207      </tr>
208      <tr>
209        <td class="prompt">Registered</td>
210        <td><%=dateFormatter.format(news.getEntryDate())%></td>
211      </tr>
212      <tr>
213        <td class="prompt">Start date</td>
214        <td><%=dateFormatter.format(news.getStartDate())%></td>
215      </tr>
216      <tr>
217        <td class="prompt">News date</td>
218        <td><%=dateFormatter.format(news.getNewsDate())%></td>
219      </tr>
220      <tr>
221        <td class="prompt">End date</td>
222        <td><%=dateFormatter.format(news.getEndDate())%></td>
223      </tr>
224      <tr >
225        <td class="prompt">Description</td>
226        <td><%=HTML.niceFormat(news.getDescription())%></td>
227      </tr>
228      </table>
229      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
230        <jsp:param name="ID" value="<%=ID%>" />
231        <jsp:param name="item_type" value="<%=itemType.name()%>" />
232        <jsp:param name="item_id" value="<%=itemId%>" />
233        <jsp:param name="title" value="Other items related to this news" />
234      </jsp:include>
235     
236    </div>
237      </t:tab>
238      </t:tabcontrol>
239
240  </base:body>
241  </base:page>
242  <%
243}
244finally
245{
246  if (dc != null) dc.close();
247}
248
249%>
Note: See TracBrowser for help on using the repository browser.