protected void Page_Load(object sender, EventArgs e) { Disabler.DisableSiteDropDown(this); _content = new Content(); FillSiteID(); FillContentID(); LoadExistingContent(); if (Page.IsPostBack) { ParsePostBack(); RestoreEmbeddablesAfterPostBack(); } else { // clear the temporary revision ID if it exists Session["newRevision"] = null; SetupTree(); if (_contentEntity != null) { FillPageContent(_contentEntity); LoadBucketsAndEmbeddables(_contentEntity); } } }
/// <summary> /// Creates a LinkButton for each revision and attaches an event handler to it. /// </summary> private void CreateRevisionLinks() { var business = new Content(); IContentEntity entity = business.GetContentEntity(_contentID); var revisions = business.LoadRevisions(_contentID, _siteID); plcRevisionLinks.Controls.Clear(); foreach (var rev in revisions) { LinkButton lnk = new LinkButton(); lnk.ID = rev.VersionID.ToString(); lnk.Text = rev.TimeStamp.ToString(); if (lnk.ID == entity.CurrentRevision.ToString()) { lnk.Text = lnk.Text.Insert(0, "LIVE - "); } lnk.Click += new EventHandler(PromoteVersion); plcRevisionLinks.Controls.Add(lnk); Literal l = new Literal(); l.Text = "<br/>"; plcRevisionLinks.Controls.Add(l); } }
/// <summary> /// Promotes a revision to the current live content. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PromoteVersion(object sender, EventArgs e) { var link = (LinkButton)sender; Content c = new Content(); IContentEntity entity = c.GetContentEntity(_contentID); entity.CurrentRevision = new Guid(link.ID); c.SaveEntity(entity); Response.Redirect(Request.RawUrl); }
/// <summary> /// Toggles which buckets and embeddables are enabled for this content revision by default. /// </summary> /// <param name="page">The IContentEntity object that represents the page.</param> private void LoadBucketsAndEmbeddables(IContentEntity page) { var business = new Content(); var content = (List <IContentRow>)business.LoadContent(page.CurrentRevision.Value); string bucket = String.Empty; foreach (var b in content) { switch (b.bucketID) { case 1: chkHeader.Checked = true; bucket = "AddHeaderEmbeddableRow"; break; case 2: chkPrimaryNav.Checked = true; bucket = "AddPrimaryNavEmbeddableRow"; break; case 3: chkContent.Checked = true; bucket = "AddContentEmbeddableRow"; break; case 4: chkSubNav.Checked = true; bucket = "AddSubNavEmbeddableRow"; break; case 5: chkFooter.Checked = true; bucket = "AddFooterEmbeddableRow"; break; default: break; } var uniqueID = Guid.NewGuid(); AddEmbeddableRowToBucket(uniqueID.ToString(), bucket, b.embeddableID); AddEmbeddableToList(uniqueID, bucket, b.embeddableID); } }