using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Xml.Linq;
using Composite.Data;
using Composite.Renderings.Page;
///
/// Summary description for PageLanguageVersions
///
public class PageLanguageVersions
{
public static IEnumerable GetForeignPageInfo()
{
// Grab all active languages...
foreach (CultureInfo culture in DataLocalizationFacade.ActiveLocalizationCultures)
{
// enter the 'data scope' of the next language
using (var scope = new DataScope(culture))
{
// fetch sitemap element for current page - if any
var match = PageStructureInfo.GetSiteMap().DescendantsAndSelf().Where(f => f.Attribute("Id") != null && f.Attribute("Id").Value == PageRenderer.CurrentPageId.ToString()).FirstOrDefault();
if (match != null)
{
var annotatedMatch = new XElement("LanguageVersion"
, new XAttribute("Culture", culture.Name)
, new XAttribute("CurrentCulture", culture.Equals(Thread.CurrentThread.CurrentCulture))
, new XAttribute("Id", match.Attribute("Id").Value)
, new XAttribute("Title", match.Attribute("Title").Value)
, (match.Attribute("MenuTitle") == null ? null : new XAttribute("MenuTitle", match.Attribute("MenuTitle").Value))
, new XAttribute("UrlTitle", match.Attribute("UrlTitle").Value)
, new XAttribute("Abstract", match.Attribute("Abstract").Value)
, new XAttribute("URL", match.Attribute("URL").Value)
);
yield return annotatedMatch;
}
}
}
}
}