private bool OutputTitles(ITracingService trace, SiteMapElement mapJson, XmlElement element) { bool titleFound = false; // Try and get deprecated element var titleAttribute = element.GetAttribute("Title"); if (!string.IsNullOrEmpty(titleAttribute)) { mapJson.title = element.GetAttribute("Title"); return(true); } var titles = element.SelectNodes("Titles/Title[@LCID='" + _lcid.ToString() + "']"); if (titles.Count == 0) { // Get just the first LCID as fall back titles = element.SelectNodes("Titles/Title[0]"); } if (titles.Count > 0) { //mapJson.WriteLine("Titles:{"); foreach (XmlElement title in titles) { mapJson.title = title.GetAttribute("Title"); } //mapJson.WriteLine("},"); titleFound = true; } else { // Get resource id and lookup string resourceId = element.GetAttribute("ResourceId"); if (!string.IsNullOrEmpty(resourceId)) { // Lookup resource from resource dictionary for available lanaguages mapJson.title = "$" + resourceId; } } trace.Trace("Title Found {0}", titleFound); return(titleFound); }
private static void InitSitemap(IDictionary <string, object> masterDictionnary, string websiteUrl, List <SiteMapElement> elements) { foreach (var key in masterDictionnary.Keys) { if (key.ToLower().EndsWith("menuitems")) { dynamic menuItems = masterDictionnary[key] as ArrayList; if (menuItems == null) { menuItems = masterDictionnary[key] as List <object>; } if (menuItems != null) { foreach (var menuItem in menuItems) { var menuItemExpendo = CacheProvider.ToExpando(menuItem); var dico = (IDictionary <string, object>)menuItemExpendo; if (dico.ContainsKey("State") && (System.Int64)dico["State"] != (System.Int64)ItemState.Published) { continue; } InitSitemap(dico, websiteUrl, elements); var updateDate = menuItem.Seo.UpdateDate; var element = new SiteMapElement { Location = UrlHelper.Concat(websiteUrl, "/", menuItem.RoutePath), Priority = "0.5", DateUpdate = updateDate.ToString("yyyy-MM-dd"), Frequence = menuItem.Seo.SitemapFrequence.ToString().ToLower() }; elements.Add(element); } } } } }