/// <summary> /// Checks if a page with the given pageId exists in the database. /// </summary> /// <param name="pageId"></param> /// <returns></returns> public static bool pageExists(int pageId) { CmsPage p = CmsPage.FetchPageById(pageId); if (p.ID >= 0) { return(true); } return(false); }
/// <summary> /// checks if a child page exists for a parent page in any of the system's languages. /// </summary> /// <param name="parentPageId"></param> /// <param name="childName"></param> /// <returns></returns> public static bool childPageWithNameExists(int parentPageId, string childName) { CmsPage parentPage = CmsPage.FetchPageById(parentPageId); if (parentPage.ID < 0) { return(false); } foreach (CmsPage p in parentPage.ChildPages) { if (StringUtils.IndexOf(p.Names, childName, StringComparison.CurrentCultureIgnoreCase) >= 0) { return(true); } } return(false); }
/// <summary> /// returns true if any of the .name fields in the specified pageLangInfos matches ChildPage.names, returns TRUE /// </summary> /// <param name="parentPageId"></param> /// <param name="pageLangInfos"></param> /// <returns></returns> public static bool childPageWithNameExists(int parentPageId, CmsPageLanguageInfo[] pageLangInfos) { CmsPage parentPage = CmsPage.FetchPageById(parentPageId); if (parentPage.ID < 0) { return(false); } foreach (CmsPage p in parentPage.ChildPages) { foreach (CmsPageLanguageInfo langInfo in pageLangInfos) { string nameToFind = langInfo.name; CmsLanguage pageLanguage = CmsLanguage.GetFromHaystack(langInfo.languageShortCode, CmsConfig.Languages); if (String.Compare(p.getName(pageLanguage), nameToFind, true) == 0) { return(true); } } } return(false); }
/// <summary> /// gets a CmsPage from the database with the given ID. /// Returns an empty CmsPage (with id = -1) if the page was not found. /// </summary> /// <param name="id"></param> /// <returns>the CmsPage with the given PageId. If not found, an empty CmsPage (with id = -1) is returned</returns> public static CmsPage getPageById(int id) { return(CmsPage.FetchPageById(id)); }