public static EntryItem CreateNewEntry(BlogHomeItem blogItem, string name, string tags = null, ID[] categories = null, DateTime? entryDate = null) { using (new UserSwitcher("sitecore\\admin", true)) { var entry = blogItem.InnerItem.Add(name, Constants.Templates.EntryTemplateId); if (tags != null) { using (new EditContext(entry)) { entry["Tags"] = tags; } } if (categories != null) { using (new EditContext(entry)) { entry["Category"] = string.Join<ID>("|", categories); } } if (entryDate != null) { using (new EditContext(entry)) { entry["Entry Date"] = DateUtil.ToIsoDate(entryDate.Value); } } return entry; } }
/// <summary> /// Checks if the current blog has RSS enabled /// </summary> /// <param name="blog">The blog to read the setting from</param> /// <returns>True if RSS is enabled, otherwise False</returns> public bool EnableRSS(BlogHomeItem blog) { if (blog == null) return false; return blog.EnableRss.Checked; }
public static CategoryItem CreateNewCategory(BlogHomeItem blogItem, string name) { using (new UserSwitcher("sitecore\\admin", true)) { var categoryRoot = blogItem.InnerItem.Children["Categories"]; return categoryRoot.Add(name, Constants.Templates.CategoryTemplateId); } }
public ThemeLink() { Blog = ManagerFactory.BlogManagerInstance.GetCurrentBlog(); Attributes = new Dictionary<HtmlTextWriterAttribute, string> { {HtmlTextWriterAttribute.Href, GetThemeUrl()}, {HtmlTextWriterAttribute.Rel, "stylesheet"}, {HtmlTextWriterAttribute.Type, "text/css"} }; }
/// <summary> /// Process to return RSD page. /// </summary> /// <param name="context">context</param> public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/xml"; using (XmlTextWriter rsd = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8)) { Database web = Factory.GetDatabase("web"); Item currentBlogItem = web.GetItem(new ID(HttpContext.Current.Request.QueryString["blogid"].ToString())); BlogHomeItem currentBlog = new BlogHomeItem(currentBlogItem); rsd.Formatting = Formatting.Indented; rsd.WriteStartDocument(); // Rsd tag rsd.WriteStartElement("rsd"); rsd.WriteAttributeString("version", "1.0"); // Service rsd.WriteStartElement("service"); rsd.WriteElementString("engineName", "Sitecore WeBlog Module"); rsd.WriteElementString("engineLink", "http://" + WebUtil.GetHostName()); rsd.WriteElementString("homePageLink", currentBlog.AbsoluteUrl); // APIs rsd.WriteStartElement("apis"); // MetaWeblog rsd.WriteStartElement("api"); rsd.WriteAttributeString("name", "MetaWeblog"); rsd.WriteAttributeString("preferred", "true"); rsd.WriteAttributeString("apiLink", "http://" + WebUtil.GetHostName() + "/sitecore modules/WeBlog/MetaBlogApi.ashx"); rsd.WriteAttributeString("blogID", currentBlog.ID.ToString()); rsd.WriteEndElement(); //// BlogML //rsd.WriteStartElement("api"); //rsd.WriteAttributeString("name", "BlogML"); //rsd.WriteAttributeString("preferred", "false"); //rsd.WriteAttributeString("apiLink", Utils.AbsoluteWebRoot + "api/BlogImporter.asmx"); //rsd.WriteAttributeString("blogID", Utils.AbsoluteWebRoot.ToString()); //rsd.WriteEndElement(); // End APIs rsd.WriteEndElement(); // End Service rsd.WriteEndElement(); // End Rsd rsd.WriteEndElement(); rsd.WriteEndDocument(); } }
public RsdLink() { Blog = ManagerFactory.BlogManagerInstance.GetCurrentBlog(); Attributes = new Dictionary<HtmlTextWriterAttribute, string> { {HtmlTextWriterAttribute.Href, "http://" + WebUtil.GetHostName() + "/sitecore modules/WeBlog/rsd.ashx?blogid=" + Blog.ID}, {HtmlTextWriterAttribute.Rel, "EditURI"}, {HtmlTextWriterAttribute.Type, "application/rsd+xml"}, {HtmlTextWriterAttribute.Title, "RSD"} }; }
/// <summary> /// Checks if emails should be displayed with comments /// </summary> /// /// <param name="blog">The blog to read the setting from</param> /// <returns>True if email should be shown, otherwise False</returns> public bool ShowEmailWithinComments(BlogHomeItem blog) { if (blog == null) return false; return blog.ShowEmailWithinComments.Checked; }
public EntryTagsCore(BlogHomeItem currentBlog) { CurrentBlog = currentBlog; }
public Dictionary<string, int> GetAllTags(BlogHomeItem blog) { return GetTagsForBlog(blog).ToDictionary(x => x.Name, x => x.Count); }
/// <summary> /// Gets the tags for the blog /// </summary> /// <param name="blogItem">The blog to get the tags for</param> /// <returns>An array of unique tags</returns> public Tag[] GetTagsForBlog(BlogHomeItem blog) { if (blog != null) { var entries = EntryManager.GetBlogEntries(blog.InnerItem); return ExtractAndSortTags(entries); } return new Tag[0]; }
public CommentsListCore(BlogHomeItem currentBlogHomeItem, EntryItem currentEntry) { CurrentBlog = currentBlogHomeItem; CurrentEntry = currentEntry; }