Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            var contextNode = GetContextNode();

            if (contextNode == null)
            {
                CallDone();
                return;
            }

            var tmp           = Content.Load(contextNode.Id);
            var pathListParam = Page.Request.Params["Paths"];

            if (string.IsNullOrEmpty(pathListParam))
            {
                return;
            }

            var pathList = pathListParam.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            switch (Page.Request.QueryString["Do"])
            {
            case "Add":
                //tmp["IsBlacklisted"] = true;
                TagManager.ManageBlacklist(true, contextNode.Id, pathList);
                TagManager.ReplaceTag(tmp.DisplayName, String.Empty, pathList);
                break;

            case "Remove":
                //tmp["IsBlacklisted"] = false;
                TagManager.ManageBlacklist(false, contextNode.Id, pathList);
                break;
            }

            tmp.Save();

            CallDone();
        }
Esempio n. 3
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;
            }
        }