From d3ea87e5e2e09e36b16c00e5e04a842fb28a71e2 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Tue, 6 Mar 2007 13:20:00 +0000 Subject: [PATCH] Merged V2.0 to HEAD 5091: AWC-1118 5092: pooledactor assignment 5100: AWC-1133 5103: CML copy and cm:name 5106: Bubble view discussion topics 5107: AWC-1030, AWC-1137, Console buttons git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5312 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 4 + .../org/alfresco/web/bean/TrashcanBean.java | 2 +- .../alfresco/web/bean/forums/ForumsBean.java | 2 +- .../alfresco/web/bean/users/UsersBean.java | 30 +++-- .../web/ui/repo/component/UIOpenSearch.java | 41 ++++++ source/web/jsp/admin/admin-console.jsp | 14 +- source/web/scripts/ajax/opensearch.js | 124 ++++++++++++++++-- 7 files changed, 187 insertions(+), 30 deletions(-) diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 03c93f173a..4a2e5fbb53 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -1310,6 +1310,10 @@ search_in=Search In no_engines_registered=Failed to find any registered OpenSearch engines! current_repo=Current Alfresco Repository toggle_options=Toggle Options +no_results=No results +of=of +failed_gen_url=Failed to generate url for search engine '{0}'.\\n\\nThis is probably caused by missing required parameters, check the template url for the search engine. +failed_search=Failed to retrieve search results for '{0}' # UI Page Titles title_about=About Alfresco diff --git a/source/java/org/alfresco/web/bean/TrashcanBean.java b/source/java/org/alfresco/web/bean/TrashcanBean.java index 4ca163cfec..c94f6c5b93 100644 --- a/source/java/org/alfresco/web/bean/TrashcanBean.java +++ b/source/java/org/alfresco/web/bean/TrashcanBean.java @@ -1184,7 +1184,7 @@ public class TrashcanBean implements IContextListener } else { - img = Utils.getFileTypeImage(node.getName(), false); + img = Utils.getFileTypeImage(node.getName(), true); } buf.append(""); buf.append(""); diff --git a/source/java/org/alfresco/web/bean/forums/ForumsBean.java b/source/java/org/alfresco/web/bean/forums/ForumsBean.java index 925a54c6c7..19a37c1d01 100644 --- a/source/java/org/alfresco/web/bean/forums/ForumsBean.java +++ b/source/java/org/alfresco/web/bean/forums/ForumsBean.java @@ -1036,7 +1036,7 @@ public class ForumsBean implements IContextListener { ResponseWriter out = context.getResponseWriter(); - out.write(""); + out.write(""); for (Iterator i = richList.getChildren().iterator(); i.hasNext(); /**/) { // output all remaining child components that are not UIColumn diff --git a/source/java/org/alfresco/web/bean/users/UsersBean.java b/source/java/org/alfresco/web/bean/users/UsersBean.java index f87892e905..ca4a5eab14 100644 --- a/source/java/org/alfresco/web/bean/users/UsersBean.java +++ b/source/java/org/alfresco/web/bean/users/UsersBean.java @@ -30,12 +30,14 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.StringTokenizer; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; +import org.alfresco.repo.search.impl.lucene.QueryParser; import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.NodeRef; @@ -45,7 +47,6 @@ import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ISO9075; import org.alfresco.web.app.Application; import org.alfresco.web.app.context.IContextListener; import org.alfresco.web.app.context.UIContextService; @@ -441,7 +442,7 @@ public class UsersBean implements IContextListener { this.usersRichList.setValue(null); - if (this.searchCriteria == null || this.searchCriteria.length() == 0) + if (this.searchCriteria == null || this.searchCriteria.trim().length() == 0) { this.users = Collections.emptyList(); } @@ -456,21 +457,30 @@ public class UsersBean implements IContextListener tx.begin(); // define the query to find people by their first or last name - String search = ISO9075.encode(this.searchCriteria); - String query = "( TYPE:\"{http://www.alfresco.org/model/content/1.0}person\") AND " + - "((@\\{http\\://www.alfresco.org/model/content/1.0\\}firstName:" + search + - "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}lastName:" + search + - "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}userName:" + search + - "*)))"; + String search = this.searchCriteria.trim(); + StringBuilder query = new StringBuilder(256); + query.append("TYPE:\"{http://www.alfresco.org/model/content/1.0}person\" AND ("); + for (StringTokenizer t = new StringTokenizer(search, " "); t.hasMoreTokens(); /**/) + { + String term = QueryParser.escape(t.nextToken()); + query.append("((@\\{http\\://www.alfresco.org/model/content/1.0\\}firstName:*"); + query.append(term); + query.append("*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}lastName:*"); + query.append(term); + query.append("*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}userName:"); + query.append(term); + query.append("*)) "); // final space here is important as default OR separator + } + query.append(")"); if (logger.isDebugEnabled()) - logger.debug("Query: " + query); + logger.debug("Query: " + query.toString()); // define the search parameters SearchParameters params = new SearchParameters(); params.setLanguage(SearchService.LANGUAGE_LUCENE); params.addStore(Repository.getStoreRef()); - params.setQuery(query); + params.setQuery(query.toString()); List people = this.searchService.query(params).getNodeRefs(); diff --git a/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java b/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java index 62c13f002a..99d9402623 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java +++ b/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java @@ -115,6 +115,47 @@ public class UIOpenSearch extends SelfRenderingComponent out.write("', '"); out.write(engine.getUrl()); out.write("');\n"); + + // pass in NLS strings + out.write(clientId); + out.write(".setMsgNoResults(\""); + out.write(Application.getMessage(context, "no_results")); + out.write("\");\n"); + + out.write(clientId); + out.write(".setMsgOf(\""); + out.write(Application.getMessage(context, "of")); + out.write("\");\n"); + + out.write(clientId); + out.write(".setMsgFailedGenerateUrl(\""); + out.write(Application.getMessage(context, "failed_gen_url")); + out.write("\");\n"); + + out.write(clientId); + out.write(".setMsgFailedSearch(\""); + out.write(Application.getMessage(context, "failed_search")); + out.write("\");\n"); + + out.write(clientId); + out.write(".setMsgFirstPage(\""); + out.write(Application.getMessage(context, "first_page")); + out.write("\");\n"); + + out.write(clientId); + out.write(".setMsgPreviousPage(\""); + out.write(Application.getMessage(context, "prev_page")); + out.write("\");\n"); + + out.write(clientId); + out.write(".setMsgNextPage(\""); + out.write(Application.getMessage(context, "next_page")); + out.write("\");\n"); + + out.write(clientId); + out.write(".setMsgLastPage(\""); + out.write(Application.getMessage(context, "last_page")); + out.write("\");\n"); } out.write("\n"); diff --git a/source/web/jsp/admin/admin-console.jsp b/source/web/jsp/admin/admin-console.jsp index b3c1af0b40..4bf58d13d5 100644 --- a/source/web/jsp/admin/admin-console.jsp +++ b/source/web/jsp/admin/admin-console.jsp @@ -106,33 +106,33 @@ <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "ballongrey", "#EEEEEE"); %> - + - + - + - + - +
- +
- +
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "ballongrey"); %> diff --git a/source/web/scripts/ajax/opensearch.js b/source/web/scripts/ajax/opensearch.js index dae7f3f9f8..3836aeecc0 100644 --- a/source/web/scripts/ajax/opensearch.js +++ b/source/web/scripts/ajax/opensearch.js @@ -34,6 +34,7 @@ Alfresco.OpenSearchClient = function(id) this.id = id; this.engines = []; this.enginesById = []; + this.searchInProgress = false; } Alfresco.OpenSearchClient.prototype = @@ -43,6 +44,24 @@ Alfresco.OpenSearchClient.prototype = engines: null, enginesById: null, + + searchInProgress: false, + + msgNoResults: null, + + msgOf: null, + + msgFailedGenerateUrl: null, + + msgFailedSearch: null, + + msgFirstPage: null, + + msgPreviousPage: null, + + msgNextPage: null, + + msgLastPage: null, /** * Registers an OpenSearch engine to be called when performing queries @@ -54,6 +73,70 @@ Alfresco.OpenSearchClient.prototype = this.enginesById[id] = se; }, + /** + * Sets the 'No Results' message + */ + setMsgNoResults: function(msg) + { + this.msgNoResults = msg; + }, + + /** + * Sets the 'of' message + */ + setMsgOf: function(msg) + { + this.msgOf = msg; + }, + + /** + * Sets the 'Failed to generate url' message + */ + setMsgFailedGenerateUrl: function(msg) + { + this.msgFailedGenerateUrl = msg; + }, + + /** + * Sets the 'Failed to retrieve search results' message + */ + setMsgFailedSearch: function(msg) + { + this.msgFailedSearch = msg; + }, + + /** + * Sets the 'First Page' message + */ + setMsgFirstPage: function(msg) + { + this.msgFirstPage = msg; + }, + + /** + * Sets the 'Previous Page' message + */ + setMsgPreviousPage: function(msg) + { + this.msgPreviousPage = msg; + }, + + /** + * Sets the 'Next Page' message + */ + setMsgNextPage: function(msg) + { + this.msgNextPage = msg; + }, + + /** + * Sets the 'Last Page' message + */ + setMsgLastPage: function(msg) + { + this.msgLastPage = msg; + }, + /** * Handles the key press event, if ENTER is pressed execute the query */ @@ -129,8 +212,11 @@ Alfresco.OpenSearchClient.prototype = } // issue the queries if there is enough search criteria - if (term != null && term.length > 1) + if (this.searchInProgress == false && term != null && term.length > 1) { + // show that we are executing a search + this.searchInProgress = true; + // remove previous results (if necessary) var resultsPanel = document.getElementById(this.id + _RESULTS_DIV_ID_SUFFIX); if (resultsPanel != null) @@ -177,8 +263,9 @@ Alfresco.OpenSearchClient.prototype = } else { - handleErrorYahoo("Failed to generate url for search engine '" + ose.label + - "'.\n\nThis is probably caused by missing required parameters, check the template url for the search engine."); + // replace the token with the engine label + var errorMsg = this.msgFailedGenerateUrl.replace("{0}", ose.label); + handleErrorYahoo(errorMsg); } }, @@ -327,7 +414,7 @@ Alfresco.OpenSearchClient.prototype = if (results == null || results.length == 0) { - return "
No results
"; + return "
" + this.msgNoResults + "
"; } else { @@ -498,7 +585,9 @@ Alfresco.OpenSearchClient.prototype = sb[sb.length] = firstUrl; sb[sb.length] = "");'>"; + sb[sb.length] = "/images/icons/FirstPage.gif' title='"; + sb[sb.length] = this.msgFirstPage; + sb[sb.length] = "' border='0' />"; } else { @@ -519,7 +608,9 @@ Alfresco.OpenSearchClient.prototype = sb[sb.length] = previousUrl; sb[sb.length] = "");'>"; + sb[sb.length] = "/images/icons/PreviousPage.gif' title='"; + sb[sb.length] = this.msgPreviousPage; + sb[sb.length] = "' border='0' />"; } else { @@ -532,7 +623,9 @@ Alfresco.OpenSearchClient.prototype = sb[sb.length] = startIndex; sb[sb.length] = " - "; sb[sb.length] = endIndex; - sb[sb.length] = " of "; + sb[sb.length] = " "; + sb[sb.length] = this.msgOf; + sb[sb.length] = " "; sb[sb.length] = totalResults; sb[sb.length] = "  "; @@ -546,7 +639,9 @@ Alfresco.OpenSearchClient.prototype = sb[sb.length] = nextUrl; sb[sb.length] = "");'>"; + sb[sb.length] = "/images/icons/NextPage.gif' title='"; + sb[sb.length] = this.msgNextPage; + sb[sb.length] = "' border='0' />"; } else { @@ -567,7 +662,9 @@ Alfresco.OpenSearchClient.prototype = sb[sb.length] = lastUrl; sb[sb.length] = "");'>"; + sb[sb.length] = "/images/icons/LastPage.gif' title='"; + sb[sb.length] = this.msgLastPage; + sb[sb.length] = "' border='0' />"; } else { @@ -595,6 +692,11 @@ Alfresco.OpenSearchEngine.processSearchResults = function(ajaxResponse) var engineId = ajaxResponse.argument[0]; var clientInstance = ajaxResponse.argument[1]; var feed = ajaxResponse.responseXML.documentElement; + + // reset the search in progress flag, we do this on the + // first set of results as this is enough time to stop + // the double press of the enter key + clientInstance.searchInProgress = false; // if the name of the feed element is "rss", get the channel child element if (feed.tagName == "rss") @@ -674,6 +776,6 @@ Alfresco.OpenSearchEngine.handleSearchError = function(ajaxResponse) var clientInstance = ajaxResponse.argument[1]; var engineLabel = clientInstance.enginesById[engineId].label; - handleErrorYahoo("Failed to retrieve search results for '" + engineLabel + - "': " + ajaxResponse.status + " " + ajaxResponse.statusText); + var errorMsg = clientInstance.msgFailedSearch.replace("{0}", engineLabel); + handleErrorYahoo(errorMsg + ": " + ajaxResponse.status + " " + ajaxResponse.statusText); }