/// <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></returns> public Dictionary<string, int> GetTagsByEntry(EntryItem entry) { var tagList = new List<string>(); tagList.AddRange(entry.TagsSplit); return SortByWeight(tagList); }
/// <summary> /// Loads the entry. /// </summary> protected virtual void LoadEntry() { // Create entry of current item EntryItem current = new EntryItem(Sitecore.Context.Item); // Fill categories ListViewCategories.DataSource = ManagerFactory.CategoryManagerInstance.GetCategoriesByEntryID(current.ID); ListViewCategories.DataBind(); //TODO Create edit possibilities for assigning categories on frontend }
protected string GetSummary(EntryItem entry) { var args = new GetSummaryArgs(); args.Entry = entry; #if SC62 || SC64 CorePipeline.Run("weblogGetSummary", args); #else CorePipeline.Run("weblogGetSummary", args, true); #endif return args.Summary; }
protected void AddComment(EntryItem entryItem, WpComment wpComment) { // todo: Wizard to ask user which language to import into string itemName = ItemUtil.ProposeValidItemName("Comment by " + wpComment.Author + " at " + wpComment.Date.ToString("d")); CommentItem commentItem = entryItem.InnerItem.Add(itemName, new TemplateID(new ID(CommentItem.TemplateId))); commentItem.BeginEdit(); commentItem.Comment.Field.Value = wpComment.Content; commentItem.Email.Field.Value = wpComment.Email; commentItem.IPAddress.Field.Value = wpComment.IP; commentItem.Website.Field.Value = wpComment.Url; commentItem.InnerItem.Fields[Sitecore.FieldIDs.Created].Value = Sitecore.DateUtil.ToIsoDate(wpComment.Date); commentItem.EndEdit(); }
/// <summary> /// Loads the entry. /// </summary> protected virtual void LoadEntry() { // Create entry of current item EntryItem current = new EntryItem(Sitecore.Context.Item); // Load tags if (!Sitecore.Context.PageMode.IsPageEditorEditing) { var tags = ManagerFactory.TagManagerInstance.GetTagsByEntry(current); var list = LoginViewTags.FindControl("TagList") as ListView; if (list != null) { list.DataSource = from tag in tags select tag.Key; list.DataBind(); } } }
/// <summary> /// Gets the categories for the blog entry given by ID /// </summary> /// <param name="EntryID">The ID of the blog entry to get teh categories from</param> /// <returns>The categories of the blog</returns> public CategoryItem[] GetCategoriesByEntryID(ID EntryID) { var categoryList = new List<CategoryItem>(); var item = GetDatabase().GetItem(EntryID); if (item != null) { var currentEntry = new EntryItem(item); if (currentEntry != null) { foreach (var cat in currentEntry.Category.ListItems) { categoryList.Add(new CategoryItem(cat)); } } } return categoryList.ToArray(); }
/// <summary> /// Gets the current context item as a blog entry /// </summary> /// <returns>The current blog entry</returns> public 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.ID.ToString(), 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 = ContentHelper.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.Introduction.Raw); rpcstruct.Add("pubDate", entry.InnerItem.Statistics.Created.ToString()); rpcstruct.Add("guid", entry.ID.ToString()); rpcstruct.Add("author", entry.InnerItem.Statistics.CreatedBy); } return rpcstruct; }
/// <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>(); var startYear = 0; var endYear = 0; if (entries.Any()) { startYear = ((EntryItem)entries.First()).Created.Year; endYear = ((EntryItem)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 BaseEntrySublayout() { CurrentEntry = new EntryItem(DataSourceItem); }
public BaseEntrySublayout() { CurrentEntry = new EntryItem(Sitecore.Context.Item); }
protected DateTime GetPublishDate(EntryItem entry) { var publishDate = ((Item)entry).Publishing.PublishDate; var createdDate = entry.Created; return (publishDate > createdDate) ? publishDate : createdDate; }