diff --git a/foreign dlls/UmbracoExamine.Providers.dll b/foreign dlls/UmbracoExamine.Providers.dll index 7065a67da5..889eaaceea 100644 Binary files a/foreign dlls/UmbracoExamine.Providers.dll and b/foreign dlls/UmbracoExamine.Providers.dll differ diff --git a/umbraco.sln b/umbraco.sln index fb743e4cb7..66cf007a64 100644 --- a/umbraco.sln +++ b/umbraco.sln @@ -24,6 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution umbraco weekly.build = umbraco weekly.build umbraco.build = umbraco.build foreign dlls\umbraco.Linq.DTMetal.Engine.dll = foreign dlls\umbraco.Linq.DTMetal.Engine.dll + foreign dlls\UmbracoExamine.Core.dll = foreign dlls\UmbracoExamine.Core.dll + foreign dlls\UmbracoExamine.Providers.dll = foreign dlls\UmbracoExamine.Providers.dll foreign dlls\UrlRewritingNet.UrlRewriter.dll = foreign dlls\UrlRewritingNet.UrlRewriter.dll foreign dlls\VistaDB.NET20.dll = foreign dlls\VistaDB.NET20.dll EndProjectSection diff --git a/umbraco/presentation/config/ClientDependency.config b/umbraco/presentation/config/ClientDependency.config index 34b1ff607f..ec9b176afc 100644 --- a/umbraco/presentation/config/ClientDependency.config +++ b/umbraco/presentation/config/ClientDependency.config @@ -1,4 +1,4 @@ - + diff --git a/umbraco/presentation/config/ExamineSettings.config b/umbraco/presentation/config/ExamineSettings.config index 4e47a58acc..85c2382884 100644 --- a/umbraco/presentation/config/ExamineSettings.config +++ b/umbraco/presentation/config/ExamineSettings.config @@ -6,15 +6,16 @@ Index sets can be defined in the ExamineIndex.config if you're using the standar More information and documentation can be found on CodePlex: http://umbracoexamine.codeplex.com --> - - + + supportUnpublished="true" + analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/> + diff --git a/umbraco/presentation/umbraco/Search/QuickSearchHandler.ashx.cs b/umbraco/presentation/umbraco/Search/QuickSearchHandler.ashx.cs index 940c34f583..fa937520c2 100644 --- a/umbraco/presentation/umbraco/Search/QuickSearchHandler.ashx.cs +++ b/umbraco/presentation/umbraco/Search/QuickSearchHandler.ashx.cs @@ -22,17 +22,46 @@ namespace umbraco.presentation.umbraco.Search public void ProcessRequest(HttpContext context) { + Authorize(); + context.Response.ContentType = "application/json"; + + var txt = UmbracoContext.Current.Request["q"]; + + //the app can be Content or Media only, otherwise an exception will be thrown + var app = "Content"; + if (!string.IsNullOrEmpty(UmbracoContext.Current.Request["app"])) + { + app = UmbracoContext.Current.Request["app"]; + } + IndexType indexType = (IndexType)Enum.Parse(typeof(IndexType), app); + int limit = 100; + int.TryParse(UmbracoContext.Current.Request["limit"], out limit); + + //if it doesn't start with "*", then search only nodeName and nodeId + var criteria = new SearchCriteria(txt + , txt.StartsWith("*") ? new string[] { } : new string[] { "nodeName", "id" } + , new string[] { } + , false + , UmbracoContext.Current.UmbracoUser.StartNodeId > 0 ? (int?)UmbracoContext.Current.UmbracoUser.StartNodeId : null + , limit + , indexType + , false); IEnumerable results = ExamineManager.Instance .SearchProviderCollection["InternalSearch"] - .Search(UmbracoContext.Current.Request["q"], 20, false); + .Search(criteria); JavaScriptSerializer js = new JavaScriptSerializer(); context.Response.Write(js.Serialize(results)); } + public static void Authorize() + { + if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID)) + throw new Exception("Client authorization failed. User is not logged in"); + } public bool IsReusable { diff --git a/umbraco/presentation/umbraco/Search/quickSearch.js b/umbraco/presentation/umbraco/Search/quickSearch.js index e267f579c0..4c55669f4b 100644 --- a/umbraco/presentation/umbraco/Search/quickSearch.js +++ b/umbraco/presentation/umbraco/Search/quickSearch.js @@ -1,6 +1,13 @@ (function($) { - + $.fn.UmbQuickSearch = function(url) { + + var getSearchApp = function() { + return (UmbClientMgr.mainWindow().location.hash != "" && UmbClientMgr.mainWindow().location.hash.toLowerCase().substring(1)) == "media".toLowerCase() + ? "Media" + : "Content"; + }; + var acOptions = { minChars: 2, max: 100, @@ -8,6 +15,15 @@ dataType: 'json', matchCase: true, matchContains: false, + extraParams: { + //return the current app, if it's not media, then it's Content as this is the only searches that are supported. + app: function() { + return getSearchApp(); + }, + rnd: function() { + return Umbraco.Utils.generateRandom(); + } + }, parse: function(data) { var parsed = []; //data = data.results; @@ -25,8 +41,8 @@ formatItem: function(item) { return item.Fields.nodeName + " (" + item.Id + ")"; } - }; - + }; + $(this) .autocomplete(url, acOptions) .result(function(e, data) { @@ -42,6 +58,14 @@ $(this).blur(function() { $(this).val(UmbClientMgr.uiKeys()["general_typeToSearch"]); }); + + $(this).keyup(function(e) { + if (e.keyCode == 13) { + + UmbClientMgr.openModalWindow('dialogs/search.aspx?rndo=' + Umbraco.Utils.generateRandom() + '&search=' + jQuery(this).val() + '&app=' + getSearchApp(), 'Search', true, 620, 470); + return false; + } + }); } - + })(jQuery); \ No newline at end of file diff --git a/umbraco/presentation/umbraco/dialogs/search.aspx.cs b/umbraco/presentation/umbraco/dialogs/search.aspx.cs index e6b4a53d41..c49c100355 100644 --- a/umbraco/presentation/umbraco/dialogs/search.aspx.cs +++ b/umbraco/presentation/umbraco/dialogs/search.aspx.cs @@ -35,9 +35,27 @@ namespace umbraco.presentation.dialogs { string query = keyword.Text; + //the app can be Content or Media only, otherwise an exception will be thrown + var app = "Content"; + if (!string.IsNullOrEmpty(UmbracoContext.Current.Request["app"])) + { + app = UmbracoContext.Current.Request["app"]; + } + IndexType indexType = (IndexType)Enum.Parse(typeof(IndexType), app); + + //if it doesn't start with "*", then search only nodeName and nodeId + var criteria = new SearchCriteria(query + , query.StartsWith("*") ? new string[] { } : new string[] { "nodeName", "id" } + , new string[] { } + , false + , UmbracoContext.Current.UmbracoUser.StartNodeId > 0 ? (int?)UmbracoContext.Current.UmbracoUser.StartNodeId : null + , 100 + , indexType + , false); + var results = ExamineManager.Instance .SearchProviderCollection["InternalSearch"] - .Search(query, 100, false); + .Search(criteria); searchResult.XPathNavigator = ResultsAsXml(results).CreateNavigator(); } diff --git a/umbraco/presentation/umbraco/umbraco.aspx b/umbraco/presentation/umbraco/umbraco.aspx index 7aadcdffb5..37624b8896 100644 --- a/umbraco/presentation/umbraco/umbraco.aspx +++ b/umbraco/presentation/umbraco/umbraco.aspx @@ -57,9 +57,7 @@
-
-
diff --git a/umbraco/presentation/umbraco/webService.asmx.cs b/umbraco/presentation/umbraco/webService.asmx.cs index 70639a2a06..ab647dfbb0 100644 --- a/umbraco/presentation/umbraco/webService.asmx.cs +++ b/umbraco/presentation/umbraco/webService.asmx.cs @@ -12,131 +12,138 @@ using System.Collections.Generic; namespace umbraco { - /// - /// Summary description for webService. - /// - /// + /// + /// Summary description for webService. + /// + /// - [WebService(Namespace="http://umbraco.org/webservices/")] - public class webService : System.Web.Services.WebService - { - public webService() - { - //CODEGEN: This call is required by the ASP.NET Web Services Designer - InitializeComponent(); - } + [WebService(Namespace = "http://umbraco.org/webservices/")] + public class webService : System.Web.Services.WebService + { + public webService() + { + //CODEGEN: This call is required by the ASP.NET Web Services Designer + InitializeComponent(); + } - [WebMethod] - public XmlNode GetNode(int NodeId, string ContextID) - { - XmlDocument xd = new XmlDocument(); - if (BasePages.BasePage.ValidateUserContextID(ContextID)) - { - return new cms.businesslogic.CMSNode(NodeId).ToXml(xd, false); - } - else - return null; - } + [WebMethod] + public XmlNode GetNode(int NodeId, string ContextID) + { + XmlDocument xd = new XmlDocument(); + if (BasePages.BasePage.ValidateUserContextID(ContextID)) + { + return new cms.businesslogic.CMSNode(NodeId).ToXml(xd, false); + } + else + return null; + } - [WebMethod] - public XmlNode GetNodeValidate(int NodeId, string Login, string Password) - { - XmlDocument xd = new XmlDocument(); - if (BusinessLogic.User.validateCredentials(Login, Password)) - { - return new cms.businesslogic.CMSNode(NodeId).ToXml(xd, false); - } - else - return null; - } + [WebMethod] + public XmlNode GetNodeValidate(int NodeId, string Login, string Password) + { + XmlDocument xd = new XmlDocument(); + if (BusinessLogic.User.validateCredentials(Login, Password)) + { + return new cms.businesslogic.CMSNode(NodeId).ToXml(xd, false); + } + else + return null; + } - [WebMethod] - public XmlNode GetDocument(int NodeId, string ContextID) - { - XmlDocument xd = new XmlDocument(); - if (BasePages.BasePage.ValidateUserContextID(ContextID)) - { - return new cms.businesslogic.web.Document(NodeId).ToXml(xd, false); - } - else - return null; - } + [WebMethod] + public XmlNode GetDocument(int NodeId, string ContextID) + { + XmlDocument xd = new XmlDocument(); + if (BasePages.BasePage.ValidateUserContextID(ContextID)) + { + return new cms.businesslogic.web.Document(NodeId).ToXml(xd, false); + } + else + return null; + } - [WebMethod] - public XmlNode GetMedia(int NodeId, string ContextID) - { - XmlDocument xd = new XmlDocument(); - if (BasePages.BasePage.ValidateUserContextID(ContextID)) - { - return new cms.businesslogic.media.Media(NodeId).ToXml(xd, false); - } - else - return null; - } + [WebMethod] + public XmlNode GetMedia(int NodeId, string ContextID) + { + XmlDocument xd = new XmlDocument(); + if (BasePages.BasePage.ValidateUserContextID(ContextID)) + { + return new cms.businesslogic.media.Media(NodeId).ToXml(xd, false); + } + else + return null; + } - [WebMethod] - public XmlNode GetMediaValidate(int NodeId, string Login, string Password) - { - XmlDocument xd = new XmlDocument(); - if (BusinessLogic.User.validateCredentials(Login, Password)) - { - return new cms.businesslogic.media.Media(NodeId).ToXml(xd, false); - } - else - return null; - } + [WebMethod] + public XmlNode GetMediaValidate(int NodeId, string Login, string Password) + { + XmlDocument xd = new XmlDocument(); + if (BusinessLogic.User.validateCredentials(Login, Password)) + { + return new cms.businesslogic.media.Media(NodeId).ToXml(xd, false); + } + else + return null; + } - [WebMethod] - public XmlNode GetDocumentValidate(int NodeId, string Login, string Password) - { - XmlDocument xd = new XmlDocument(); - if (BusinessLogic.User.validateCredentials(Login, Password)) - { - return new cms.businesslogic.web.Document(NodeId).ToXml(xd, false); - } - else - return null; - } + [WebMethod] + public XmlNode GetDocumentValidate(int NodeId, string Login, string Password) + { + XmlDocument xd = new XmlDocument(); + if (BusinessLogic.User.validateCredentials(Login, Password)) + { + return new cms.businesslogic.web.Document(NodeId).ToXml(xd, false); + } + else + return null; + } - [WebMethod] - public XmlNode GetDocumentsBySearchValidate(string Query, int StartNodeId, string Login, string Password) - { - XmlDocument xd = new XmlDocument(); - if (BusinessLogic.User.validateCredentials(Login, Password)) - { - return doQuery(Query, xd, StartNodeId); - } - else - { - XmlNode result = xd.CreateNode(XmlNodeType.Element, "error", ""); - result.AppendChild(xmlHelper.addTextNode(xd, "error", "Not a valid login")); - return result; - } - } + [WebMethod] + public XmlNode GetDocumentsBySearchValidate(string Query, int StartNodeId, string Login, string Password) + { + XmlDocument xd = new XmlDocument(); + if (BusinessLogic.User.validateCredentials(Login, Password)) + { + return doQuery(Query, xd, StartNodeId); + } + else + { + XmlNode result = xd.CreateNode(XmlNodeType.Element, "error", ""); + result.AppendChild(xmlHelper.addTextNode(xd, "error", "Not a valid login")); + return result; + } + } - [WebMethod] - public XmlNode GetDocumentsBySearch(string Query, int StartNodeId, string ContextID) - { - XmlDocument xd = new XmlDocument(); - if (BasePages.BasePage.ValidateUserContextID(ContextID)) - { - return doQuery(Query, xd, StartNodeId); - } - else - { - XmlNode result = xd.CreateNode(XmlNodeType.Element, "error", ""); - result.AppendChild(xmlHelper.addTextNode(xd, "error", "Not a valid login")); - return result; - } -} + [WebMethod] + public XmlNode GetDocumentsBySearch(string Query, int StartNodeId, string ContextID) + { + XmlDocument xd = new XmlDocument(); + if (BasePages.BasePage.ValidateUserContextID(ContextID)) + { + return doQuery(Query, xd, StartNodeId); + } + else + { + XmlNode result = xd.CreateNode(XmlNodeType.Element, "error", ""); + result.AppendChild(xmlHelper.addTextNode(xd, "error", "Not a valid login")); + return result; + } + } + + private XmlNode doQuery(string Query, XmlDocument xd, int StartNodeId) + { + XmlNode result = xd.CreateNode(XmlNodeType.Element, "documents", ""); + try + { + //if the query starts with "*" then query all fields + var criteria = new SearchCriteria(Query + , Query.StartsWith("*") ? new string[] { } : new string[] { "nodeName", "id" } + , new string[] { } + , false + , StartNodeId > 0 ? (int?)StartNodeId : null + , 20); - private XmlNode doQuery(string Query, XmlDocument xd, int StartNodeId) - { - XmlNode result = xd.CreateNode(XmlNodeType.Element, "documents", ""); - try - { - var criteria = new SearchCriteria(Query, new string[] { }, new string[] { }, false, StartNodeId > 0 ? (int?)StartNodeId : null, 20); IEnumerable results = ExamineManager.Instance .SearchProviderCollection["InternalSearch"] .Search(criteria); @@ -148,43 +155,43 @@ namespace umbraco x.SetAttribute("nodeName", r.Fields["nodeName"]); result.AppendChild(x); } - } - catch (Exception ee) - { - XmlElement x = xd.CreateElement("document"); - x.SetAttribute("id", "0"); - x.SetAttribute("nodeName", "Error in search: " + ee.ToString()); - result.AppendChild(x); - } - return result; - } + } + catch (Exception ee) + { + XmlElement x = xd.CreateElement("document"); + x.SetAttribute("id", "0"); + x.SetAttribute("nodeName", "Error in search: " + ee.ToString()); + result.AppendChild(x); + } + return result; + } - #region Component Designer generated code - - //Required by the Web Services Designer - private IContainer components = null; - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - } + #region Component Designer generated code - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if(disposing && components != null) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #endregion - - } + //Required by the Web Services Designer + private IContainer components = null; + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing && components != null) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #endregion + + } } diff --git a/umbraco/presentation/web.config.SHANDEMVAIO.xslt b/umbraco/presentation/web.config.SHANDEMVAIO.xslt index 6ae57ab874..3a764515ed 100644 --- a/umbraco/presentation/web.config.SHANDEMVAIO.xslt +++ b/umbraco/presentation/web.config.SHANDEMVAIO.xslt @@ -8,7 +8,7 @@ - 4.1.0.beta + 4.1.0.betaII