private IEnumerable<EditPartFieldViewModel> GetTypeFields(ContentTypeDefinition contentTypeDefinition) { var implicitTypePart = contentTypeDefinition.Parts.SingleOrDefault(p => string.Equals(p.PartDefinition.Name, Name, StringComparison.OrdinalIgnoreCase)); return implicitTypePart == null ? Enumerable.Empty<EditPartFieldViewModel>() : implicitTypePart.PartDefinition.Fields.Select((f, i) => new EditPartFieldViewModel(i, f) { Part = new EditPartViewModel(implicitTypePart.PartDefinition) }); }
public int Create() { try { SchemaBuilder.CreateTable("ProxyPartRecord", table => table .ContentPartRecord() .Column("ServiceUrl", DbType.String) ); var proxy = new ContentTypeDefinition("Proxy", "Proxy"); ContentDefinitionManager.StoreTypeDefinition(proxy); ContentDefinitionManager.AlterTypeDefinition("Proxy", cfg => cfg.Creatable() .WithPart("ProxyPart") .WithPart("CommonPart") .WithPart("TitlePart") .WithPart("IdentityPart") .WithPart("ContentPermissionsPart", builder => builder .WithSetting("ContentPermissionsPartSettings.View", "Administrator") .WithSetting("ContentPermissionsPartSettings.Publish", "Administrator") .WithSetting("ContentPermissionsPartSettings.Edit", "Administrator") .WithSetting("ContentPermissionsPartSettings.Delete", "Administrator") .WithSetting("ContentPermissionsPartSettings.DisplayedRoles", "Administrator,Authenticated") ) ); } catch (Exception e) { var message = string.Format("Error creating Proxy module. {0}", e.Message); Logger.Warning(message); Notifier.Warning(T(message)); return 0; } return 1; }
private string GetLayout(ContentTypeDefinition contentTypeDefinition, ICollection<Section> data) { //check field valid if (contentTypeDefinition.Parts.Any()) { var part = contentTypeDefinition.Parts.First(x => x.PartDefinition.Name == contentTypeDefinition.Name); var partFields = part.PartDefinition.Fields.ToList(); var fields = data.SelectMany(x => x.Rows) .SelectMany(x => x.Columns) .Where(x => x.Field != null) .Select(x => x.Field).ToList(); if (partFields.Any(f => f.Settings.ContainsKey(AlwaysInLayoutKey) && bool.Parse(f.Settings[AlwaysInLayoutKey]) && !fields.Select(x => x.FieldName).Contains(f.Name))) { return string.Empty; } foreach (var field in fields) { if (partFields.Any(x => x.Name == field.FieldName)) { field.IsValid = true; } else if (contentTypeDefinition.Parts.Any(x => x.PartDefinition.Name == field.FieldName)) { field.IsValid = true; } } } ViewDataDictionary viewData = new ViewDataDictionary(); viewData.Add("Layout", data); string layout = _templateViewService .RenderView("Coevery.FormDesigner", "FormTemplate", "FormDesignerLayout", viewData); return layout; }
public EditTypeViewModel(ContentTypeDefinition contentTypeDefinition) { Name = contentTypeDefinition.Name; DisplayName = contentTypeDefinition.DisplayName; Settings = contentTypeDefinition.Settings; TypeDefinition = contentTypeDefinition; }
/// <summary> /// Generates a permission dynamically for a content type /// </summary> public static Permission CreateSubmitPermission(ContentTypeDefinition typeDefinition) { return new Permission { Name = String.Format(SubmitForm.Name, typeDefinition.Name), Description = String.Format(SubmitForm.Description, typeDefinition.DisplayName), Category = "Custom Forms", ImpliedBy = new [] { SubmitForm } }; }
public override IDisplayResult Edit(ContentTypeDefinition contentTypeDefinition) { return Shape<ContentTypeViewModel>("ContentType_Edit", model => { model.DisplayName = contentTypeDefinition.DisplayName; return Task.CompletedTask; }).Location("Content"); }
/// <summary> /// Generates a permission dynamically for a content type /// </summary> public static Permission CreateDynamicPermission(Permission template, ContentTypeDefinition typeDefinition) { return new Permission { Name = String.Format(template.Name, typeDefinition.Name), Description = String.Format(template.Description, typeDefinition.DisplayName), Category = typeDefinition.DisplayName, ImpliedBy = (template.ImpliedBy ?? new Permission[0]).Select(t => CreateDynamicPermission(t, typeDefinition)) }; }
public EditTypeViewModel(ContentTypeDefinition contentTypeDefinition) { Name = contentTypeDefinition.Name; DisplayName = contentTypeDefinition.DisplayName; Settings = contentTypeDefinition.Settings; Fields = GetTypeFields(contentTypeDefinition).ToList(); Parts = GetTypeParts(contentTypeDefinition).ToList(); _Definition = contentTypeDefinition; }
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) { var settings = definition.Settings.GetModel<ContentPermissionsTypeSettings>(); var model = new SecurableContentItemsSettingsViewModel { SecurableContentItems = settings.SecurableContentItems, }; yield return DefinitionTemplate(model); }
public Task BuildTypeEditorAsync(ContentTypeDefinition model, BuildEditorContext context) { return _typeDisplayDrivers.InvokeAsync(async contentDisplay => { var result = await contentDisplay.BuildEditorAsync(model, context); if (result != null) result.Apply(context); }, Logger); }
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) { var settings = definition.Settings.GetModel<DynamicTypeSettings>(); var model = new DynamicTypeSettingsViewModel { IsDeployed = settings.IsDeployed }; yield return DefinitionTemplate(model); }
public XElement Export(ContentTypeDefinition typeDefinition) { var typeElement = NewElement(typeDefinition.Name, typeDefinition.Settings); if (typeElement.Attribute("DisplayName") == null && typeDefinition.DisplayName != null) { typeElement.Add(new XAttribute("DisplayName", typeDefinition.DisplayName)); } foreach(var typePart in typeDefinition.Parts) { typeElement.Add(NewElement(typePart.PartDefinition.Name, typePart.Settings)); } return typeElement; }
public void GivenIHaveAContainableContentType(string name) { var webApp = Binding<WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var cdm = environment.Resolve<IContentDefinitionManager>(); var contentTypeDefinition = new ContentTypeDefinition(name, name); cdm.StoreTypeDefinition(contentTypeDefinition); cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("CommonPart").WithPart("BodyPart").WithPart("RoutePart").WithPart("ContainablePart").Creatable().Draftable()); } }); }
public ContentTypeDefinitionModel(ContentTypeDefinition contentTypeDefinition) { Parts = new List<ContentPartDefinitionModel>(); Settings = new Dictionary<string, string>(contentTypeDefinition.Settings); foreach (var partDefinitionModel in contentTypeDefinition.Parts.Select(partDefinition => new ContentPartDefinitionModel(partDefinition))) { Parts.Add(partDefinitionModel); } Name = contentTypeDefinition.Name; DisplayName = contentTypeDefinition.DisplayName; }
public ContentTypeDefinitionBuilder(ContentTypeDefinition existing) { if (existing == null) { _parts = new List<ContentTypePartDefinition>(); _settings = new SettingsDictionary(); } else { _name = existing.Name; _displayName = existing.DisplayName; _parts = existing.Parts.ToList(); _settings = new SettingsDictionary(existing.Settings.ToDictionary(kv => kv.Key, kv => kv.Value)); } }
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) { var settings = definition.Settings.GetModel<ContentTypeSettings>(); var model = new ContentTypeSettingsViewModel { Creatable = settings.Creatable, Draftable = settings.Draftable, }; if(definition.Settings.ContainsKey("Stereotype")) { model.Stereotype = definition.Settings["Stereotype"] ?? String.Empty; } yield return DefinitionTemplate(model); }
private TreeNode GetContentTypeNode(ContentTypeDefinition definition) { return new TreeNode { Title = definition.DisplayName, Type = "content-type", Id = definition.Name, Url = _url.Action( "List", "Admin", new RouteValueDictionary { {"area", "Contents"}, {"model.Id", definition.Name} }) }; }
/// <summary> /// Exports a content type definition to a XML format. /// </summary> /// <param name="contentTypeDefinition">The type definition to be exported.</param> /// <returns>The content type definition in an XML format.</returns> public XElement Export(ContentTypeDefinition contentTypeDefinition) { Argument.ThrowIfNull(contentTypeDefinition, "typeDefinition"); var typeElement = NewElement(contentTypeDefinition.Name, contentTypeDefinition.Settings); if (typeElement.Attribute("DisplayName") == null && contentTypeDefinition.DisplayName != null) { typeElement.Add(new XAttribute("DisplayName", contentTypeDefinition.DisplayName)); } foreach (var typePart in contentTypeDefinition.Parts.OrderBy(x => x.PartDefinition.Name)) { typeElement.Add(NewElement(typePart.PartDefinition.Name, typePart.Settings)); } return typeElement; }
public ContentTypeDefinitionBuilder(ContentTypeDefinition existing) { Current = existing; if (existing == null) { _parts = new List<ContentTypePartDefinition>(); } else { _name = existing.Name; _parts = existing.Parts.ToList(); } }
public override async Task<IDisplayResult> UpdateAsync(ContentTypeDefinition contentTypeDefinition, UpdateTypeEditorContext context) { var model = new ContentTypeSettingsViewModel(); if (await context.Updater.TryUpdateModelAsync(model, Prefix)) { context.Builder.Creatable(model.Creatable); context.Builder.Listable(model.Listable); context.Builder.Draftable(model.Draftable); context.Builder.Securable(model.Securable); context.Builder.Stereotype(model.Stereotype); } return Edit(contentTypeDefinition, context.Updater); }
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) { var settings = definition.Settings.ToObject<ContentTypeSettings>(); var model = new ContentTypeSettingsViewModel { Creatable = settings.Creatable, Listable = settings.Listable, Draftable = settings.Draftable, Securable = settings.Securable, }; model.Stereotype = definition.Settings.Value<string>("Stereotype") ?? ""; yield return DefinitionTemplate(model); }
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) { var shadowPart = definition.Parts.SingleOrDefault(part => part.PartDefinition.Name == definition.Name); if (shadowPart == null) yield break; if (!shadowPart.PartDefinition.Fields.Any(field => field.FieldDefinition.Name == "TaxonomyField")) { yield break; } var model = definition.Settings.GetModel<AssociativyTaxonomiesAdapterTypeSettings>(); model.AvailableGraphs = _graphManager.FindGraphsByContentTypes(definition.Name); yield return DefinitionTemplate(model); }
public override async Task<IDisplayResult> UpdateAsync(ContentTypeDefinition contentTypeDefinition, UpdateTypeEditorContext context) { var model = new ContentTypeViewModel(); await context.Updater.TryUpdateModelAsync(model, Prefix); context.Builder.DisplayedAs(model.DisplayName); if (String.IsNullOrWhiteSpace(model.DisplayName)) { context.Updater.ModelState.AddModelError("DisplayName", T["The Content Type name can't be empty."]); } return Edit(contentTypeDefinition, context.Updater); }
public override IDisplayResult Edit(ContentTypeDefinition contentTypeDefinition) { return Shape<ContentTypeSettingsViewModel>("ContentTypeSettings_Edit", model => { var settings = contentTypeDefinition.Settings.ToObject<ContentTypeSettings>(); model.Creatable = settings.Creatable; model.Listable = settings.Listable; model.Draftable = settings.Draftable; model.Securable = settings.Securable; model.Stereotype = settings.Stereotype; return Task.CompletedTask; }).Location("Content:5"); }
private static string AddPlacement(ContentTypeDefinition builder, PlacementType placementType, string shapeType, string differentiator, string zone, string position) { var serializer = new JavaScriptSerializer(); var placementSettings = GetPlacement(builder, placementType).ToList(); placementSettings = placementSettings.Where(x => !x.IsSameAs(new PlacementSettings { ShapeType = shapeType, Differentiator = differentiator })).ToList(); placementSettings.Add(new PlacementSettings { ShapeType = shapeType, Differentiator = differentiator, Zone = zone, Position = position }); var placement = serializer.Serialize(placementSettings.ToArray()); return placement; }
public ContentTypeDefinitionBuilder(ContentTypeDefinition existing) { Current = existing; if (existing == null) { _parts = new List<ContentTypePartDefinition>(); _settings = new JObject(); } else { _name = existing.Name; _displayName = existing.DisplayName; _parts = existing.Parts.ToList(); _settings = new JObject(existing.Settings); } }
public void GivenIHaveAContainableContentType(string name) { var webApp = Binding<WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var cdm = environment.Resolve<IContentDefinitionManager>(); var contentTypeDefinition = new ContentTypeDefinition(name, name); cdm.StoreTypeDefinition(contentTypeDefinition); cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("CommonPart").WithPart("BodyPart").WithPart("TitlePart").WithPart("ContainablePart").Creatable().Draftable()); cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("AutoroutePart", builder => builder .WithSetting("AutorouteSettings.AllowCustomPattern", "true") .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false") .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-list'}]") .WithSetting("AutorouteSettings.DefaultPatternIndex", "0") )); } }); }
public ConnectorDescriptor(Orchard.ContentManagement.MetaData.Models.ContentTypeDefinition connectorDefinition, ConnectorTypePartSettings settings = null) { // Store def Definition = connectorDefinition; // Initialize lazies _PartDefinition = new Lazy <ContentTypePartDefinition>(() => { var partDef = Definition.Parts.Where(p => p.PartDefinition.Name == "ConnectorPart").FirstOrDefault(); if (partDef == null) { throw new ArgumentException("Connector definition must have ConnectorPart"); } return(partDef); }); if (settings != null) { _Settings = new Lazy <ConnectorTypePartSettings>(() => settings); } else { _Settings = new Lazy <ConnectorTypePartSettings>(() => PartDefinition.Settings.GetModel <ConnectorTypePartSettings>()); } }
public IEnumerable<ContentPartBindingDescriptor> DescribeBindingsFor(ContentTypeDefinition contentTypeDefinition) { var contexts = DescribeBindingContexts().ToLookup(x => x.ContextName); foreach (var part in contentTypeDefinition.Parts) { var partName = part.PartDefinition.Name; var partBinding = new ContentPartBindingDescriptor() { Part = part, BindingContexts = contexts[partName].ToList() }; foreach (var field in part.PartDefinition.Fields) { var fieldName = field.FieldDefinition.Name; var fieldBinding = new ContentFieldBindingDescriptor { Field = field, BindingContexts = contexts[fieldName].ToList() }; partBinding.FieldBindings.Add(fieldBinding); } yield return partBinding; } }
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) { if (definition.Settings.ContainsKey("Stereotype") && definition.Settings["Stereotype"] == "Media") { var model = definition.Settings.GetModel<MediaFileNameEditorSettings>(); yield return DefinitionTemplate(model); } }
private IEnumerable<EditTypePartViewModel> GetTypeParts(ContentTypeDefinition contentTypeDefinition) { return contentTypeDefinition.Parts .Where(p => !string.Equals(p.PartDefinition.Name, Name, StringComparison.OrdinalIgnoreCase)) .Select((p, i) => new EditTypePartViewModel(i, p) { Type = this }); }