示例#1
0
 public int Create()
 {
     _contentDefinitionManager.AlterPartDefinition("Page", p => p
                                                   .WithDisplayName("Page")
                                                   .WithHtmlField("UnauthorizedHtml", "Unauthorized Html", "Displayed when no redirect is provided and the user is not authorized", "0")
                                                   );
     _contentDefinitionManager.AlterTypeDefinition("Page", type => type
                                                   .DisplayedAs("Page")
                                                   .Creatable()
                                                   .Listable()
                                                   .Draftable()
                                                   .Versionable()
                                                   .Securable()
                                                   .WithPart("LocalizationPart", part => part
                                                             .WithPosition("0")
                                                             )
                                                   .WithPart("TitlePart", part => part
                                                             .WithPosition("1")
                                                             )
                                                   .WithPart("AutoroutePart", part => part
                                                             .WithPosition("2")
                                                             .WithSettings(new AutoroutePartSettings
     {
         AllowCustomPath    = true,
         Pattern            = "{{ ContentItem | display_text | slugify }}",
         ShowHomepageOption = true,
     })
                                                             )
                                                   .WithFlow("3")
                                                   .WithContentPermission("4")
                                                   .WithPart("Page", p => p.WithPosition("5"))
                                                   );
     return(2);
 }
示例#2
0
        public async Task <dynamic> UpdatePartEditorAsync(ContentPartDefinition contentPartDefinition, IUpdateModel updater, string groupId)
        {
            if (contentPartDefinition == null)
            {
                throw new ArgumentNullException(nameof(contentPartDefinition));
            }

            var contentPartDefinitionShape = CreateContentShape("ContentPartDefinition_Edit");

            UpdatePartEditorContext partContext = null;

            _contentDefinitionManager.AlterPartDefinition(contentPartDefinition.Name, partBuilder =>
            {
                partContext = new UpdatePartEditorContext(
                    partBuilder,
                    contentPartDefinitionShape,
                    groupId,
                    _shapeFactory,
                    _layoutAccessor.GetLayout(),
                    updater
                    );
            });

            await BindPlacementAsync(partContext);

            await _handlers.InvokeAsync(handler => handler.UpdatePartEditorAsync(contentPartDefinition, partContext), Logger);

            return(contentPartDefinitionShape);
        }
示例#3
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("FlowPart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a customizable body for your content item where you can build a content structure with widgets."));

            return(1);
        }
示例#4
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("SamplePart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a Sample part for your content item."));

            return(1);
        }
示例#5
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("FlowPart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a customizable body for your content item."));

            return(1);
        }
示例#6
0
        public int UpdateFrom1()
        {
            _contentDefinitionManager.AlterTypeDefinition("WorkMapPhase", item => item
                                                          .Enabled()
                                                          .DisplayedAs("Work Map Phase")
//                 .Draftable(false)
//                 .Creatable(false)
//                 .Listable(false)
//                 .Securable(false)
                                                          .WithPart("WorkMapPhase") //need to add dummy type part for fields to be attached
//                 .WithPart("TitlePart", part => part.WithPosition("0"))
//                 .WithPart("PolicySectionPart", part => part.WithPosition("1"))
//                 .WithPart("MarkdownPart", part => part.WithPosition("2"))
                                                          );

            // Fields can not be attached directly to a Content Type. To add fields to a content type, create a part using the same name as the type and add fields to this part.
            _contentDefinitionManager.AlterPartDefinition("WorkMapPhase", part => part


                                                          .WithField("Title", field => field
                                                                     .OfType("TextField")
                                                                     .WithDisplayName("Title")
                                                                     // .WithSetting("Position", "0")
                                                                     .WithSettings(new ContentPartFieldSettings()
            {
                Position = "0"
            })
                                                                     ));

            _contentDefinitionManager.AlterTypeDefinition("WorkMapStep", item => item
                                                          .Enabled()
                                                          .DisplayedAs("Work Map Step")
//                 .Draftable(false)
//                 .Creatable(false)
//                 .Listable(false)
//                 .Securable(false)
                                                          .WithPart("WorkMapStep") //need to add dummy type part for fields to be attached
//                     .WithPart("TitlePart", part => part.WithPosition("0"))
//                 .WithPart("PolicySectionPart", part => part.WithPosition("1"))
//                 .WithPart("MarkdownPart", part => part.WithPosition("2"))
                                                          );
            // Fields can not be attached directly to a Content Type. To add fields to a content type, create a part using the same name as the type and add fields to this part.
            _contentDefinitionManager.AlterPartDefinition("WorkMapStep", part => part


                                                          .WithField("Title", field => field
                                                                     .OfType("TextField")
                                                                     .WithDisplayName("Title")
                                                                     //.WithSetting("Position", "0")
                                                                     .WithSettings(new ContentPartFieldSettings()
            {
                Position = "0"
            })
                                                                     ));


            return(2);
        }
示例#7
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("MarkdownBodyPart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a Markdown formatted body for your content item."));

            // Return 4 to shortcut the third migration on new content definition schemas.
            return(4);
        }
示例#8
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("SamplePart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a Sample part for your content item.")
                                                          .WithField("MyTextField", field => field
                                                                     .OfType("TextField")
                                                                     .WithDisplayName("My Text Field"))
                                                          );

            return(1);
        }
示例#9
0
        private void VTimeline()
        {
            _contentDefinitionManager.AlterTypeDefinition("VTimeline", type => type
                                                          .DisplayedAs("VTimeline")
                                                          .Stereotype("Widget")
                                                          .WithPart("VTimeline", part => part
                                                                    .WithPosition("0")
                                                                    )
                                                          .WithPart("FlowPart", part => part
                                                                    .WithSettings(new FlowPartSettings
            {
                ContainedContentTypes = new[] { "VTimelineItem" },
            })
                                                                    )
                                                          );

            _contentDefinitionManager.AlterPartDefinition("VTimeline", part => part
                                                          .WithField("Props", field => field
                                                                     .OfType("MultiTextField")
                                                                     .WithDisplayName("Props")
                                                                     .WithEditor("Picker")
                                                                     .WithPosition("0")
                                                                     .WithSettings(new MultiTextFieldSettings
            {
                Options = new MultiTextFieldValueOption[] {
                    new MultiTextFieldValueOption()
                    {
                        Name = "Align Top", Value = "align-top"
                    },
                    new MultiTextFieldValueOption()
                    {
                        Name = "Dark", Value = "dark"
                    },
                    new MultiTextFieldValueOption()
                    {
                        Name = "Dense", Value = "dense"
                    },
                    new MultiTextFieldValueOption()
                    {
                        Name = "Light", Value = "light"
                    },
                    new MultiTextFieldValueOption()
                    {
                        Name = "Reverse", Value = "reverse"
                    }
                },
            })
                                                                     )
                                                          );
        }
示例#10
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("FlowPart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a customizable body for your content item where you can build a content structure with widgets."));

            _contentDefinitionManager.AlterPartDefinition("BagPart", builder => builder
                                                          .Attachable()
                                                          .Reusable()
                                                          .WithDescription("Provides a collection behavior for your content item where you can place other content items."));

            // Shortcut other migration steps on new content definition schemas.
            return(3);
        }
示例#11
0
        public async Task <int> CreateAsync()
        {
            _contentDefinitionManager.AlterPartDefinition("SiteSearch", part => part
                                                          .WithDescription("Adds site search to page.")
                                                          .WithDisplayName("Site Search"));

            await _recipeMigrator.ExecuteAsync("create.recipe.json", this);

            _contentDefinitionManager.AlterPartDefinition("SearchablePart", part => part
                                                          .Attachable()
                                                          .WithDescription("Makes content type included within site search.")
                                                          .WithDisplayName("Searchable"));

            return(1);
        }
示例#12
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition(nameof(EditableContentPart), builder => builder
                                                          .Attachable()
                                                          .WithDisplayName("Editable Content Part")
                                                          .Reusable(false)
                                                          .WithDescription("Turns content type into a content item editable from front end."));

            _contentDefinitionManager.AlterPartDefinition(nameof(CreatableContentPart), builder => builder
                                                          .Attachable()
                                                          .WithDisplayName("Creatable Content Part")
                                                          .Reusable(false)
                                                          .WithDescription("Turns content type into a content item creatable from front end."));
            return(1);
        }
示例#13
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition(nameof(LayoutPart), builder => builder
                                                          .WithDisplayName("Layout Part")
                                                          .Attachable()
                                                          .Reusable()
                                                          .WithDescription("Provides a layout part for your content item."));


            //partpanel part
            _contentDefinitionManager.AlterPartDefinition(nameof(PartPanelPart), builder => builder
                                                          .WithDisplayName("Part Panel Part")
                                                          .Attachable()
                                                          .WithDescription("Provides a Part Panel section for your content item."));

//            _contentDefinitionManager.AlterPartDefinition(nameof(PartPanelPart), part => part
//                .WithField("Part", field => field
//                    .OfType("TextField")
//                    .WithDisplayName("Part")
//                    .WithSetting("Position", "0")
//                    .WithSettings(new ContentPartFieldSettings() {Position = "0"})
//                )
//                .WithField("Hidden", field => field
//                    .OfType("BooleanField")
//                    .WithDisplayName("Hidden")
//                    //  .WithSetting("Position", "1")
//                    .WithSettings(new ContentPartFieldSettings() {Position = "1"})
//                )
//            );


            //part panel WIDGET

            _contentDefinitionManager.AlterTypeDefinition("PartPanel", item => item
                                                          .DisplayedAs("Part Panel")
                                                          .Draftable()
                                                          .Versionable()
                                                          .Enabled()
                                                          .Securable()
                                                          .WithPart("PartPanel") //need to add dummy type part for fields to be attached
                                                          .WithPart(nameof(PartPanelPart), part => part.WithPosition("0"))
                                                                                 // .WithPart("FlowPart", part => part.WithPosition("1"))
                                                          .Stereotype("Widget")
                                                          );


            return(1);
        }
示例#14
0
        public int Create()
        {
            //parts
            _contentDefinitionManager.AlterPartDefinition(nameof(ProjectPart), builder => builder
                                                          .Attachable()
                                                          .WithDisplayName("Project Part")
                                                          .Reusable(false)
                                                          .WithDescription("Turns content type into a Project."));



            //content types
            //binder
            _contentDefinitionManager.AlterTypeDefinition("Project", item => item
                                                          .DisplayedAs("Project")
                                                          .Draftable()
                                                          .Creatable()
                                                          .Listable()
                                                          .Enabled()
                                                          .Securable(false)
                                                          .WithPart("Project")
                                                          .WithPart("TitlePart", part => part.WithPosition("0"))
                                                          .WithPart(nameof(ProjectPart), part => part.WithPosition("1"))

                                                          // .WithPart("ListPart", builder => builder.WithSetting("ContainedContentTypes", new[] { "WorkDocument", "SpreadSheet", "Presentation" }).WithSetting("PageSize", "20"))
                                                          );



            return(1);
        }
示例#15
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("ProfilePart", builder => builder
                                                          .WithDescription("Links content item to user.")
                                                          .WithDefaultPosition("0")
                                                          );

            _contentDefinitionManager.AlterTypeDefinition(Constants.ContentTypeName, type => type
                                                          .WithPart("ProfilePart")
                                                          );

            SchemaBuilder.CreateMapIndexTable(nameof(ProfilePartIndex), table => table
                                              .Column <string>("UserIdentifier", c => c.WithLength(UserIdenityMaxLength))
                                              );

            SchemaBuilder.AlterTable(nameof(ProfilePartIndex), table => table
                                     .CreateIndex("IDX_ProfilePartIndex_UserIdentifier", "UserIdentifier")
                                     );

            /**
             * Note:
             * Caused an issue on initial orchard recipe setup so commented this out
             */

            // await CreateProfilesForExistingUsersAsync();

            return(2);
        }
示例#16
0
        public int Create()
        {
            SchemaBuilder.CreateTable(nameof(Notification), table => table
                                      .Column <int>(nameof(Notification.Id), col => col.PrimaryKey().Identity())
                                      .Column <string>(nameof(Notification.CorrelationId), c => c.WithLength(26))
                                      .Column <string>(nameof(Notification.Event), c => c.WithLength(50))
                                      .Column <int>(nameof(Notification.NotificationType), col => col.WithDefault(0))
                                      .Column <string>(nameof(Notification.Title), c => c.WithLength(100))
                                      .Column <string>(nameof(Notification.Content), c => c.WithLength(250))
                                      .Column <DateTime>(nameof(Notification.CreatedUtc), col => col.NotNull())
                                      .Column <string>(nameof(Notification.FromUserId), c => c.WithLength(50))
                                      .Column <string>(nameof(Notification.ToUserId), c => c.WithLength(50))
                                      .Column <string>(nameof(Notification.GroupId), c => c.WithLength(50))
                                      .Column <bool>(nameof(Notification.IsSeen), col => col.WithDefault(false))
                                      );

            SchemaBuilder.AlterTable(nameof(Notification), table => table
                                     .CreateIndex("IDX_Notification_CorrelationId", "CorrelationId")
                                     );
            SchemaBuilder.AlterTable(nameof(Notification), table => table
                                     .CreateIndex("IDX_Notification_Event", "Event")
                                     );

            SchemaBuilder.AlterTable(nameof(Notification), table => table
                                     .CreateIndex("IDX_Notification_Event_Correlation", "Event", "CorrelationId")
                                     );

            _contentDefinitionManager.AlterPartDefinition(nameof(NotificationPart), builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a notification section for your content item."));

            return(1);
        }
        public int Create()
        {
            // Now you can configure PersonPart. For example you can add content fields (as mentioned earlier) here.
            _contentDefinitionManager.AlterPartDefinition(nameof(PersonPart), part => part
                                                          // Each field has its own configuration. Here you will give a display name for it and add some
                                                          // additional settings like a hint to be displayed in the editor.
                                                          .WithField(nameof(PersonPart.Biography), field => field
                                                                     .OfType(nameof(TextField))
                                                                     .WithDisplayName("Biography")
                                                                     .Hint("Person's biography")
                                                                     .WithSetting("Editor", "TextArea")));

            // We create a new content type. Note that there's only an alter method: this will create the type if it
            // doesn't exist or modify it if it does. Make sure you understand what content types are:
            // http://docs.orchardproject.net/Documentation/Content-types. The content type's name is arbitrary, but
            // choose a meaningful one. Notice that we attach parts by specifying their name. For our own parts we use
            // nameof(): this is not mandatory but serves great if we change the part's name during development.
            _contentDefinitionManager.AlterTypeDefinition("Person", builder => builder
                                                          .Creatable()
                                                          .Listable()
                                                          .WithPart(nameof(PersonPart))
                                                          );

            // This one will create an index table for the PersonPartIndex as explained in the BookMigrations file.
            SchemaBuilder.CreateMapIndexTable(nameof(PersonPartIndex), table => table
                                              .Column <DateTime>(nameof(PersonPartIndex.BirthDateUtc))
                                              .Column <string>(nameof(PersonPartIndex.ContentItemId), c => c.WithLength(26))
                                              );

            return(1);
        }
 public int Create()
 {
     _contentDefinitionManager.AlterPartDefinition("PricePart", builder => builder
                                                   .Attachable()
                                                   .WithDescription("Adds a simple price to a product."));
     return(1);
 }
示例#19
0
        public int Create()
        {
            SchemaBuilder.CreateTable(nameof(ActivityStreamItem), table => table
                                      .Column <int>(nameof(ActivityStreamItem.Id), col => col.PrimaryKey().Identity())
                                      .Column <string>(nameof(ActivityStreamItem.CorrelationId), c => c.WithLength(26))
                                      .Column <DateTime>(nameof(ActivityStreamItem.CreatedUtc), col => col.NotNull())
                                      .Column <string>(nameof(ActivityStreamItem.EventName), c => c.Nullable().WithLength(128))
                                      .Column <string>(nameof(ActivityStreamItem.FullEventName), c => c.WithLength(512))
                                      .Column <string>(nameof(ActivityStreamItem.Category), c => c.WithLength(64))
                                      .Column <string>(nameof(ActivityStreamItem.User), c => c.WithLength(26))
                                      .Column <string>(nameof(ActivityStreamItem.Description), c => c.WithLength(1000))
                                      .Column <string>(nameof(ActivityStreamItem.ActivityStreamData), c => c.WithLength(4000))


                                      );

            SchemaBuilder.AlterTable(nameof(ActivityStreamItem), table => table
                                     .CreateIndex("IDX_ActivityStreamItem_CorrelationId", "CorrelationId")
                                     );

            SchemaBuilder.AlterTable(nameof(ActivityStreamItem), table => table
                                     .CreateIndex("IDX_ActivityStreamItem_User", "User"));

            _contentDefinitionManager.AlterPartDefinition(nameof(ActivityStreamPart), builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides an activity stream section for your content item."));

            return(1);
        }
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("StripePaymentFormPart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides the template needed to display a stripe payment form.")
                                                          .WithField("StripePublishableKey", f => f
                                                                     .OfType("TextField")
                                                                     .WithSettings(new TextFieldSettings()
            {
                Required = true, Hint = "Enter your stripe publishable API key (https://stripe.com/docs/keys)"
            })
                                                                     .WithDisplayName("Stripe Publishable Key")
                                                                     )
                                                          .WithField("StripeSecretKey", f => f
                                                                     .OfType("TextField")
                                                                     .WithSettings(new TextFieldSettings()
            {
                Required = true, Hint = "Enter your stripe secret API key (https://stripe.com/docs/keys)"
            })
                                                                     .WithDisplayName("Stripe Secret Key")
                                                                     )
                                                          );

            _contentDefinitionManager.AlterTypeDefinition("StripePaymentForm", builder => builder
                                                          .Creatable()
                                                          .Listable()
                                                          .WithPart("TitlePart", part => part.WithPosition("1"))
                                                          .WithPart("PaymentPart", part => part.WithPosition("2"))
                                                          .WithPart("StripePaymentFormPart", part => part.WithPosition("3"))
                                                          );

            return(1);
        }
示例#21
0
 public int Create()
 {
     _contentDefinitionManager.AlterPartDefinition("TermContainerPart", builder => builder
                                                   .Attachable()
                                                   .WithDescription("Provides a term container part for your taxonomy terms."));
     return(1);
 }
 public int Create()
 {
     _contentDefinitionManager.AlterPartDefinition("PriceVariantsPart", builder => builder
                                                   .Attachable()
                                                   .WithDescription("A product variants prices based on predefined attributes."));
     return(1);
 }
示例#23
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("AutoroutePart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a custom url for your content item."));

            SchemaBuilder.CreateMapIndexTable <AutoroutePartIndex>(table => table
                                                                   .Column <string>("ContentItemId", c => c.WithLength(26))
                                                                   .Column <string>("ContainedContentItemId", c => c.WithLength(26))
                                                                   .Column <string>("JsonPath", c => c.Unlimited())
                                                                   .Column <string>("Path", col => col.WithLength(AutoroutePart.MaxPathLength))
                                                                   .Column <bool>("Published")
                                                                   .Column <bool>("Latest")
                                                                   );

            SchemaBuilder.AlterTable(nameof(AutoroutePartIndex), table => table
                                     .CreateIndex("IDX_AutoroutePartIndex_ContentItemIds", "ContentItemId", "ContainedContentItemId")
                                     );

            SchemaBuilder.AlterTable(nameof(AutoroutePartIndex), table => table
                                     .CreateIndex("IDX_AutoroutePartIndex_State", "Published", "Latest")
                                     );

            // Return 4 to shortcut the second migration on new content definition schemas.
            return(4);
        }
示例#24
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition("SeoMetaPart", builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a part that allows SEO meta descriptions to be applied to a content item.")
                                                          .WithField("DefaultSocialImage", field => field
                                                                     .OfType("MediaField")
                                                                     .WithDisplayName("Default social image")
                                                                     .WithSettings(new MediaFieldSettings {
                Multiple = false
            }))
                                                          .WithField("OpenGraphImage", field => field
                                                                     .OfType("MediaField")
                                                                     .WithDisplayName("Open graph image")
                                                                     .WithSettings(new MediaFieldSettings {
                Multiple = false
            }))
                                                          .WithField("TwitterImage", field => field
                                                                     .OfType("MediaField")
                                                                     .WithDisplayName("Twitter image")
                                                                     .WithSettings(new MediaFieldSettings {
                Multiple = false
            }))
                                                          );

            return(1);
        }
示例#25
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition(nameof(ProfileGroupOwnershipPart), builder => builder
                                                          .Attachable()
                                                          .WithDisplayName("Profile Group Ownership")
                                                          .WithDescription("Add ability to assign ownership to a Profile Group, optionally restricting access.")
                                                          .WithField(GroupOwnershipConstants.GroupFieldName, field => field
                                                                     .OfType(nameof(ProfileGroupField))
                                                                     .WithDisplayName("Owned by group")
                                                                     .WithDescription("Specifies which group owns the current content")
                                                                     .WithSettings(new ProfileGroupFieldSettings
            {
                Hint = "Which group owns this content."
            })
                                                                     ));

            SchemaBuilder.CreateMapIndexTable(nameof(GroupOwnershipIndex), table => table
                                              .Column <string>(nameof(GroupOwnershipIndex.GroupContentItemId), c => c.WithLength(26))
                                              );

            SchemaBuilder.AlterTable(nameof(GroupOwnershipIndex), table => table
                                     .CreateIndex($"IDX_{nameof(GroupOwnershipIndex)}_{nameof(GroupOwnershipIndex.GroupContentItemId)}", nameof(GroupOwnershipIndex.GroupContentItemId))
                                     );

            return(1);
        }
示例#26
0
 public static void CreateBasicWidget(this IContentDefinitionManager manager, string name)
 {
     manager.AlterPartDefinition(name, p => p.WithDisplayName(name));
     manager.AlterTypeDefinition(name, t => t.Stereotype("Widget")
                                 .WithPart(name, p => p.WithPosition("0"))
                                 );
 }
示例#27
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition(nameof(AliasPart), builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a way to define custom aliases for content items."));

            // NOTE: The Alias Length has been upgraded from 64 characters to 767.
            // For existing SQL databases update the AliasPartIndex tables Alias column length manually.
            // INFO: The Alias Length is now of 740 chars, but this is only used on a new installation.
            SchemaBuilder.CreateMapIndexTable <AliasPartIndex>(table => table
                                                               .Column <string>("Alias", col => col.WithLength(AliasPart.MaxAliasLength))
                                                               .Column <string>("ContentItemId", c => c.WithLength(26))
                                                               .Column <bool>("Latest", c => c.WithDefault(false))
                                                               .Column <bool>("Published", c => c.WithDefault(true))
                                                               );

            SchemaBuilder.AlterIndexTable <AliasPartIndex>(table => table
                                                           .CreateIndex("IDX_AliasPartIndex_DocumentId",
                                                                        "DocumentId",
                                                                        "Alias",
                                                                        "ContentItemId",
                                                                        "Published",
                                                                        "Latest")
                                                           );

            // Shortcut other migration steps on new content definition schemas.
            return(4);
        }
示例#28
0
        public int Create()
        {
            _contentDefinitionManager.AlterPartDefinition(nameof(LocalizationPart), builder => builder
                                                          .Attachable()
                                                          .WithDescription("Provides a way to create localized version of content."));

            SchemaBuilder.CreateMapIndexTable <LocalizedContentItemIndex>(table => table
                                                                          .Column <string>("LocalizationSet", col => col.WithLength(26))
                                                                          .Column <string>("Culture", col => col.WithLength(16))
                                                                          .Column <string>("ContentItemId", c => c.WithLength(26))
                                                                          .Column <bool>("Published")
                                                                          .Column <bool>("Latest")
                                                                          );

            SchemaBuilder.AlterIndexTable <LocalizedContentItemIndex>(table => table
                                                                      .CreateIndex("IDX_LocalizationPartIndex_DocumentId",
                                                                                   "DocumentId",
                                                                                   "LocalizationSet",
                                                                                   "Culture",
                                                                                   "ContentItemId",
                                                                                   "Published",
                                                                                   "Latest")
                                                                      );

            // Shortcut other migration steps on new content definition schemas.
            return(3);
        }
示例#29
0
        public async Task <int> CreateAsync()
        {
            _contentDefinitionManager.AlterPartDefinition(nameof(LeverPostingPart), part => part
                                                          .WithDescription("Create a Lever posting content.")
                                                          .WithDisplayName(Constants.Lever.DisplayName));

            _contentDefinitionManager.AlterTypeDefinition(Constants.Lever.ContentType, type => type
                                                          .Draftable()
                                                          .Versionable()
                                                          .Listable()
                                                          .Creatable()
                                                          .Securable()
                                                          .WithPart(nameof(TitlePart))
                                                          .WithPart("AutoroutePart", part => part.WithSettings(new AutoroutePartSettings
            {
                AllowCustomPath = true,
                Pattern         = "{{ Model.ContentItem | display_text | slugify }}"
            }))
                                                          .WithPart(nameof(LeverPostingPart))
                                                          .DisplayedAs(Constants.Lever.DisplayName));

            SchemaBuilder.CreateMapIndexTable <LeverPostingPartIndex>(table => table
                                                                      .Column <string>("LeverId")
                                                                      );

            SchemaBuilder.AlterTable(nameof(LeverPostingPartIndex), table => table
                                     .CreateIndex("IDX_LeverPostingPartIndex_LeverId", "LeverId")
                                     );

            await _recipeMigrator.ExecuteAsync("create.recipe.json", this);

            return(1);
        }
示例#30
0
        public int Create()
        {
            //content types
            _contentDefinitionManager.AlterTypeDefinition("MessageRoom", item => item
                                                          .DisplayedAs("Message Room")
                                                          .Draftable()
                                                          .Creatable()
                                                          .Listable()
                                                          .Enabled()
                                                          .Securable()
                                                          .WithPart("MessageRoom") //need to add dummy type part for fields to be attached
                                                          .WithPart("TitlePart", part => part.WithPosition("0"))
                                                          .WithPart("AutoroutePart", part => part.WithPosition("1"))
                                                          .WithPart("CommentPart", part => part.WithPosition("2"))
                                                          // .WithPart("CommonPart", part => part.WithPosition("3").WithSettings(new CommonPartSettings{DisplayDateEditor = true,DisplayOwnerEditor = true}))
                                                          );

            // Fields can not be attached directly to a Content Type. To add fields to a content type, create a part using the same name as the type and add fields to this part.
            _contentDefinitionManager.AlterPartDefinition("MessageRoom", part => part
                                                          .WithField("Members", field => field
                                                                     .OfType(nameof(ContentPickerField))
                                                                     .WithDisplayName("Members")
                                                                     .WithSettings(new ContentPartFieldSettings()
            {
                Position = "0", DisplayName = "Members"
            })
                                                                     .WithSettings(new ContentPickerFieldSettings()
            {
                Multiple = true, Hint = "Select members for the room", DisplayedContentTypes = new[] { "Party" }
            })
                                                                     ));

            return(1);
        }
示例#31
0
        public TaxonomyPartHandler(
            IRepository<TaxonomyPartRecord> repository, 
            ITaxonomyService taxonomyService,
            IContentDefinitionManager contentDefinitionManager)
        {
            string previousName = null;

            Filters.Add(StorageFilter.For(repository));
            OnPublished<TaxonomyPart>((context, part) => {
                var previousTermTypeName = part.TermTypeName;

                if (previousName == null || part.Name == previousName) {
                    // is it a new taxonomy ?
                    taxonomyService.CreateTermContentType(part);
                }
                else {
                    // keep the previous term type name as it would otherwise force us
                    // to update all terms to use another type
                    part.TermTypeName = previousTermTypeName;

                    // update existing fields
                    foreach (var partDefinition in contentDefinitionManager.ListPartDefinitions()) {
                        foreach (var field in partDefinition.Fields) {
                            if (field.FieldDefinition.Name == typeof (TaxonomyField).Name) {

                                if (field.Settings.GetModel<TaxonomyFieldSettings>().Taxonomy == previousName) {
                                    contentDefinitionManager.AlterPartDefinition(partDefinition.Name,
                                        cfg => cfg.WithField(field.Name,
                                            builder => builder.WithSetting("TaxonomyFieldSettings.Taxonomy", part.Name)));
                                }
                            }
                        }
                    }
                }
            });

            OnLoading<TaxonomyPart>( (context, part) => part.TermsField.Loader(x => taxonomyService.GetTerms(part.Id)));

            OnUpdating<TitlePart>((context, part) => {
                // if altering the title of a taxonomy, save the name
                if (part.As<TaxonomyPart>() != null) {
                    previousName = part.Title;
                }
            });
        }
示例#32
0
        public OptionSetPartHandler(
            IRepository<OptionSetPartRecord> repository, 
            IOptionSetService optionSetService,
            IContentDefinitionManager contentDefinitionManager) {

            int? previousId = null;

            Filters.Add(StorageFilter.For(repository));
            OnPublished<OptionSetPart>((context, part) => {
                var previousTermTypeName = part.TermTypeName;

                if (previousId != null && part.Id != previousId) {

                    // remove previous term type
                    contentDefinitionManager.DeleteTypeDefinition(previousTermTypeName);

                    // update existing fields
                    foreach (var partDefinition in contentDefinitionManager.ListPartDefinitions()) {
                        foreach (var field in partDefinition.Fields) {
                            if (field.FieldDefinition.Name == typeof (OptionSetField).Name) {

                                if (field.Settings.GetModel<OptionSetFieldSettings>().OptionSetId == previousId) {
                                    contentDefinitionManager.AlterPartDefinition(partDefinition.Name, 
                                        cfg => cfg.WithField(field.Name,
                                            builder => builder.WithSetting("TaxonomyFieldSettings.TaxonomyId", part.Id.ToString())));
                                }
                            }
                        }
                    }
                }
            });

            OnLoading<OptionSetPart>((context, part) => part.OptionItemsField.Loader(x => optionSetService.GetOptionItems(part.Id)));

            OnUpdating<TitlePart>((context, part) => {
                // if altering the title of a taxonomy, save the name
                if (part.As<OptionSetPart>() != null) {
                    previousId = part.Id;
                }
            });
        }