Permalink
Browse files

Merge pull request #49 from EKT/DS-1236

DS-1236 Auto update advance search drop down lists from configuration file

Squashed commit of the following:

commit 612ac62f740fc26cd10d8a338db3537c49b3d4bd
Author: Andrea Bollini <bollini@cilea.it>
Date:   Fri Sep 14 10:38:05 2012 +0200

    I18N fix, improved configuration and code readability

    included the default index in the configuration
    refactored the jsp to reduce code for backward compatibility
    fixed messages.properties key to use a common strategy to derive it
    from the search index

commit 81b3da2
Author: EKT <kstamatis@ekt.gr>
Date:   Fri Sep 14 08:43:33 2012 +0300

    Conflicts:
    	dspace/config/dspace.cfg
  • Loading branch information...
kstamatis authored and Andrea Bollini committed Sep 14, 2012
1 parent 7bc92a8 commit 12b4d6b296b4399f4ae707adf60e07bc08786c7e
@@ -807,12 +807,12 @@ jsp.search.advanced.title = Advanced Searc
jsp.search.advanced.type = Search type:
jsp.search.advanced.type.abstract = Abstract
jsp.search.advanced.type.author = Author
-jsp.search.advanced.type.id = Identifier
-jsp.search.advanced.type.keyword = Keyword
+jsp.search.advanced.type.identifier = Identifier
+jsp.search.advanced.type.ANY = Keyword
jsp.search.advanced.type.language = Language (ISO)
jsp.search.advanced.type.series = Series
jsp.search.advanced.type.sponsor = Sponsor
-jsp.search.advanced.type.subject = Subject
+jsp.search.advanced.type.keyword = Subject
jsp.search.advanced.type.title = Title
jsp.search.error.invalid-search-string = Invalid search string
jsp.search.error.number-format-exception = Number format exception
@@ -18,6 +18,8 @@
<%@ page import="org.apache.commons.lang.StringEscapeUtils" %>
<%@ page import="org.dspace.content.Community" %>
<%@ page import="org.dspace.search.QueryResults" %>
+<%@ page import="java.util.ArrayList" %>
+<%@ page import="org.dspace.core.ConfigurationManager" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
@@ -37,6 +39,35 @@
QueryResults qResults = (QueryResults)request.getAttribute("queryresults");
+ //Read the configuration to find out the search indices dynamically
+ int idx = 1;
+ String definition;
+ ArrayList<String> searchIndices = new ArrayList<String>();
+ int dateIndex = -1;
+ String dateIndexConfig = ConfigurationManager.getProperty("search.index.date");
+
+ while ( ((definition = ConfigurationManager.getProperty("jspui.search.index.display." + idx))) != null){
+
+ String index = definition;
+ searchIndices.add(index);
+ if (index.equals(dateIndexConfig))
+ dateIndex = idx+1;
+ idx++;
+ }
+
+ // backward compatibility
+ if (searchIndices.size() == 0)
+ {
+ searchIndices.add("ANY");
+ searchIndices.add("author");
+ searchIndices.add("title");
+ searchIndices.add("keyword");
+ searchIndices.add("abstract");
+ searchIndices.add("series");
+ searchIndices.add("sponsor");
+ searchIndices.add("identifier");
+ searchIndices.add("language");
+ }
%>
<dspace:layout locbar="nolink" titlekey="jsp.search.advanced.title">
@@ -70,15 +101,15 @@
<%-- Search type: <br> --%>
<label for="tfield1"><fmt:message key="jsp.search.advanced.type"/></label> <br/>
<select name="field1" id="tfield1">
- <option value="ANY" <%= field1.equals("ANY") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.keyword"/></option>
- <option value="author" <%= field1.equals("author") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.author"/></option>
- <option value="title" <%= field1.equals("title") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.title"/></option>
- <option value="keyword" <%= field1.equals("keyword") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.subject"/></option>
- <option value="abstract" <%= field1.equals("abstract") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.abstract"/></option>
- <option value="series" <%= field1.equals("series") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.series"/></option>
- <option value="sponsor" <%= field1.equals("sponsor") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.sponsor"/></option>
- <option value="identifier" <%= field1.equals("identifier") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.id"/></option>
- <option value="language" <%= field1.equals("language") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.language"/></option>
+ <%
+ for (String index : searchIndices)
+ {
+ String key = "jsp.search.advanced.type." + index;
+ %>
+ <option value="<%= index %>" <%= field1.equals(index) ? "selected=\"selected\"" : "" %>><fmt:message key="<%= key %>"/></option>
+ <%
+ }
+ %>
</select>
</td>
@@ -100,15 +131,15 @@
</td>
<td width="20%" align="left" valign="top" nowrap="nowrap">
<select name="field2">
- <option value="ANY" <%= field2.equals("ANY") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.keyword"/></option>
- <option value="author" <%= field2.equals("author") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.author"/></option>
- <option value="title" <%= field2.equals("title") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.title"/></option>
- <option value="keyword" <%= field2.equals("keyword") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.subject"/></option>
- <option value="abstract" <%= field2.equals("abstract") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.abstract"/></option>
- <option value="series" <%= field2.equals("series") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.series"/></option>
- <option value="sponsor" <%= field2.equals("sponsor") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.sponsor"/></option>
- <option value="identifier" <%= field2.equals("identifier") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.id"/></option>
- <option value="language" <%= field2.equals("language") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.language"/></option>
+ <%
+ for (String index : searchIndices)
+ {
+ String key = "jsp.search.advanced.type." + index;
+ %>
+ <option value="<%= index %>" <%= field2.equals(index) ? "selected=\"selected\"" : "" %>><fmt:message key="<%= key %>"/></option>
+ <%
+ }
+ %>
</select>
</td>
<td align="left" valign="top" nowrap="nowrap" width="68%">
@@ -126,15 +157,15 @@
<td width="20%" align="left" valign="top" nowrap="nowrap">
<select name="field3">
- <option value="ANY" <%= field3.equals("ANY") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.keyword"/></option>
- <option value="author" <%= field3.equals("author") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.author"/></option>
- <option value="title" <%= field3.equals("title") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.title"/></option>
- <option value="keyword" <%= field3.equals("keyword") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.subject"/></option>
- <option value="abstract" <%= field3.equals("abstract") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.abstract"/></option>
- <option value="series" <%= field3.equals("series") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.series"/></option>
- <option value="sponsor" <%= field3.equals("sponsor") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.sponsor"/></option>
- <option value="identifier" <%= field3.equals("identifier") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.id"/></option>
- <option value="language" <%= field3.equals("language") ? "selected=\"selected\"" : "" %>><fmt:message key="jsp.search.advanced.type.language"/></option>
+ <%
+ for (String index : searchIndices)
+ {
+ String key = "jsp.search.advanced.type." + index;
+ %>
+ <option value="<%= index %>" <%= field3.equals(index) ? "selected=\"selected\"" : "" %>><fmt:message key="<%= key %>"/></option>
+ <%
+ }
+ %>
</select>
<br/>
</td>
View
@@ -1569,6 +1569,19 @@ itemmap.author.index = author
# webui.mydspace.showgroupmemberships = false
+### Configure the search indices to appear in advance search drop down lists
+#
+jspui.search.index.display.1 = ANY
+jspui.search.index.display.2 = author
+jspui.search.index.display.3 = title
+jspui.search.index.display.4 = keyword
+jspui.search.index.display.5 = abstract
+jspui.search.index.display.6 = series
+jspui.search.index.display.7 = sponsor
+jspui.search.index.display.8 = identifier
+jspui.search.index.display.9 = language
+
+
##### SFX Server #####
# SFX query is appended to this URL. If this property is commented out or

0 comments on commit 12b4d6b

Please sign in to comment.