Exemplo n.º 1
0
        /// <summary>
        /// Reset web navigation to its default configuration. Disabled the term set as navigation term set.
        /// </summary>
        /// <param name="web">The web</param>
        /// <param name="settings">The managed navigation settings. Set null if you want to keep the associated termset unchanged</param>
        public void ResetWebNavigationToDefault(SPWeb web, ManagedNavigationInfo settings)
        {
            var taxonomySession = new TaxonomySession(web.Site);

            if (taxonomySession.TermStores.Count > 0)
            {
                if (settings != null)
                {
                    // Disable the navigation flag on the the term set
                    var termStore = taxonomySession.DefaultSiteCollectionTermStore;
                    var group     = this.taxonomyService.GetTermGroupFromStore(termStore, settings.TermGroup.Name);
                    var termSet   = this.taxonomyService.GetTermSetFromGroup(termStore, group, settings.TermSet.Label);

                    const string PropertyName = "_Sys_Nav_IsNavigationTermSet";
                    string       propertyValue;
                    if (termSet.CustomProperties.TryGetValue(PropertyName, out propertyValue))
                    {
                        termSet.DeleteCustomProperty(PropertyName);
                        termSet.TermStore.CommitAll();
                    }
                }

                var navigationSettings = new WebNavigationSettings(web);
                navigationSettings.ResetToDefaults();
                navigationSettings.Update(taxonomySession);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the web navigation settings.
        /// </summary>
        /// <param name="web">The web.</param>
        /// <param name="settings">The settings.</param>
        public void SetWebNavigationSettings(SPWeb web, ManagedNavigationInfo settings)
        {
            var taxonomySession = new TaxonomySession(web.Site);

            if (taxonomySession.TermStores.Count > 0)
            {
                var termStore = settings.TermSet.ResolveParentTermStore(taxonomySession);
                var group     = settings.TermSet.ResolveParentGroup(taxonomySession, web.Site);
                var termSet   = this.taxonomyService.GetTermSetFromGroup(termStore, group, settings.TermSet.Label);

                // Flag the term set as a navigation term set
                termSet.SetCustomProperty(SystemIsNavigationTermSet, "True");
                termStore.CommitAll();

                var navigationSettings = new WebNavigationSettings(web);

                navigationSettings.GlobalNavigation.Source      = StandardNavigationSource.TaxonomyProvider;
                navigationSettings.GlobalNavigation.TermStoreId = termStore.Id;
                navigationSettings.GlobalNavigation.TermSetId   = termSet.Id;

                navigationSettings.CurrentNavigation.Source      = StandardNavigationSource.TaxonomyProvider;
                navigationSettings.CurrentNavigation.TermStoreId = termStore.Id;
                navigationSettings.CurrentNavigation.TermSetId   = termSet.Id;

                navigationSettings.AddNewPagesToNavigation       = settings.AddNewPagesToNavigation;
                navigationSettings.CreateFriendlyUrlsForNewPages = settings.CreateFriendlyUrlsForNewsPages;
                navigationSettings.Update(taxonomySession);

                if (settings.PreserveTaggingOnTermSet)
                {
                    termSet.IsAvailableForTagging = true;
                    termStore.CommitAll();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reset web navigation to its default configuration. Disabled the term set as navigation term set.
        /// </summary>
        /// <param name="web">The web</param>
        /// <param name="settings">The managed navigation settings. Set null if you want to keep the associated termset unchanged</param>
        public void ResetWebNavigationToDefault(SPWeb web, ManagedNavigationInfo settings)
        {
            var taxonomySession = new TaxonomySession(web.Site);

            if (taxonomySession.TermStores.Count > 0)
            {
                if (settings != null)
                {
                    // Disable the navigation flag on the the term set
                    var termStore = settings.TermSet.ResolveParentTermStore(taxonomySession);
                    var group     = settings.TermSet.ResolveParentGroup(taxonomySession, web.Site);
                    var termSet   = this.taxonomyService.GetTermSetFromGroup(termStore, group, settings.TermSet.Label);

                    string propertyValue;
                    if (termSet.CustomProperties.TryGetValue(SystemIsNavigationTermSet, out propertyValue))
                    {
                        termSet.DeleteCustomProperty(SystemIsNavigationTermSet);
                        termStore.CommitAll();
                    }
                }

                var navigationSettings = new WebNavigationSettings(web);
                navigationSettings.ResetToDefaults();
                navigationSettings.Update(taxonomySession);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets the web navigation settings.
        /// </summary>
        /// <param name="web">The web.</param>
        /// <param name="settings">The settings.</param>
        public void SetWebNavigationSettings(SPWeb web, ManagedNavigationInfo settings)
        {
            var taxonomySession = new TaxonomySession(web.Site);
            if (taxonomySession.TermStores.Count > 0)
            {
                var termStore = settings.TermSet.ResolveParentTermStore(taxonomySession);
                var group = settings.TermSet.ResolveParentGroup(taxonomySession, web.Site);
                var termSet = this.taxonomyService.GetTermSetFromGroup(termStore, group, settings.TermSet.Label);

                // Flag the term set as a navigation term set
                termSet.SetCustomProperty(SystemIsNavigationTermSet, "True");
                termStore.CommitAll();

                var navigationSettings = new WebNavigationSettings(web);

                navigationSettings.GlobalNavigation.Source = StandardNavigationSource.TaxonomyProvider;
                navigationSettings.GlobalNavigation.TermStoreId = termStore.Id;
                navigationSettings.GlobalNavigation.TermSetId = termSet.Id;

                navigationSettings.CurrentNavigation.Source = StandardNavigationSource.TaxonomyProvider;
                navigationSettings.CurrentNavigation.TermStoreId = termStore.Id;
                navigationSettings.CurrentNavigation.TermSetId = termSet.Id;

                navigationSettings.AddNewPagesToNavigation = settings.AddNewPagesToNavigation;
                navigationSettings.CreateFriendlyUrlsForNewPages = settings.CreateFriendlyUrlsForNewsPages;
                navigationSettings.Update(taxonomySession);

                if (settings.PreserveTaggingOnTermSet)
                {
                    termSet.IsAvailableForTagging = true;
                    termStore.CommitAll();
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Sets the web navigation settings.
        /// </summary>
        /// <param name="web">The web.</param>
        /// <param name="settings">The settings.</param>
        public void SetWebNavigationSettings(SPWeb web, ManagedNavigationInfo settings)
        {
            var taxonomySession = new TaxonomySession(web.Site);

            if (taxonomySession.TermStores.Count > 0)
            {
                // we assume we're always dealing with the site coll's default term store
                var termStore = taxonomySession.DefaultSiteCollectionTermStore;
                var group     = this.taxonomyService.GetTermGroupFromStore(termStore, settings.TermGroup.Name);
                var termSet   = this.taxonomyService.GetTermSetFromGroup(termStore, group, settings.TermSet.Label);

                // Flag the term set as a navigation term set
                termSet.SetCustomProperty("_Sys_Nav_IsNavigationTermSet", "True");
                termSet.TermStore.CommitAll();

                var navigationSettings = new WebNavigationSettings(web);

                navigationSettings.GlobalNavigation.Source      = StandardNavigationSource.TaxonomyProvider;
                navigationSettings.GlobalNavigation.TermStoreId = termStore.Id;
                navigationSettings.GlobalNavigation.TermSetId   = termSet.Id;

                navigationSettings.CurrentNavigation.Source      = StandardNavigationSource.TaxonomyProvider;
                navigationSettings.CurrentNavigation.TermStoreId = termStore.Id;
                navigationSettings.CurrentNavigation.TermSetId   = termSet.Id;

                navigationSettings.AddNewPagesToNavigation       = settings.AddNewPagesToNavigation;
                navigationSettings.CreateFriendlyUrlsForNewPages = settings.CreateFriendlyUrlsForNewsPages;
                navigationSettings.Update(taxonomySession);

                if (settings.PreserveTaggingOnTermSet)
                {
                    termSet.IsAvailableForTagging = true;
                    termSet.TermStore.CommitAll();
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Sets the web navigation settings.
        /// </summary>
        /// <param name="web">The web.</param>
        /// <param name="settings">The settings.</param>
        public void SetWebNavigationSettings(SPWeb web, ManagedNavigationInfo settings)
        {
            var taxonomySession = new TaxonomySession(web.Site);
            if (taxonomySession.TermStores.Count > 0)
            {
                // we assume we're always dealing with the site coll's default term store
                var termStore = taxonomySession.DefaultSiteCollectionTermStore;
                var group = this.taxonomyService.GetTermGroupFromStore(termStore, settings.TermGroup.Name);
                var termSet = this.taxonomyService.GetTermSetFromGroup(termStore, group, settings.TermSet.Label);

                // Flag the term set as a navigation term set
                termSet.SetCustomProperty("_Sys_Nav_IsNavigationTermSet", "True");
                termSet.TermStore.CommitAll();

                var navigationSettings = new WebNavigationSettings(web);

                navigationSettings.GlobalNavigation.Source = StandardNavigationSource.TaxonomyProvider;
                navigationSettings.GlobalNavigation.TermStoreId = termStore.Id;
                navigationSettings.GlobalNavigation.TermSetId = termSet.Id;

                navigationSettings.CurrentNavigation.Source = StandardNavigationSource.TaxonomyProvider;
                navigationSettings.CurrentNavigation.TermStoreId = termStore.Id;
                navigationSettings.CurrentNavigation.TermSetId = termSet.Id;

                navigationSettings.AddNewPagesToNavigation = settings.AddNewPagesToNavigation;
                navigationSettings.CreateFriendlyUrlsForNewPages = settings.CreateFriendlyUrlsForNewsPages;
                navigationSettings.Update(taxonomySession);

                if (settings.PreserveTaggingOnTermSet)
                {
                    termSet.IsAvailableForTagging = true;
                    termSet.TermStore.CommitAll();
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Reset web navigation to its default configuration. Disabled the term set as navigation term set.
        /// </summary>
        /// <param name="web">The web</param>
        /// <param name="settings">The managed navigation settings. Set null if you want to keep the associated termset unchanged</param>
        public void ResetWebNavigationToDefault(SPWeb web, ManagedNavigationInfo settings)
        {
            var taxonomySession = new TaxonomySession(web.Site);
            if (taxonomySession.TermStores.Count > 0)
            {
                if (settings != null)
                {
                    // Disable the navigation flag on the the term set
                    var termStore = taxonomySession.DefaultSiteCollectionTermStore;
                    var group = this.taxonomyService.GetTermGroupFromStore(termStore, settings.TermGroup.Name);
                    var termSet = this.taxonomyService.GetTermSetFromGroup(termStore, group, settings.TermSet.Label);

                    const string PropertyName = "_Sys_Nav_IsNavigationTermSet";
                    string propertyValue;
                    if (termSet.CustomProperties.TryGetValue(PropertyName, out propertyValue))
                    {
                        termSet.DeleteCustomProperty(PropertyName);
                        termSet.TermStore.CommitAll();
                    }
                }

                var navigationSettings = new WebNavigationSettings(web);
                navigationSettings.ResetToDefaults();
                navigationSettings.Update(taxonomySession);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Reset web navigation to its default configuration. Disabled the term set as navigation term set.
        /// </summary>
        /// <param name="web">The web</param>
        /// <param name="settings">The managed navigation settings. Set null if you want to keep the associated termset unchanged</param>
        public void ResetWebNavigationToDefault(SPWeb web, ManagedNavigationInfo settings)
        {
            var taxonomySession = new TaxonomySession(web.Site);
            if (taxonomySession.TermStores.Count > 0)
            {
                if (settings != null)
                {
                    // Disable the navigation flag on the the term set
                    var termStore = settings.TermSet.ResolveParentTermStore(taxonomySession);
                    var group = settings.TermSet.ResolveParentGroup(taxonomySession, web.Site);
                    var termSet = this.taxonomyService.GetTermSetFromGroup(termStore, group, settings.TermSet.Label);

                    string propertyValue;
                    if (termSet.CustomProperties.TryGetValue(SystemIsNavigationTermSet, out propertyValue))
                    {
                        termSet.DeleteCustomProperty(SystemIsNavigationTermSet);
                        termStore.CommitAll();
                    }
                }

                var navigationSettings = new WebNavigationSettings(web);
                navigationSettings.ResetToDefaults();
                navigationSettings.Update(taxonomySession);
            }
        }