public void OnEnable() { languageSelector = (LanguageSelector)target; languageSelectorSO = new SerializedObject(languageSelector); languageIndex = languageSelectorSO.FindProperty("langKey"); keyIndex = languageSelectorSO.FindProperty("textKey"); }
private IEnumerable <BasicContent> CreateFoldersFromChannels(VideoFolder entryPoint) { var type = ContentTypeRepository.Service.Load <VideoFolder>(); List <Album> albums = TwentyThreeVideoRepository.GetChannelList(); foreach (var album in albums) { var folder = ContentFactory.Service.CreateContent(type, new BuildingContext(type) { Parent = entryPoint, LanguageSelector = LanguageSelector.AutoDetect(), SetPropertyValues = true }) as VideoFolder; if (folder == null) { continue; } if (album.AlbumId != null) { var id = (int)album.AlbumId; folder.ContentLink = new ContentReference(id, Constants.ProviderKey); folder.Name = album.Title; var editorGroup = new EditorGroupChannelMappingRepository().GetEditorGroupForChannel(folder.Name); if (!string.IsNullOrWhiteSpace(editorGroup)) { folder.EditorGroup = editorGroup; } _log.Information("23Video: Channel {0} created.", album.Title); yield return(folder); } } }
public IEnumerable <EntryContentBase> GetVariants(ProductContent content) { var variants = content.GetVariants(); var variantItems = _contentLoader.GetItems(variants, LanguageSelector.AutoDetect()); return(FilterForVisitor.Filter(variantItems).OfType <EntryContentBase>()); }
internal int Start(Action<string> statusUpdateAction) { Logger.WriteToLog($"Starting BulkIndexer! Languages:{string.Join(", ",Context.Languages.Select(x=> x.TwoLetterISOLanguageName))}"); var itemsIndexed = 0; foreach (var cultureInfo in Context.Languages) { Logger.WriteToLog($"Starting to bulk index {cultureInfo.TwoLetterISOLanguageName}"); ContentLanguage.Instance.SetCulture(cultureInfo.TwoLetterISOLanguageName); var numberOfContentToIndex = Context.ContentReferences.Count(); var bulkSize = BulkSize.GetValueOrDefault(99); for (int index = 0; (index*bulkSize) < numberOfContentToIndex; ++index) { var itemsToTake = Context.ContentReferences.Skip(index*bulkSize).Take(bulkSize); var languageSelector = new LanguageSelector(cultureInfo.Name); var contentToIndex = _contentLoader.GetItems(itemsToTake, languageSelector).ToList(); contentToIndex = contentToIndex.Where(x => !x.IsDeleted).ToList(); if (contentToIndex.Any()) { var bulkResponse = ContentIndexer.Instance.Index(contentToIndex); itemsIndexed += contentToIndex.Count(); if (bulkResponse != null) statusUpdateAction(bulkResponse.Errors.ToString()); } } } return itemsIndexed; }
private IDictionary <string, int> GetStatusCount(int projectId) { var statuses = StatusList.ToDictionary(di => di.Key, di => di.Value); //clone the dictionary var versionableItems = _contentLoader.GetItems(_projectRepository.ListItems(projectId).Select(i => i.ContentLink), LanguageSelector.AutoDetect()).OfType <IVersionable>(); foreach (var versionableItem in versionableItems) { var status = HasExpired(versionableItem) ? ExtendedVersionStatus.Expired : (ExtendedVersionStatus)versionableItem.Status; var key = status.ToString().ToLowerInvariant(); var contentItem = (IContent)versionableItem; var isDeleted = contentItem.IsDeleted; var hasEditAccess = _contentLoaderService.HasEditAccess(contentItem, AccessLevel.Publish); if (isDeleted || !hasEditAccess) { key += NoAccesKey; } statuses[key]++; } return(statuses); }
protected virtual IEnumerable <CurrentLanguageContent> GetLanguageBranches(ContentReference contentLink) { bool isSpecificLanguage = !string.IsNullOrWhiteSpace(this.SitemapData.Language); if (isSpecificLanguage) { LanguageSelector languageSelector = !this.SitemapData.EnableLanguageFallback ? new LanguageSelector(this.SitemapData.Language) : LanguageSelector.Fallback(this.SitemapData.Language, false); IContent contentData; if (this.ContentRepository.TryGet(contentLink, languageSelector, out contentData)) { return(new[] { new CurrentLanguageContent { Content = contentData, CurrentLanguage = new CultureInfo(this.SitemapData.Language), MasterLanguage = GetMasterLanguage(contentData) } }); } return(Enumerable.Empty <CurrentLanguageContent>()); } if (this.SitemapData.EnableLanguageFallback) { return(GetFallbackLanguageBranches(contentLink)); } return(this.ContentRepository.GetLanguageBranches <IContent>(contentLink).Select(x => new CurrentLanguageContent { Content = x, CurrentLanguage = GetCurrentLanguage(x), MasterLanguage = GetMasterLanguage(x) })); }
public static SitemapEntry ToSitemapEntry(this PageData page, LanguageSelector language, string bundle) { if (page == null) { return(SitemapEntry.Empty); } var urlRewriter = ServiceLocator.Current.GetInstance <IUrlRewriteProviderWrapper>(); var hostBindingsService = ServiceLocator.Current.GetInstance <IHostBindingsService>(); Uri baseUri; baseUri = hostBindingsService.AllBindings().TryGetValue(language.LanguageBranch, out baseUri) ? baseUri : hostBindingsService.DefaultHost(); var location = new UrlBuilder(new Uri(baseUri, page.LinkURL.ToLower())); urlRewriter.GetFriendlyUrl(location, null, Encoding.UTF8); return(new SitemapEntry { IsEmpty = false, Location = location.Uri, LastModified = page.Changed, ChangeFrequency = Frequency.Weekly, Priority = 0.5F, Language = language.LanguageBranch, Bundle = !string.IsNullOrWhiteSpace(bundle) ? bundle : Constants.Bundles.Default }); }
public void ProcessRequest(HttpContext context) { if (_provider.Service == null) { throw new InvalidOperationException("Implementation of `IResourceListProvider` is not configured in IoC container."); } var languageSelector = LanguageSelector.AutoDetect(); var languageName = string.IsNullOrEmpty(context.Request.QueryString["lang"]) ? languageSelector.Language.Name : context.Request.QueryString["lang"]; var filename = ExtractFileName(context); var debugMode = context.Request.QueryString["debug"] != null; var alias = string.IsNullOrEmpty(context.Request.QueryString["alias"]) ? "jsl10n" : context.Request.QueryString["alias"]; var cacheKey = CacheKeyHelper.GenerateKey(filename, languageName, debugMode); var responseObject = CacheManager.Get(cacheKey) as string; if (responseObject == null) { responseObject = _provider.Service.GetJson(filename, context, languageName, debugMode); responseObject = $"window.{alias} = {responseObject}"; CacheManager.Insert(cacheKey, responseObject); } context.Response.Write(responseObject); context.Response.ContentType = "text/javascript"; }
/// <summary> /// Returns all the content items of <typeparamref name="T"/> from <paramref name="contentAreaItems"/> /// </summary> /// <typeparam name="T">Type of <see cref="IContentData"/> items to extract.</typeparam> /// <param name="contentAreaItems">The <see cref="IEnumerable{ContentAreaItem}"/> to extract <see cref="IContent"/> instances of type <typeparamref name="T"/> from.</param> /// <param name="language">The <see cref="CultureInfo"/> to use. If none is specified, current culture will be used.</param> /// <param name="contentLoader">The <see cref="IContentLoader"/> to use</param> /// <returns>A <see cref="IEnumerable{T}"/> containing all <see cref="IContent"/> items found in the <paramref name="contentAreaItems"/> collection.</returns> public static IEnumerable <T> GetContentItems <T>(this IEnumerable <ContentAreaItem> contentAreaItems, CultureInfo language = null, IContentLoader contentLoader = null) where T : IContentData { if (contentAreaItems == null) { return(Enumerable.Empty <T>()); } if (contentLoader == null) { contentLoader = ServiceLocator.Current.GetInstance <IContentLoader>(); } if (language == null) { language = LanguageSelector.AutoDetect().Language; } var items = contentLoader.GetItems(contentAreaItems.Select(i => i.ContentLink), language).OfType <T>(); var publishedFilter = new FilterPublished(); var accessFilter = new FilterAccess(); var filterItems = items.OfType <IContent>().Where(x => !publishedFilter.ShouldFilter(x) && !accessFilter.ShouldFilter(x)); return(filterItems.OfType <T>()); }
protected override IList <GetChildrenReferenceResult> LoadChildrenReferencesAndTypes(ContentReference contentLink, string languageId, out bool languageSpecific) { var videoTypeId = _contentTypeRepository.Load(typeof(Video)); var videoFolderTypeId = _contentTypeRepository.Load(typeof(VideoFolder)); languageSpecific = false; if (contentLink.CompareToIgnoreWorkID(EntryPoint)) { var test = _items.Where(x => x.ContentTypeID.Equals(videoFolderTypeId.ID)) .Select(p => new GetChildrenReferenceResult() { ContentLink = p.ContentLink, ModelType = typeof(VideoFolder) }).ToList(); return(test); } var content = LoadContent(contentLink, LanguageSelector.AutoDetect()); return(_items .Where(p => p.ContentTypeID.Equals(videoTypeId.ID) && p.ParentLink.ID.Equals(content.ContentLink.ID)) .Select(p => new GetChildrenReferenceResult() { ContentLink = p.ContentLink, ModelType = typeof(Video) }).ToList()); }
public static SitemapEntry ToSitemapEntry(this PageData page, LanguageSelector language, string bundle) { if (page == null) { return SitemapEntry.Empty; } var urlRewriter = ServiceLocator.Current.GetInstance<IUrlRewriteProviderWrapper>(); var hostBindingsService = ServiceLocator.Current.GetInstance<IHostBindingsService>(); Uri baseUri; baseUri = hostBindingsService.AllBindings().TryGetValue(language.LanguageBranch, out baseUri) ? baseUri : hostBindingsService.DefaultHost(); var location = new UrlBuilder(new Uri(baseUri, page.LinkURL.ToLower())); urlRewriter.GetFriendlyUrl(location, null, Encoding.UTF8); return new SitemapEntry { IsEmpty = false, Location = location.Uri, LastModified = page.Changed, ChangeFrequency = Frequency.Weekly, Priority = 0.5F, Language = language.LanguageBranch, Bundle = !string.IsNullOrWhiteSpace(bundle) ? bundle : Constants.Bundles.Default }; }
private IEnumerable <TEntryContent> GetRelatedEntries <TEntryContent>(IVariantContainer content) where TEntryContent : EntryContentBase { var relatedItems = content.GetVariantRelations(LinksRepository).Select(x => x.Target); return(ContentLoader.GetItems(relatedItems, LanguageSelector.AutoDetect()).OfType <TEntryContent>()); }
public virtual LocalizationContainer GetOrAddLocalizationContainer() { if (CachedLocalizationContainer == null) { lock (Lock) { var findLocalizationContainer = FindLocalizationContainer(LanguageSelector.MasterLanguage()) ?? AddLocalizationContainer(); CachedLocalizationContainer = findLocalizationContainer.ContentLink; return(findLocalizationContainer); } } try { return(_contentRepository.Service.Get <LocalizationContainer>(CachedLocalizationContainer, LanguageSelector.MasterLanguage())); } catch (PageNotFoundException) { // this can happen when we cached the localization pagereference but the page has been removed mean while. var newLocalizationContainer = AddLocalizationContainer(); CachedLocalizationContainer = newLocalizationContainer.ContentLink; return(newLocalizationContainer); } }
// Boot public static void Start() { BootScreen.ShowStartScreen(); Console.ForegroundColor = ConsoleColor.White; Console.Clear(); LanguageSelector.ShowLanguageDialog(); Console.Clear(); }
private static PageData FindPageByName(PageReference rootPage, string pageName, string pageType) { PageDataCollection children = DataFactory.Instance.GetChildren(rootPage); children.Add(DataFactory.Instance.GetChildren(rootPage, LanguageSelector.MasterLanguage())); return(children.FirstOrDefault(page => page.PageName.Equals(pageName) && page.PageTypeName.Equals(pageType))); }
private void menuItemsSelectionChanged(object sender, SelectionChangedEventArgs args) { MenuItemDataModel item = this.lvMenuItems.SelectedItem as MenuItemDataModel; if (item != null) { this.Hide(); switch (item.Code) { case MenuCode.Language: LanguageSelector.ShowBox(this.mainWindow, DI.W.Languages); break; case MenuCode.Dashboards: DashboardConfigSelect.ShowBox(this); break; case MenuCode.Ethernet: //this.runPageManager.Open(typeof(EthernetRun)); break; case MenuCode.Usb: //this.runPageManager.Open(typeof(SerialRun)); break; case MenuCode.Wifi: //this.runPageManager.Open(typeof(WifiRun)); break; case MenuCode.Bluetooth: //this.runPageManager.Open(typeof(BTRun)); RunBT win = new RunBT(); win.ShowDialog(); break; case MenuCode.BLE: //this.runPageManager.Open(typeof(BLE_Full)); break; case MenuCode.CodeSamples: CodeSelectWin.ShowBox(this.mainWindow); break; case MenuCode.Settings: //MainSettings.ShowBox(this.mainWindow); break; default: // Not supported break; } this.lvMenuItems.SelectionChanged -= this.menuItemsSelectionChanged; this.Hide(); this.lvMenuItems.UnselectAll(); this.lvMenuItems.SelectionChanged += this.menuItemsSelectionChanged; } }
private IEnumerable <BasicContent> ConvertToBasicContent(IEnumerable <IntermediateVideoDataModel> dataModels) { var helper = new VideoHelper(); var entryPoint = ContentRepositry.Service.GetChildren <VideoFolder>(ContentReference.RootPage).FirstOrDefault(); var videoType = ContentTypeRepository.Service.Load <Video>(); var videoFolderType = ContentTypeRepository.Service.Load <VideoFolder>(); var videos = new List <Video>(); var folders = new List <VideoFolder>(); var rawcontents = dataModels as IList <IntermediateVideoDataModel> ?? dataModels.ToList(); foreach (IntermediateVideoDataModel dataModel in rawcontents.Where(_ => _.VideoContentType == VideoContentType.VideoFolder)) { var folder = ContentFactory.Service.CreateContent(videoFolderType, new BuildingContext(videoFolderType) { Parent = entryPoint, LanguageSelector = LanguageSelector.AutoDetect(), SetPropertyValues = true }) as VideoFolder; folder.Name = dataModel.Name; folder.EditorGroup = dataModel.EditorGroup; folder.ContentLink = dataModel.ContentLink; folder.ContentGuid = dataModel.Guid; folders.Add(folder); } foreach (IntermediateVideoDataModel dataModel in rawcontents.Where(_ => _.VideoContentType == VideoContentType.Video)) { var video = ContentFactory.Service.CreateContent(videoType, new BuildingContext(videoType) { Parent = folders.FirstOrDefault(x => x.ContentLink == dataModel.ParentLink), LanguageSelector = LanguageSelector.AutoDetect(), SetPropertyValues = true }) as Video; video.Id = dataModel.Id; video.ContentLink = dataModel.ContentLink; video.Name = dataModel.Name; video.oEmbedHtml = dataModel.oEmbedHtml; video.oEmbedVideoName = dataModel.oEmbedVideoName; video.VideoUrl = dataModel.VideoUrl; video.VideoDownloadUrl = dataModel.VideoDownloadUrl; video.Thumbnail = dataModel.Thumbnail; video.BinaryData = dataModel.Binarydata; video.ContentGuid = dataModel.Guid; video.OriginalHeight = dataModel.OriginalHeight; video.OriginalWidth = dataModel.OriginalWidth; helper.PopulateStandardVideoProperties(video); videos.Add(video); } foreach (VideoFolder folder in folders) { yield return(folder); } foreach (Video video in videos) { yield return(video); } }
public ActionResult LanguageSelector() { var model = new LanguageSelector { ActiveLanguage = this.LanguageRepository.GetActive(), SupportedLanguages = this.LanguageRepository.GetSupportedLanguages().ToList() }; return(this.View(model)); }
public virtual PageObjectManager GetPageObjectManagerForPage(int pageId, string language) { var languageSelector = new LanguageSelector(language); var pageData = DataFactory.Instance.GetPage(new PageReference(pageId), languageSelector); if (pageData == null) { throw new NullReferenceException(string.Format("PageData is null for pageid: {0}.", pageId)); } return new PageObjectManager(pageData); }
private ContentReference GetParent(ContentReference contentLink) { var content = _contentRepository.Get <IContent>(contentLink, LanguageSelector.AutoDetect(true)); if (content == null) { return(null); } var source = _contentLanguageSettingsHandler.Get(content.ParentLink); return(source?.FirstOrDefault()?.DefinedOnContent); }
public void PickLanguagesThatAreKnownToTheRace() { var strategy = new CharacterStrategy(); strategy.AddLanguageKnown("Elvish"); strategy.AddLanguageKnown("Giant"); var character = new CharacterSheet(strategy); var subject = new LanguageSelector(languageGateway); subject.ExecuteStep(character); Assert.NotStrictEqual(character.Languages.Select(x => x.Name), new string[] { "Elvish", "Giant" }); }
private FlowLayoutWidget GetLanguageControl() { FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(top: 4); TextWidget settingsLabel = new TextWidget("Language".Localize()); settingsLabel.AutoExpandBoundsToText = true; settingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingsLabel.VAnchor = VAnchor.ParentTop; FlowLayoutWidget controlsContainer = new FlowLayoutWidget(); controlsContainer.HAnchor = HAnchor.ParentLeftRight; FlowLayoutWidget optionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); optionsContainer.Margin = new BorderDouble(bottom: 6); LanguageSelector languageSelector = new LanguageSelector(); languageSelector.SelectionChanged += new EventHandler(LanguageDropList_SelectionChanged); languageSelector.HAnchor = HAnchor.ParentLeftRight; optionsContainer.AddChild(languageSelector); optionsContainer.Width = 200; languageRestartButton = textImageButtonFactory.Generate("Restart"); languageRestartButton.VAnchor = Agg.UI.VAnchor.ParentCenter; languageRestartButton.Visible = false; languageRestartButton.Margin = new BorderDouble(right: 6); languageRestartButton.Click += (sender, e) => { if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting) { StyledMessageBox.ShowMessageBox(null, cannotRestartWhilePrintIsActiveMessage, cannotRestartWhileActive); } else { RestartApplication(); } }; buttonRow.AddChild(settingsLabel); buttonRow.AddChild(new HorizontalSpacer()); buttonRow.AddChild(languageRestartButton); buttonRow.AddChild(optionsContainer); return(buttonRow); }
/// <summary> /// Load the content for a <see cref="ContentReference"/>. /// </summary> /// <param name="contentLink"> /// The content link. /// </param> /// <param name="languageSelector"> /// The language selector. /// </param> /// <returns> /// The <see cref="IContent"/>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// contentLink /// </exception> /// <exception cref="System.NotSupportedException"> /// Only cloning of pages is supported /// </exception> protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector) { if (ContentReference.IsNullOrEmpty(contentLink) || contentLink.ID == 0) { throw new ArgumentNullException("contentLink"); } if (languageSelector == null) { languageSelector = LanguageSelector.AutoDetect(); } if (contentLink.WorkID > 0) { return(this.ContentStore.LoadVersion(contentLink, -1)); } ILanguageBranchRepository languageBranchRepository = ServiceLocator.Current.GetInstance <ILanguageBranchRepository>(); LanguageSelectorContext context = new LanguageSelectorContext( contentLink, languageBranchRepository, this.Load); if (contentLink.GetPublishedOrLatest) { languageSelector.SelectPageLanguage(context); LanguageBranch langBr = null; if (context.SelectedLanguage != null) { langBr = languageBranchRepository.Load(context.SelectedLanguage); } return(this.ContentStore.LoadVersion(contentLink, langBr != null ? langBr.ID : -1)); } languageSelector.SetInitializedLanguageBranch(context); // Get published version of Content IContent originalContent = this.ContentStore.Load( contentLink, context.SelectedLanguageBranch != null ? context.SelectedLanguageBranch.ID : -1); PageData page = originalContent as PageData; if (page == null) { throw new NotSupportedException("Only cloning of pages is supported"); } return(this.ClonePage(page)); }
private static void HandleChildren(PageData data, string oldUrl, CultureInfo cultureInfo, SystemRedirectReason systemRedirectReason) { var languageSelector = new LanguageSelector(cultureInfo.Name); var pageDataCollection = DataFactory.Instance.GetChildren(data.PageLink, languageSelector); foreach (var pageData in pageDataCollection) { var oldChildUrl = SystemRedirectsHelper.Combine(oldUrl, pageData.URLSegment); AddRedirects(pageData, oldChildUrl, systemRedirectReason); HandleChildren(pageData, oldChildUrl, cultureInfo, systemRedirectReason); } }
public void PickLanguagesThatAreKnownToTheRace() { var race = new Race(); race.KnownLanguages.Add("Elvish"); race.KnownLanguages.Add("Giant"); var subject = new LanguageSelector(new LanguageTestRepo()); var res = subject.PickLanguages(race, 0); Assert.AreEqual(2, res.Count()); Assert.IsTrue(res.Any(x => x.Name == "Elvish")); Assert.IsTrue(res.Any(x => x.Name == "Giant")); }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
private IEnumerable <ContentReference> GetDescendentsOfType <T>(ContentReference contentReference) where T : ContentData { foreach (var reference in ContentLoader.GetDescendents(contentReference)) { var contentItem = ContentLoader.Get <ContentData>(reference, LanguageSelector.AutoDetect()) as T; if (contentItem == null) { continue; } yield return(reference); } }
private void AddEntriesRecursiveFrom(PageData page, LanguageSelector language, Action<SitemapEntry> add) { if (ShowInSiteMap(page)) { add(page.ToSitemapEntry(language, Constants.Bundles.PageTree)); } var children = _contentLoader.GetChildren<PageData>(page.PageLink, language); foreach (var child in children) { AddEntriesRecursiveFrom(child, language, add); } }
public void DoNotRepeatedlyAddKnownLanguages() { var strategy = new CharacterStrategy(); strategy.AddLanguageKnown("Corgi"); strategy.AddLanguageKnown("Corgi"); strategy.AddLanguageKnown("Elvish"); var subject = new LanguageSelector(languageGateway); var character = new CharacterSheet(strategy); subject.ExecuteStep(character); Assert.NotStrictEqual(character.GetAll <Language>().Select(x => x.Name), new string[] { "Corgi", "Elvish" }); }
private void AddEntriesRecursiveFrom(PageData page, LanguageSelector language, Action <SitemapEntry> add) { if (ShowInSiteMap(page)) { add(page.ToSitemapEntry(language, Constants.Bundles.PageTree)); } var children = _contentLoader.GetChildren <PageData>(page.PageLink, language); foreach (var child in children) { AddEntriesRecursiveFrom(child, language, add); } }
/// <summary> /// Initializes a new instance of the SettingsViewModel class. /// </summary> public SettingsViewModel() { AvailableLanguages = Configurator.returnAllLanguages(); selectedLanguage = AvailableLanguages.SingleOrDefault(l => l.FileName == Configurator.getLanguage()); FindCommand = new RelayCommand(SelectGameFolder); if (!Configurator.getFirstStart()) { Message = LocalizationHelper.getValueForKey("First_Start"); } else { Message = ""; } }
/// <summary> /// Get the content data object using the latest version if in edit mode. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="contentLink"></param> /// <param name="editMode"></param> /// <returns></returns> public static T GetItem <T>(ContentReference contentLink, bool editMode) where T : IContentData { if (editMode) { var versionRepo = _versionRepository.Service; var latest = versionRepo.List(contentLink).OrderByDescending(v => v.Saved).FirstOrDefault(v => v.IsMasterLanguageBranch); contentLink = latest.ContentLink; } T content; _contentRepository.Service.TryGet <T>(contentLink, LanguageSelector.AutoDetect(false), out content); return(content); }
public IEnumerable <ContentSummary> List(int contentTypeId) { var allContent = new List <ContentSummary>(); var contentType = _contentTypeRepository.Load(contentTypeId); if (contentType == null) { return(Enumerable.Empty <ContentSummary>()); } IList <ContentUsage> contentUsages = _contentModelUsage.ListContentOfContentType(contentType); IEnumerable <ContentSummary> collection = contentUsages .Distinct(new Comparer()) .Select(contentUsage => { ContentReference contentLink = contentUsage.ContentLink.ToReferenceWithoutVersion(); var content = _contentLoader.Get <IContent>(contentLink, LanguageSelector.MasterLanguage()); var translations = new Dictionary <string, string>(); string masterLanguageName = string.Empty; var localizable = content as ILocalizable; if (localizable != null) { CultureInfo masterLanguage = localizable.MasterLanguage; masterLanguageName = masterLanguage.Name; translations = GetTranslations(contentLink, localizable.ExistingLanguages.Except(new[] { masterLanguage })); } translations.Add(masterLanguageName, content.Name); return(new ContentSummary { ContentLink = contentLink, Translations = translations, MasterLanguage = masterLanguageName, IsDeleted = content.IsDeleted }); }).ToList(); allContent.AddRange(collection); return(allContent.OrderBy(item => item.ContentLink.ID).ToList()); }
protected virtual IEnumerable <CurrentLanguageContent> GetFallbackLanguageBranches(ContentReference contentLink) { foreach (var languageBranch in this.EnabledLanguages) { var languageContent = ContentRepository.Get <IContent>(contentLink, LanguageSelector.Fallback(languageBranch.Culture.Name, false)); if (languageContent == null) { continue; } yield return(new CurrentLanguageContent { Content = languageContent, CurrentLanguage = languageBranch.Culture, MasterLanguage = GetMasterLanguage(languageContent) }); } }
private FlowLayoutWidget GetLanguageControl() { FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(top: 4); TextWidget settingsLabel = new TextWidget("Language Options".Localize()); settingsLabel.AutoExpandBoundsToText = true; settingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingsLabel.VAnchor = VAnchor.ParentTop; FlowLayoutWidget controlsContainer = new FlowLayoutWidget(); controlsContainer.HAnchor = HAnchor.ParentLeftRight; FlowLayoutWidget optionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); optionsContainer.Margin = new BorderDouble(bottom: 6); LanguageSelector languageSelector = new LanguageSelector(); languageSelector.SelectionChanged += new EventHandler(LanguageDropList_SelectionChanged); languageSelector.HAnchor = HAnchor.ParentLeftRight; optionsContainer.AddChild(languageSelector); optionsContainer.Width = 200; languageRestartButton = textImageButtonFactory.Generate("Restart"); languageRestartButton.VAnchor = Agg.UI.VAnchor.ParentCenter; languageRestartButton.Visible = false; languageRestartButton.Margin = new BorderDouble(right: 6); languageRestartButton.Click += (sender, e) => { RestartApplication(); }; buttonRow.AddChild(settingsLabel); buttonRow.AddChild(new HorizontalSpacer()); buttonRow.AddChild(languageRestartButton); buttonRow.AddChild(optionsContainer); return buttonRow; }