protected virtual void AddLinkToOutput(HtmlTextWriter output, BlogHomeItem blogItem) { output.AddAttribute(HtmlTextWriterAttribute.Rel, "EditURI"); output.AddAttribute(HtmlTextWriterAttribute.Type, "application/rsd+xml"); output.AddAttribute(HtmlTextWriterAttribute.Title, "RSD"); output.AddAttribute(HtmlTextWriterAttribute.Href, "http://" + WebUtil.GetHostName() + "/sitecore modules/WeBlog/rsd.ashx?blogid=" + blogItem.ID); output.RenderBeginTag(HtmlTextWriterTag.Link); output.RenderEndTag(); }
public void AddCommentToEntry() { // Perform this test in master DB as comments get created there var db = Sitecore.Configuration.Factory.GetDatabase("master"); var blogSettings = new BlogHomeItem(m_blog1).BlogSettings; var originalCount = m_entry12.Axes.GetDescendants().Count(i => i.TemplateID == blogSettings.CommentTemplateID); ID commentId = null; try { var comment = new Sitecore.Modules.WeBlog.Model.Comment() { AuthorEmail = "*****@*****.**", AuthorName = "commentor", Text = "My Comment" }; comment.Fields[Sitecore.Modules.WeBlog.Constants.Fields.IpAddress] = "127.0.0.1"; comment.Fields[Sitecore.Modules.WeBlog.Constants.Fields.Website] = "website"; commentId = new Mod.CommentManager().AddCommentToEntry(m_entry12.ID, comment); var childCount = m_entry12.Axes.GetDescendants().Count(i => i.TemplateID == blogSettings.CommentTemplateID); Assert.IsTrue(commentId != ID.Null); Assert.AreEqual(originalCount + 1, childCount); var commentItem = db.GetItem(commentId); Assert.IsNotNull(commentItem); var commentAsComment = new Sitecore.Modules.WeBlog.Items.WeBlog.CommentItem(commentItem); Assert.AreEqual("*****@*****.**", commentAsComment.Email.Text); Assert.AreEqual("commentor", commentAsComment.Name.Text); Assert.AreEqual("127.0.0.1", commentAsComment.IPAddress.Text); Assert.AreEqual("website", commentAsComment.Website.Text); Assert.AreEqual("My Comment", StringUtil.RemoveTags(commentAsComment.Comment.Text)); } finally { var webDb = Sitecore.Configuration.Factory.GetDatabase("web"); if (commentId != (ID)null) { var commentItem = db.GetItem(commentId); if (commentItem != null) { using (new SecurityDisabler()) { commentItem.Delete(); } } commentItem = webDb.GetItem(commentId); if (commentItem != null) { using (new SecurityDisabler()) { commentItem.Delete(); } } } } }