Exemple #1
0
        protected virtual IEnumerable <CurrentLanguageContent> GetLanguageBranches(ContentReference contentLink)
        {
            bool isSpecificLanguage = !string.IsNullOrWhiteSpace(this.SitemapData.Language);

            if (isSpecificLanguage)
            {
                ILanguageSelector 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)
            }));
        }
        /// <summary>
        /// The find pages with criteria.
        /// </summary>
        /// <param name="pageLink">
        /// The page link.
        /// </param>
        /// <param name="criterias">
        /// The criterias.
        /// </param>
        /// <param name="languageBranch">
        /// The language branch.
        /// </param>
        /// <param name="selector">
        /// The selector.
        /// </param>
        /// <returns>
        /// The <see cref="PageDataCollection"/>.
        /// </returns>
        public PageDataCollection FindPagesWithCriteria(
            PageReference pageLink,
            PropertyCriteriaCollection criterias,
            string languageBranch,
            ILanguageSelector selector)
        {
            if (PageReference.IsNullOrEmpty(pageLink))
            {
                return(new PageDataCollection());
            }

            // Any search beneath the entry root should in fact be performed under the clone root as that's where the original content resides
            if (pageLink.CompareToIgnoreWorkID(this.EntryRoot))
            {
                pageLink = this.CloneRoot;
            }
            else if (!string.IsNullOrWhiteSpace(pageLink.ProviderName))
            {
                // Any search beneath a cloned page should in fact be performed under the original page, so we use a page link without any provider information
                pageLink = new PageReference(pageLink.ID);
            }

            PageDataCollection pages = DataFactory.Instance.FindPagesWithCriteria(
                pageLink, criterias, languageBranch, selector);

            // Return cloned search result set
            return(new PageDataCollection(pages.Select(this.ClonePage)));
        }
        public virtual T GetContent <T>(IndexItemBase indexItem, bool filterOnCulture) where T : IContent
        {
            if (indexItem == null || string.IsNullOrEmpty(indexItem.Id))
            {
                return(default(T));
            }
            var input = indexItem.Id.Split(new[]
            {
                '|'
            }).FirstOrDefault();

            System.Guid guid;
            if (System.Guid.TryParse(input, out guid))
            {
                ILanguageSelector selector = filterOnCulture ? this.languageSelectorFactory.AutoDetect(false) : this.GetLanguageSelector(indexItem.Culture);
                try
                {
                    //return this.contentRepository.Get<T>(guid, selector);
                    return(contentRepository.Get <T>(guid));
                }
                catch (ContentNotFoundException exception)
                {
                    LuceneContentSearchHandler.log.Warn(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Search index returned an item with GUID {0:B}, that no longer exists in the content repository.", new object[]
                    {
                        guid
                    }), exception);
                }
            }
            return(default(T));
        }
Exemple #4
0
        private bool PageExistsInLanguageContext(PageData page, ILanguageSelector languageSelector)
        {
            //Checks if page exist in current language context or if a fallback exist
            LanguageSelectorContext args = new LanguageSelectorContext(page);

            languageSelector.SelectPageLanguage(args);
            return(!String.IsNullOrEmpty(args.SelectedLanguage));
        }
        public IEnumerable <T> GetChildren <T>(ContentReference contentLink, ILanguageSelector selector, int startIndex, int maxRows) where T : IContentData
        {
            string stepName = string.Format("GetChildren<{0}>[{1}:{2}:{3}]", typeof(T).Name, contentLink, startIndex, maxRows);

            using (MiniProfiler.Current.Step(stepName))
            {
                return(DataFactory.Instance.GetChildren <T>(contentLink, selector, startIndex, maxRows));
            }
        }
        /// <summary>
        /// Brings up a dialog that will create a new user profile
        /// </summary>
        private void MakeNewProfile()
        {
            _splash.SetStatusText("Creating new profile");

            ILanguageSelector languageSelector = _container.Resolve <ILanguageSelector>();

            MainForm = languageSelector as Form;
            MainForm.Show();
        }
        public T Get <T>(ContentReference contentLink, ILanguageSelector selector) where T : IContentData
        {
            string stepName = string.Format("Get<{0}>[{1}]", typeof(T).Name, contentLink);

            using (MiniProfiler.Current.Step(stepName))
            {
                return(DataFactory.Instance.Get <T>(contentLink, selector));
            }
        }
        public T CreateLanguageBranch <T>(ContentReference contentLink, ILanguageSelector languageSelector, AccessLevel access) where T : IContentData
        {
            string stepName = string.Format("CreateLanguageBranch<{0}>[{1}]", typeof(T), access);

            using (MiniProfiler.Current.Step(stepName))
            {
                return(DataFactory.Instance.CreateLanguageBranch <T>(contentLink, languageSelector, access));
            }
        }
		/// <summary>
		///     <see cref="PageProviderBase.GetLocalPage"/>
		/// </summary>
		/// <param name="pageLink">Page link</param>
		/// <param name="languageSelector">Language selector</param>
		/// <returns>Page Data</returns>
		protected override PageData GetLocalPage(PageReference pageLink, ILanguageSelector languageSelector)
		{
			if (pageLink == null || PageReference.IsNullOrEmpty(pageLink))
			{
				return null;
			}

			return GetPage(MappedPPDB.Instance.LoadMapping(Name, pageLink.ID).Key, pageLink, languageSelector);
		}
        public T GetDefault <T>(ContentReference parentLink, int contentTypeID, ILanguageSelector languageSelector) where T : IContentData
        {
            string stepName = string.Format("GetDefault<{0}>[parent:{1}:{2}]", typeof(T), parentLink, contentTypeID);

            using (MiniProfiler.Current.Step(stepName))
            {
                return(DataFactory.Instance.GetDefault <T>(parentLink, contentTypeID, languageSelector));
            }
        }
Exemple #11
0
        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            IContentNode <IContentData> contentNode = AllContent.FirstOrDefault(x => x.ContentLink.Equals(contentLink));

            if (contentNode == null)
            {
                return(null);
            }

            return(contentNode.Content as IContent);
        }
        /// <summary>
        /// The load contents.
        /// </summary>
        /// <param name="contentReferences">
        /// The content references.
        /// </param>
        /// <param name="selector">
        /// The selector.
        /// </param>
        /// <returns>
        /// An <see cref="IEnumerable{IContent}"/> of cloned content.
        /// </returns>
        protected override IEnumerable <IContent> LoadContents(
            IList <ContentReference> contentReferences, ILanguageSelector selector)
        {
            IContentRepository contentRepository = ServiceLocator.Current.GetInstance <IContentRepository>();

            return
                (contentReferences.Select(
                     contentReference =>
                     this.ClonePage(contentRepository.Get <PageData>(new PageReference(contentReference.ID))))
                 .Cast <IContent>()
                 .ToList());
        }
        /// <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));
        }
Exemple #14
0
        public ILanguage GetLanguage()
        {
            ILanguageSelector languageSelector = GetLanguageSelector();

            if (languageSelector == null)
            {
                return(new CSharpV4());
            }
            else
            {
                return(languageSelector.GetLanguage());
            }
        }
Exemple #15
0
        public ILanguage GetLanguage()
        {
            ILanguageSelector languageSelector = GetLanguageSelector();

            if (languageSelector == null)
            {
                return(LanguageFactory.GetLanguage(CSharpVersion.V7));
            }
            else
            {
                return(languageSelector.GetLanguage());
            }
        }
Exemple #16
0
 public TranslationProcess(
     IResourceFileReader resourceFileReader,
     ILanguageSelector languageSelector,
     ITranslationClient translateClient,
     IResourceFileWriter resourceFileWriter,
     IResourceFileTranslatorUi ui
     )
 {
     ResourceFileReader = resourceFileReader;
     LanguageSelector   = languageSelector;
     TranslationClient  = translateClient;
     ResourceFileWriter = resourceFileWriter;
     Ui = ui;
 }
        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            // contentLink: Id: 319, ProviderName = "google-contacts-provider"

            var identityMappingService = ServiceLocator.Current.GetInstance <IdentityMappingService>();
            var googleContactsService  = ServiceLocator.Current.GetInstance <GoogleContactsService>();

            // tblMappedIdentity
            var mappedIdentity = identityMappingService.Get(contentLink);

            string resourceName = mappedIdentity.ExternalIdentifier.Segments[1]; // c5792122681440133761

            return(Convert(googleContactsService.GetContact("people/" + resourceName).Result));
        }
Exemple #18
0
        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            var mappedItem = _identityMappingService.Get(contentLink);

            if (mappedItem == null)
            {
                return(null);
            }

            switch (GetYouTubeResourceType(mappedItem.ExternalIdentifier))
            {
            case YouTubeResourceType.Playlist:

                var playlist = _youTubeRepository.GetPlaylist(mappedItem.ExternalIdentifier.Segments[3]);
                if (playlist != null)
                {
                    return(CreateYouTubeData(mappedItem, typeof(YouTubePlaylist), playlist));
                }
                break;

            case YouTubeResourceType.PlaylistItem:

                var playlistItem = _youTubeRepository.GetPlaylistItem(mappedItem.ExternalIdentifier.Segments[4]);
                if (playlistItem != null)
                {
                    return(CreatePlaylistItem(mappedItem, playlistItem));
                }
                break;

            case YouTubeResourceType.Subscription:

                var subscription = _youTubeRepository.GetSubscription(RemoveEndingSlash(mappedItem.ExternalIdentifier.Segments[3]));
                if (subscription != null)
                {
                    return(CreateYouTubeData(mappedItem, typeof(YouTubeSubscription), subscription));
                }
                break;

            case YouTubeResourceType.Video:

                var video = _youTubeRepository.GetVideo(RemoveEndingSlash(mappedItem.ExternalIdentifier.Segments[3]));
                if (video != null)
                {
                    return(CreateVideo(mappedItem, video));
                }
                break;
            }

            return(CreateAndAssignIdentity(mappedItem, typeof(YouTubeFolder), RemoveStartingSlash(mappedItem.ExternalIdentifier.LocalPath)));
        }
        public PageData CreateLanguageBranch(PageReference pageLink, ILanguageSelector selector, AccessLevel access)
        {
            PageData masterPage = GetPage(pageLink);

            LanguageSelectorContext ls = new LanguageSelectorContext(masterPage);

            selector.LoadLanguage(ls);
            PageData      pageData  = ConstructContentData <PageData>(masterPage.PageName, masterPage.PageLink, masterPage.ParentLink, ls.SelectedLanguage);
            List <String> languages = new List <string>(masterPage.PageLanguages);

            languages.Add(ls.SelectedLanguage);
            pageData.InitializeData(languages);
            pageData.PageGuid    = masterPage.PageGuid;
            pageData.PageLink.ID = masterPage.PageLink.ID;
            return(pageData);
        }
Exemple #20
0
        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            if (ContentReference.IsNullOrEmpty(contentLink) || contentLink.ID == 0)
            {
                throw new ArgumentNullException("contentLink");
            }

            if (contentLink.WorkID > 0)
            {
                return(ContentStore.LoadVersion(contentLink, -1));
            }

            var languageBranchRepository = ServiceLocator.Current.GetInstance <ILanguageBranchRepository>();

            return(Load(contentLink, languageSelector));

            /* var context = new LanguageSelectorContext(contentLink, languageBranchRepository, Load);
             * var culture = languageSelector.Language;
             *
             * if (contentLink.GetPublishedOrLatest)
             * {
             *   languageSelector.SelectPageLanguage(context);
             *
             *   LanguageBranch langBr = null;
             *
             *   if (context.SelectedLanguage != null)
             *   {
             *       langBr = languageBranchRepository.Load(context.SelectedLanguage);
             *   }
             *
             *   return ContentStore.LoadVersion(contentLink, langBr != null ? langBr.ID : -1);
             * }
             *
             * languageSelector .SetInitializedLanguageBranch(context);
             *
             * // Get published version of Content
             * var originalContent = ContentStore.Load(contentLink, context.SelectedLanguageBranch != null ? context.SelectedLanguageBranch.ID : -1);
             *
             * var page = originalContent as PageData;
             *
             * if(page == null)
             * {
             *   throw new NotSupportedException("Only cloning of pages is supported");
             * }
             *
             * return ClonePage(page);*/
        }
        private PageData GetPage(PageReference pageLink, ILanguageSelector selector)
        {
            PageData        page = null;
            List <PageData> pages;

            if (!_pages.TryGetValue(pageLink, out pages))
            {
                throw new PageNotFoundException(pageLink);
            }
            page = pages.Last();
            LanguageSelector ls = selector as LanguageSelector;

            if (ls != null && !String.IsNullOrEmpty(ls.LanguageBranch))
            {
                page = pages.Find(p => p.LanguageBranch == ls.LanguageBranch);
            }

            return(page);
        }
        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            var item = _items.FirstOrDefault(p => p.ContentLink.Equals(contentLink));

            if (item == null)
            {
                item = _items.FirstOrDefault(p => p.ContentLink.CompareToIgnoreWorkID(contentLink));
            }
            if (contentLink.WorkID > 0)
            {
                var video = item as Video;
                if (video != null)
                {
                    Video writeableVideo = video.CreateWritableClone() as Video;
                    ((IVersionable)writeableVideo).Status = VersionStatus.CheckedOut;
                    return(writeableVideo);
                }
            }
            return(item);
        }
Exemple #23
0
        /// <summary>
        /// Reads data from the backing XML file and creates a PageData object from the data.
        /// </summary>
        /// <remarks>
        /// The language selector is used to see if a specific language is preferred, if language does not
        /// exist or a specific language was not given master language branch is returned.
        /// </remarks>
        /// <param name="pageLink">The page link.</param>
        /// <param name="selector">The selector which states the preffered language</param>
        /// <returns>A fully initialized PageData object</returns>
        protected override PageData GetLocalPage(PageReference pageLink, ILanguageSelector languageSelector)
        {
            List <string> pageLanguages            = new List <string>();
            PageData      pageData                 = new PageData();
            Dictionary <string, string> properties = new ExcelParser(_excelFilePath, _idColumn, _pageNameColumn, _sheetName).GetPageProperties(pageLink.ID);

            base.InitializePageData(pageData, properties[_pageNameColumn], _pageTypeName, GetGuidFromID(pageLink.ID), pageLink.CreateWritableClone(), EntryPoint, pageLanguages);

            foreach (KeyValuePair <string, string> keyValuePair in properties)
            {
                if (keyValuePair.Key != _idColumn && keyValuePair.Key != _pageNameColumn)
                {
                    pageData.SetValue(keyValuePair.Key, keyValuePair.Value);
                }
            }
            SetPageStatus(pageData, VersionStatus.Published);
            SetDynamicProperties(pageData);

            return(pageData);
        }
Exemple #24
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);


            IEnumerable <ProductVariation> relationsBySource =
                linksRepository.GetRelationsBySource(CurrentContent.ContentLink).OfType <ProductVariation>();

            ILanguageSelector selector = ServiceLocator.Current.GetInstance <ILanguageSelector>();
            // LanguageSelector.AutoDetect() // is also valid argument for the method below

            IEnumerable <FashionVariation> variations =
                base.contentLoader.GetItems(relationsBySource.Select(r => r.Target), selector)
                .OfType <FashionVariation>();

            rptVariantsOfProducts.DataSource = variations;
            rptVariantsOfProducts.DataBind();

            // can also do like this
            // var relations = CurrentContent.GetVariantRelations().ToList();
        }
        protected virtual LocalizationContainer FindLocalizationContainer(ILanguageSelector languageSelector)
        {
            var rootPage = ContentReference.RootPage;

            if (rootPage == null)
            {
                // the GetString method is called before EPiServer is fully initialized.
                // If this is the case we are not able to return any resources since we depend on the epi cms api
                return(null);
            }

            try
            {
                var criteria = new PropertyCriteria
                {
                    Condition = CompareCondition.Equal,
                    Value     = typeof(LocalizationContainer).Name,
                    Required  = true,
                    Name      = "PageTypeName",
                    Type      = PropertyDataType.PageType
                };

                var localizationPages = DataFactory.Instance.FindPagesWithCriteria(rootPage, new PropertyCriteriaCollection {
                    criteria
                }, null, languageSelector);

                if (localizationPages.Count > 1)
                {
                    throw new InvalidOperationException("The cms tree contains more then 1 instance of the Localizations container this is not allowed");
                }

                return((LocalizationContainer)localizationPages.FirstOrDefault());
            }
            catch (ContentProviderNotFoundException)
            {
                // the GetString method is called before EPiServer is fully initialized.
                // If this is the case we are not able to return any resources since we depend on the epi cms api
                return(null);
            }
        }
        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            if (ContentReference.IsNullOrEmpty(contentLink) || contentLink.ID == 0)
            {
                throw new ArgumentNullException("contentLink");
            }

            if (contentLink.WorkID > 0)
            {
                return(_contentStore.LoadVersion(contentLink, -1));
            }

            var languageBranchRepository = DependencyHelper.LanguageBranchRepository;

            LanguageBranch langBr = null;

            if (languageSelector.Language != null)
            {
                langBr = languageBranchRepository.Load(languageSelector.Language);
            }

            if (contentLink.GetPublishedOrLatest)
            {
                return(_contentStore.LoadVersion(contentLink, langBr != null ? langBr.ID : -1));
            }

            // Get published version of Content
            var originalContent = _contentStore.Load(contentLink, langBr != null ? langBr.ID : -1);

            var page = originalContent as PageData;

            if (page == null)
            {
                throw new NotSupportedException("Only cloning of pages is supported");
            }

            return(ClonePage(page));
        }
 public virtual PageDataCollection GetChildren(PageReference pageLink, ILanguageSelector selector, Int32 startIndex, Int32 maxRows)
 {
     return DataFactory.Instance.GetChildren(pageLink, selector, startIndex, maxRows);
 }
 public virtual PageDataCollection GetChildren(PageReference pageLink, ILanguageSelector selector)
 {
     return DataFactory.Instance.GetChildren(pageLink, selector);
 }
 public virtual PageData GetDefaultPageData(PageReference parentPageLink, String pageTypeName, ILanguageSelector selector)
 {
     return DataFactory.Instance.GetDefaultPageData(parentPageLink, pageTypeName, selector);
 }
Exemple #30
0
 protected override IEnumerable <IContent> LoadContents(IList <ContentReference> contentReferences, ILanguageSelector selector)
 {
     return(contentReferences
            .Select(contentReference => ClonePage(ContentLoader.Get <PageData>(contentReference.ToReferenceWithoutVersion())))
            .Cast <IContent>()
            .ToList());
 }
        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            if (ContentReference.IsNullOrEmpty(contentLink) || contentLink.ID == 0)
            {
                throw new ArgumentNullException("contentLink");
            }

            if (contentLink.WorkID > 0)
            {
                return ContentStore.LoadVersion(contentLink, -1);
            }

            var languageBranchRepository = ServiceLocator.Current.GetInstance<ILanguageBranchRepository>();

            var context = new LanguageSelectorContext(contentLink, languageBranchRepository, Load);

            if (contentLink.GetPublishedOrLatest)
            {
                languageSelector.SelectPageLanguage(context);

                LanguageBranch langBr = null;

                if (context.SelectedLanguage != null)
                {
                    langBr = languageBranchRepository.Load(context.SelectedLanguage);
                }

                return ContentStore.LoadVersion(contentLink, langBr != null ? langBr.ID : -1);
            }

            languageSelector.SetInitializedLanguageBranch(context);

            // Get published version of Content
            var originalContent = ContentStore.Load(contentLink, context.SelectedLanguageBranch != null ? context.SelectedLanguageBranch.ID : -1);

            var page = originalContent as PageData;

            if(page == null)
            {
                throw new NotSupportedException("Only cloning of pages is supported");
            }

            return ClonePage(page);
        }
        protected virtual LocalizationContainer FindLocalizationContainer(ILanguageSelector languageSelector)
        {
            var rootPage = ContentReference.RootPage;
            if (rootPage == null)
            {
                // the GetString method is called before EPiServer is fully initialized.
                // If this is the case we are not able to return any resources since we depend on the epi cms api
                return null;
            }

            try
            {
                var criteria = new PropertyCriteria
                {
                    Condition = CompareCondition.Equal,
                    Value = typeof(LocalizationContainer).Name,
                    Required = true,
                    Name = "PageTypeName",
                    Type = PropertyDataType.PageType
                };

                var localizationPages = DataFactory.Instance.FindPagesWithCriteria(rootPage, new PropertyCriteriaCollection {criteria}, null, languageSelector);

                if(localizationPages.Count > 1)
                    throw new InvalidOperationException("The cms tree contains more then 1 instance of the Localizations container this is not allowed");

                return (LocalizationContainer) localizationPages.FirstOrDefault();
            }
            catch (ContentProviderNotFoundException)
            {
                // the GetString method is called before EPiServer is fully initialized. 
                // If this is the case we are not able to return any resources since we depend on the epi cms api                        
                return null;
            }            
        }
 public virtual PageData CreateLanguageBranch(PageReference pageLink, ILanguageSelector selector, AccessLevel access)
 {
     return DataFactory.Instance.CreateLanguageBranch(pageLink, selector, access);
 }
 public virtual PageDataCollection FindPagesWithCriteria(PageReference pageLink, PropertyCriteriaCollection criterias,
                                                         String languageBranch, ILanguageSelector selector)
 {
     return DataFactory.Instance.FindPagesWithCriteria(pageLink, criterias, languageBranch, selector);
 }
        public PageDataCollection FindPagesWithCriteria(PageReference pageLink, PropertyCriteriaCollection criterias, string languageBranch, ILanguageSelector selector)
        {
            // Any search beneath the entry root should in fact be performed under the clone root as that's where the original content resides
            if (pageLink.CompareToIgnoreWorkID(EntryRoot))
            {
                pageLink = CloneRoot;
            }
            else if (!string.IsNullOrWhiteSpace(pageLink.ProviderName)) // Any search beneath a cloned page should in fact be performed under the original page, so we use a page link without any provider information
            {
                pageLink = new PageReference(pageLink.ID);
            }

            var pages = DataFactory.Instance.FindPagesWithCriteria(pageLink, criterias, languageBranch, selector);

            // Return cloned search result set
            return new PageDataCollection(pages.Select(ClonePage));
        }
		/// <summary>
		///     Get existing language and page name
		/// </summary>
		/// <param name="key">Key</param>
		/// <param name="catalog">Catalog</param>
		/// <param name="pageLink">Page Link</param>
		/// <param name="languageSelector">Language selector</param>
		/// <param name="nodeType">Node type</param>
		/// <param name="pageName">Page name to return</param>
		/// <param name="languageBranchId"></param>
		/// <returns></returns>
		private static IList<string> GetExistingLanguage(IDictionary<string, string> key, CatalogDto.CatalogRow catalog, PageReference
						pageLink, ILanguageSelector languageSelector, NodeType nodeType, out string pageName, out string languageBranchId)
		{
			var context = new LanguageSelectorContext(pageLink);
			languageSelector.SetInitializedLanguageBranch(context);
			languageBranchId = context.MasterLanguageBranch;
			if (!string.IsNullOrEmpty(context.SelectedLanguage))
			{
				languageBranchId = context.SelectedLanguage;
			}
			if (string.IsNullOrEmpty(languageBranchId))
			{
				var langSelector = languageSelector as LanguageSelector;
				if (langSelector != null)
					languageBranchId = langSelector.LanguageBranch;
			}
			if (!string.IsNullOrEmpty(languageBranchId))
			{
				languageBranchId = languageBranchId.ToUpperInvariant();
			}
			var enabledLanguages = LanguageBranch.ListEnabled().Select(l => l.LanguageID);
			// get existing language from mediachase
			var existingLanguage = new List<string>();
			if (!string.IsNullOrEmpty(catalog.DefaultLanguage)
				&& enabledLanguages.Contains(catalog.DefaultLanguage, StringComparer.OrdinalIgnoreCase))
			{
				existingLanguage.Add(catalog.DefaultLanguage.ToUpperInvariant());
			}

			catalog.GetCatalogLanguageRows().ToList().ForEach(row =>
			{
				if (!string.IsNullOrEmpty(row.LanguageCode) && !existingLanguage.Contains(row.LanguageCode, StringComparer.OrdinalIgnoreCase)
					&& enabledLanguages.Contains(row.LanguageCode, StringComparer.OrdinalIgnoreCase))
				{
					existingLanguage.Add(row.LanguageCode.ToUpperInvariant());
				}
			});

			pageName = key[CatalogName];
			string results = string.Empty;
			switch (nodeType)
			{
				case NodeType.CatalogEntry:
					results = GetEntryPageName(key, existingLanguage, languageBranchId, catalog);
					if (results.Length > 0)
					{
						pageName = results;
					}
					break;
				case NodeType.CatalogNode:
					results = GetNodePageName(key, existingLanguage, languageBranchId, catalog);
					if (results.Length > 0)
					{
						pageName = results;
					}
					break;
			}
			return existingLanguage;
		}
		/// <summary>
		/// 	<see cref="MappedPageProvider.GetPage(string, PageReference, ILanguageSelector)"/>
		/// </summary>
		/// <param name="key">Key to page of the provider</param>
		/// <param name="pageLink"></param>
		/// <param name="languageSelector"></param>
		/// <returns></returns>
		protected override PageData GetPage(string key, PageReference pageLink, ILanguageSelector languageSelector)
		{
			var param = SplitKey(key);
			var parentKey = string.Empty;
			var parentNodeId = Convert.ToInt32(param[ParentNodeId], CultureInfo.InvariantCulture);
			var nodeType = (NodeType)Enum.Parse(typeof(NodeType), param[CatalogNodeType]);

			// look up catalog first
			var catalog = LookUpCatalog(Convert.ToInt32(param[CatalogId], CultureInfo.InvariantCulture));

			if (parentNodeId >= 0)
			{
				// get corresponding parent key
				parentKey = GetParentKey(param, parentNodeId, catalog);
			}

			string pageName;
			string languageBranchId;

			// retrieve existing language and page name
			var existingLanguage = GetExistingLanguage(param, catalog, pageLink, languageSelector, nodeType, out pageName, out languageBranchId);

			// initialize page data
			var pageData = new PageData();
			InitializePageData(pageData, key, pageName, parentKey, existingLanguage, languageBranchId);
			pageData.VisibleInMenu = true;
			pageData.MasterLanguageBranch = catalog.DefaultLanguage;
			switch (nodeType)
			{
				case NodeType.Catalog:
					try
					{
						pageData.Property[EPiServer.Business.Commerce.Constants.PropertyNodeName].Value = param[CatalogName];
					}
					catch (NullReferenceException ese)
					{
						_logger.Error(string.Format(CultureInfo.CurrentCulture, "Catalog page type is not valid, property {0} not found.", EPiServer.Business.Commerce.Constants.PropertyNodeName), ese);
					}
					catch (EPiServerException ex)
					{
						_logger.Error(string.Format(CultureInfo.CurrentCulture, "Catalog page type is not valid, property {0} not found.", EPiServer.Business.Commerce.Constants.PropertyNodeName), ex);
					}
					break;
				case NodeType.CatalogNode:
					try
					{
						pageData.Property[EPiServer.Business.Commerce.Constants.PropertyCatalogNode].Value = param[NodeCode];
						pageData.Property[EPiServer.Business.Commerce.Constants.PropertyNodeName].Value = CatalogContext.Current.GetCatalogNode(param[NodeCode]).Name;
					}
					catch (NullReferenceException ese)
					{
						_logger.Error(string.Format(CultureInfo.CurrentCulture, "Product List page type is not valid, property {0} or {1} not found.", EPiServer.Business.Commerce.Constants.PropertyCatalogNode, EPiServer.Business.Commerce.Constants.PropertyNodeName), ese);
					}
					catch (EPiServerException ex)
					{
						_logger.Error(string.Format(CultureInfo.CurrentCulture, "Product List page type is not valid, property {0} or {1} not found.", EPiServer.Business.Commerce.Constants.PropertyCatalogNode, EPiServer.Business.Commerce.Constants.PropertyNodeName), ex);
					}
					break;
				default: // catalog entry
					try
					{
						// set the entry code to the property
						pageData[EPiServer.Business.Commerce.Constants.ParameterEntryCode] = param[NodeCode];
					}
					catch (NullReferenceException ese)
					{
						_logger.Error(string.Format(CultureInfo.CurrentCulture, "Product detail page type is not valid, property {0} not found.", EPiServer.Business.Commerce.Constants.ParameterEntryCode), ese);
					}
					catch (EPiServerException ex)
					{
						_logger.Error(string.Format(CultureInfo.CurrentCulture, "Product detail page type is not valid, property {0} not found.", EPiServer.Business.Commerce.Constants.ParameterEntryCode), ex);
					}
					break;
			}

			// set page status to published
			SetPageStatus(pageData, VersionStatus.Published);
			return pageData;
		}
 /// <summary>
 /// Shorthand for DataFactory.Instance.GetPage
 /// </summary>
 public static PageData GetPage(this PageReference pageLink, ILanguageSelector languageSelector)
 {
     return(DataFactory.Instance.GetPage(pageLink, languageSelector));
 }
        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            var mappedItem = _identityMappingService.Get(contentLink);
            if (mappedItem == null) return null;

            switch (GetYouTubeResourceType(mappedItem.ExternalIdentifier))
            {
                case YouTubeResourceType.Playlist:

                    var playlist = _youTubeRepository.GetPlaylist(mappedItem.ExternalIdentifier.Segments[3]);
                    if (playlist != null)
                        return CreateYouTubeData(mappedItem, typeof(YouTubePlaylist), playlist);
                    break;

                case YouTubeResourceType.PlaylistItem:

                    var playlistItem = _youTubeRepository.GetPlaylistItem(mappedItem.ExternalIdentifier.Segments[4]);
                    if (playlistItem != null)
                        return CreatePlaylistItem(mappedItem, playlistItem);
                    break;

                case YouTubeResourceType.Subscription:

                    var subscription = _youTubeRepository.GetSubscription(RemoveEndingSlash(mappedItem.ExternalIdentifier.Segments[3]));
                    if (subscription != null)
                        return CreateYouTubeData(mappedItem, typeof(YouTubeSubscription), subscription);
                    break;

                case YouTubeResourceType.Video:

                    var video = _youTubeRepository.GetVideo(RemoveEndingSlash(mappedItem.ExternalIdentifier.Segments[3]));
                    if (video != null)
                        return CreateVideo(mappedItem, video);
                    break;
            }

            return CreateAndAssignIdentity(mappedItem, typeof(YouTubeFolder), RemoveStartingSlash(mappedItem.ExternalIdentifier.LocalPath));
        }
Exemple #40
0
 public MaterialCard(ILanguageSelector <IMaterial> languageSelector)
 {
     MaterialGetter = (context) => languageSelector[context.Language];
 }
        /// <summary>
        /// The load contents.
        /// </summary>
        /// <param name="contentReferences">
        /// The content references.
        /// </param>
        /// <param name="selector">
        /// The selector.
        /// </param>
        /// <returns>
        /// An <see cref="IEnumerable{IContent}"/> of cloned content.
        /// </returns>
        protected override IEnumerable<IContent> LoadContents(
            IList<ContentReference> contentReferences, ILanguageSelector selector)
        {
            IContentRepository contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();

            return
                contentReferences.Select(
                    contentReference =>
                    this.ClonePage(contentRepository.Get<PageData>(new PageReference(contentReference.ID))))
                                 .Cast<IContent>()
                                 .ToList();
        }
Exemple #42
0
 public Product(ILanguageSelector <IMaterial> description, float initialPrice)
 {
 }
 public virtual PageData GetPage(PageReference pageLink, ILanguageSelector selector)
 {
     return DataFactory.Instance.GetPage(pageLink, selector);
 }
		/// <summary>
		///     Gets page data by key
		/// </summary>
		/// <param name="key">Key to page of the provider</param>
		/// <param name="pageLink"></param>
		/// <param name="languageSelector"></param>
		/// <returns></returns>
		protected abstract PageData GetPage(string key, PageReference pageLink, ILanguageSelector languageSelector);
 protected override IEnumerable<IContent> LoadContents(IList<ContentReference> contentReferences, ILanguageSelector selector)
 {
     return contentReferences
            .Select(contentReference => ClonePage(new PageReference(contentReference.ID).GetPage()))
            .Cast<IContent>()
            .ToList();
 }
Exemple #46
0
 protected override IEnumerable <IContent> LoadContents(IList <ContentReference> contentReferences, ILanguageSelector selector)
 {
     return(contentReferences
            .Select(contentReference => ClonePage(new PageReference(contentReference.ID).GetPage()))
            .Cast <IContent>()
            .ToList());
 }
 protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
 {
     var item = _items.FirstOrDefault(p => p.ContentLink.Equals(contentLink));
     return item ?? _items.FirstOrDefault();
 }