Inheritance: CustomItem
Beispiel #1
0
        protected string GetSummary(EntryItem entry)
        {
            var args = new GetSummaryArgs();
            args.Entry = entry;

            CorePipeline.Run("weblogGetSummary", args, true);

            return args.Summary;
        }
Beispiel #2
0
        public PostListEntry(EntryItem entry)
        {
            EntryItem = entry;
            var currentBlog = ManagerFactory.BlogManagerInstance.GetCurrentBlog(entry);
            Size maxEntryImage = currentBlog.MaximumThumbnailImageSizeDimension;
            if (maxEntryImage != Size.Empty)
            {
                MaxWidth = maxEntryImage.Width;
                MaxHeight = maxEntryImage.Height;
            }
            Summary = GetSummary(EntryItem);

            ShowCommentsCount = currentBlog.EnableComments.Checked && !EntryItem.DisableComments.Checked;
        }
Beispiel #3
0
        public static CommentItem CreateNewComment(EntryItem entryItem, DateTime? creationDate = null)
        {
            if(creationDate == null)
                creationDate = DateTime.Now;

            using (new UserSwitcher("sitecore\\admin", true))
            {
                var commentItem = entryItem.InnerItem.Add(ID.NewID.ToShortID().ToString(), Constants.Templates.CommentTemplateId);
                using (new EditContext(commentItem))
                {
                    commentItem[FieldIDs.Created] = DateUtil.ToIsoDate(creationDate.Value);
                }

                return commentItem;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Populates the velocity template context. Only the objects that were
        /// added in this method will be accessible in the mail template.
        /// </summary>
        /// <remarks>Override this to add your own data to the context</remarks>
        protected virtual void PopulateContext(WorkflowPipelineArgs args)
        {
            velocityContext.Put("args", args);
            velocityContext.Put("item", args.DataItem);
            velocityContext.Put("processor", args.ProcessorItem);
            velocityContext.Put("user", Sitecore.Context.User);
            velocityContext.Put("history", args.DataItem.State.GetWorkflow().GetHistory(args.DataItem));
            velocityContext.Put("state", args.DataItem.State.GetWorkflowState());
            velocityContext.Put("nextState", GetNextState(args));
            velocityContext.Put("site", Sitecore.Context.Site);
            velocityContext.Put("time", DateTime.Now);

            EntryItem entryItem = null;
            if (args.DataItem.TemplateIsOrBasedOn(Settings.EntryTemplateID))
            {
                entryItem = new EntryItem(args.DataItem);
            }
            else if (args.DataItem.TemplateIsOrBasedOn(Settings.CommentTemplateID))
            {
                CommentItem commentItem = new CommentItem(args.DataItem);
                entryItem = ManagerFactory.EntryManagerInstance.GetBlogEntryByComment(commentItem);
                velocityContext.Put("comment", commentItem);
            }

            if (entryItem != null)
            {
                velocityContext.Put("entry", entryItem);
                if (!string.IsNullOrEmpty(entryItem.InnerItem.Statistics.CreatedBy))
                {
                    UserProfile createdBy = User.FromName(entryItem.InnerItem.Statistics.CreatedBy, false).Profile;
                    velocityContext.Put("entryCreatedBy", createdBy);
                }
                if (!string.IsNullOrEmpty(entryItem.InnerItem.Statistics.UpdatedBy))
                {
                    UserProfile updatedBy = User.FromName(entryItem.InnerItem.Statistics.UpdatedBy, false).Profile;
                    velocityContext.Put("entryUpdatedBy", updatedBy);
                }

                BlogHomeItem blog = ManagerFactory.BlogManagerInstance.GetCurrentBlog(entryItem);
                velocityContext.Put("blog", blog);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Gets the years from latest blog entry's year to oldest blog entry's year
        /// </summary>
        /// <returns></returns>
        protected virtual int[] GetYears(EntryItem[] entries)
        {
            var years = new List<int>();
            if (entries.Any())
            {
                var startYear = entries.First().Created.Year;
                var endYear = entries.Last().Created.Year;

                if (startYear != 0 && endYear != 0)
                {
                    for (var year = startYear; year >= endYear; year--)
                    {
                        if (YearHasBlogEntries(year))
                        {
                            years.Add(year);
                        }
                    }
                }
            }

            return years.ToArray();
        }
Beispiel #6
0
        public Dictionary<string, int> GetTagsByEntry(EntryItem entry)
        {
            var tagList = new List<string>();

            if(entry != null)
                tagList.AddRange(entry.TagsSplit);

            return SortByWeight(tagList);
        }
Beispiel #7
0
 /// <summary>
 /// Gets the tags for a blog entry and sorts by weight
 /// </summary>
 /// <param name="entry">The entry to get the tags for</param>
 /// <returns>The sorted tags for the entry</returns>
 public Tag[] GetTagsForEntry(EntryItem entry)
 {
     return ExtractAndSortTags(new[] { entry });
 }
Beispiel #8
0
 public BaseEntrySublayout()
 {
     CurrentEntry = new EntryItem(DataSourceItem);
 }
Beispiel #9
0
 public CommentsListCore(BlogHomeItem currentBlogHomeItem, EntryItem currentEntry)
 {
     CurrentBlog = currentBlogHomeItem;
     CurrentEntry = currentEntry;
 }
Beispiel #10
0
 public virtual EntryItem GetCurrentBlogEntry()
 {
     var current = new EntryItem(Context.Item);
     return current;
 }
Beispiel #11
0
        /// <summary>
        /// Sets the item data from an XML RPC struct
        /// </summary>
        /// <param name="item">The item to set the data on</param>
        /// <param name="rpcstruct">The struct to read the data from</param>
        private void SetItemData(Item item, XmlRpcStruct rpcstruct)
        {
            if (item != null)
            {
                var entry = new EntryItem(item);

                entry.BeginEdit();

                if (rpcstruct["title"] != null)
                    entry.Title.Field.Value = rpcstruct["title"].ToString();

                if (rpcstruct["description"] != null)
                    entry.Content.Field.Value = rpcstruct["description"].ToString();

                if (rpcstruct["categories"] != null)
                    entry.Category.Field.Value = GetCategoriesAsString(item, rpcstruct);

                if (rpcstruct["dateCreated"] != null)
                {
                    DateTime publishDate = DateTime.MinValue;
                    if (DateTime.TryParse(rpcstruct["dateCreated"].ToString(), out publishDate))
                        entry.InnerItem.Publishing.PublishDate = publishDate;
                }

                entry.EndEdit();
            }
        }
Beispiel #12
0
        public XmlRpcStruct getPost(string postid, string username, string password)
        {
            Authenticate(username, password);
            CheckUserRights(postid, username);

            var rpcstruct = new XmlRpcStruct();
            var entryItem = GetContentDatabase().GetItem(postid);
            if (entryItem != null)
            {
                var entry = new EntryItem(entryItem);

                rpcstruct.Add("title", entry.Title.Raw);
                rpcstruct.Add("link", entry.AbsoluteUrl);
                rpcstruct.Add("description", entry.Content.Raw);
                rpcstruct.Add("pubDate", entry.EntryDate.DateTime);
                rpcstruct.Add("guid", entry.ID.ToString());
                rpcstruct.Add("author", entry.InnerItem.Statistics.CreatedBy);
            }

            return rpcstruct;
        }