protected string GetSummary(EntryItem entry) { var args = new GetSummaryArgs(); args.Entry = entry; CorePipeline.Run("weblogGetSummary", args, true); return args.Summary; }
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; }
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; } }
/// <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); } }
/// <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(); }
public Dictionary<string, int> GetTagsByEntry(EntryItem entry) { var tagList = new List<string>(); if(entry != null) tagList.AddRange(entry.TagsSplit); return SortByWeight(tagList); }
/// <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 }); }
public BaseEntrySublayout() { CurrentEntry = new EntryItem(DataSourceItem); }
public CommentsListCore(BlogHomeItem currentBlogHomeItem, EntryItem currentEntry) { CurrentBlog = currentBlogHomeItem; CurrentEntry = currentEntry; }
public virtual EntryItem GetCurrentBlogEntry() { var current = new EntryItem(Context.Item); return current; }
/// <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(); } }
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; }