FindContentByID() public method

public FindContentByID ( System.Guid siteID, System.Guid rootContentID ) : ContentPage
siteID System.Guid
rootContentID System.Guid
return ContentPage
		public void SearchTwo() {
			this.Widgets = null;
			this.Pages = null;

			using (ContentPageHelper pageHelper = new ContentPageHelper()) {
				this.SelectedPage = pageHelper.FindContentByID(SiteData.CurrentSiteID, this.SelectedItem);
				this.Widgets = this.SelectedPage.GetWidgetList();
			}
		}
		public ContentPageExport(Guid siteID, Guid rootContentID) {
			ContentPage cp = null;

			using (ContentPageHelper cph = new ContentPageHelper()) {
				cp = cph.FindContentByID(siteID, rootContentID);
			}

			List<Widget> widgets = cp.GetWidgetList();

			SetVals(cp, widgets);
		}
Exemplo n.º 3
0
		public ContentPage GetContentPage() {
			ContentPage cp = null;
			if (SiteData.IsPageSampler) {
				cp = ContentPageHelper.GetSamplerView();
			} else {
				using (ContentPageHelper cph = new ContentPageHelper()) {
					cp = cph.FindContentByID(this.SiteID, this.Root_ContentID);
				}
			}
			return cp;
		}
		public void SetCurrent(Guid id) {
			this.Root_ContentID = id;

			using (ContentPageHelper pageHelper = new ContentPageHelper()) {
				this.ContentPage = pageHelper.FindContentByID(this.SiteID, id);

				this.History.DataSource = pageHelper.GetVersionHistory(this.SiteID, id);
				this.History.TotalRecords = this.History.DataSource.Count();
				this.History.PageSize = this.History.TotalRecords * 2;
			}
		}
		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 void Save() {
			this.CopyCount = 0;
			if (this.Widgets != null) {
				List<Guid> lstSel = this.Widgets.Where(x => x.Selected).Select(x => x.Root_WidgetID).ToList();

				using (ContentPageHelper pageHelper = new ContentPageHelper()) {
					this.SelectedPage = pageHelper.FindContentByID(SiteData.CurrentSiteID, this.SelectedItem);
					this.Widgets = this.SelectedPage.GetWidgetList();
				}

				using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) {
					cmsHelper.OverrideKey(this.Root_ContentID);

					if (cmsHelper.cmsAdminWidget != null) {
						List<Widget> cacheWidget = cmsHelper.cmsAdminWidget;

						List<Widget> ww = (from w in this.SelectedPage.GetWidgetList()
										   where lstSel.Contains(w.Root_WidgetID) && w.IsLatestVersion == true
										   select w).ToList();

						if (ww != null) {
							this.CopyCount = ww.Count;

							foreach (var w in ww) {
								Guid newWidget = Guid.NewGuid();

								Widget wCpy = new Widget {
									Root_ContentID = this.Root_ContentID,
									Root_WidgetID = newWidget,
									WidgetDataID = Guid.NewGuid(),
									PlaceholderName = this.PlaceholderName,
									ControlPath = w.ControlPath,
									ControlProperties = w.ControlProperties,
									IsLatestVersion = true,
									IsPendingChange = true,
									IsWidgetActive = true,
									IsWidgetPendingDelete = false,
									WidgetOrder = w.WidgetOrder,
									GoLiveDate = w.GoLiveDate,
									RetireDate = w.RetireDate,
									EditDate = SiteData.CurrentSite.Now
								};

								cacheWidget.Add(wCpy);
							}
						}

						cmsHelper.cmsAdminWidget = cacheWidget;
					}
				}
			}
		}
Exemplo n.º 7
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();
					}
				}
			}
		}
Exemplo n.º 8
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);
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
 public void OverrideKey(Guid guidContentID)
 {
     filePage = null;
     using (ContentPageHelper pageHelper = new ContentPageHelper()) {
         filePage = pageHelper.FindContentByID(SiteData.CurrentSiteID, guidContentID);
     }
 }
Exemplo n.º 10
0
		public bool IsUniqueFilename() {
			string theFileName = this.FileName;

			theFileName = ContentPageHelper.ScrubFilename(this.Root_ContentID, theFileName);

			theFileName = theFileName.ToLower();

			if (SiteData.IsPageSpecial(theFileName) || SiteData.IsLikelyHomePage(theFileName)) {
				return false;
			}

			if (SiteData.CurrentSite.GetSpecialFilePathPrefixes().Where(x => theFileName.StartsWith(x.ToLower())).Count() > 0
				|| theFileName.StartsWith(SiteData.CurrentSite.BlogFolderPath.ToLower())) {
				return false;
			}

			using (ContentPageHelper pageHelper = new ContentPageHelper()) {
				ContentPage fn = pageHelper.FindByFilename(SiteData.CurrentSite.SiteID, theFileName);

				ContentPage cp = pageHelper.FindContentByID(SiteData.CurrentSite.SiteID, this.Root_ContentID);

				if (cp == null && this.Root_ContentID != Guid.Empty) {
					cp = pageHelper.GetVersion(SiteData.CurrentSite.SiteID, this.Root_ContentID);
				}

				if (fn == null || (fn != null && cp != null && fn.Root_ContentID == cp.Root_ContentID)) {
					return true;
				}
			}

			return false;
		}
Exemplo n.º 11
0
		public bool IsUniqueBlog() {
			DateTime dateGoLive = Convert.ToDateTime(this.GoLiveDate);
			DateTime dateOrigGoLive = DateTime.MinValue;

			string thePageSlug = ContentPageHelper.ScrubFilename(this.Root_ContentID, this.PageSlug).ToLower();

			string theFileName = thePageSlug;

			using (ContentPageHelper pageHelper = new ContentPageHelper()) {
				ContentPage cp = pageHelper.FindContentByID(SiteData.CurrentSite.SiteID, this.Root_ContentID);

				if (cp != null) {
					dateOrigGoLive = cp.GoLiveDate;
				}
				if (cp == null && this.Root_ContentID != Guid.Empty) {
					ContentPageExport cpe = ContentImportExportUtils.GetSerializedContentPageExport(this.Root_ContentID);
					if (cpe != null) {
						dateOrigGoLive = cpe.ThePage.GoLiveDate;
					}
				}

				theFileName = ContentPageHelper.CreateFileNameFromSlug(SiteData.CurrentSite.SiteID, dateGoLive, thePageSlug);

				if (SiteData.IsPageSpecial(theFileName) || SiteData.IsLikelyHomePage(theFileName)) {
					return false;
				}

				ContentPage fn1 = pageHelper.FindByFilename(SiteData.CurrentSite.SiteID, theFileName);

				if (cp == null && this.Root_ContentID != Guid.Empty) {
					cp = pageHelper.GetVersion(SiteData.CurrentSite.SiteID, this.Root_ContentID);
				}

				if (fn1 == null || (fn1 != null && cp != null && fn1.Root_ContentID == cp.Root_ContentID)) {
					return true;
				}
			}

			return false;
		}
Exemplo n.º 12
0
 public static ContentPage GetPage(Guid guidContentID)
 {
     ContentPage pageContents = null;
     using (ContentPageHelper pageHelper = new ContentPageHelper()) {
         pageContents = pageHelper.FindContentByID(CurrentSiteID, guidContentID);
     }
     return pageContents;
 }
        public ContentPage SavePost()
        {
            ContentPage page = this.ContentPage;
            ContentPage pageContents = null;

            using (ContentPageHelper pageHelper = new ContentPageHelper()) {
                pageContents = pageHelper.FindContentByID(SiteData.CurrentSiteID, page.Root_ContentID);
            }
            if (pageContents == null) {
                pageContents = new ContentPage(SiteData.CurrentSiteID, ContentPageType.PageType.BlogEntry);
            }

            pageContents.GoLiveDate = page.GoLiveDate;
            pageContents.RetireDate = page.RetireDate;

            pageContents.IsLatestVersion = true;
            pageContents.Thumbnail = page.Thumbnail;

            pageContents.TemplateFile = page.TemplateFile;

            pageContents.TitleBar = page.TitleBar;
            pageContents.NavMenuText = page.NavMenuText;
            pageContents.PageHead = page.PageHead;
            pageContents.FileName = page.FileName;
            pageContents.PageSlug = page.PageSlug;

            pageContents.MetaDescription = page.MetaDescription;
            pageContents.MetaKeyword = page.MetaKeyword;

            pageContents.EditDate = SiteData.CurrentSite.Now;
            pageContents.NavOrder = SiteData.BlogSortOrderNumber;

            pageContents.PageText = page.PageText;
            pageContents.LeftPageText = page.LeftPageText;
            pageContents.RightPageText = page.RightPageText;

            pageContents.PageActive = page.PageActive;
            pageContents.ShowInSiteNav = false;
            pageContents.ShowInSiteMap = false;
            pageContents.BlockIndex = page.BlockIndex;

            pageContents.Parent_ContentID = page.Parent_ContentID;

            pageContents.CreditUserId = page.CreditUserId;

            pageContents.EditUserId = SecurityData.CurrentUserGuid;

            List<ContentCategory> lstCat = (from l in SiteData.CurrentSite.GetCategoryList()
                                            join cr in this.SelectedCategories on l.ContentCategoryID.ToString().ToLowerInvariant() equals cr.ToLowerInvariant()
                                            select l).ToList();
            List<ContentTag> lstTag = (from l in SiteData.CurrentSite.GetTagList()
                                       join cr in this.SelectedTags on l.ContentTagID.ToString().ToLowerInvariant() equals cr.ToLowerInvariant()
                                       select l).ToList();

            pageContents.ContentCategories = lstCat;
            pageContents.ContentTags = lstTag;

            pageContents.SavePageEdit();
            SaveTextWidgets();

            return pageContents;
        }
        public ContentPage SavePage()
        {
            ContentPage page = this.ContentPage;
            ContentPage pageContents = null;

            using (ContentPageHelper pageHelper = new ContentPageHelper()) {
                pageContents = pageHelper.FindContentByID(SiteData.CurrentSiteID, page.Root_ContentID);
            }

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

            pageContents.GoLiveDate = page.GoLiveDate;
            pageContents.RetireDate = page.RetireDate;

            pageContents.IsLatestVersion = true;
            pageContents.Thumbnail = page.Thumbnail;

            pageContents.TemplateFile = page.TemplateFile;

            pageContents.TitleBar = page.TitleBar;
            pageContents.NavMenuText = page.NavMenuText;
            pageContents.PageHead = page.PageHead;
            pageContents.FileName = page.FileName;
            pageContents.PageSlug = null;

            pageContents.MetaDescription = page.MetaDescription;
            pageContents.MetaKeyword = page.MetaKeyword;

            pageContents.EditDate = SiteData.CurrentSite.Now;
            pageContents.NavOrder = page.NavOrder;

            pageContents.PageText = page.PageText;
            pageContents.LeftPageText = page.LeftPageText;
            pageContents.RightPageText = page.RightPageText;

            pageContents.PageActive = page.PageActive;
            pageContents.ShowInSiteNav = page.ShowInSiteNav;
            pageContents.ShowInSiteMap = page.ShowInSiteMap;
            pageContents.BlockIndex = page.BlockIndex;

            pageContents.Parent_ContentID = page.Parent_ContentID;

            pageContents.CreditUserId = page.CreditUserId;

            pageContents.EditUserId = SecurityData.CurrentUserGuid;

            pageContents.SavePageEdit();

            SaveTextWidgets();

            return pageContents;
        }
        public ContentPage GetPost(Guid? id, Guid? versionid, Guid? importid, string mode)
        {
            ContentPage pageContents = null;
            this.ImportID = importid;
            this.VersionID = versionid;
            this.Mode = (String.IsNullOrEmpty(mode) || mode.Trim().ToLowerInvariant() != "raw") ? "html" : "raw";

            using (ContentPageHelper pageHelper = new ContentPageHelper()) {
                if (!id.HasValue && !versionid.HasValue && !importid.HasValue) {
                    if (pageContents == null) {
                        pageContents = new ContentPage(SiteData.CurrentSiteID, ContentPageType.PageType.BlogEntry);
                    }

                    pageContents.Root_ContentID = Guid.Empty;
                } else {
                    if (importid.HasValue) {
                        ContentPageExport cpe = ContentImportExportUtils.GetSerializedContentPageExport(importid.Value);
                        if (cpe != null) {
                            pageContents = cpe.ThePage;
                            pageContents.EditDate = SiteData.CurrentSite.Now;

                            var rp = pageHelper.GetLatestContentByURL(SiteData.CurrentSiteID, 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;
                            }
                            pageContents.Parent_ContentID = null;
                            pageContents.NavOrder = SiteData.BlogSortOrderNumber;
                        }
                    }
                    if (versionid.HasValue) {
                        pageContents = pageHelper.GetVersion(SiteData.CurrentSiteID, versionid.Value);
                    }
                    if (id.HasValue && pageContents == null) {
                        pageContents = pageHelper.FindContentByID(SiteData.CurrentSiteID, id.Value);
                    }
                }
            }

            OverrideCache(pageContents);

            SetPage(pageContents);

            return pageContents;
        }