Inheritance: ISiteContent
		public ContentPageExport() {
			CarrotCakeVersion = SiteData.CarrotCakeCMSVersion;
			ExportDate = DateTime.UtcNow;

			ThePage = new ContentPage();
			ThePageWidgets = new List<Widget>();
		}
Esempio n. 2
0
		public static PagePayload GetContent(ContentPage cp) {
			PagePayload page = new PagePayload();
			page.ThePage = cp;

			page.Load();
			return page;
		}
		public override string GetHtml() {
			string sFieldValue = string.Empty;

			if (this.ContentPage == null) {
				this.ContentPage = SiteData.GetCurrentPage();
			}

			SiteNav navNext = new SiteNav();

			if (this.NavigationDirection != NavDirection.Unknown) {
				using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
					if (NavigationDirection == NavDirection.Prev) {
						navNext = navHelper.GetPrevPost(SiteData.CurrentSiteID, this.ContentPage.Root_ContentID, !SecurityData.IsAuthEditor);
					}
					if (NavigationDirection == NavDirection.Next) {
						navNext = navHelper.GetNextPost(SiteData.CurrentSiteID, this.ContentPage.Root_ContentID, !SecurityData.IsAuthEditor);
					}

					if (navNext != null) {
						if (this.UseDefaultText) {
							string sField = this.CaptionDataField.ToString();

							object objData = ReflectionUtilities.GetPropertyValue(navNext, sField);
							if (objData != null) {
								sFieldValue = String.Format("{0}", objData);
							}

							this.NavigateText = sFieldValue;
						}

						this.NavigateUrl = navNext.FileName;
					} else {
						this.NavigateUrl = String.Empty;
					}
				}
			} else {
				this.NavigateUrl = String.Empty;
			}

			if (!String.IsNullOrEmpty(this.NavigateUrl)) {
				var lnkBuilder = new TagBuilder("a");
				lnkBuilder.MergeAttribute("href", this.NavigateUrl);

				lnkBuilder.InnerHtml = this.NavigateUrl;
				if (!String.IsNullOrEmpty(this.NavigateText)) {
					lnkBuilder.InnerHtml = this.NavigateText;
				}

				var lnkAttribs = (IDictionary<string, object>)HtmlHelper.AnonymousObjectToHtmlAttributes(linkAttributes);
				lnkBuilder.MergeAttributes(lnkAttribs);

				return lnkBuilder.ToString(TagRenderMode.Normal);
			} else {
				return String.Empty;
			}
		}
		protected void Page_Load(object sender, EventArgs e) {
			Master.UsesSaved = true;
			Master.HideSave();

			guidContentID = GetGuidPageIDFromQuery();
			guidWidgetID = GetGuidParameterFromQuery("widgetid");

			sFieldName = GetStringParameterFromQuery("field").ToLower();
			sMode = GetStringParameterFromQuery("mode").ToLower();

			cmsHelper.OverrideKey(guidContentID);

			if (cmsHelper.cmsAdminContent != null) {
				pageContents = cmsHelper.cmsAdminContent;

				if (sMode == "plain") {
					divCenter.Visible = false;
					reBody.CssClass = "mcePlainText";
					pnlPlain.Visible = true;
				} else {
					pnlRichEdit.Visible = true;
				}

				if (!IsPostBack) {
					if (guidWidgetID != Guid.Empty) {
						Widget pageWidget = (from w in cmsHelper.cmsAdminWidget
											 where w.Root_WidgetID == guidWidgetID
											 select w).FirstOrDefault();

						reBody.Text = pageWidget.ControlProperties;
					} else {
						switch (sFieldName) {
							case "c":
								reBody.Text = pageContents.PageText;
								break;

							case "l":
								reBody.Text = pageContents.LeftPageText;
								break;

							case "r":
								reBody.Text = pageContents.RightPageText;
								break;
						}
					}
				}
			}
		}
        protected void btnSave_Click(object sender, EventArgs e)
        {
            pageContents = new ContentPage(SiteID, ContentPageType.PageType.ContentEntry);

            DateTime dtSite = CMSConfigHelper.CalcNearestFiveMinTime(SiteData.CurrentSite.Now);

            int iOrder = pageHelper.GetMaxNavOrder(SiteID) + 1;
            Guid? parentContentID = ParentPagePicker.SelectedPage;

            pageContents.Parent_ContentID = parentContentID;

            pageContents.TitleBar = txtTitle.Text;
            pageContents.NavMenuText = txtNav.Text;
            pageContents.PageHead = txtHead.Text;
            pageContents.FileName = txtFileName.Text;

            pageContents.MetaDescription = txtDescription.Text;
            pageContents.MetaKeyword = txtKey.Text;

            pageContents.Heartbeat_UserId = SecurityData.CurrentUserGuid;
            pageContents.EditHeartbeat = dtSite.AddMinutes(5);

            pageContents.EditUserId = SecurityData.CurrentUserGuid;
            pageContents.IsLatestVersion = true;
            pageContents.EditDate = SiteData.CurrentSite.Now;
            pageContents.NavOrder = iOrder;
            pageContents.PageActive = false;
            pageContents.ShowInSiteMap = true;
            pageContents.ShowInSiteNav = true;
            pageContents.ContentType = ContentPageType.PageType.ContentEntry;

            pageContents.GoLiveDate = dtSite;
            pageContents.RetireDate = dtSite.AddYears(200);

            pageContents.SavePageEdit();

            pnlAdd.Visible = false;
            pnlSaved.Visible = true;

            litPageName.Text = pageContents.FileName;
            lnkNew.NavigateUrl = pageContents.FileName;

            if (pageContents.FileName.ToLowerInvariant().EndsWith(SiteData.DefaultDirectoryFilename)) {
                VirtualDirectory.RegisterRoutes(true);
            }

            Master.ShowSave();
        }
		protected override void OnInit(EventArgs e) {
			base.OnInit(e);

			pph = new PageProcessingHelper(this.Page);

			pph.LoadData();
			if (pph.ThePage != null) {
				theSite = pph.TheSite;
				pageContents = pph.ThePage;
				pageWidgets = pph.ThePageWidgets;
			}

			if (SiteData.IsWebView) {
				pph.LoadPageControls();
			}
		}
		protected void Page_Load(object sender, EventArgs e) {
			Master.UsesSaved = true;
			Master.HideSave();

			guidContentID = GetGuidPageIDFromQuery();

			cmsHelper.OverrideKey(guidContentID);

			if (cmsHelper.cmsAdminContent != null) {
				pageContents = cmsHelper.cmsAdminContent;
				litPageName.Text = pageContents.FileName;

				if (!IsPostBack) {
					GeneralUtilities.BindList(listCats, SiteData.CurrentSite.GetCategoryList().OrderBy(x => x.CategoryText));
					GeneralUtilities.BindList(listTags, SiteData.CurrentSite.GetTagList().OrderBy(x => x.TagText));

					txtTitle.Text = pageContents.TitleBar;
					txtNav.Text = pageContents.NavMenuText;
					txtHead.Text = pageContents.PageHead;
					txtThumb.Text = pageContents.Thumbnail;

					txtDescription.Text = pageContents.MetaDescription;
					txtKey.Text = pageContents.MetaKeyword;

					txtReleaseDate.Text = pageContents.GoLiveDate.ToShortDateString();
					txtReleaseTime.Text = pageContents.GoLiveDate.ToShortTimeString();
					txtRetireDate.Text = pageContents.RetireDate.ToShortDateString();
					txtRetireTime.Text = pageContents.RetireDate.ToShortTimeString();

					lblUpdated.Text = pageContents.EditDate.ToString();

					chkActive.Checked = pageContents.PageActive;
					chkHide.Checked = pageContents.BlockIndex;

					if (pageContents.CreditUserId.HasValue) {
						var usr = new ExtendedUserData(pageContents.CreditUserId.Value);
						hdnCreditUserID.Value = usr.UserName;
						txtSearchUser.Text = string.Format("{0} ({1})", usr.UserName, usr.EmailAddress);
					}

					GeneralUtilities.SelectListValues(listTags, pageContents.ContentTags.Cast<IContentMetaInfo>().Select(x => x.ContentMetaInfoID.ToString()).ToList());
					GeneralUtilities.SelectListValues(listCats, pageContents.ContentCategories.Cast<IContentMetaInfo>().Select(x => x.ContentMetaInfoID.ToString()).ToList());
				}
			}
		}
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.UsesSaved = true;
            Master.HideSave();

            guidContentID = GetGuidPageIDFromQuery();

            cmsHelper.OverrideKey(guidContentID);

            if (cmsHelper.cmsAdminContent != null) {
                pageContents = cmsHelper.cmsAdminContent;
                litPageName.Text = pageContents.FileName;

                if (!IsPostBack) {

                    txtTitle.Text = pageContents.TitleBar;
                    txtNav.Text = pageContents.NavMenuText;
                    txtHead.Text = pageContents.PageHead;
                    txtThumb.Text = pageContents.Thumbnail;

                    txtDescription.Text = pageContents.MetaDescription;
                    txtKey.Text = pageContents.MetaKeyword;

                    txtReleaseDate.Text = pageContents.GoLiveDate.ToShortDateString();
                    txtReleaseTime.Text = pageContents.GoLiveDate.ToShortTimeString();
                    txtRetireDate.Text = pageContents.RetireDate.ToShortDateString();
                    txtRetireTime.Text = pageContents.RetireDate.ToShortTimeString();

                    lblUpdated.Text = pageContents.EditDate.ToString();

                    chkActive.Checked = pageContents.PageActive;
                    chkNavigation.Checked = pageContents.ShowInSiteNav;
                    chkSiteMap.Checked = pageContents.ShowInSiteMap;
                    chkHide.Checked = pageContents.BlockIndex;

                    if (pageContents.CreditUserId.HasValue) {
                        var usr = new ExtendedUserData(pageContents.CreditUserId.Value);
                        hdnCreditUserID.Value = usr.UserName;
                        txtSearchUser.Text = string.Format("{0} ({1})", usr.UserName, usr.EmailAddress);
                    }

                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.ActivateTab(AdminBaseMasterPage.SectionID.SiteTemplate);

            Guid siteID = SiteData.CurrentSiteID;

            pageHome = pageHelper.FindHome(siteID, true);

            if (!IsPostBack) {

                List<CMSTemplate> lstTemplate = cmsHelper.Templates;

                GeneralUtilities.BindListDefaultText(ddlBlogIndex, lstTemplate, null, sSelTemplate, "0");
                GeneralUtilities.BindListDefaultText(ddlHome, lstTemplate, null, sSelTemplate, "0");

                if (pageHome != null && pageHome.Root_ContentID != Guid.Empty) {

                    if (SiteData.CurrentSite.Blog_Root_ContentID.HasValue) {
                        pageIndex = pageHelper.FindContentByID(siteID, SiteData.CurrentSite.Blog_Root_ContentID.Value);
                    }

                    litHomepage.Text = pageHome.NavMenuText + "  [" + pageHome.FileName + "]";

                    GeneralUtilities.BindListDefaultText(ddlHome, lstTemplate, pageHome.TemplateFile, sSelTemplate, "0");

                    if (pageIndex != null) {
                        ParentPagePicker.SelectedPage = pageIndex.Root_ContentID;
                        GeneralUtilities.SelectListValue(ddlBlogIndex, pageIndex.TemplateFile);
                    } else {
                        ParentPagePicker.SelectedPage = null;
                        //ddlBlogIndex.Enabled = false;
                    }
                }

                GeneralUtilities.BindListDefaultText(ddlAll, lstTemplate, null, sSelTemplate, "0");
                GeneralUtilities.BindListDefaultText(ddlTop, lstTemplate, null, sSelTemplate, "0");
                GeneralUtilities.BindListDefaultText(ddlSub, lstTemplate, null, sSelTemplate, "0");
                GeneralUtilities.BindListDefaultText(ddlPages, lstTemplate, null, sSelTemplate, "0");
                GeneralUtilities.BindListDefaultText(ddlPosts, lstTemplate, null, sSelTemplate, "0");

            }
        }
 public static ContentPage GetEmptyHome()
 {
     ContentPage navData = new ContentPage();
     navData.ContentID = Guid.Empty;
     navData.Root_ContentID = Guid.Empty;
     navData.SiteID = SiteData.CurrentSiteID;
     navData.TemplateFile = "_EmptyHome";
     navData.FileName = SiteData.DefaultDirectoryFilename;
     navData.NavMenuText = "NONE";
     navData.PageHead = "NONE";
     navData.TitleBar = "NONE";
     navData.PageActive = false;
     navData.PageText = "<p>NO PAGE CONTENT</p>";
     navData.EditDate = DateTime.Now.Date.AddDays(-1);
     navData.CreateDate = DateTime.Now.Date.AddDays(-10);
     navData.GoLiveDate = DateTime.Now.Date.AddDays(1);
     navData.RetireDate = DateTime.Now.Date.AddDays(90);
     navData.ContentType = ContentPageType.PageType.ContentEntry;
     return navData;
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Guid siteID = SiteData.CurrentSiteID;

            SiteData.CurrentSite.Blog_Root_ContentID = ParentPagePicker.SelectedPage;
            if (ParentPagePicker.SelectedPage.HasValue) {
                pageIndex = pageHelper.FindContentByID(siteID, ParentPagePicker.SelectedPage.Value);
            }
            SiteData.CurrentSite.Save();

            if (ddlPosts.SelectedValue.Length > 5) {
                pageHelper.UpdateAllBlogTemplates(siteID, ddlPosts.SelectedValue);
            }
            if (ddlPages.SelectedValue.Length > 5) {
                pageHelper.UpdateAllPageTemplates(siteID, ddlPages.SelectedValue);
            }

            if (ddlTop.SelectedValue.Length > 5) {
                pageHelper.UpdateTopPageTemplates(siteID, ddlTop.SelectedValue);
            }
            if (ddlSub.SelectedValue.Length > 5) {
                pageHelper.UpdateSubPageTemplates(siteID, ddlSub.SelectedValue);
            }

            if (pageHome != null && ddlHome.SelectedValue.Length > 5) {
                pageHome.TemplateFile = ddlHome.SelectedValue;
                pageHome.ApplyTemplate();
            }
            if (pageIndex != null && ddlBlogIndex.SelectedValue.Length > 5) {
                pageIndex.TemplateFile = ddlBlogIndex.SelectedValue;
                pageIndex.ApplyTemplate();
            }

            if (ddlAll.SelectedValue.Length > 5) {
                pageHelper.UpdateAllContentTemplates(siteID, ddlAll.SelectedValue);
            }

            Response.Redirect(SiteData.CurrentScriptName);
        }
 public ContentPage GetLatestContentByURL(Guid siteID, bool bActiveOnly, string sPage)
 {
     ContentPage content = null;
     vw_carrot_Content cont = CompiledQueries.GetLatestContentByURL(db, siteID, bActiveOnly, sPage);
     if (cont != null) {
         content = new ContentPage(cont);
     }
     return content;
 }
 public ContentPage FindHome(Guid siteID, bool bActiveOnly)
 {
     ContentPage content = null;
     vw_carrot_Content cont = CompiledQueries.FindHome(db, siteID, bActiveOnly);
     if (cont != null) {
         content = new ContentPage(cont);
     }
     return content;
 }
 public ContentPage FindContentByID(Guid siteID, Guid rootContentID)
 {
     ContentPage content = null;
     vw_carrot_Content cont = CompiledQueries.GetLatestContentByID(db, siteID, false, rootContentID);
     if (cont != null) {
         content = new ContentPage(cont);
     }
     return content;
 }
 public ContentPage FindByPageSlug(Guid siteID, DateTime datePublished, string urlPageSlug)
 {
     ContentPage content = null;
     vw_carrot_Content cont = CompiledQueries.cqGetLatestContentBySlug(db, siteID, datePublished, urlPageSlug);
     if (cont != null) {
         content = new ContentPage(cont);
     }
     return content;
 }
		private void CreateEmptyHome() {
			DateTime dtSite = CMSConfigHelper.CalcNearestFiveMinTime(SiteData.CurrentSite.Now);

			ContentPage pageContents = new ContentPage {
				SiteID = SiteID,
				Root_ContentID = Guid.NewGuid(),
				ContentID = Guid.NewGuid(),
				EditDate = SiteData.CurrentSite.Now,
				CreateUserId = SecurityData.CurrentUserGuid,
				CreateDate = SiteData.CurrentSite.Now,
				GoLiveDate = dtSite.AddMinutes(-5),
				RetireDate = dtSite.AddYears(200),
				TitleBar = "Home",
				NavMenuText = "Home",
				PageHead = "Home",
				FileName = "/home",
				PageText = SiteData.StarterHomePageSample,
				LeftPageText = String.Empty,
				RightPageText = String.Empty,
				NavOrder = 0,
				IsLatestVersion = true,
				PageActive = true,
				ShowInSiteNav = true,
				ShowInSiteMap = true,
				BlockIndex = false,
				EditUserId = SecurityData.CurrentUserGuid,
				ContentType = ContentPageType.PageType.ContentEntry,
				TemplateFile = SiteData.DefaultTemplateFilename
			};

			pageContents.SavePageEdit();
		}
        public static ContentPage GetSamplerView()
        {
            string sFile1 = String.Empty;
            string sFile2 = String.Empty;

            try {
                Assembly _assembly = Assembly.GetExecutingAssembly();

                using (StreamReader oTextStream = new StreamReader(_assembly.GetManifestResourceStream("Carrotware.CMS.Core.SiteContent.Mock.SampleContent1.txt"))) {
                    sFile1 = oTextStream.ReadToEnd();
                }
                using (StreamReader oTextStream = new StreamReader(_assembly.GetManifestResourceStream("Carrotware.CMS.Core.SiteContent.Mock.SampleContent2.txt"))) {
                    sFile2 = oTextStream.ReadToEnd();
                }

                List<string> imageNames = (from i in _assembly.GetManifestResourceNames()
                                           where i.Contains("SiteContent.Mock.sample")
                                           && i.EndsWith(".png")
                                           select i).ToList();

                foreach (string img in imageNames) {
                    var imgURL = CMSConfigHelper.GetWebResourceUrl(typeof(ContentPage), img);
                    sFile1 = sFile1.Replace(img, imgURL);
                    sFile2 = sFile2.Replace(img, imgURL);
                }
            } catch { }

            ContentPage pageNew = new ContentPage();
            pageNew.Root_ContentID = SiteData.CurrentSiteID;
            pageNew.ContentID = pageNew.Root_ContentID;
            pageNew.SiteID = SiteData.CurrentSiteID;
            pageNew.Parent_ContentID = null;

            pageNew.PageText = "<h2>Content CENTER</h2>\r\n" + sFile1;
            pageNew.LeftPageText = "<h2>Content LEFT</h2>\r\n" + sFile2;
            pageNew.RightPageText = "<h2>Content RIGHT</h2>\r\n" + sFile2;

            pageNew.IsLatestVersion = true;
            pageNew.NavOrder = -1;
            pageNew.TitleBar = "Template Preview - TITLE";
            pageNew.NavMenuText = "Template PV - NAV"; ;
            pageNew.PageHead = "Template Preview - HEAD";
            pageNew.PageActive = true;
            pageNew.ShowInSiteNav = true;
            pageNew.ShowInSiteMap = true;

            pageNew.EditUserId = SecurityData.CurrentUserGuid;

            pageNew.EditDate = DateTime.Now.Date.AddHours(-8);
            pageNew.CreateDate = DateTime.Now.Date.AddHours(-38);
            pageNew.GoLiveDate = pageNew.EditDate.AddHours(-5);
            pageNew.RetireDate = pageNew.CreateDate.AddYears(5);

            pageNew.TemplateFile = SiteData.PreviewTemplateFile;
            pageNew.FileName = SiteData.PreviewTemplateFilePage;
            pageNew.MetaDescription = "Meta Description";
            pageNew.MetaKeyword = "Meta Keyword";

            pageNew.ContentType = ContentPageType.PageType.BlogEntry;
            pageNew.PageSlug = "sampler-page-view";

            List<ContentCategory> lstK = new List<ContentCategory>();
            List<ContentTag> lstT = new List<ContentTag>();

            for (int i = 0; i < 5; i++) {
                ContentCategory k = new ContentCategory {
                    ContentCategoryID = Guid.NewGuid(),
                    CategoryText = "Keyword Text " + i.ToString(),
                    CategorySlug = "keyword-slug-" + i.ToString()
                };
                ContentTag t = new ContentTag {
                    ContentTagID = Guid.NewGuid(),
                    TagText = "Tag Text " + i.ToString(),
                    TagSlug = "tag-slug-" + i.ToString()
                };

                lstK.Add(k);
                lstT.Add(t);
            }

            pageNew.ContentCategories = lstK;
            pageNew.ContentTags = lstT;

            return pageNew;
        }
Esempio n. 18
0
 public string ConstructedCanonicalURL(ContentPage cp)
 {
     return RemoveDupeSlashesURL(this.MainCanonicalURL + cp.FileName);
 }
        public static ContentPage CreateWPContentPage(WordPressSite wps, WordPressPost c, SiteData site)
        {
            ContentPage cont = null;

            ContentPageType.PageType contType = ContentPageType.PageType.Unknown;
            switch (c.PostType)
            {
            case WordPressPost.WPPostType.BlogPost:
                contType = ContentPageType.PageType.BlogEntry;
                break;

            case WordPressPost.WPPostType.Page:
                contType = ContentPageType.PageType.ContentEntry;
                break;
            }

            if (c != null)
            {
                cont           = new ContentPage(site.SiteID, contType);
                cont.ContentID = Guid.NewGuid();

                cont.CreateUserId = SecurityData.CurrentUserGuid;
                cont.EditUserId   = SecurityData.CurrentUserGuid;

                if (!string.IsNullOrEmpty(c.PostAuthor))
                {
                    WordPressUser wpu = wps.Authors.Where(x => x.Login.ToLower() == c.PostAuthor.ToLower()).FirstOrDefault();

                    if (wpu != null && wpu.ImportUserID != Guid.Empty)
                    {
                        MembershipUser usr = SecurityData.GetUserByGuid(wpu.ImportUserID);
                        if (usr != null)
                        {
                            cont.CreateUserId = wpu.ImportUserID;
                            cont.EditUserId   = wpu.ImportUserID;
                        }
                    }
                }

                cont.Root_ContentID   = c.ImportRootID;
                cont.FileName         = c.ImportFileName.Replace("//", "/");
                cont.PageSlug         = null;
                cont.NavOrder         = c.PostOrder;
                cont.Parent_ContentID = null;

                cont.CreateDate  = site.ConvertUTCToSiteTime(c.PostDateUTC);
                cont.PageActive  = c.IsPublished;
                cont.ContentType = ContentPageType.PageType.Unknown;

                if (c.PostType == WordPressPost.WPPostType.BlogPost)
                {
                    cont.ContentType      = ContentPageType.PageType.BlogEntry;
                    cont.PageSlug         = c.ImportFileSlug.Replace("//", "/");
                    cont.NavOrder         = SiteData.BlogSortOrderNumber;
                    cont.Parent_ContentID = null;
                }
                if (c.PostType == WordPressPost.WPPostType.Page)
                {
                    cont.ContentType = ContentPageType.PageType.ContentEntry;
                }

                if (cont.ContentType == ContentPageType.PageType.ContentEntry)
                {
                    cont.ShowInSiteMap = true;
                    cont.ShowInSiteNav = true;
                }
                else
                {
                    cont.ShowInSiteMap = false;
                    cont.ShowInSiteNav = false;
                }

                cont.IsLatestVersion = true;

                cont.IsLatestVersion = true;
                cont.TitleBar        = c.PostTitle;
                cont.NavMenuText     = c.PostTitle;
                cont.PageHead        = c.PostTitle;
                cont.PageText        = c.PostContent;
                cont.LeftPageText    = "";
                cont.RightPageText   = "";

                cont.MetaDescription = "";
                cont.MetaKeyword     = "";

                cont.ContentCategories = new List <ContentCategory>();
                cont.ContentTags       = new List <ContentTag>();

                List <ContentTag>      lstTags       = site.GetTagList();
                List <ContentCategory> lstCategories = site.GetCategoryList();

                cont.ContentCategories = (from l in lstCategories
                                          join o in c.Categories on l.CategorySlug.ToLower() equals o.ToLower()
                                          select l).Distinct().ToList();

                cont.ContentTags = (from l in lstTags
                                    join o in c.Tags on l.TagSlug.ToLower() equals o.ToLower()
                                    select l).Distinct().ToList();
            }

            return(cont);
        }
Esempio n. 20
0
 public void OverrideKey(string sPageName)
 {
     filePage = null;
     using (ContentPageHelper pageHelper = new ContentPageHelper()) {
         filePage = pageHelper.FindByFilename(SiteData.CurrentSiteID, sPageName);
     }
 }
Esempio n. 21
0
		private void LoadGuids() {
			using (ContentPageHelper pageHelper = new ContentPageHelper()) {
				if (!String.IsNullOrEmpty(CurrentEditPage)) {
					filePage = pageHelper.FindByFilename(SiteData.CurrentSite.SiteID, CurrentEditPage);
					if (filePage != null) {
						CurrentPageGuid = filePage.Root_ContentID;
					}
				} else {
					if (CurrentPageGuid != Guid.Empty) {
						filePage = pageHelper.FindContentByID(SiteData.CurrentSite.SiteID, CurrentPageGuid);
						if (filePage != null) {
							CurrentEditPage = filePage.FileName;
						}
					} else {
						filePage = new ContentPage();
					}
				}
			}
		}
		public ContentPage FindByFilename(Guid siteID, string urlFileName) {
			ContentPage content = null;
			vw_carrot_Content cont = CompiledQueries.GetLatestContentByURL(db, siteID, false, urlFileName);

			if (cont != null) {
				content = new ContentPage(cont);
			}
			if (content == null && urlFileName == SiteData.DefaultDirectoryFilename) {
				content = FindHome(siteID, false);
			}

			return content;
		}
		public ContentPage GetLatestContentByURL(Guid siteID, bool bActiveOnly, string sPage) {
			ContentPage content = null;
			vw_carrot_Content cont = CompiledQueries.GetLatestContentByURL(db, siteID, bActiveOnly, sPage);
			if (cont != null) {
				content = new ContentPage(cont);
			}
			if (content == null && sPage == SiteData.DefaultDirectoryFilename) {
				content = FindHome(siteID, bActiveOnly);
			}
			return content;
		}
 public ContentPage GetVersion(Guid siteID, Guid contentID)
 {
     ContentPage content = null;
     vw_carrot_Content cont = CompiledQueries.cqGetContentByContentID(db, siteID, contentID);
     if (cont != null) {
         content = new ContentPage(cont);
     }
     return content;
 }
		public ContentPageExport(ContentPage cp, List<Widget> widgets) {
			SetVals(cp, widgets);
		}
 public bool IsPageLocked(ContentPage cp)
 {
     bool bLock = false;
     if (cp.Heartbeat_UserId != null) {
         if (cp.Heartbeat_UserId != SecurityData.CurrentUserGuid
                 && cp.EditHeartbeat.Value > DateTime.UtcNow.AddMinutes(-2)) {
             bLock = true;
         }
         if (cp.Heartbeat_UserId == SecurityData.CurrentUserGuid
             || cp.Heartbeat_UserId == null) {
             bLock = false;
         }
     }
     return bLock;
 }
		private void SetVals(ContentPage cp, List<Widget> widgets) {
			CarrotCakeVersion = SiteData.CarrotCakeCMSVersion;
			ExportDate = DateTime.UtcNow;
			Guid siteID = cp.SiteID;

			NewRootContentID = Guid.NewGuid();

			cp.LoadAttributes();

			ThePage = cp;
			ThePageWidgets = widgets;

			if (ThePage == null) {
				ThePage = new ContentPage();
				ThePage.Root_ContentID = Guid.NewGuid();
				ThePage.ContentID = ThePage.Root_ContentID;
			}
			if (ThePageWidgets == null) {
				ThePageWidgets = new List<Widget>();
			}

			OriginalRootContentID = ThePage.Root_ContentID;
			OriginalSiteID = ThePage.SiteID;
			OriginalParentContentID = Guid.Empty;
			ParentFileName = "";

			if (ThePage.Parent_ContentID != null) {
				ContentPage parent = new ContentPage();
				using (ContentPageHelper cph = new ContentPageHelper()) {
					parent = cph.FindContentByID(siteID, ThePage.Parent_ContentID.Value);
				}
				ParentFileName = parent.FileName;
				OriginalParentContentID = parent.Root_ContentID;
			}

			ThePage.Root_ContentID = NewRootContentID;
			ThePage.ContentID = NewRootContentID;

			foreach (var w in ThePageWidgets) {
				w.Root_ContentID = NewRootContentID;
				w.Root_WidgetID = Guid.NewGuid();
				w.WidgetDataID = Guid.NewGuid();
			}

			Guid userID1 = Guid.Empty;

			if (!cp.EditUserId.HasValue) {
				userID1 = cp.CreateUserId;
			} else {
				userID1 = cp.EditUserId.Value;
			}

			ExtendedUserData u1 = new ExtendedUserData(userID1);
			this.TheUser = new SiteExportUser(u1);

			Guid userID2 = Guid.Empty;

			if (cp.CreditUserId.HasValue) {
				userID2 = cp.CreditUserId.Value;
			}

			ExtendedUserData u2 = new ExtendedUserData(userID2);
			if (u2 != null) {
				this.CreditUser = new SiteExportUser(u2);
			} else {
				this.CreditUser = null;
			}
		}
		public ActionResult PageAddChild(Guid id, bool? saved) {
			//if (saved.HasValue && saved.Value) {
			//	ShowSave();
			//}

			ContentPageModel model = new ContentPageModel();

			var pageContentsParent = pageHelper.FindContentByID(this.SiteID, id);
			var pageContents = new ContentPage(this.SiteID, ContentPageType.PageType.ContentEntry);

			if (pageContentsParent != null && pageContentsParent.ContentType == ContentPageType.PageType.ContentEntry) {
				pageContents.Parent_ContentID = id;
			} else {
				pageContents.Parent_ContentID = Guid.Empty;
			}

			model.SetPage(pageContents);

			model.VisitPage = false;
			model.ParentID = id;

			return View(model);
		}
 public ContentPage FindByFilename(Guid siteID, string urlFileName)
 {
     ContentPage content = null;
     vw_carrot_Content cont = CompiledQueries.GetLatestContentByURL(db, siteID, false, urlFileName);
     if (cont != null) {
         content = new ContentPage(cont);
     }
     return content;
 }
		protected void SavePage(bool bRedirect) {
			ContentPage pageContents = null;
			if (guidVersionContentID != Guid.Empty) {
				pageContents = pageHelper.GetVersion(SiteID, guidVersionContentID);
			}
			if (guidContentID != Guid.Empty && pageContents == null) {
				pageContents = pageHelper.FindContentByID(SiteID, guidContentID);
			}
			if (guidImportContentID != Guid.Empty) {
				pageContents = ContentImportExportUtils.GetSerializedContentPageExport(guidImportContentID).ThePage;

				if (pageContents != null) {
					pageContents.SiteID = SiteID;
					pageContents.EditDate = SiteData.CurrentSite.Now;
					pageContents.CreateUserId = SecurityData.CurrentUserGuid;
					pageContents.CreateDate = SiteData.CurrentSite.Now;

					var rp = pageHelper.GetLatestContentByURL(SiteID, false, pageContents.FileName);
					if (rp != null) {
						pageContents.Root_ContentID = rp.Root_ContentID;
						pageContents.ContentID = rp.ContentID;
					} else {
						pageContents.Root_ContentID = Guid.Empty;
						pageContents.ContentID = Guid.Empty;
					}
				}
			}

			if (pageContents == null) {
				pageContents = new ContentPage(SiteData.CurrentSiteID, ContentPageType.PageType.ContentEntry);
			}

			DateTime dtSite = CalcNearestFiveMinTime(SiteData.CurrentSite.Now);
			pageContents.GoLiveDate = dtSite.AddMinutes(-5);
			pageContents.RetireDate = dtSite.AddYears(200);

			pageContents.IsLatestVersion = true;
			pageContents.Thumbnail = txtThumb.Text;

			pageContents.TemplateFile = ddlTemplate.SelectedValue;

			pageContents.TitleBar = txtTitle.Text;
			pageContents.NavMenuText = txtNav.Text;
			pageContents.PageHead = txtHead.Text;
			pageContents.FileName = txtFileName.Text;

			pageContents.MetaDescription = txtDescription.Text;
			pageContents.MetaKeyword = txtKey.Text;

			pageContents.EditDate = SiteData.CurrentSite.Now;
			pageContents.NavOrder = int.Parse(txtSort.Text);

			pageContents.PageText = reBody.Text;
			pageContents.LeftPageText = reLeftBody.Text;
			pageContents.RightPageText = reRightBody.Text;

			pageContents.PageActive = chkActive.Checked;
			pageContents.ShowInSiteNav = chkNavigation.Checked;
			pageContents.ShowInSiteMap = chkSiteMap.Checked;
			pageContents.BlockIndex = chkHide.Checked;

			pageContents.ContentType = ContentPageType.PageType.ContentEntry;

			if (ParentPagePicker.SelectedPage.HasValue) {
				pageContents.Parent_ContentID = ParentPagePicker.SelectedPage.Value;
			} else {
				pageContents.Parent_ContentID = null;
			}

			if (String.IsNullOrEmpty(hdnCreditUserID.Value)) {
				pageContents.CreditUserId = null;
			} else {
				var usr = new ExtendedUserData(hdnCreditUserID.Value);
				pageContents.CreditUserId = usr.UserId;
			}

			pageContents.GoLiveDate = Convert.ToDateTime(txtReleaseDate.Text + " " + txtReleaseTime.Text);
			pageContents.RetireDate = Convert.ToDateTime(txtRetireDate.Text + " " + txtRetireTime.Text);
			pageContents.EditUserId = SecurityData.CurrentUserGuid;

			pageContents.NewTrackBackURLs = txtTrackback.Text;

			if (!chkDraft.Checked) {
				pageContents.SavePageEdit();
			} else {
				pageContents.SavePageAsDraft();
			}

			//if importing, copy in all meta data possible
			if (guidImportContentID != Guid.Empty) {
				List<Widget> widgets = ContentImportExportUtils.GetSerializedContentPageExport(guidImportContentID).ThePageWidgets;

				foreach (var wd in widgets) {
					wd.Root_ContentID = pageContents.Root_ContentID;
					wd.Root_WidgetID = Guid.NewGuid();
					wd.WidgetDataID = Guid.NewGuid();
					wd.IsPendingChange = true;
					wd.EditDate = SiteData.CurrentSite.Now;
					wd.Save();
				}

				ContentImportExportUtils.RemoveSerializedExportData(guidImportContentID);
			}

			cmsHelper.OverrideKey(pageContents.Root_ContentID);
			if (cmsHelper.cmsAdminWidget != null) {
				var ww = (from w in cmsHelper.cmsAdminWidget
						  where w.IsLatestVersion == true
						  && w.IsPendingChange == true
						  && (w.ControlPath.StartsWith("CLASS:Carrotware.CMS.UI.Controls.ContentRichText,")
						  || w.ControlPath.StartsWith("CLASS:Carrotware.CMS.UI.Controls.ContentPlainText,"))
						  select w);

				foreach (Widget w in ww) {
					w.Save();
				}
			}

			cmsHelper.cmsAdminContent = null;
			cmsHelper.cmsAdminWidget = null;

			if (pageContents.FileName.ToLower().EndsWith(SiteData.DefaultDirectoryFilename)) {
				VirtualDirectory.RegisterRoutes(true);
			}

			if (!bRedirect) {
				if (sPageMode.Length < 1) {
					Response.Redirect(SiteData.CurrentScriptName + "?id=" + pageContents.Root_ContentID.ToString());
				} else {
					Response.Redirect(SiteData.CurrentScriptName + "?mode=raw&id=" + pageContents.Root_ContentID.ToString());
				}
			} else {
				Response.Redirect(pageContents.FileName);
			}
		}
Esempio n. 31
0
 protected void LoadGuids()
 {
     if (filePage == null) {
         using (ContentPageHelper pageHelper = new ContentPageHelper()) {
             if (SiteData.IsPageSampler && filePage == null) {
                 filePage = ContentPageHelper.GetSamplerView();
             } else {
                 if (SiteData.CurrentScriptName.ToLower().StartsWith(SiteData.AdminFolderPath)) {
                     Guid guidPage = Guid.Empty;
                     if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["pageid"])) {
                         guidPage = new Guid(HttpContext.Current.Request.QueryString["pageid"].ToString());
                     }
                     filePage = pageHelper.FindContentByID(SiteData.CurrentSiteID, guidPage);
                 } else {
                     filePage = pageHelper.FindByFilename(SiteData.CurrentSiteID, SiteData.CurrentScriptName);
                 }
             }
         }
     }
 }