mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
enable tag cloud in browsing
This commit is contained in:

committed by
Ivan Masár

parent
0365b342a5
commit
15b16b0040
@@ -805,4 +805,10 @@ public final class BrowseIndex
|
|||||||
{
|
{
|
||||||
return "bi_" + Integer.toString(number);
|
return "bi_" + Integer.toString(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTagCloudEnabled() {
|
||||||
|
|
||||||
|
return ConfigurationManager.getBooleanProperty("webui.browse.index.tagcloud." + number);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -354,7 +354,7 @@ public class BrowserScope
|
|||||||
*/
|
*/
|
||||||
public void setResultsPerPage(int resultsPerPage)
|
public void setResultsPerPage(int resultsPerPage)
|
||||||
{
|
{
|
||||||
if (resultsPerPage > -1)
|
if (resultsPerPage > -1 || browseIndex.isTagCloudEnabled())
|
||||||
{
|
{
|
||||||
this.resultsPerPage = resultsPerPage;
|
this.resultsPerPage = resultsPerPage;
|
||||||
}
|
}
|
||||||
|
@@ -156,7 +156,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
query.setMaxResults(limit > 0 ? limit : 20);
|
query.setMaxResults(limit/* > 0 ? limit : 20*/);
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
query.setStart(offset);
|
query.setStart(offset);
|
||||||
@@ -254,7 +254,7 @@ public class SolrBrowseDAO implements BrowseDAO
|
|||||||
List<FacetResult> facet = resp.getFacetResult(facetField);
|
List<FacetResult> facet = resp.getFacetResult(facetField);
|
||||||
int count = doCountQuery();
|
int count = doCountQuery();
|
||||||
int start = offset > 0 ? offset : 0;
|
int start = offset > 0 ? offset : 0;
|
||||||
int max = limit > 0 ? limit : 20;
|
int max = limit > 0 ? limit : count; //if negative, return everything
|
||||||
List<String[]> result = new ArrayList<String[]>();
|
List<String[]> result = new ArrayList<String[]>();
|
||||||
if (ascending)
|
if (ascending)
|
||||||
{
|
{
|
||||||
|
@@ -165,8 +165,8 @@ public abstract class AbstractBrowserServlet extends DSpaceServlet
|
|||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if no resultsperpage set, default to 20
|
// if no resultsperpage set, default to 20 - if tag cloud enabled, leave it as is!
|
||||||
if (resultsperpage < 0)
|
if (resultsperpage < 0 && !bi.isTagCloudEnabled())
|
||||||
{
|
{
|
||||||
resultsperpage = 20;
|
resultsperpage = 20;
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,7 @@ public class TagCloudTag extends SimpleTagSupport{
|
|||||||
Map<String, Integer> data;
|
Map<String, Integer> data;
|
||||||
String index;
|
String index;
|
||||||
String scope;
|
String scope;
|
||||||
|
String type = "0"; // 0=facet, 1=browse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -77,7 +78,7 @@ public class TagCloudTag extends SimpleTagSupport{
|
|||||||
for (String subject : data.keySet()){
|
for (String subject : data.keySet()){
|
||||||
if (data.get(subject).intValue() > Integer.parseInt(parameters.getCuttingLevel())){
|
if (data.get(subject).intValue() > Integer.parseInt(parameters.getCuttingLevel())){
|
||||||
for (int i=0; i<data.get(subject).intValue(); i++){
|
for (int i=0; i<data.get(subject).intValue(); i++){
|
||||||
Tag tag2 = new Tag(subject, ((HttpServletRequest) pageContext.getRequest()).getContextPath()+(scope!=null?scope:"")+"/simple-search?filterquery="+subject+"&filtername="+index+"&filtertype=equals"); // creates a tag
|
Tag tag2 = new Tag(subject, ((HttpServletRequest) pageContext.getRequest()).getContextPath()+(scope!=null?scope:"")+(type.equals("0")?("/simple-search?filterquery="+subject+"&filtername="+index+"&filtertype=equals"):("/browse?type="+index+"&value="+subject))); // creates a tag
|
||||||
//tag2.setScore(subjects.get(subject).doubleValue());
|
//tag2.setScore(subjects.get(subject).doubleValue());
|
||||||
cloud.addTag(tag2);
|
cloud.addTag(tag2);
|
||||||
}
|
}
|
||||||
@@ -206,4 +207,8 @@ public class TagCloudTag extends SimpleTagSupport{
|
|||||||
public void setScope(String scope) {
|
public void setScope(String scope) {
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -548,6 +548,11 @@
|
|||||||
<required>true</required>
|
<required>true</required>
|
||||||
<rtexprvalue>true</rtexprvalue>
|
<rtexprvalue>true</rtexprvalue>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute>
|
||||||
|
<name>type</name>
|
||||||
|
<required>false</required>
|
||||||
|
<rtexprvalue>true</rtexprvalue>
|
||||||
|
</attribute>
|
||||||
</tag>
|
</tag>
|
||||||
|
|
||||||
<tag>
|
<tag>
|
||||||
|
@@ -123,6 +123,10 @@
|
|||||||
<fmt:message key="browse.single.header"><fmt:param value="<%= scope %>"/></fmt:message> <fmt:message key="<%= typeKey %>"/>
|
<fmt:message key="browse.single.header"><fmt:param value="<%= scope %>"/></fmt:message> <fmt:message key="<%= typeKey %>"/>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
<%
|
||||||
|
if (!bix.isTagCloudEnabled())
|
||||||
|
{
|
||||||
|
%>
|
||||||
<%-- Include the main navigation for all the browse pages --%>
|
<%-- Include the main navigation for all the browse pages --%>
|
||||||
<%-- This first part is where we render the standard bits required by both possibly navigations --%>
|
<%-- This first part is where we render the standard bits required by both possibly navigations --%>
|
||||||
<div id="browse_navigation" class="well text-center">
|
<div id="browse_navigation" class="well text-center">
|
||||||
@@ -311,5 +315,15 @@
|
|||||||
<%--
|
<%--
|
||||||
<!-- <%= bi.toString() %> -->
|
<!-- <%= bi.toString() %> -->
|
||||||
--%>
|
--%>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
%>
|
||||||
|
<div class="row" style="overflow:hidden">
|
||||||
|
<%@ include file="static-tagcloud-browse.jsp" %>
|
||||||
|
</div>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
</dspace:layout>
|
</dspace:layout>
|
||||||
|
@@ -0,0 +1,52 @@
|
|||||||
|
<%--
|
||||||
|
|
||||||
|
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/
|
||||||
|
|
||||||
|
--%>
|
||||||
|
<%--
|
||||||
|
- fragment JSP to be included in single browse gsp pages
|
||||||
|
-
|
||||||
|
--%>
|
||||||
|
|
||||||
|
<%@page import="org.dspace.content.DSpaceObject"%>
|
||||||
|
<%@ page import="java.net.URLEncoder"%>
|
||||||
|
<%@ page import="org.apache.commons.lang.StringUtils"%>
|
||||||
|
<%@ page import="java.util.HashMap"%>
|
||||||
|
<%@ page import="java.util.Map"%>
|
||||||
|
<%@ page import="org.dspace.browse.BrowseInfo" %>
|
||||||
|
<%@ page import="org.dspace.browse.BrowseIndex" %>
|
||||||
|
<%@ page import="org.dspace.core.Utils" %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
BrowseInfo bi2 = (BrowseInfo) request.getAttribute("browse.info");
|
||||||
|
BrowseIndex bix2 = bi2.getBrowseIndex();
|
||||||
|
|
||||||
|
String type2 = "1";
|
||||||
|
String index = "subject";
|
||||||
|
String scope2 = "";
|
||||||
|
DSpaceObject dso = bi2.getBrowseContainer();
|
||||||
|
if (dso!=null){
|
||||||
|
scope2 = "/handle/" + dso.getHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Integer> data = new HashMap<String, Integer>();
|
||||||
|
|
||||||
|
String[][] results2 = bi2.getStringResults();
|
||||||
|
|
||||||
|
for (int i = 0; i < results2.length; i++)
|
||||||
|
{
|
||||||
|
String value = Utils.addEntities(results2[i][0]);
|
||||||
|
int count = Integer.parseInt(results2[i][2]);
|
||||||
|
data.put(value, count);
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<div>
|
||||||
|
<dspace:tagcloud index='<%= index %>' scope='<%= scope2 %>' data='<%= data %>' type='<%= type2 %>'/><br/><br/>
|
||||||
|
</div>
|
||||||
|
<%
|
||||||
|
|
||||||
|
%>
|
@@ -1124,6 +1124,9 @@ webui.browse.index.4 = subject:metadata:dc.subject.*:text
|
|||||||
## example of authority-controlled browse category - see authority control config
|
## example of authority-controlled browse category - see authority control config
|
||||||
#webui.browse.index.5 = lcAuthor:metadataAuthority:dc.contributor.author:authority
|
#webui.browse.index.5 = lcAuthor:metadataAuthority:dc.contributor.author:authority
|
||||||
|
|
||||||
|
#Enable/Disable tag cloud in browsing. Default is false.
|
||||||
|
webui.browse.index.tagcloud.4 = true
|
||||||
|
|
||||||
# Set the options for what can be sorted by
|
# Set the options for what can be sorted by
|
||||||
#
|
#
|
||||||
# Sort options will be available when browsing a list of items (i.e. an 'item' browse,
|
# Sort options will be available when browsing a list of items (i.e. an 'item' browse,
|
||||||
|
Reference in New Issue
Block a user