From ac26ef5b64cface7d89f336a3e4788df9d536776 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Thu, 22 Nov 2007 10:22:56 +0000 Subject: [PATCH] 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 --- .../app/webui/jsptag/BrowseListTag.java | 80 ++++++++++++------- dspace/config/dspace.cfg | 23 ++++++ 2 files changed, 76 insertions(+), 27 deletions(-) diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/jsptag/BrowseListTag.java b/dspace-jspui/src/main/java/org/dspace/app/webui/jsptag/BrowseListTag.java index 18a75aa41b..e480717571 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/jsptag/BrowseListTag.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/jsptag/BrowseListTag.java @@ -40,47 +40,30 @@ package org.dspace.app.webui.jsptag; import org.apache.log4j.Logger; -import org.dspace.app.webui.util.Authenticate; import org.dspace.app.webui.util.UIUtil; - -import org.dspace.authorize.AuthorizeManager; - +import org.dspace.browse.*; import org.dspace.content.Bitstream; -import org.dspace.content.Bundle; import org.dspace.content.DCDate; import org.dspace.content.DCValue; import org.dspace.content.Item; - import org.dspace.core.ConfigurationManager; import org.dspace.core.Constants; import org.dspace.core.Context; import org.dspace.core.Utils; - 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.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.jstl.fmt.LocaleSupport; import javax.servlet.jsp.tagext.TagSupport; - -import org.dspace.browse.BrowseItem; -import org.dspace.browse.Thumbnail; -import org.dspace.browse.CrossLinks; -import org.dspace.browse.BrowseIndex; -import org.dspace.browse.BrowseException; -import org.dspace.browse.BrowseInfo; +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; /** * Tag for display a list of items @@ -157,10 +140,53 @@ public class BrowseListTag extends TagSupport */ // get the elements to display - String configLine = ConfigurationManager.getProperty("webui.itemlist.columns"); - if (configLine != null) + String browseListLine = 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 diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index f258840e62..e39a66f6c7 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -398,6 +398,29 @@ plugin.single.org.dspace.app.webui.util.StyleSelection = \ # # 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..sort..columns +# webui.itemlist.sort..columns +# webui.itemlist.browse..columns +# webui.itemlist..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. 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 ###### # # Use this to configure the browse indices. Each entry will receive a link in the