Ejemplo n.º 1
0
        //+
        //- #OnInit -//
        protected override void OnInit(EventArgs e)
        {
            Func <BlogEntry, IndexEntry> indexTransformation = p => new IndexEntry
            {
                Url             = Themelia.Web.WebDomain.GetUrl() + Themelia.Web.UrlCleaner.FixWebPathHead(p.MappingNameList.FirstOrDefault()),
                Title           = p.Title,
                TypeGuid        = p.BlogEntryTypeGuid,
                PostDateTime    = p.PostDateTime,
                LabelList       = p.LabelList,
                DateTimeString  = String.Format("{0}, {1} {2}, {3}", p.PostDateTime.DayOfWeek, p.PostDateTime.ToString("MMMM"), p.PostDateTime.Day, p.PostDateTime.Year),
                DateTimeDisplay = String.Format("{0}/{1}/{2} {3}", p.PostDateTime.Month, p.PostDateTime.Day, p.PostDateTime.Year, p.PostDateTime.ToShortTimeString())
            };
            List <IndexEntry> indexDataSource;

            //+ index
            if (this.Index > 0)
            {
                String   blogGuid      = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.BlogGuid);
                DateTime startDateTime = new DateTime(this.Index, 1, 1, 0, 0, 0);
                DateTime endDateTime   = new DateTime(this.Index, 12, 31, 23, 59, 59);
                //+
                indexDataSource = BlogAgent.GetBlogEntryListByDateRange(blogGuid, startDateTime, endDateTime, false, true).Select(indexTransformation).ToList();
                List <Int32> yearDataSource = BlogAgent.GetBlogEntryList(blogGuid, 0, false, BlogEntryRetreivalType.VeryBasic)
                                              .Where(p => p.PostDateTime.Year != this.Index)
                                              .Select(p => p.PostDateTime.Year)
                                              .Distinct()
                                              .OrderByDescending(p => p)
                                              .ToList();
                indexListSeries = new IndexListSeries()
                {
                    HeadingSuffix       = BlogSection.GetConfigSection().Suffix.Index,
                    BlogEntryDataSource = indexDataSource,
                    YearDataSource      = yearDataSource,
                    Year = this.Index
                };
                indexListSeries.ID = "indexListSeries";
                this.Controls.Add(indexListSeries);
            }
            //+ blog
            else
            {
                if (this.AccessType == AccessType.Archive || this.AccessType == AccessType.Label)
                {
                    if (this.DataSource != null && this.DataSource.Count > 0)
                    {
                        indexDataSource   = this.DataSource.Select(indexTransformation).ToList();
                        indexEntryList    = new IndexEntryList(this.AccessType, indexDataSource);
                        indexEntryList.ID = "indexEntryList";
                        this.Controls.Add(indexEntryList);
                    }
                }
                //+
                phNoEntries    = __BuildNoEntryPlaceHolderControl();
                phNoEntries.ID = "phNoEntries";
                this.Controls.Add(phNoEntries);
                //+
                rptPosts    = this.__BuildPostRepeaterControl();
                rptPosts.ID = "rptPosts";
                this.Controls.Add(rptPosts);
                //+
                if (this.SupportCommenting)
                {
                    mvCommentContent = this.__BuildCommentMultiViewControl();
                    this.Controls.Add(mvCommentContent);
                }
            }
            //+
            base.OnInit(e);
        }