private void RegisterSearchHandlers(bool fullSearch)
        {
            #region search scripts
            StringBuilder sb = new StringBuilder();

            string searchText    = Page.Request["search"];
            var    activeHandler = SearchHandlerManager.GetActiveHandlerEx();

            var allHandlers = SearchHandlerManager.GetHandlersExForProduct(_currentProductID);

            if (_currentProductID.Equals(Guid.Empty) || !allHandlers.Exists(sh => !sh.ProductID.Equals(Guid.Empty)))
            {
                if (!fullSearch)
                {
                    allHandlers.RemoveAll(sh => sh is StudioSearchHandler);
                }
                else
                {
                    allHandlers.RemoveAll(sh => !(sh is StudioSearchHandler));
                }

                _singleSearch = true;
            }

            if (SingleSearchHandlerType != null)
            {
                allHandlers.RemoveAll(sh => !sh.GetType().Equals(SingleSearchHandlerType));
                _singleSearch = true;
            }


            bool isFirst = true;
            foreach (var sh in allHandlers)
            {
                if (sh == null)
                {
                    continue;
                }

                var module = WebItemManager.Instance[sh.ModuleID];
                if (module != null && module.IsDisabled())
                {
                    continue;
                }

                var shi = new SearchHandlerItem()
                {
                    Handler = sh,
                    LogoURL = (sh.Logo != null) ? WebImageSupplier.GetAbsoluteWebPath(sh.Logo.ImageFileName, sh.Logo.PartID) : "",
                    Active  = String.IsNullOrEmpty(searchText) ? (sh.GetType().Equals(typeof(StudioSearchHandler)) || _singleSearch) :
                              (sh.Equals(activeHandler) || (activeHandler == null && isFirst))
                };

                _handlerItems.Add(shi);



                string absoluteSearchURL = sh.AbsoluteSearchURL;

                if (sh.ProductID.Equals(Guid.Empty) && !this._currentProductID.Equals(Guid.Empty))
                {
                    absoluteSearchURL = absoluteSearchURL + (absoluteSearchURL.IndexOf("?") != -1 ? "&" : "?") + CommonLinkUtility.GetProductParamsPair(this._currentProductID);
                }


                sb.Append(" Searcher.AddHandler(new SearchHandler('" + shi.ID + "','" + sh.SearchName.Replace("'", "\\'") + "','" + shi.LogoURL + "'," + (shi.Active ? "true" : "false") + ",'" + absoluteSearchURL + "')); ");

                isFirst = false;
            }


            _handlerItems.Sort((h1, h2) =>
            {
                return(h1.CompareTo(h2));
            });


            //script
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "topnavpanel_init_script", sb.ToString(), true);
            #endregion
        }
Exemplo n.º 2
0
        private string GetMoreUrl(ISearchHandlerEx sh, ref Guid productID)
        {
            var path = sh.AbsoluteSearchURL;

            if (sh.ProductID.Equals(Guid.Empty) && !productID.Equals(Guid.Empty))
            {
                path = sh.AbsoluteSearchURL + (sh.AbsoluteSearchURL.IndexOf("?") != -1 ? "&" : "?") + CommonLinkUtility.GetProductParamsPair(productID);
            }

            path = path + (path.IndexOf("?") != -1 ? "&search=" : "?search=") + HttpUtility.UrlEncode(_searchText, Encoding.UTF8);

            return(path);
        }
Exemplo n.º 3
0
        public static string GetUrlForModule(Guid productId, Guid?moduleId)
        {
            var url = string.Format("{0}?{1}", VirtualPathUtility.ToAbsolute(PageUrl), CommonLinkUtility.GetProductParamsPair(productId));

            if (moduleId.HasValue)
            {
                url = string.Format("{0}#mid{1}mid", url, moduleId.Value);
            }
            return(url);
        }