void AccountNewsIconManage_Edit(object sender, EventArgs e) { long iconId = 0; bool edit = false; try { iconId = long.Parse(core.Http.Query["id"]); } catch { core.Display.ShowMessage("Invalid", "If you have stumbled onto this page by mistake, click back in your browser."); return; } SetTemplate("account_news_icon_edit"); News news = new News(core, Owner); NewsIcon icon = null; if (iconId > 0) { edit = true; try { icon = new NewsIcon(core, iconId); } catch (InvalidNewsIconException) { core.Display.ShowMessage("Invalid", "If you have stumbled onto this page by mistake, click back in your browser."); } template.Parse("ICON_TITLE", icon.Title); } }
public static void Show(object sender, ShowGPageEventArgs e) { e.Template.SetTemplate("News", "viewnews"); News news = null; try { news = new News(e.Core, e.Page.Owner); } catch (InvalidNewsException) { news = News.Create(e.Core, e.Page.Owner, e.Page.Owner.TitleNameOwnership + " News", 10); } e.Template.Parse("PAGE_TITLE", e.Core.Prose.GetString("NEWS")); e.Core.Display.ParsePageList(e.Page.Owner, true); List<Article> articles = news.GetArticles(e.Page.TopLevelPageNumber, 10); e.Template.Parse("NEWS_COUNT", articles.Count.ToString()); foreach (Article article in articles) { VariableCollection articleVariableCollection = e.Template.CreateChild("news_list"); e.Core.Display.ParseBbcode(articleVariableCollection, "BODY", article.ArticleBody, e.Page.Owner); articleVariableCollection.Parse("TITLE", article.ArticleSubject); articleVariableCollection.Parse("U_ARTICLE", article.Uri); articleVariableCollection.Parse("U_POSTER", article.Poster.Uri); articleVariableCollection.Parse("USERNAME", article.Poster.DisplayName); articleVariableCollection.Parse("COMMENTS", article.Comments.ToString()); articleVariableCollection.Parse("DATE", e.Core.Tz.DateTimeToString(article.GetCreatedDate(e.Core.Tz))); } if (news.Access.Can("CREATE_ARTICLES")) { e.Template.Parse("U_CREATE_ARTICLE", news.Owner.AccountUriStub); e.Template.Parse("L_POST_NEWS_ARTICLE", "New Article"); } e.Core.Display.ParsePagination(e.Template, news.Uri, 10, e.Page.Group.GroupInfo.NewsArticles); List<string[]> breadCrumbParts = new List<string[]>(); breadCrumbParts.Add(new string[] { "news", e.Core.Prose.GetString("NEWS") }); e.Page.Group.ParseBreadCrumbs(breadCrumbParts); }
void AccountNewsIconManage_Show(object sender, EventArgs e) { SetTemplate("account_news_icon_manage"); News news = new News(core, Owner); List<NewsIcon> icons = news.GetIcons(); foreach (NewsIcon icon in icons) { VariableCollection articlesVariableCollection = template.CreateChild("icon_list"); articlesVariableCollection.Parse("TITLE", icon.Title); articlesVariableCollection.Parse("I_ICON", icon.Uri); articlesVariableCollection.Parse("U_EDIT", BuildUri("icon", "edit", icon.Id)); articlesVariableCollection.Parse("U_DELETE", BuildUri("icon", "delete", icon.Id)); } }
public void ShowGroupNews(HookEventArgs e) { Template template = new Template(Assembly.GetExecutingAssembly(), "viewprofilenews"); template.Medium = core.Template.Medium; template.SetProse(core.Prose); if (e.Owner is UserGroup) { News news = new News(e.core, (UserGroup)e.Owner); List<Article> articles = news.GetArticles(1, 5); foreach (Article article in articles) { VariableCollection articleVariableCollection = template.CreateChild("news_list"); articleVariableCollection.Parse("TITLE", article.ArticleSubject); } } e.core.AddSidePanel(template); }
void AccountNewsWrite_Save(object sender, EventArgs e) { string subject = core.Http.Form["title"]; string body = core.Http.Form["post"]; News news = null; try { news = new News(core, Owner); } catch (InvalidNewsException) { news = News.Create(core, Owner, Owner.TitleNameOwnership + " News", 10); } Article newArticle = Article.Create(core, news, subject, body); SetRedirectUri(BuildUri("manage")); core.Display.ShowMessage("Article Published", "The news article has been published."); }
public static Article Create(Core core, News news, string subject, string body) { if (core == null) { throw new NullCoreException(); } if (news == null) { throw new InvalidNewsException(); } // TODO: fix this Item item = Item.Create(core, typeof(Article), new FieldValuePair("article_item_id", news.Owner.Id), new FieldValuePair("article_item_type_id", news.Owner.TypeId), new FieldValuePair("article_time_ut", UnixTime.UnixTimeStamp()), new FieldValuePair("article_subject", subject), new FieldValuePair("article_body", body), new FieldValuePair("user_id", core.LoggedInMemberId)); return (Article)item; }
public static NewsIcon Create(Core core, News news, string title, string storageName, string contentType) { if (core == null) { throw new NullCoreException(); } if (news == null) { throw new InvalidNewsException(); } // TODO: fix this Item item = Item.Create(core, typeof(NewsIcon), new FieldValuePair("icon_item_id", news.Owner.Id), new FieldValuePair("icon_item_type_id", news.Owner.TypeId), new FieldValuePair("icon_title", title), new FieldValuePair("icon_storage_path", storageName), new FieldValuePair("icon_content_type", contentType)); return (NewsIcon)item; }
void AccountNewsManage_Show(object sender, EventArgs e) { SetTemplate("account_news_manage"); News news = null; try { news = new News(core, Owner); } catch (InvalidNewsException) { news = News.Create(core, Owner, Owner.TitleNameOwnership + " News", 10); } List<Article> articles = news.GetArticles(core.TopLevelPageNumber, 25); foreach (Article article in articles) { VariableCollection articlesVariableCollection = template.CreateChild("news_list"); DateTime postedTime = article.GetCreatedDate(tz); articlesVariableCollection.Parse("COMMENTS", article.Comments.ToString()); articlesVariableCollection.Parse("TITLE", article.ArticleSubject); articlesVariableCollection.Parse("POSTED", tz.DateTimeToString(postedTime)); articlesVariableCollection.Parse("U_VIEW", article.Uri); articlesVariableCollection.Parse("U_EDIT", BuildUri("write", "edit", article.Id)); articlesVariableCollection.Parse("U_DELETE", BuildUri("write", "delete", article.Id)); } if (Owner is UserGroup) { core.Display.ParsePagination(template, BuildUri(), 25, ((UserGroup)Owner).GroupInfo.NewsArticles); } }