Esempio n. 1
0
        public override void RenderInViewMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] param)
        {
            StringBuilder html = new StringBuilder();

            NewsArticleDb db = new NewsArticleDb();

            NewsArticleDb.NewsArticleDetailsData news = db.fetchNewsDetails(page, identifier, langToRenderFor, true);

            html.Append("<h2>");
            html.Append(news.DateOfNews.ToString("MMM d yyyy"));
            html.Append("</h2>");
            writer.Write(html.ToString());
        }
        public override void RenderInEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] param)
        {
            NewsArticleDb db = new NewsArticleDb();

            NewsArticleDb.NewsArticleAggregatorData entity = db.fetchNewsAggregator(page, identifier, langToRenderFor, true);

            string ProjectSummaryId = "ProjectSummary_" + page.ID.ToString() + "_" + identifier.ToString() + "_" + langToRenderFor.shortCode;

            // ------- CHECK THE FORM FOR ACTIONS
            string action = PageUtils.getFromForm(ProjectSummaryId + "_Action", "");

            if (action.Trim().ToLower() == "update")
            {
                // save the data to the database
                int id             = PageUtils.getFromForm(ProjectSummaryId + "_ProjectSummaryId", -1);
                int newDefaultYear = PageUtils.getFromForm("defaultYear_" + ProjectSummaryId, -1);

                entity.YearToDisplay = newDefaultYear;

                bool b = db.updateNewsAggregator(page, identifier, langToRenderFor, entity);
                if (!b)
                {
                    writer.Write("Error saving updates to database!");
                }
            }

            // ------- START RENDERING
            // note: no need to put in the <form></form> tags.

            StringBuilder html = new StringBuilder();

            html.Append("<p><strong>News Aggregator Display Settings:</strong></p>");

            html.Append("<table>");
            string dropDownHtml = PageUtils.getInputTextHtml("defaultYear_" + ProjectSummaryId, "defaultYear_" + ProjectSummaryId, entity.YearToDisplay.ToString(), 7, 4);

            html.Append("<tr><td>Default Year to display summaries for: (-1 = all years)</td>");
            html.Append("<td>" + dropDownHtml + "</td></tr>");

            html.Append("</table>");

            html.Append("<input type=\"hidden\" name=\"" + ProjectSummaryId + "_Action\" value=\"update\">");
            html.Append("<input type=\"hidden\" name=\"" + ProjectSummaryId + "_ProjectSummaryId\" value=\"" + page.ID.ToString() + "\">");

            writer.WriteLine(html.ToString());
        }
        public override void RenderInViewMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] param)
        {
            AddNewsArticleCommandToEditMenu(page, page);


            CmsPage       currentPage = CmsContext.currentPage;
            StringBuilder html        = new StringBuilder();

            NewsArticleDb db = new NewsArticleDb();

            NewsArticleDb.NewsArticleAggregatorData newsAggregator = db.fetchNewsAggregator(page, identifier, langToRenderFor, true);

            RenderParameters renderParams = RenderParameters.fromParamList(param, newsAggregator);

            NewsAggItem[] newsToShow = FetchAllNewsAggItems(page, identifier, langToRenderFor, renderParams, CmsUrlFormat.RelativeToRoot);

            // -- display results
            html.Append(getHtmlForSummaryView(newsToShow, renderParams, langToRenderFor));
            writer.Write(html.ToString());
        }
        }     // NewsAggItem class

        private NewsAggItem[] FetchAutoAggregatedNewsArticleDetails(CmsPage aggregatorPage, int aggIdentifier, CmsLanguage aggLang, RenderParameters renderParams, CmsUrlFormat linkUrlFormat)
        {
            CmsPage rootPageToGatherFrom = aggregatorPage;

            if (renderParams.PageIdToGatherNewsFrom >= 0)
            {
                rootPageToGatherFrom = CmsContext.getPageById(renderParams.PageIdToGatherNewsFrom);
            }

            CmsContext.PageGatheringMode gatherMode = CmsContext.PageGatheringMode.ChildPagesOnly;
            if (renderParams.RecursiveGatherNews)
            {
                gatherMode = CmsContext.PageGatheringMode.FullRecursion;
            }

            CmsPage[] newsDetailsPages = CmsContext.getAllPagesWithPlaceholder("NewsArticleDetails", rootPageToGatherFrom, gatherMode);
            NewsArticleDb.NewsArticleDetailsData[] newsToShow = new NewsArticleDb().getNewsDetailsByYear(newsDetailsPages, renderParams.AggregatorData.YearToDisplay, aggLang);

            return(NewsAggItem.FromNewsArticleDetailsData(newsToShow, linkUrlFormat));
        }
Esempio n. 5
0
        public override void RenderInEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] param)
        {
            // CmsContext.setCurrentCultureInfo(langToRenderFor);
            NewsArticleDb db = new NewsArticleDb();

            NewsArticleDb.NewsArticleDetailsData entity = new NewsArticleDb.NewsArticleDetailsData(page, identifier, langToRenderFor);
            string dateString = "";
            string editId     = "newsDetails_" + page.ID.ToString() + "_" + identifier.ToString() + "_" + langToRenderFor.shortCode;

            // ------- CHECK THE FORM FOR ACTIONS
            string action = PageUtils.getFromForm(editId + "_Action", "");

            if (action.Trim().ToLower() == "update")
            {
                dateString = PageUtils.getFromForm("dateOfNews_" + editId, "");
                try
                {
                    entity.DateOfNews = Convert.ToDateTime(dateString);
                }
                catch { }
                db.updateNewsDetails(page, identifier, langToRenderFor, entity);
            }
            else
            {
                entity     = db.fetchNewsDetails(page, identifier, langToRenderFor, true);
                dateString = entity.DateOfNews.ToString("d");
            }

            // ------- START RENDERING
            StringBuilder arg0 = new StringBuilder();

            arg0.Append("<div style=\"width: 100%\">");
            arg0.Append("<p>Date of News (" + CmsLanguage.CurrentShortDateFormat + "): ");
            arg0.Append(PageUtils.getInputTextHtml("dateOfNews_" + editId, "dateOfNews_" + editId, dateString, 10, 10));
            arg0.Append("</p>");

            arg0.Append("<input type=\"hidden\" name=\"" + editId + "_Action\" value=\"update\">");
            arg0.Append("</div>");

            writer.WriteLine(arg0.ToString());
        }