Add ability to customise the item list display for different browse indexes and sort options

git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2355 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2007-11-22 10:22:56 +00:00
parent a7cfd21ed1
commit ac26ef5b64
2 changed files with 76 additions and 27 deletions

View File

@@ -40,47 +40,30 @@
package org.dspace.app.webui.jsptag; package org.dspace.app.webui.jsptag;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.app.webui.util.Authenticate;
import org.dspace.app.webui.util.UIUtil; import org.dspace.app.webui.util.UIUtil;
import org.dspace.browse.*;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.content.Bitstream; import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
import org.dspace.content.DCDate; import org.dspace.content.DCDate;
import org.dspace.content.DCValue; import org.dspace.content.DCValue;
import org.dspace.content.Item; import org.dspace.content.Item;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.Utils; import org.dspace.core.Utils;
import org.dspace.storage.bitstore.BitstreamStorageManager; import org.dspace.storage.bitstore.BitstreamStorageManager;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import java.util.StringTokenizer;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.jstl.fmt.LocaleSupport; import javax.servlet.jsp.jstl.fmt.LocaleSupport;
import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.tagext.TagSupport;
import java.awt.image.BufferedImage;
import org.dspace.browse.BrowseItem; import java.io.IOException;
import org.dspace.browse.Thumbnail; import java.io.InputStream;
import org.dspace.browse.CrossLinks; import java.io.UnsupportedEncodingException;
import org.dspace.browse.BrowseIndex; import java.sql.SQLException;
import org.dspace.browse.BrowseException; import java.util.StringTokenizer;
import org.dspace.browse.BrowseInfo;
/** /**
* Tag for display a list of items * Tag for display a list of items
@@ -157,10 +140,53 @@ public class BrowseListTag extends TagSupport
*/ */
// get the elements to display // get the elements to display
String configLine = ConfigurationManager.getProperty("webui.itemlist.columns"); String browseListLine = null;
if (configLine != null)
// As different indexes / sort options may require different columns to be displayed
// try to obtain a custom configuration based for the browse that has been performed
if (browseInfo != null)
{ {
listFields = configLine; SortOption so = browseInfo.getSortOption();
BrowseIndex bix = browseInfo.getBrowseIndex();
// We have obtained the index that was used for this browse
if (bix != null)
{
// First, try to get a configuration for this browse and sort option combined
if (so != null && browseListLine == null)
browseListLine = ConfigurationManager.getProperty("webui.itemlist.browse." + bix.getName() + ".sort." + so.getName() + ".columns");
// We haven't got a sort option defined, so get one for the index
// - it may be required later
if (so == null)
so = bix.getSortOption();
}
// If no config found, attempt to get one for this sort option
if (so != null && browseListLine == null)
browseListLine = ConfigurationManager.getProperty("webui.itemlist.sort." + so.getName() + ".columns");
// If no config found, attempt to get one for this browse index
if (bix != null && browseListLine == null)
browseListLine = ConfigurationManager.getProperty("webui.itemlist.browse." + bix.getName() + ".columns");
// If no config found, attempt to get a general one, using the sort name
if (so != null && browseListLine == null)
browseListLine = ConfigurationManager.getProperty("webui.itemlist." + so.getName() + ".columns");
// If no config found, attempt to get a general one, using the index name
if (bix != null && browseListLine == null)
browseListLine = ConfigurationManager.getProperty("webui.itemlist." + bix.getName() + ".columns");
}
if (browseListLine == null)
{
browseListLine = ConfigurationManager.getProperty("webui.itemlist.columns");
}
if (browseListLine != null)
{
listFields = browseListLine;
} }
// get the date and title fields // get the date and title fields

View File

@@ -398,6 +398,29 @@ plugin.single.org.dspace.app.webui.util.StyleSelection = \
# #
# webui.itemlist.columns = dc.date.issued(date), dc.title, dc.contributor.* # webui.itemlist.columns = dc.date.issued(date), dc.title, dc.contributor.*
# Additionally, you can override the DC fields used on the listing page for
# a given browse index and/or sort option. As a sort option or index may be defined
# on a field that isn't normally included in the list, this allows you to display
# the fields that have been indexed / sorted on.
#
# There are a number of forms the configuration can take, and the order in which
# they are listed below is the priority in which they will be used (so a combination
# of an index name and sort name will take precedence over just the browse name).
#
# webui.itemlist.browse.<index name>.sort.<sort name>.columns
# webui.itemlist.sort.<sort name>.columns
# webui.itemlist.browse.<browse name>.columns
# webui.itemlist.<sort or index name>.columns
#
# In the last case, a sort option name will always take precedence over a browse
# index name. Note also, that for any additional columns you list, you will need to
# ensure there is an itemlist.<field name> entry in the messages file.
#
# The following example would display the date of accession in place of the issue date
# whenever the dateaccessioned browse index or sort option is selected.
#
# webui.itemlist.dateaccessioned.columns = dc.date.accessioned(date), dc.title, dc.contributor.*
###### Browse Configuration ###### ###### Browse Configuration ######
# #
# Use this to configure the browse indices. Each entry will receive a link in the # Use this to configure the browse indices. Each entry will receive a link in the