internal static string GetUrlForPageInstanceId(int pageInstanceId) { foreach (var pageIndex in _pageLanguageIndex) { var item = pageIndex.GetPageIndexItem(pageInstanceId); if (item != null) { return(item.PageUrl); } } // If above fails, try to get from database (this occurs when a newer version is published) var pageInstance = PageInstanceData.GetById(pageInstanceId); if (pageInstance == null) { return(string.Empty); } var page = GetPage(pageInstance.PageId, pageInstance.LanguageId); if (page == null) { return(string.Empty); } return(page.PageUrl.ToString()); }
private void LoadVersions() { var stringBuilder = new StringBuilder(); var versions = PageInstanceData.GetById(_pageId, _languageId); foreach (var version in versions) { var classAttribute = string.Empty; if (version.Status == PageInstanceStatus.Published) { classAttribute = " class=\"success middle\""; } else if (version.Status == PageInstanceStatus.WorkingCopy) { classAttribute = " class=\"warning middle\""; } else { classAttribute = " class=\"middle\""; } stringBuilder.AppendFormat("<tr{0}><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td><button type=\"button\" data-pageid=\"{5}\" data-version=\"{1}\" class=\"btn btn-primary edit-button\">Edit</a></td></tr>", classAttribute, version.CurrentVersion, version.UpdateDate, version.Author, GetFriendlyStatusName(version.Status), _pageId); } VersionRows.Text = stringBuilder.ToString(); }
public static CmsPage GetWorkingCopy(Guid pageId) { var page = GetPage(pageId); var pageInstance = PageInstanceData.GetByStatus(pageId, Language.CurrentLanguageId, PageInstanceStatus.WorkingCopy); if (pageInstance == null) { return(page.CreateWorkingCopy()); } PopulatePageFromPageInstance(page, pageInstance); return(page); }
public static CmsPage GetSpecificVersion(Guid pageId, int languageId, int version) { var page = GetPage(pageId, languageId); var pageInstance = PageInstanceData.GetByVersion(pageId, languageId, version); if (pageInstance == null) { var message = string.Format("Can't find version {0} of page '{1}'", version, pageId); Logger.Write(message, Logger.Severity.Major); throw new Exception(message); } PopulatePageFromPageInstance(page, pageInstance); return(page); }