1 | <%-- $Id: news.jsp 6177 2012-10-22 07:25:58Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Gregory Vincic |
---|
5 | |
---|
6 | This file is part of BASE - BioArray Software Environment. |
---|
7 | Available at http://base.thep.lu.se/ |
---|
8 | |
---|
9 | BASE is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 3 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | BASE is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | ------------------------------------------------------------------ |
---|
22 | |
---|
23 | This page lists all news in case they are too many to be shown |
---|
24 | on the fron page. |
---|
25 | |
---|
26 | @author Nicklas |
---|
27 | @version 2.0 |
---|
28 | --%> |
---|
29 | <%@ page pageEncoding="UTF-8" session="false" |
---|
30 | import="net.sf.basedb.core.SessionControl" |
---|
31 | import="net.sf.basedb.core.DbControl" |
---|
32 | import="net.sf.basedb.core.News" |
---|
33 | import="net.sf.basedb.core.ItemQuery" |
---|
34 | import="net.sf.basedb.core.ItemResultList" |
---|
35 | import="net.sf.basedb.core.query.Orders" |
---|
36 | import="net.sf.basedb.core.query.Hql" |
---|
37 | import="net.sf.basedb.core.query.Expressions" |
---|
38 | import="net.sf.basedb.clients.web.Base" |
---|
39 | import="net.sf.basedb.clients.web.util.HTML" |
---|
40 | import="net.sf.basedb.util.Values" |
---|
41 | import="net.sf.basedb.util.formatter.Formatter" |
---|
42 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
43 | import="net.sf.basedb.clients.web.servlet.RssNewsFeed" |
---|
44 | import="java.util.Date" |
---|
45 | %> |
---|
46 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
47 | <% |
---|
48 | final SessionControl sc = Base.getSessionControl(pageContext, true); |
---|
49 | final String ID = sc.getId(); |
---|
50 | final DbControl dc = sc.newDbControl(); |
---|
51 | final String root = request.getContextPath()+"/"; |
---|
52 | ItemResultList<News> news = null; |
---|
53 | String broadcastTitle = (String)application.getAttribute("broadcast.title"); |
---|
54 | String broadcastMessage = (String)application.getAttribute("broadcast.message"); |
---|
55 | boolean denyLogin = Boolean.TRUE.equals(application.getAttribute("broadcast.deny-login")); |
---|
56 | |
---|
57 | try |
---|
58 | { |
---|
59 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
60 | %> |
---|
61 | <base:page type="default" title=""> |
---|
62 | <base:head styles="login.css" /> |
---|
63 | <base:body style="padding-top: 5em;"> |
---|
64 | |
---|
65 | <table style="margin: auto; width: 600px;"> |
---|
66 | <tr><td><base:icon image="goback.png" /><a href="<%=root%>main.jsp?ID=<%=ID%>">Back to login</a></td></tr> |
---|
67 | <tr> |
---|
68 | <td> |
---|
69 | <h3 style="margin-top: 1em;">News and announcements |
---|
70 | <% |
---|
71 | if (RssNewsFeed.isEnabled()) |
---|
72 | { |
---|
73 | %> |
---|
74 | <a href="info/news.rss" |
---|
75 | title="Subscribe to news from this BASE server" |
---|
76 | ><base:icon image="rss.png" style="float: right; margin-top: 1px;"/></a> |
---|
77 | <% |
---|
78 | } |
---|
79 | %> |
---|
80 | </h3> |
---|
81 | <div id="news" class="news"> |
---|
82 | <% |
---|
83 | if (broadcastTitle != null) |
---|
84 | { |
---|
85 | %> |
---|
86 | <div class="item"> |
---|
87 | <div class="headline"> |
---|
88 | <base:icon image="warning.png" /> |
---|
89 | <a name="broadcast"></a> |
---|
90 | <span class="date"><%=dateFormatter.format(new Date())%></span> |
---|
91 | <%=HTML.encodeTags(broadcastTitle)%><%=denyLogin ? " (login disabled)" : "" %> |
---|
92 | </div> |
---|
93 | <div class="text"><%=HTML.niceFormat(broadcastMessage)%></div> |
---|
94 | </div> |
---|
95 | <% |
---|
96 | } |
---|
97 | ItemQuery<News> query = News.getQuery(); |
---|
98 | query.order(Orders.desc(Hql.property("newsDate"))); |
---|
99 | query.order(Orders.desc(Hql.property("id"))); |
---|
100 | query.setCacheResult(true); |
---|
101 | news = query.list(dc); |
---|
102 | for (News n : news) |
---|
103 | { |
---|
104 | %> |
---|
105 | <div class="item"> |
---|
106 | <div class="headline"> |
---|
107 | <a name="<%=n.getId() + "-" + n.getVersion()%>"></a> |
---|
108 | <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span> |
---|
109 | <%=HTML.encodeTags(n.getName())%> |
---|
110 | </div> |
---|
111 | <div class="text"><%=Values.getString(n.getDescription())%></div> |
---|
112 | </div> |
---|
113 | <% |
---|
114 | } |
---|
115 | %> |
---|
116 | </div> |
---|
117 | </td> |
---|
118 | </tr> |
---|
119 | <tr><td><base:icon image="goback.png" /><a href="<%=root%>main.jsp?ID=<%=ID%>">Back to login</a></td></tr> |
---|
120 | </table> |
---|
121 | </base:body> |
---|
122 | </base:page> |
---|
123 | <% |
---|
124 | } |
---|
125 | finally |
---|
126 | { |
---|
127 | if (dc != null) dc.close(); |
---|
128 | } |
---|
129 | %> |
---|
130 | |
---|