/// <summary> /// Return the sitemap url node for the page /// </summary> /// <param name = "objTab">The page being indexed</param> /// <param name="language">Culture code to use in the URL</param> /// <returns>A SitemapUrl object for the current page</returns> /// <remarks> /// </remarks> private OpenSitemapUrl GetPageUrl(TabInfo objTab, string language, params string[] AdditionalParameters) { var pageUrl = new OpenSitemapUrl(); pageUrl.Url = Globals.NavigateURL(objTab.TabID, objTab.IsSuperTab, ps, "", language, AdditionalParameters); if (pageUrl.Url.ToLower().IndexOf(ps.PortalAlias.HTTPAlias.ToLower()) == -1) { // code to fix a bug in dnn5.1.2 for navigateurl if ((HttpContext.Current != null)) { pageUrl.Url = Globals.AddHTTP(HttpContext.Current.Request.Url.Host + pageUrl.Url); } else { // try to use the portalalias pageUrl.Url = Globals.AddHTTP(ps.PortalAlias.HTTPAlias.ToLower()) + pageUrl.Url; } } pageUrl.Priority = GetPriority(objTab); pageUrl.LastModified = objTab.LastModifiedOnDate; var modCtrl = new ModuleController(); foreach (ModuleInfo m in modCtrl.GetTabModules(objTab.TabID).Values) { if (m.LastModifiedOnDate > objTab.LastModifiedOnDate) { pageUrl.LastModified = m.LastModifiedOnDate; } } pageUrl.ChangeFrequency = SitemapChangeFrequency.Daily; return(pageUrl); }
/// <summary> /// Includes page urls on the sitemap /// </summary> /// <remarks> /// Pages that are included: /// - are not deleted /// - are not disabled /// - are normal pages (not links,...) /// - are visible (based on date and permissions) /// </remarks> public override List <SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version) { //Logger.Error("Opencontent sitemap generation page : start"); //var objTabs = new TabController(); OpenSitemapUrl pageUrl = null; var urls = new List <SitemapUrl>(); useLevelBasedPagePriority = bool.Parse(PortalController.GetPortalSetting("SitemapLevelMode", portalId, "False")); minPagePriority = float.Parse(PortalController.GetPortalSetting("SitemapMinPriority", portalId, "0.1"), CultureInfo.InvariantCulture); includeHiddenPages = bool.Parse(PortalController.GetPortalSetting("SitemapIncludeHidden", portalId, "False")); this.ps = ps; var Locales = ps.ContentLocalizationEnabled ? LocaleController.Instance.GetPublishedLocales(ps.PortalId).Values : LocaleController.Instance.GetLocales(ps.PortalId).Values; bool MultiLanguage = Locales.Count > 1; var currentLanguage = ps.CultureCode; if (string.IsNullOrEmpty(currentLanguage)) { currentLanguage = Localization.GetPageLocale(ps).Name; } var languagePublished = LocaleController.Instance.GetLocale(ps.PortalId, currentLanguage).IsPublished; var tabs = TabController.Instance.GetTabsByPortal(portalId).Values .Where(t => /* !t.IsSystem && */ !ps.ContentLocalizationEnabled || (languagePublished && t.CultureCode.Equals(currentLanguage, StringComparison.InvariantCultureIgnoreCase))); foreach (TabInfo objTab in tabs) { if (objTab.CultureCode == currentLanguage || objTab.IsNeutralCulture) { if (!objTab.IsDeleted && !objTab.DisableLink && objTab.TabType == TabType.Normal && (Null.IsNull(objTab.StartDate) || objTab.StartDate < DateTime.Now) && (Null.IsNull(objTab.EndDate) || objTab.EndDate > DateTime.Now) && IsTabPublic(objTab.TabPermissions) ) { var allowIndex = true; if ((!objTab.TabSettings.ContainsKey("AllowIndex") || !bool.TryParse(objTab.TabSettings["AllowIndex"].ToString(), out allowIndex) || allowIndex) && (includeHiddenPages || objTab.IsVisible)) { // modules urls var rules = OpenContentUrlProvider.GetRules(portalId); foreach (var rule in rules.Where(r => r.TabId == objTab.TabID && r.InSitemap == true)) { if (rule.CultureCode == null || rule.CultureCode == currentLanguage) { string[] pars = rule.Parameters.Split('&'); pageUrl = GetPageUrl(objTab, MultiLanguage ? currentLanguage : null, pars); // if module support ML //pageUrl.Alternates.AddRange(GetAlternates(objTab.TabID, pars)); urls.Add(pageUrl); //Logger.Error("Opencontent sitemap generation page : " + pageUrl.Url); } } } } } } return(urls); }