public IEnumerable <ChromeLanguageInfo> GetLanguageInfo(PageData page)
        {
            List <ChromeLanguageInfo> languages     = new List <ChromeLanguageInfo>();
            ReadOnlyStringList        pageLanguages = page.PageLanguages;
            string currentLanguage = page.LanguageBranch;

            foreach (string language in pageLanguages)
            {
                LanguageBranch languageBranch = _languageBranchRepository.ListEnabled().FirstOrDefault(l => l.LanguageID.Equals(language, StringComparison.InvariantCultureIgnoreCase));
                if (languageBranch != null)
                {
                    languages.Add(new ChromeLanguageInfo()
                    {
                        DisplayName = languageBranch.Name,
                        IconUrl     = languageBranch.ResolvedIconPath, //"/Content/Images/flags/" + language + ".png",
                        // We use this to enable language switching inside edit mode too
                        Url      = languageBranch.CurrentUrlSegment,
                        EditUrl  = PageEditing.GetEditUrlForLanguage(page.ContentLink, languageBranch.LanguageID),
                        Selected = string.Compare(language, currentLanguage, StringComparison.InvariantCultureIgnoreCase) == 0
                    });
                }
            }

            return(languages);
        }
        private static SearchResult MapAzureSearchResult(SearchResult <T> result)
        {
            var previewText = string.Empty;

            if (result.Highlights != null && result.Highlights.Count > 0)
            {
                previewText = result.Highlights.First().Value.First();
            }

            var editModeUrl = PageEditing.GetEditUrlForLanguage(new ContentReference(result.Document.ContentComplexReference), result.Document.ContentLanguage);

            return(new SearchResult(editModeUrl, result.Document.ContentName, previewText)
            {
                Metadata =
                {
                    new KeyValuePair <string, string>("languageBranch", result.Document.ContentLanguage),
                    new KeyValuePair <string, string>("id",             result.Document.ContentComplexReference)
                }
            });
        }
Exemple #3
0
 public string GetEditUrlForLanguage(ContentReference contentLink, string language)
 {
     return(PageEditing.GetEditUrlForLanguage(contentLink, language));
 }
 private Dictionary <string, string> CreateEditContentUrls(ContentSummary contentSummary)
 {
     return(contentSummary.Translations.ToDictionary(
                x => x.Key,
                x => PageEditing.GetEditUrlForLanguage(contentSummary.ContentLink, x.Key)));
 }