Commit aaf587f9fba5b5ea0629c02ffb3ef4987e7b7055

Authored by Tiago Guimarães
1 parent cb0f044f52
Exists in researchcenters

initial test

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