Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
            }
        }