Inheritance: CustomItem
コード例 #1
0
ファイル: PostListEntry.cs プロジェクト: WeTeam/WeBlog
        protected string GetSummary(EntryItem entry)
        {
            var args = new GetSummaryArgs();
            args.Entry = entry;

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

            return args.Summary;
        }
コード例 #2
0
ファイル: PostListEntry.cs プロジェクト: WeTeam/WeBlog
        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;
        }
コード例 #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;
            }
        }
コード例 #4
0
ファイル: ExtendedMailAction.cs プロジェクト: WeTeam/WeBlog
        /// <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);
            }
        }
コード例 #5
0
ファイル: ArchiveCore.cs プロジェクト: WeTeam/WeBlog
        /// <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();
        }
コード例 #6
0
ファイル: TagManager.cs プロジェクト: WeTeam/WeBlog
        public Dictionary<string, int> GetTagsByEntry(EntryItem entry)
        {
            var tagList = new List<string>();

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

            return SortByWeight(tagList);
        }
コード例 #7
0
ファイル: TagManager.cs プロジェクト: WeTeam/WeBlog
 /// <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 });
 }
コード例 #8
0
ファイル: BaseEntrySublayout.cs プロジェクト: WeTeam/WeBlog
 public BaseEntrySublayout()
 {
     CurrentEntry = new EntryItem(DataSourceItem);
 }
コード例 #9
0
ファイル: CommentsListCore.cs プロジェクト: WeTeam/WeBlog
 public CommentsListCore(BlogHomeItem currentBlogHomeItem, EntryItem currentEntry)
 {
     CurrentBlog = currentBlogHomeItem;
     CurrentEntry = currentEntry;
 }
コード例 #10
0
ファイル: EntryManager.cs プロジェクト: WeTeam/WeBlog
 public virtual EntryItem GetCurrentBlogEntry()
 {
     var current = new EntryItem(Context.Item);
     return current;
 }
コード例 #11
0
ファイル: MetaBlogApi.ashx.cs プロジェクト: WeTeam/WeBlog
        /// <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();
            }
        }
コード例 #12
0
ファイル: MetaBlogApi.ashx.cs プロジェクト: WeTeam/WeBlog
        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;
        }