GetLatestContentByURL() public method

public GetLatestContentByURL ( System.Guid siteID, bool bActiveOnly, string sPage ) : ContentPage
siteID System.Guid
bActiveOnly bool
sPage string
return ContentPage
Esempio n. 1
0
        public static ContentPage GetPage(string sCurrentPage)
        {
            ContentPage pageContents = null;

            using (ContentPageHelper pageHelper = new ContentPageHelper()) {
                if (SecurityData.IsAdmin || SecurityData.IsSiteEditor) {
                    if (sCurrentPage.Length <= 1 || sCurrentPage == SiteData.DefaultDirectoryFilename) {
                        pageContents = pageHelper.FindHome(SiteData.CurrentSiteID);
                    } else {
                        pageContents = pageHelper.FindByFilename(SiteData.CurrentSiteID, sCurrentPage);
                    }
                } else {
                    if (sCurrentPage.Length <= 1 || sCurrentPage == SiteData.DefaultDirectoryFilename) {
                        pageContents = pageHelper.FindHome(SiteData.CurrentSiteID, true);
                    } else {
                        pageContents = pageHelper.GetLatestContentByURL(SiteData.CurrentSiteID, true, sCurrentPage);
                    }
                }
            }

            return pageContents;
        }
Esempio n. 2
0
        public static ContentPage GetCurrentLivePage()
        {
            ContentPage pageContents = null;

            using (ContentPageHelper pageHelper = new ContentPageHelper()) {

                bool IsPageTemplate = false;
                string sCurrentPage = SiteData.CurrentScriptName;
                string sScrubbedURL = SiteData.AlternateCurrentScriptName;

                if (sScrubbedURL.ToLower() != sCurrentPage.ToLower()) {
                    sCurrentPage = sScrubbedURL;
                }

                if (SecurityData.IsAdmin || SecurityData.IsSiteEditor) {
                    pageContents = pageHelper.FindByFilename(SiteData.CurrentSiteID, sCurrentPage);
                } else {
                    pageContents = pageHelper.GetLatestContentByURL(SiteData.CurrentSiteID, true, sCurrentPage);
                }

                if (pageContents == null && SiteData.IsPageReal) {
                    IsPageTemplate = true;
                }

                if ((SiteData.IsPageSampler || IsPageTemplate || !IsWebView) && pageContents == null) {
                    pageContents = ContentPageHelper.GetSamplerView();
                }

                if (IsPageTemplate) {
                    pageContents.TemplateFile = sCurrentPage;
                }
            }

            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;
        }