Blame view

dspace-jspui/src/main/webapp/researchcenters-list.jsp 7.55 KB
496f7f86b   Tiago Guimarães   Research Centers ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
  <%--
  
      The contents of this file are subject to the license and copyright
      detailed in the LICENSE and NOTICE files at the root of the source
      tree and available online at
  
      http://www.dspace.org/license/
  
  --%>
  
  <%--
    - Display hierarchical list of communities and collections
    -
    - Attributes to be passed in:
    -    communities         - array of communities
    -    collections.map  - Map where a keys is a community IDs (Integers) and 
    -                      the value is the array of collections in that community
    -    subcommunities.map  - Map where a keys is a community IDs (Integers) and 
    -                      the value is the array of subcommunities in that community
    -    admin_button - Boolean, show admin 'Create Top-Level Community' button
    --%>
  
  <%@page import="org.dspace.content.Bitstream"%>
  <%@page import="org.apache.commons.lang.StringUtils"%>
  <%@ page contentType="text/html;charset=UTF-8" %>
  
  <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
  	
  <%@ page import="org.dspace.app.webui.servlet.admin.EditCommunitiesServlet" %>
  <%@ page import="org.dspace.app.webui.util.UIUtil" %>
  <%@ page import="org.dspace.browse.ItemCountException" %>
  <%@ page import="org.dspace.browse.ItemCounter" %>
  <%@ page import="org.dspace.content.Collection" %>
  <%@ page import="org.dspace.content.Community" %>
  <%@ page import="org.dspace.core.ConfigurationManager" %>
  <%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %>
  <%@ page import="java.io.IOException" %>
  <%@ page import="java.sql.SQLException" %>
  <%@ page import="org.dspace.handle.HandleManager" %>
  <%@ page import="org.dspace.core.Context" %>
  <%@ page import="javax.xml.bind.JAXBContext" %>
  <%@ page import="javax.xml.bind.Unmarshaller" %>
  <%@ page import="pt.uminho.sdum.researchcenters.CentersType" %>
  <%@ page import="java.io.File" %>
  <%@ page import="pt.uminho.sdum.researchcenters.CenterType" %>
  
  <%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
  
  <%
  
      boolean admin_button = false;
      ItemCounter ic = new ItemCounter(UIUtil.obtainContext(request));
  %>
  
  <%!
      void showCommunity(Community c, JspWriter out, HttpServletRequest request, ItemCounter ic)
              throws ItemCountException, IOException, SQLException
      {
  		boolean showLogos = ConfigurationManager.getBooleanProperty("jspui.community-list.logos", true);
          out.println( "<li class=\"media well\">" );
          Bitstream logo = c.getLogo();
          if (showLogos && logo != null)
          {
          	out.println("<a class=\"pull-left col-md-1\" href=\"" + request.getContextPath() + "/handle/" 
          		+ c.getHandle() + "\"><img class=\"media-object img-responsive\" src=\"" + 
          		request.getContextPath() + "/retrieve/" + logo.getID() + "\" alt=\"community logo\"></a>");
          }
  
          //FR: Change - pushed up the cols and comms
          Collection[] cols = c.getCollections();
          Community[] comms = c.getSubcommunities();
  
          if (cols != null && cols.length > 0 || (comms!= null && comms.length > 0))
          {
  
          //FR - Collapse collections 
          out.print("<span class=\"paneltitle\"><a class=\"collapsed label label-default\" href=\"javascript:void(0)\" data-toggle=\"collapse\" data-target=\"."+c.getHandle().replaceAll("(.*)/","comTop")+"\"> </a></span>");
          }
          //End Change
  
  
          out.println( "<div class=\"media-body\"><h4 class=\"media-heading\"><a href=\"" + request.getContextPath() + "/handle/" 
          	+ c.getHandle() + "\">" + c.getMetadata("name") + "</a>");
          if(ConfigurationManager.getBooleanProperty("webui.strengths.show"))
          {
              out.println(" <span class=\"badge\">" + ic.getCount(c) + "</span>");
          }
  		out.println("</h4>");
  		if (StringUtils.isNotBlank(c.getMetadata("short_description")))
  		{
  			out.println(c.getMetadata("short_description"));
  		}
  		
  
          out.println("<br>");
          // Get the collections in this community
          
          //FR: Change
          //Collection[] cols = (Collection[]) collectionMap.get(c.getID());
          if (cols != null && cols.length > 0)
          {
  
          //FR - Change
              out.println("<ul class=\""+c.getHandle().replaceAll("(.*)/","comTop")+" collapse media-list\">");
    //          out.println("<ul class=\"media-list\">");
  
  
              for (int j = 0; j < cols.length; j++)
              {
                  out.println("<li class=\"media well\">");
                  
                  Bitstream logoCol = cols[j].getLogo();
                  if (showLogos && logoCol != null)
                  {
                  	out.println("<a class=\"pull-left col-md-1\" href=\"" + request.getContextPath() + "/handle/" 
                  		+ cols[j].getHandle() + "\"><img class=\"media-object img-responsive\" src=\"" + 
                  		request.getContextPath() + "/retrieve/" + logoCol.getID() + "\" alt=\"collection logo\"></a>");
                  }
                  out.println("<div class=\"media-body\"><h4 class=\"media-heading\"><a href=\"" + request.getContextPath() + "/handle/" + cols[j].getHandle() + "\">" + cols[j].getMetadata("name") +"</a>");
  				if(ConfigurationManager.getBooleanProperty("webui.strengths.show"))
                  {
                      out.println(" [" + ic.getCount(cols[j]) + "]");
                  }
  				out.println("</h4>");
  				if (StringUtils.isNotBlank(cols[j].getMetadata("short_description")))
  				{
  					out.println(cols[j].getMetadata("short_description"));
  				}
  				out.println("</div>");
                  out.println("</li>");
              }
              out.println("</ul>");
          }
  
          // Get the sub-communities in this community
          //FR: Change - collapse
          //Community[] comms = (Community[]) subcommunityMap.get(c.getID());
          if (comms != null && comms.length > 0)
          {
              //FR Change
              out.println("<ul class=\""+c.getHandle().replaceAll("(.*)/","comTop")+" collapse media-list\" >");  
              //out.println("<ul class=\"media-list\">");
              for (int k = 0; k < comms.length; k++)
              {
                 showCommunity(comms[k], out, request, ic);
              }
              out.println("</ul>"); 
          }
          out.println("</div>");
          out.println("</li>");
      }
  %>
  
  <dspace:layout titlekey="jsp.community-list.title">
  
  <%
      if (admin_button)
      {
  %>     
  <dspace:sidebar>
  			<div class="panel panel-warning">
  			<div class="panel-heading">
  				<fmt:message key="jsp.admintools"/>
  				<span class="pull-right">
  					<dspace:popup page="<%= LocaleSupport.getLocalizedMessage(pageContext, \"help.site-admin\")%>"><fmt:message key="jsp.adminhelp"/></dspace:popup>
  				</span>
  			</div>
  			<div class="panel-body">
                  <form method="post" action="<%=request.getContextPath()%>/dspace-admin/edit-communities">
                      <input type="hidden" name="action" value="<%=EditCommunitiesServlet.START_CREATE_COMMUNITY%>" />
  					<input class="btn btn-default" type="submit" name="submit" value="<fmt:message key="jsp.community-list.create.button"/>" />
                  </form>
              </div>
  </dspace:sidebar>
  <%
      }
  %>
  	<h1><fmt:message key="jsp.community-list.title"/></h1>
  	<p><fmt:message key="jsp.community-list.text1"/></p>
  
  
      <ul class="media-list">
  <%
      Context context = UIUtil.obtainContext(request);
  
      JAXBContext jc = JAXBContext.newInstance(CentersType.class);
      Unmarshaller u = jc.createUnmarshaller();
      CentersType o =(CentersType) u.unmarshal( new File( "/dspace/config/modules/researchcenters.xml" ) );
  
  
      for (CenterType center : o.getCenter()) {
          showCommunity((Community) HandleManager.resolveToObject(context,center.getHandle()), out, request, ic);
      }
  %>
      </ul>
  
  </dspace:layout>