예제 #1
0
        public int UpdateFrom1()
        {
            ContentDefinitionManager.AlterTypeDefinition("MenuRootToSite", cfg => cfg
                                                         .WithPart("ConnectorPart", part => part
                                                                   .WithSetting("ConnectorTypePartSettings.AllowedContentLeft", "Page")
                                                                   )
                                                         .WithPart("SequencePart", part => part
                                                                   .WithSetting("SequenceTypePartSettings.EnablePaging", "false"))
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("SiteToMenuRoot", cfg => cfg
                                                         .WithPart("ConnectorPart", part => part
                                                                   .WithSetting("ConnectorTypePartSettings.AllowedContentRight", "Page")
                                                                   )
                                                         );
            ContentDefinitionManager.AlterTypeDefinition("MenuChild", cfg => cfg
                                                         .WithPart("ConnectorPart", part => part
                                                                   .WithSetting("ConnectorTypePartSettings.AllowedContentLeft", "Page")
                                                                   .WithSetting("ConnectorTypePartSettings.AllowedContentRight", "Page")
                                                                   ));

            ContentDefinitionManager.AlterTypeDefinition("MenuParent", cfg => cfg
                                                         .WithPart("ConnectorPart",
                                                                   part => part
                                                                   .WithSetting("ConnectorTypePartSettings.AllowedContentLeft", "Page")
                                                                   .WithSetting("ConnectorTypePartSettings.AllowedContentRight", "Page")
                                                                   ));
            if (ContentDefinitionManager.ListTypeDefinitions().Any(d => d.Name == "MenuRoot"))
            {
                ContentDefinitionManager.AlterTypeDefinition("MenuRoot", cfg => cfg.Creatable(false));
            }
            return(2);
        }
        /// <summary>
        /// This update is required by the fact we added the setting to choose which Parts and Fields
        /// should be diplayed or edited on the front-end.
        /// </summary>
        public int UpdateFrom1()
        {
            ContentDefinitionManager.AlterPartDefinition("ProfilePart", builder => builder
                                                         .Attachable(false));

            //All ContentTypes that contain a ProfilePart are affected by the changes
            var typeDefinitions = ContentDefinitionManager
                                  .ListTypeDefinitions()
                                  .Where(ctd => ctd.Parts.Any(ctpd => ctpd.PartDefinition.Name == "ProfilePart"));

            //By default, every part and field will be configured to not show on front-end, both
            //for Display and Edit. This is a break with what was in place before, when everything
            //sould be shown in front-end. However, this is also safer.
            //We will only go and change the setting for those ContentParts that we know must be
            //available on the front-end.
            //For each type we will only run those providers that are defined to handle settings
            //for a ContentPart that is actually in the type's definition
            foreach (var typeDefinition in typeDefinitions)
            {
                foreach (var provider in _frontEndSettingsProviders
                         .Where(provider => {
                    return(typeDefinition
                           .Parts
                           .Select(ctpd => ctpd.PartDefinition.Name)
                           .Any(name => provider.ForParts().Contains(name)));
                }))
                {
                    provider.ConfigureDefaultValues(typeDefinition);
                }
            }

            return(2);
        }
예제 #3
0
 private IEnumerable <ContentTypeDefinition> GetCreatableTypes(bool andContainable)
 {
     return(ContentDefinitionManager.ListTypeDefinitions().Where(ctd =>
                                                                 TomeltServices.Authorizer.Authorize(ArticleManagePermissions.EditContent, TomeltServices.ContentManager.New(ctd.Name)) &&
                                                                 ctd.Name == ContentTypeName &&
                                                                 ctd.Settings.GetModel <ContentTypeSettings>().Creatable&&
                                                                 (!andContainable || ctd.Parts.Any(p => p.PartDefinition.Name == "ContainablePart"))));
 }
        public int Create()
        {
            var mediaContentTypes = ContentDefinitionManager.ListTypeDefinitions().Where(x => x.Settings.ContainsKey("Stereotype") && x.Settings["Stereotype"].Equals("Media", System.StringComparison.InvariantCultureIgnoreCase));

            // adds LocalizationPart to all "Media" stereotypes
            foreach (var mediaCT in mediaContentTypes)
            {
                ContentDefinitionManager.AlterTypeDefinition(mediaCT.Name, td => td
                                                             .WithPart("LocalizationPart"));
            }
            return(1);
        }
예제 #5
0
파일: Migrations.cs 프로젝트: itc20/orchard
        public int UpdateFrom4()
        {
            // Adding some culture neutral patterns if they don't exist
            var autoroutePartDefinitions = ContentDefinitionManager.ListTypeDefinitions()
                                           .Where(t => t.Parts.Any(p => p.PartDefinition.Name.Equals(typeof(AutoroutePart).Name)))
                                           .Select(s => new { contentTypeName = s.Name, autoroutePart = s.Parts.First(x => x.PartDefinition.Name == "AutoroutePart") });

            foreach (var partDefinition in autoroutePartDefinitions)
            {
                var settingsDictionary = partDefinition.autoroutePart.Settings;
                var settings           = settingsDictionary.GetModel <AutorouteSettings>();

                if (!settings.Patterns.Any(x => String.IsNullOrWhiteSpace(x.Culture)))
                {
                    string        siteCulture = _cultureManager.GetSiteCulture();
                    List <string> newPatterns = new List <string>();

                    if (settings.Patterns.Any(x => String.Equals(x.Culture, siteCulture, StringComparison.OrdinalIgnoreCase)))
                    {
                        var siteCulturePatterns = settings.Patterns.Where(x => String.Equals(x.Culture, siteCulture, StringComparison.OrdinalIgnoreCase)).ToList();

                        foreach (RoutePattern pattern in siteCulturePatterns)
                        {
                            newPatterns.Add(String.Format("{{\"Name\":\"{0}\",\"Pattern\":\"{1}\",\"Description\":\"{2}\"}}", pattern.Name, pattern.Pattern, pattern.Description));
                        }
                    }
                    else
                    {
                        newPatterns.Add(String.Format("{{\"Name\":\"{0}\",\"Pattern\":\"{1}\",\"Description\":\"{2}\"}}", "Title", "{Content.Slug}", "my-title"));
                    }

                    if (settingsDictionary.ContainsKey("AutorouteSettings.PatternDefinitions"))
                    {
                        string oldPatterns = settingsDictionary["AutorouteSettings.PatternDefinitions"];
                        if (oldPatterns.StartsWith("[") && oldPatterns.EndsWith("]"))
                        {
                            newPatterns.Add(oldPatterns.Substring(1, oldPatterns.Length - 2));
                        }
                    }

                    ContentDefinitionManager.AlterTypeDefinition(partDefinition.contentTypeName, cfg => cfg
                                                                 .WithPart("AutoroutePart", builder => builder
                                                                           .WithSetting("AutorouteSettings.PatternDefinitions", "[" + String.Join(",", newPatterns) + "]")
                                                                           ));
                }
            }

            return(5);
        }
        public int Create()
        {
            ContentDefinitionManager.AlterPartDefinition("SecureMediaPart", p =>
                                                         p.WithDescription("Used with the Secure Media feature to store the secure status of the attached item")
                                                         );

            var mediaTypes = ContentDefinitionManager.ListTypeDefinitions().Where(x => x.Settings.ContainsKey("Stereotype") && "Media".Equals(x.Settings["Stereotype"], System.StringComparison.OrdinalIgnoreCase));

            foreach (var mediaType in mediaTypes)
            {
                if ((mediaType.DisplayName?.Contains("External") ?? false) || (mediaType.Name?.Contains("External") ?? false))
                {
                    continue;
                }
                ContentDefinitionManager.AlterTypeDefinition(mediaType.Name, t =>
                                                             t.WithPart("SecureMediaPart")
                                                             );
            }

            return(1);
        }