Пример #1
0
        public void FeaturedContent()
        {
            Controller cn = new Controller("/default");
            Page page = new Page();
            page.PageNumber = 1;
            page.Name = "New featured content page";
            page.Body = "Yay";

            Page page2 = new Page();
            page2.PageNumber = 2;
            page2.Name = "Page 2";
            page2.Body = "Not page 3";

            cn.AddPage(page);

            cn.AddPage(page2);

            cn.Save();

            cn = new Controller("/default");
            cn.RemovePage(1);

            cn.Save();
        }
Пример #2
0
        protected void UpdatePageText()
        {
            this.FeaturedContent.Title = this.txtTitle.Text;
            foreach (RepeaterItem item in this.PageList.Items)
            {
                TextBox name = item.FindControl("txtPageName") as TextBox;
                HiddenField pageNum = item.FindControl("txtPageNumber") as HiddenField;
                if (name != null && pageNum != null && name.Visible)
                {
                    int pageNumber = -1;
                    int.TryParse(pageNum.Value, out pageNumber);
                    Mubble.Models.Page workingPage = this.FeaturedContent.GetPage(pageNumber);

                    if (workingPage == null)
                    {
                        workingPage = new Mubble.Models.Page();
                        workingPage.PageNumber = pageNumber;
                        this.FeaturedContent.AddPage(workingPage);
                    }
                    workingPage.Name = name.Text;
                    workingPage.Body = Mubble.Config.Caching.ResolveMediaPaths(this.txtBody.Text);
                }
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.AssertPermission("full", "publish", "draft");
            this.PreRender += new EventHandler(Article_PreRender);
            if (!Page.IsPostBack)
            {
                Cache.Remove(this.WorkingCacheKey);
                this.CurrentPageNumber = 1;
                txtTitle.Text = Controller.Title;
                txtContentBody.Text = Controller.Body;
                txtExcerpt.Text = Controller.Excerpt;

                if (this.FeaturedContent.Pages.Count == 0)
                {
                    Mubble.Models.Page blank = new Mubble.Models.Page();
                    blank.PageNumber = 1;
                    blank.Name = "Page 1";
                    blank.Body = "This is page 1";
                    this.FeaturedContent.AddPage(blank);
                    this.FeaturedContent.Save();
                }
                #region Initialize date crapola
                this.lstMonth.SelectedValue = Controller.PublishDate.Month.ToString();
                for (int i = 1; i <= 31; i++)
                {
                    this.lstDay.Items.Add(i.ToString());
                }
                this.lstDay.SelectedValue = Controller.PublishDate.Day.ToString();

                for (int i = 1995; i <= DateTime.Now.Year + 10; i++)
                {
                    this.lstYear.Items.Add(i.ToString());
                }
                this.lstYear.SelectedValue = Controller.PublishDate.Year.ToString();

                for (int i = 1; i <= 12; i++)
                {
                    ListItem item = new ListItem();
                    item.Value = i.ToString();
                    item.Text = (i < 10) ? "0" + i.ToString() : i.ToString();
                    item.Selected = (i == Controller.PublishDate.Hour || i + 12 == Controller.PublishDate.Hour);

                    this.lstHour.Items.Add(item);
                }

                for (int i = 0; i <= 59; i++)
                {
                    ListItem item = new ListItem();
                    item.Value = i.ToString();
                    item.Text = (i < 10) ? "0" + i.ToString() : i.ToString();
                    item.Selected = (i == Controller.PublishDate.Minute);

                    this.lstMinute.Items.Add(item);
                }

                this.lstAmPm.SelectedValue = (Controller.PublishDate.Hour >= 12) ? "PM" : "AM";

                #endregion
            }
            Mubble.UI.Admin.ActiveObjectFieldEditor.BindActiveObjectEditors(this, this.FeaturedContent);
        }
Пример #4
0
 protected void AddPage_Click(object sender, System.EventArgs e)
 {
     this.UpdatePageText();
     Mubble.Models.Page newPage = new Mubble.Models.Page();
     newPage.PageNumber = this.FeaturedContent.Pages.Count + 1;
     newPage.Body = string.Format("Page {0} text.", newPage.PageNumber);
     newPage.Name = string.Format("Page {0}", newPage.PageNumber);
     this.FeaturedContent.AddPage(newPage);
     this.CurrentPageNumber = newPage.PageNumber;
 }
Пример #5
0
 /// <summary>
 /// Adds a page to the featured content and returns the page number.
 /// </summary>
 /// <param name="page">The page to add.</param>
 /// <returns>The page number of the new page</returns>
 public int AddPage(Page page)
 {
     bool pageExists = false;
     int maxPage = 0;
     foreach (Page p in this.Pages)
     {
         if (p.PageNumber == page.PageNumber)
         {
             pageExists = true;
         }
         if (p.PageNumber > maxPage)
         {
             maxPage = p.PageNumber;
         }
     }
     if (pageExists)
     {
         page.PageNumber = maxPage + 1;
     }
     page.DataManager.IsDirty = true;
     this.Pages.Add(page);
     return page.PageNumber;
 }