mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 05:53:08 +00:00
display item page use the same configuration then browse system
git-svn-id: http://scm.dspace.org/svn/repo/trunk@2256 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -41,6 +41,8 @@ package org.dspace.app.webui.jsptag;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.webui.util.UIUtil;
|
import org.dspace.app.webui.util.UIUtil;
|
||||||
|
import org.dspace.browse.BrowseException;
|
||||||
|
import org.dspace.browse.BrowseIndex;
|
||||||
|
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
@@ -158,11 +160,23 @@ public class ItemTag extends TagSupport
|
|||||||
/** log4j logger */
|
/** log4j logger */
|
||||||
private static Logger log = Logger.getLogger(ItemTag.class);
|
private static Logger log = Logger.getLogger(ItemTag.class);
|
||||||
|
|
||||||
|
/** Hashmap of linked metadata to browse, from dspace.cfg */
|
||||||
|
private Map<String,String> linkedMetadata;
|
||||||
|
|
||||||
public ItemTag()
|
public ItemTag()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
getThumbSettings();
|
getThumbSettings();
|
||||||
collectionStyles = null;
|
collectionStyles = null;
|
||||||
|
linkedMetadata = new HashMap<String, String>();
|
||||||
|
String linkMetadata;
|
||||||
|
for (int i = 1; null != (linkMetadata = ConfigurationManager.getProperty("webui.browse.link."+i)); i++)
|
||||||
|
{
|
||||||
|
String[] linkedMetadataSplit = linkMetadata.split(":");
|
||||||
|
String indexName = linkedMetadataSplit[0].trim();
|
||||||
|
String metadataName = linkedMetadataSplit[1].trim();
|
||||||
|
linkedMetadata.put(indexName, metadataName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int doStartTag() throws JspException
|
public int doStartTag() throws JspException
|
||||||
@@ -305,8 +319,16 @@ public class ItemTag extends TagSupport
|
|||||||
String field = st.nextToken().trim();
|
String field = st.nextToken().trim();
|
||||||
boolean isDate = false;
|
boolean isDate = false;
|
||||||
boolean isLink = false;
|
boolean isLink = false;
|
||||||
boolean isAuthor = isAuthor(field);
|
String browseIndex;
|
||||||
boolean isSubject = isSubject(field);
|
try
|
||||||
|
{
|
||||||
|
browseIndex = getBrowseField(field);
|
||||||
|
}
|
||||||
|
catch (BrowseException e)
|
||||||
|
{
|
||||||
|
log.error(e);
|
||||||
|
browseIndex = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Find out if the field should rendered as a date or link
|
// Find out if the field should rendered as a date or link
|
||||||
|
|
||||||
@@ -366,33 +388,11 @@ public class ItemTag extends TagSupport
|
|||||||
// Parse the date
|
// Parse the date
|
||||||
out.print(UIUtil.displayDate(dd, false, false, (HttpServletRequest)pageContext.getRequest()));
|
out.print(UIUtil.displayDate(dd, false, false, (HttpServletRequest)pageContext.getRequest()));
|
||||||
}
|
}
|
||||||
else if (isAuthor)
|
else if (browseIndex != null)
|
||||||
{
|
{
|
||||||
String bType = ConfigurationManager.getProperty("webui.authorlinks.browse");
|
out.print("<a href=\"" + request.getContextPath() + "/browse?type=" + browseIndex + "&value="
|
||||||
if (bType != null)
|
|
||||||
{
|
|
||||||
out.print("<a href=\"" + request.getContextPath() + "/browse?type=" + bType + "&value="
|
|
||||||
+ URLEncoder.encode(values[j].value, "UTF-8") + "\">" + Utils.addEntities(values[j].value)
|
+ URLEncoder.encode(values[j].value, "UTF-8") + "\">" + Utils.addEntities(values[j].value)
|
||||||
+ "</a>");
|
+ "</a>");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out.print(Utils.addEntities(values[j].value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (isSubject)
|
|
||||||
{
|
|
||||||
String sType = ConfigurationManager.getProperty("webui.authorlinks.browse");
|
|
||||||
if (sType != null)
|
|
||||||
{
|
|
||||||
out.print("<a href=\"" + request.getContextPath() + "/browse?type=" + sType + "&value="
|
|
||||||
+ URLEncoder.encode(values[j].value, "UTF-8") + "\">" + Utils.addEntities(values[j].value)
|
|
||||||
+ "</a>");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out.print(Utils.addEntities(values[j].value));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -912,119 +912,53 @@ public class ItemTag extends TagSupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the given field name an Author field?
|
* Return the browse index related to the field. <code>null</code> if the field is not a browse field
|
||||||
*
|
* (look for <cod>webui.browse.link.<n></code> in dspace.cfg)
|
||||||
* If undefined in dspace.cfg (webui.browse.index.author) it defaults
|
|
||||||
* to using any field containing 'creator'.
|
|
||||||
*
|
*
|
||||||
* @param field
|
* @param field
|
||||||
* @return Whether or not the given String is an author
|
* @return the browse index related to the field. Null otherwise
|
||||||
|
* @throws BrowseException
|
||||||
*/
|
*/
|
||||||
private boolean isAuthor(String field)
|
private String getBrowseField(String field) throws BrowseException
|
||||||
{
|
{
|
||||||
// Does the user want to link to authors?
|
for (String indexName : linkedMetadata.keySet())
|
||||||
if (ConfigurationManager.getBooleanProperty("webui.authorlinks.enable", true) == false)
|
|
||||||
{
|
{
|
||||||
return false;
|
StringTokenizer bw_dcf = new StringTokenizer(linkedMetadata.get(indexName), ".");
|
||||||
}
|
|
||||||
|
|
||||||
//Check whether a given metadata field should be considered an author field.
|
String[] bw_tokens = { "", "", "" };
|
||||||
String authorField = ConfigurationManager.getProperty("webui.browse.index.author");
|
int i = 0;
|
||||||
if (authorField == null)
|
while(bw_dcf.hasMoreTokens())
|
||||||
{
|
|
||||||
if (field.indexOf("contributor") > 0 || field.indexOf("creator") > 0)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StringTokenizer st = new StringTokenizer(authorField, ",");
|
|
||||||
String aField;
|
|
||||||
|
|
||||||
while (st.hasMoreTokens())
|
|
||||||
{
|
{
|
||||||
aField = st.nextToken().trim();
|
bw_tokens[i] = bw_dcf.nextToken().toLowerCase().trim();
|
||||||
// does dspace.cfg allow all qualifiers for this element?
|
i++;
|
||||||
if (aField.endsWith(".*"))
|
|
||||||
{
|
|
||||||
// does the field have a qualifier?
|
|
||||||
int i = field.lastIndexOf(".");
|
|
||||||
if (i != field.indexOf("."))
|
|
||||||
{
|
|
||||||
// lop off qualifier
|
|
||||||
field = field.substring(0, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check field against dspace.cfg
|
|
||||||
if (aField.indexOf(field) >= 0)
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
//no match found
|
String bw_schema = bw_tokens[0];
|
||||||
return false;
|
String bw_element = bw_tokens[1];
|
||||||
}
|
String bw_qualifier = bw_tokens[2];
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
StringTokenizer dcf = new StringTokenizer(field, ".");
|
||||||
* Is the given field name a Subject field?
|
|
||||||
*
|
|
||||||
* If undefined in dspace.cfg (webui.browse.index.subject) it defaults
|
|
||||||
* to using any field containing 'subject'.
|
|
||||||
*
|
|
||||||
* @param field
|
|
||||||
* @return Whether or not the given String is a subject
|
|
||||||
*/
|
|
||||||
private boolean isSubject(String field)
|
|
||||||
{
|
|
||||||
// Does the user want to link to subjects?
|
|
||||||
if (ConfigurationManager.getBooleanProperty("webui.subjectlinks.enable", false) == false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether a given metadata field should be considered a subject field
|
String[] tokens = { "", "", "" };
|
||||||
String subjectField = ConfigurationManager.getProperty("webui.browse.index.subject");
|
int j = 0;
|
||||||
|
while(dcf.hasMoreTokens())
|
||||||
if (subjectField == null)
|
|
||||||
{
|
|
||||||
if (field.indexOf("subject") > 0)
|
|
||||||
{
|
{
|
||||||
return true;
|
tokens[j] = dcf.nextToken().toLowerCase().trim();
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
else
|
String schema = tokens[0];
|
||||||
|
String element = tokens[1];
|
||||||
|
String qualifier = tokens[2];
|
||||||
|
if (schema.equals(bw_schema) // schema match
|
||||||
|
&& element.equals(bw_element) // element match
|
||||||
|
&& (
|
||||||
|
(bw_qualifier != null) && ((qualifier != null && qualifier.equals(bw_qualifier)) // both not null and equals
|
||||||
|
|| bw_qualifier.equals("*")) // browse link with jolly
|
||||||
|
|| (bw_qualifier == null && qualifier == null)) // both null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return false;
|
return indexName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
return null;
|
||||||
{
|
|
||||||
StringTokenizer st = new StringTokenizer(subjectField, ",");
|
|
||||||
String sField;
|
|
||||||
|
|
||||||
while (st.hasMoreTokens())
|
|
||||||
{
|
|
||||||
sField = st.nextToken().trim();
|
|
||||||
// does dspace.cfg allow all qualifiers for this element?
|
|
||||||
if (sField.endsWith(".*"))
|
|
||||||
{
|
|
||||||
// does the field have a qualifier?
|
|
||||||
int i = field.lastIndexOf(".");
|
|
||||||
if (i != field.indexOf("."))
|
|
||||||
{
|
|
||||||
// lop off qualifier
|
|
||||||
field = field.substring(0, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check field against dspace.cfg
|
|
||||||
if (sField.indexOf(field) >= 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//no match found
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user