public ActionResult CmsPagesLanguages(int id) { List <BackEndCmsPagesLanguagesAddEdit> backEndCmsPagesLanguagesAddEditList = new List <BackEndCmsPagesLanguagesAddEdit>(); CmsPages CmsPages = new CmsPages(); CmsPage CmsPage; BackEndCmsPagesLanguagesAddEdit backEndCmsPagesLanguagesAddEdit; PagesLanguages backEndCmsPagesLanguages = new PagesLanguages(); PageLanguage backEndCmsPageLanguage; foreach (Language language in new Languages().GetAllLanguages(isActive: true)) { backEndCmsPagesLanguagesAddEdit = new BackEndCmsPagesLanguagesAddEdit(); CmsPage = CmsPages.GetPageByPageId(id); if (CmsPage.IsNotNull()) { backEndCmsPagesLanguagesAddEdit.PageId = CmsPage.PageId; backEndCmsPagesLanguagesAddEdit.LanguageCode = language.LanguageCode; backEndCmsPagesLanguagesAddEdit.PageName = CmsPage.PageName; backEndCmsPagesLanguagesAddEdit.LanguageName = language.LanguageName; backEndCmsPageLanguage = backEndCmsPagesLanguages.GetPageLanguage(CmsPage.PageId, language.LanguageCode); if (backEndCmsPageLanguage.IsNotNull()) { backEndCmsPagesLanguagesAddEdit.MenuName = backEndCmsPageLanguage.MenuName; backEndCmsPagesLanguagesAddEdit.MetaTagTitle = backEndCmsPageLanguage.MetaTagTitle; backEndCmsPagesLanguagesAddEdit.MetaTagKeywords = backEndCmsPageLanguage.MetaTagKeywords; backEndCmsPagesLanguagesAddEdit.MetaTagDescription = backEndCmsPageLanguage.MetaTagDescription; backEndCmsPagesLanguagesAddEdit.Robots = backEndCmsPageLanguage.Robots; backEndCmsPagesLanguagesAddEdit.HtmlCode = backEndCmsPageLanguage.HtmlCode; } else { backEndCmsPagesLanguages.AddEdit(id, backEndCmsPagesLanguagesAddEdit.LanguageCode, CmsPage.PageName, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty); backEndCmsPageLanguage = backEndCmsPagesLanguages.GetPageLanguage(CmsPage.PageId, language.LanguageCode); } } else { ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist); ViewData.IsFormVisible(false); break; } backEndCmsPagesLanguagesAddEditList.Add(backEndCmsPagesLanguagesAddEdit); } return(View(backEndCmsPagesLanguagesAddEditList)); }
public static IHtmlString GetFooterMenu(this HtmlHelper htmlHelper, FrontEndCmsPage model, string className = "nav nav-pills") { string footerMenu = string.Empty; List <CmsPage> pagesObj = new CmsPages().GetAllPages(); if (pagesObj != null) { pagesObj = (from page in pagesObj where page.ShowInBottomMenu && page.IsActive select page).ToList(); if (pagesObj != null && pagesObj.Count > 0) { footerMenu += "<ul class=\"" + className + "\">"; string url; GlobalConfiguration globalConfiguration = new GlobalConfigurations().GetGlobalConfiguration(); PagesLanguages backEndCmsPagesContent = new PagesLanguages(); PageLanguage backEndCmsPageLanguage; string pageTitle = string.Empty; foreach (CmsPage pageObj in pagesObj) { backEndCmsPageLanguage = backEndCmsPagesContent.GetPageLanguage(pageObj.PageId, model.LanguageCode); if (backEndCmsPageLanguage.IsNotNull() && backEndCmsPageLanguage.MenuName.IsNotEmptyOrWhiteSpace()) { pageTitle = backEndCmsPageLanguage.MenuName; } else { pageTitle = pageObj.PageName; } if (pageObj.PageTemplateId.IsNull()) { url = pageObj.Url; } else { url = "/"; if (!pageObj.IsHomePage || model.LanguageCode != globalConfiguration.DefaultLanguageCode) { if (pageObj.IsHomePage) { url += model.LanguageCode + "/"; } else { url += model.LanguageCode + "/" + pageObj.FullSegment + "/"; } } } footerMenu += "<li><a href=\"" + url + "\" target=\"" + pageObj.Target + "\" title=\"" + pageTitle + "\">" + pageTitle + "</a></li>"; } footerMenu += "</ul>"; } } return(htmlHelper.Raw(footerMenu)); }
private static void BuildBreadCrumbs(CmsPages pages, PagesLanguages pageLanguages, ref string breadCrumbs, int?pageId, string langCode, string separator, bool isPreviousHomePage) { CmsPage page = pages.GetPageByPageId(pageId); if (page.IsNotNull()) { PageLanguage pageLanguage = pageLanguages.GetPageLanguage(pageId, langCode); string title = page.PageName; if (pageLanguage.IsNotNull() && pageLanguage.MenuName.IsNotEmptyOrWhiteSpace()) { title = pageLanguage.MenuName; } if (breadCrumbs.IsEmptyOrWhiteSpace()) { breadCrumbs = "<li class=\"active\">" + title + "</li>"; } else { GlobalConfiguration globalConfiguration = new GlobalConfigurations().GetGlobalConfiguration(); string url = "/"; if (!page.IsHomePage || langCode != globalConfiguration.DefaultLanguageCode) { if (page.IsHomePage) { url += langCode + "/"; } else { url += langCode + "/" + page.FullSegment + "/"; } } breadCrumbs = "<li><a href=\"" + url + "\">" + title + "</a></li>" + breadCrumbs; } BuildBreadCrumbs(pages, pageLanguages, ref breadCrumbs, page.PageParentId, langCode, separator, page.IsHomePage); } else if (page.IsNull() && !isPreviousHomePage) { page = pages.GetHomePage(); if (page.IsNotNull()) { BuildBreadCrumbs(pages, pageLanguages, ref breadCrumbs, page.PageId, langCode, separator, page.IsHomePage); } } }
private static void BuildMainMenu(List <CmsPage> backEndCmsPageList, int currentLevel, int?pageParentId, ref string mainMenu, string savedNode, string className, string langCode) { if (backEndCmsPageList != null && currentLevel <= 2) { List <CmsPage> pagesObj = (from page in backEndCmsPageList where page.PageParentId == pageParentId && page.ShowInMainMenu && page.IsActive select page).ToList(); if (pagesObj != null && pagesObj.Count() > 0) { mainMenu += Environment.NewLine + "<ul"; if (currentLevel == 1) { mainMenu += " class=\"" + className + "\""; } else { mainMenu += " class=\"dropdown-menu\""; } mainMenu += ">" + Environment.NewLine; if (savedNode.IsNotEmptyOrWhiteSpace()) { mainMenu += savedNode + "<li class=\"divider\"></li>"; } GlobalConfiguration globalConfiguration = new GlobalConfigurations().GetGlobalConfiguration(); PagesLanguages backEndCmsPagesLanguages = new PagesLanguages(); PageLanguage backEndCmsPageLanguage; string pageTitle; foreach (CmsPage pageObj in pagesObj) { backEndCmsPageLanguage = backEndCmsPagesLanguages.GetPageLanguage(pageObj.PageId, langCode); if (backEndCmsPageLanguage.IsNotNull() && backEndCmsPageLanguage.MenuName.IsNotEmptyOrWhiteSpace()) { pageTitle = backEndCmsPageLanguage.MenuName; } else { pageTitle = pageObj.PageName; } bool hasChildren = (from page in backEndCmsPageList where page.PageParentId == pageObj.PageId && page.ShowInMainMenu && page.IsActive select page).Count() > 0; mainMenu += "<li"; if (hasChildren && currentLevel < 2) { savedNode = "<li><a href=\"/"; if (!pageObj.IsHomePage || langCode != globalConfiguration.DefaultLanguageCode) { if (pageObj.IsHomePage) { savedNode += langCode + "/"; } else { savedNode += langCode + "/" + pageObj.FullSegment + "/"; } } savedNode += "\" title=\"" + pageTitle + "\" target=\"" + pageObj.Target + "\">" + pageTitle + "</a></li>"; mainMenu += " class=\"dropdown\""; } mainMenu += ">"; if (hasChildren && currentLevel < 2) { mainMenu += "<a href=\"#\" title=\"" + pageTitle + "\" target=\"" + pageObj.Target + "\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">" + pageTitle + " <b class=\"caret\"></b></a>"; } else { mainMenu += "<a href=\"{$url}\" title=\"" + pageTitle + "\" target=\"" + pageObj.Target + "\">" + pageTitle + "</a>"; } if (pageObj.PageTemplateId.IsNull()) { mainMenu = mainMenu.Replace("{$url}", pageObj.Url); } else { if (!pageObj.IsHomePage || langCode != globalConfiguration.DefaultLanguageCode) { if (pageObj.IsHomePage) { mainMenu = mainMenu.Replace("{$url}", "/" + langCode + "/"); } else { mainMenu = mainMenu.Replace("{$url}", "/" + langCode + "/" + pageObj.FullSegment + "/"); } } else { mainMenu = mainMenu.Replace("{$url}", "/"); } } currentLevel++; BuildMainMenu(backEndCmsPageList, currentLevel, pageObj.PageId, ref mainMenu, savedNode, className, langCode); currentLevel--; mainMenu += "</li>" + Environment.NewLine; } mainMenu += "</ul>" + Environment.NewLine; } } }
private static void BuildSitemap(List <CmsPage> backEndCmsPageList, PagesLanguages pagesLanguages, int currentLevel, int?pageParentId, ref string sitemap, string className, string langCode) { if (backEndCmsPageList != null) { List <CmsPage> pagesObj = (from page in backEndCmsPageList where page.PageParentId == pageParentId && page.ShowInSitemap && page.IsActive select page).ToList(); if (pagesObj != null && pagesObj.Count() > 0) { sitemap += Environment.NewLine + "<ul"; if (currentLevel == 1 && className.IsNotEmptyOrWhiteSpace()) { sitemap += " class=\"" + className + "\""; } sitemap += ">" + Environment.NewLine; GlobalConfiguration globalConfiguration = new GlobalConfigurations().GetGlobalConfiguration(); PageLanguage backEndCmsPageLanguage; string pageTitle; string url; foreach (CmsPage pageObj in pagesObj) { backEndCmsPageLanguage = pagesLanguages.GetPageLanguage(pageObj.PageId, langCode); pageTitle = pageObj.PageName; if (backEndCmsPageLanguage.IsNotNull() && backEndCmsPageLanguage.MenuName.IsNotEmptyOrWhiteSpace()) { pageTitle = backEndCmsPageLanguage.MenuName; } if (pageObj.PageTemplateId.IsNull()) { url = pageObj.Url; } else { if (!pageObj.IsHomePage || langCode != globalConfiguration.DefaultLanguageCode) { if (pageObj.IsHomePage) { url = "/" + langCode + "/"; } else { url = "/" + langCode + "/" + pageObj.FullSegment + "/"; } } else { url = "/"; } } sitemap += "<li><a href=\"" + url + "\" title=\"" + pageTitle + "\" target=\"" + pageObj.Target + "\">" + pageTitle + "</a>"; currentLevel++; BuildSitemap(backEndCmsPageList, pagesLanguages, currentLevel, pageObj.PageId, ref sitemap, className, langCode); currentLevel--; sitemap += "</li>" + Environment.NewLine; } sitemap += "</ul>" + Environment.NewLine; } } }