mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +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.dspace.app.webui.util.UIUtil;
|
||||
import org.dspace.browse.BrowseException;
|
||||
import org.dspace.browse.BrowseIndex;
|
||||
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
@@ -158,11 +160,23 @@ public class ItemTag extends TagSupport
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(ItemTag.class);
|
||||
|
||||
/** Hashmap of linked metadata to browse, from dspace.cfg */
|
||||
private Map<String,String> linkedMetadata;
|
||||
|
||||
public ItemTag()
|
||||
{
|
||||
super();
|
||||
getThumbSettings();
|
||||
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
|
||||
@@ -305,8 +319,16 @@ public class ItemTag extends TagSupport
|
||||
String field = st.nextToken().trim();
|
||||
boolean isDate = false;
|
||||
boolean isLink = false;
|
||||
boolean isAuthor = isAuthor(field);
|
||||
boolean isSubject = isSubject(field);
|
||||
String browseIndex;
|
||||
try
|
||||
{
|
||||
browseIndex = getBrowseField(field);
|
||||
}
|
||||
catch (BrowseException e)
|
||||
{
|
||||
log.error(e);
|
||||
browseIndex = null;
|
||||
}
|
||||
|
||||
// Find out if the field should rendered as a date or link
|
||||
|
||||
@@ -366,33 +388,11 @@ public class ItemTag extends TagSupport
|
||||
// Parse the date
|
||||
out.print(UIUtil.displayDate(dd, false, false, (HttpServletRequest)pageContext.getRequest()));
|
||||
}
|
||||
else if (isAuthor)
|
||||
else if (browseIndex != null)
|
||||
{
|
||||
String bType = ConfigurationManager.getProperty("webui.authorlinks.browse");
|
||||
if (bType != null)
|
||||
{
|
||||
out.print("<a href=\"" + request.getContextPath() + "/browse?type=" + bType + "&value="
|
||||
out.print("<a href=\"" + request.getContextPath() + "/browse?type=" + browseIndex + "&value="
|
||||
+ URLEncoder.encode(values[j].value, "UTF-8") + "\">" + Utils.addEntities(values[j].value)
|
||||
+ "</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
|
||||
{
|
||||
@@ -912,119 +912,53 @@ public class ItemTag extends TagSupport
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given field name an Author field?
|
||||
*
|
||||
* If undefined in dspace.cfg (webui.browse.index.author) it defaults
|
||||
* to using any field containing 'creator'.
|
||||
* 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)
|
||||
*
|
||||
* @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?
|
||||
if (ConfigurationManager.getBooleanProperty("webui.authorlinks.enable", true) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check whether a given metadata field should be considered an author field.
|
||||
String authorField = ConfigurationManager.getProperty("webui.browse.index.author");
|
||||
if (authorField == null)
|
||||
{
|
||||
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();
|
||||
// does dspace.cfg allow all qualifiers for this element?
|
||||
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
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 subjectField = ConfigurationManager.getProperty("webui.browse.index.subject");
|
||||
|
||||
if (subjectField == null)
|
||||
{
|
||||
if (field.indexOf("subject") > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(subjectField, ",");
|
||||
String sField;
|
||||
for (String indexName : linkedMetadata.keySet())
|
||||
{
|
||||
StringTokenizer bw_dcf = new StringTokenizer(linkedMetadata.get(indexName), ".");
|
||||
|
||||
while (st.hasMoreTokens())
|
||||
String[] bw_tokens = { "", "", "" };
|
||||
int i = 0;
|
||||
while(bw_dcf.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;
|
||||
}
|
||||
bw_tokens[i] = bw_dcf.nextToken().toLowerCase().trim();
|
||||
i++;
|
||||
}
|
||||
String bw_schema = bw_tokens[0];
|
||||
String bw_element = bw_tokens[1];
|
||||
String bw_qualifier = bw_tokens[2];
|
||||
|
||||
//no match found
|
||||
return false;
|
||||
StringTokenizer dcf = new StringTokenizer(field, ".");
|
||||
|
||||
String[] tokens = { "", "", "" };
|
||||
int j = 0;
|
||||
while(dcf.hasMoreTokens())
|
||||
{
|
||||
tokens[j] = dcf.nextToken().toLowerCase().trim();
|
||||
j++;
|
||||
}
|
||||
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 indexName;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user