Inheritance: CustomItem
Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 public ThemeLink()
 {
     Blog = ManagerFactory.BlogManagerInstance.GetCurrentBlog();
     Attributes = new Dictionary<HtmlTextWriterAttribute, string>
     {
         {HtmlTextWriterAttribute.Href, GetThemeUrl()},
         {HtmlTextWriterAttribute.Rel, "stylesheet"},
         {HtmlTextWriterAttribute.Type, "text/css"}
     };
 }
Exemplo n.º 5
0
        /// <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();

            }
        }
Exemplo n.º 6
0
 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"}
     };
 }
Exemplo n.º 7
0
        /// <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;
        }
Exemplo n.º 8
0
 public EntryTagsCore(BlogHomeItem currentBlog)
 {
     CurrentBlog = currentBlog;
 }
Exemplo n.º 9
0
 public Dictionary<string, int> GetAllTags(BlogHomeItem blog)
 {
     return GetTagsForBlog(blog).ToDictionary(x => x.Name, x => x.Count);
 }
Exemplo n.º 10
0
        /// <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];
        }
Exemplo n.º 11
0
 public CommentsListCore(BlogHomeItem currentBlogHomeItem, EntryItem currentEntry)
 {
     CurrentBlog = currentBlogHomeItem;
     CurrentEntry = currentEntry;
 }