Ejemplo n.º 1
0
        //+
        //- @InstantiateIn -//
        public void InstantiateIn(System.Web.UI.Control container)
        {
            PlaceHolder lit = new PlaceHolder();

            switch (type)
            {
            case ListItemType.Header:
                lit.DataBinding += new EventHandler(delegate(Object sender, System.EventArgs ea)
                {
                });
                break;

            case ListItemType.Item:
                lit.DataBinding += new EventHandler(delegate(Object sender, System.EventArgs ea)
                {
                    PlaceHolder literal             = (PlaceHolder)sender;
                    RepeaterItem item               = (RepeaterItem)literal.NamingContainer;
                    Repeater repeater               = item.Parent as Repeater;
                    IndexListSeries indexListSeries = repeater.Parent as IndexListSeries;
                    if (indexListSeries != null)
                    {
                        Int32 month = (Int32?)DataBinder.Eval(item.DataItem, "Number") ?? 0;
                        String name = DataBinder.Eval(item.DataItem, "Name") as String;
                        if (month > 0)
                        {
                            Func <IndexEntry, Boolean> blogEntryListForMonth = be => be.PostDateTime.Month == month;
                            List <IndexEntry> blogEntryList = indexListSeries.BlogEntryDataSource.Where(blogEntryListForMonth).OrderBy(p => p.PostDateTime).ToList();
                            if (blogEntryList.Count > 0)
                            {
                                literal.Controls.Add(new IndexEntryList(AccessType.Index, blogEntryList)
                                {
                                    Heading = name
                                });
                            }
                        }
                    }
                });
                break;
            }
            container.Controls.Add(lit);
        }
Ejemplo n.º 2
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);
        }