/// <summary>
        /// Get the search result
        /// </summary>
        /// <param name="actNode">The actual Node</param>
        /// <returns>Return IENumerable value which is te search value</returns>
        private IEnumerable GetResult(Node actNode)
        {
            var queryString = string.Empty;

            if (Context.Request.Params.Get("TagFilter") != null)
            {
                queryString = Context.Request.Params.Get("TagFilter");
            }

            if (actNode.NodeType.Id == ActiveSchema.NodeTypes["Tag"].Id)
            {
                queryString = actNode.Name;
            }

            char[] splitchars       = { ',' };
            var    contentTypeArray = ContentTypes.Split(splitchars, StringSplitOptions.RemoveEmptyEntries);
            var    searchPathArray  = SearchPaths.ToLower().Split(splitchars, StringSplitOptions.RemoveEmptyEntries);
            var    allTypes         = new List <string>();

            foreach (var type in contentTypeArray)
            {
                allTypes.Add(type.ToLower());

                if (IncludeChildren)//if all descendant types are needed
                {
                    var baseType = ContentType.GetByName(type);
                    if (baseType != null)
                    {
                        foreach (var childType in ContentType.GetContentTypes())
                        {
                            if (childType.IsDescendantOf(baseType))
                            {
                                allTypes.Add(childType.Name.ToLower());
                            }
                        }
                    }
                }
            }

            var contentsId = TagManager.GetNodeIds(queryString, searchPathArray, allTypes.ToArray(), QueryFilter);

            var result = new NodeList <Node>(contentsId);

            return(result);
        }
Ejemplo n.º 2
0
        protected override void OnPreRender(EventArgs e)
        {
            UITools.AddStyleSheetToHeader(UITools.GetHeader(), "$skin/styles/SN.Tagging.css");
            using (var traceOperation = Logger.TraceOperation("TagCloudPortlet.OnPreRender: ", this.Name))
            {
                base.OnPreRender(e);
                //if cached return
                if (Cacheable && CanCache && IsInCache)
                {
                    //System.Diagnostics.Trace.WriteLine(this.ID + " OnPreRender END - Portlet cached.");
                    return;
                }

                char[] splitchars       = { ',' };
                var    contentTypeArray = ContentTypes.Split(splitchars, StringSplitOptions.RemoveEmptyEntries);
                var    searchPathArray  = !string.IsNullOrEmpty(SearchPaths)
                                          ? SearchPaths.ToLower().Split(splitchars, StringSplitOptions.RemoveEmptyEntries)
                                          : (ContextNode == null ? new string[0] : new[] { ContextNode.Path.ToLower() });
                var allTypes = new List <string>();

                foreach (var type in contentTypeArray)
                {
                    allTypes.Add(type.ToLower());

                    if (IncludeChildren) //if all descendant types are needed
                    {
                        var baseType = ContentType.GetByName(type);
                        if (baseType != null)
                        {
                            foreach (var childType in ContentType.GetContentTypes())
                            {
                                if (childType.IsDescendantOf(baseType))
                                {
                                    allTypes.Add(childType.Name.ToLower());
                                }
                            }
                        }
                    }
                }

                var ctrl = Page.LoadControl(contentViewPath) as TagCloudControl;
                if (ctrl != null)
                {
                    var repeater = ctrl.FindControl("TagCloudRepeater") as System.Web.UI.WebControls.Repeater;
                    if (repeater != null)
                    {
                        if (allTypes.Count == 0 && searchPathArray.Count() == 0)
                        {
                            repeater.DataSource = TagManager.GetTagClasses(MaxCount);
                        }
                        else
                        {
                            repeater.DataSource = TagManager.GetTagClasses(searchPathArray, allTypes.ToArray(), MaxCount);
                        }
                        ctrl.SearchPortletPath = SearchPortletPath;
                        repeater.DataBind();
                    }

                    Controls.Add(ctrl);
                }
                else
                {
                    Controls.Add(new LiteralControl("ContentView error."));
                }
                traceOperation.IsSuccessful = true;
            }
        }