public static bool ArrayContainsNews(NewsAggItem[] haystack, NewsAggItem newsToFind)
            {
                Dictionary <string, NewsAggItem> hash = new Dictionary <string, NewsAggItem>();

                foreach (NewsAggItem f in haystack)
                {
                    hash.Add(f.GetContentHash(), f);
                }

                return(hash.ContainsKey(newsToFind.GetContentHash()));
            }
        }     // 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));
        }
        private string getHtmlForSummaryView(NewsAggItem[] newsDetails, RenderParameters renderParams, CmsLanguage lang)
        {
            StringBuilder html = new StringBuilder();

            int displayYear = renderParams.AggregatorData.YearToDisplay;

            if (newsDetails.Length == 0)
            {
                if (displayYear < 0)
                {
                    html.Append("<p><strong>" + getNoNewsText(lang) + "</strong>");
                }
                else
                {
                    html.Append("<p><strong>" + getNoNewsForYearText(lang) + displayYear.ToString() + ".</strong>");
                }
            }
            else
            {
                newsDetails = NewsAggItem.SortByNewsDate(newsDetails);

                bool showYearTitles = false;
                if (displayYear == -1)
                {
                    showYearTitles = true;
                }

                int  previousYearTitle  = -1;
                int  previousMonthTitle = -1;
                bool monthULStarted     = false;

                foreach (NewsAggItem news in newsDetails)
                {
                    if (displayYear >= 0 && news.NewsDate.Year != displayYear)
                    {
                        continue; // skip this item.
                    }
                    if (showYearTitles && (previousYearTitle == -1 || news.NewsDate.Year != previousYearTitle))
                    {
                        if (monthULStarted)
                        {
                            html.Append("</ul>");
                        }

                        html.Append("<h2>");
                        html.Append(news.NewsDate.Year);
                        html.Append("</h2>");
                        previousYearTitle = news.NewsDate.Year;
                    }

                    if (previousMonthTitle == -1 || news.NewsDate.Month != previousMonthTitle)
                    {
                        if (monthULStarted)
                        {
                            html.Append("</ul>");
                        }
                        if (showYearTitles)
                        {
                            html.Append("<strong>");
                        }
                        else
                        {
                            html.Append("<h2>");
                        }
                        html.Append(news.NewsDate.ToString("MMMM"));
                        if (showYearTitles)
                        {
                            html.Append("</strong>");
                        }
                        else
                        {
                            html.Append("</h2>");
                        }
                        html.Append("<ul>");
                        monthULStarted     = true;
                        previousMonthTitle = news.NewsDate.Month;
                    }

                    string FormattedDisplay = news.getHtmlDisplay(renderParams, lang);
                    html.Append(FormattedDisplay);
                } // foreach
                if (monthULStarted)
                {
                    html.Append("</ul>");
                }
            }
            return(html.ToString());
        }
 private static int CompareNewsByDate(NewsAggItem x, NewsAggItem y)
 {
     return(DateTime.Compare(x.NewsDate, y.NewsDate));
 }