Esempio n. 1
0
        private string TagInfo(Tag tag, List<Topic> topics)
        {
            StringBuilder sb = new StringBuilder();
            
            sb.Append("<div id=\"forum_tag_" + tag.ID + "\" class=\"tintMedium borderBase cornerAll clearFix\" style='padding:5px; margin:5px;'>");
            sb.Append("<input type=\"hidden\" id=\"forum_tag_approved_" + tag.ID + "\"  value=\"" + (tag.IsApproved ? "1" : "0") + "\"/>");
            
            sb.Append("<div style=\"float:left; width:30%;\">");
            
            sb.Append("<div id=\"forum_tag_name_info_" + tag.ID + "\" class=\"clearFix\">");                        
            sb.Append("<div id=\"forum_tni_" + tag.ID + "\" style=\"float:left; font-weight:bolder; width:66%;\">");
            sb.Append(HttpUtility.HtmlEncode(tag.Name));            
            sb.Append("</div>");

            //edit remove
            sb.Append("<div style=\"float:right; width:33%;\">");
            sb.Append("<a href=\"javascript:ForumMakerProvider.ShowEditTag('" + tag.ID + "');\"><img title='" + Resources.ForumResource.EditShortButton + "' src=\"" + WebImageSupplier.GetAbsoluteWebPath("mail_edit.png", ForumManager.ModuleID) + "\" border=\"0\"/></a>");
            sb.Append("<a style='margin-left:5px;' href=\"javascript:ForumMakerProvider.DeleteTag('" + tag.ID + "')\"><img title='" + Resources.ForumResource.EditShortButton + "' src=\"" + WebImageSupplier.GetAbsoluteWebPath("remove.png", ForumManager.ModuleID) + "\" border=\"0\"/></a>");
            sb.Append("</div>");
            sb.Append("</div>");
            
            sb.Append("<div id=\"forum_tag_name_edit_" + tag.ID + "\" class=\"clearFix\"></div>");

            sb.Append("</div>");

            //topics
            sb.Append("<div style=\"float:left; width:69%;\">");
            foreach (var topicTag in topics)
            {
                if (topicTag.Tags.Find(t => t.ID == tag.ID) == null)
                    continue;

                sb.Append("<div id=\"forum_tag_topic_" + tag.ID + "_" + topicTag.ID + "\" class=\"tintLight borderBase cornerAll clearFix\" style='padding:2px; margin:2px 0px;'>");

                sb.Append("<div style=\"float:left; width:70%;\">");
                sb.Append("<a href=\"posts.aspx?t=" + topicTag.ID + "\">" + HttpUtility.HtmlEncode(topicTag.Title) + "</a>");
                sb.Append("</div>");

                sb.Append("<div style=\"float:right; width:29%px; text-align:right;\">");
                sb.Append("<a class=\"linkAction\" href=\"javascript:ForumMakerProvider.DeleteTagFromTopic('" + tag.ID + "','" + topicTag.ID + "')\">" + Resources.ForumResource.DeleteTagFomTopicButton + "</a>");                
                sb.Append("</div>");

                sb.Append("</div>");
            }
            sb.Append("</div>");
     

            sb.Append("</div>");

            return sb.ToString();
        }
        private List<Tag> CreateTags()
        {
            List<Tag> list = new List<Tag>(0);

            _tagString = _tagString.TrimEnd(',');
            if (!String.IsNullOrEmpty(_tagString))
            {

                List<Tag> searchTags = new List<Tag>(0);
                if (!String.IsNullOrEmpty(_tagValues))
                {
                    foreach (string tagItem in _tagValues.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        Tag tag = new Tag()
                        {
                            ID = Convert.ToInt32(tagItem.Split('@')[1]),
                            Name = tagItem.Split('@')[0]
                        };
                        if(searchTags.Find(t=> t.ID == tag.ID)==null)
                            searchTags.Add(tag);
                    }
                }

                foreach (string inputTagName in _tagString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    Tag tag = new Tag()
                    {
                        ID = 0,
                        Name = inputTagName.Trim()
                    };
                    foreach (Tag _tag in searchTags)
                    {
                        if (String.Compare(inputTagName.Trim(), _tag.Name, StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            tag = _tag;
                            break;
                        }
                    }

                    if (list.Find(t => t.ID == tag.ID && t.ID != 0) == null)
                        list.Add(tag);
                }
            }
            return list;
        }