/// <summary> /// Initializes a new instance of the <see cref="ProductOptionApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="contentTypeService"> /// Umbraco's <see cref="IContentTypeService"/> /// </param> public ProductOptionApiController(IMerchelloContext merchelloContext, IContentTypeService contentTypeService) : base(merchelloContext) { Mandate.ParameterNotNull(contentTypeService, "contentTypeService"); _contentTypeService = contentTypeService; _productOptionService = merchelloContext.Services.ProductOptionService; }
/// <summary> /// public ctor - will generally just be used for unit testing /// </summary> /// <param name="contentService"></param> /// <param name="mediaService"></param> /// <param name="contentTypeService"></param> /// <param name="dataTypeService"></param> /// <param name="fileService"></param> /// <param name="localizationService"></param> /// <param name="packagingService"></param> /// <param name="entityService"></param> /// <param name="relationService"></param> /// <param name="sectionService"></param> /// <param name="treeService"></param> /// <param name="tagService"></param> public ServiceContext( IContentService contentService, IMediaService mediaService, IContentTypeService contentTypeService, IDataTypeService dataTypeService, IFileService fileService, ILocalizationService localizationService, PackagingService packagingService, IEntityService entityService, IRelationService relationService, ISectionService sectionService, IApplicationTreeService treeService, ITagService tagService) { _tagService = new Lazy<ITagService>(() => tagService); _contentService = new Lazy<IContentService>(() => contentService); _mediaService = new Lazy<IMediaService>(() => mediaService); _contentTypeService = new Lazy<IContentTypeService>(() => contentTypeService); _dataTypeService = new Lazy<IDataTypeService>(() => dataTypeService); _fileService = new Lazy<IFileService>(() => fileService); _localizationService = new Lazy<ILocalizationService>(() => localizationService); _packagingService = new Lazy<PackagingService>(() => packagingService); _entityService = new Lazy<IEntityService>(() => entityService); _relationService = new Lazy<IRelationService>(() => relationService); _sectionService = new Lazy<ISectionService>(() => sectionService); _treeService = new Lazy<IApplicationTreeService>(() => treeService); }
public RelationsController() { relationService = ApplicationContext.Services.RelationService; contentService = ApplicationContext.Services.ContentService; mediaService = ApplicationContext.Services.MediaService; contentTypeService = ApplicationContext.Services.ContentTypeService; entityService = ApplicationContext.Services.EntityService; }
public ChangeAliasDeliverable( TextWriter writer, TextReader reader, IContentTypeService contentTypeService ) : base(reader, writer) { this.contentTypeService = contentTypeService; }
/// <summary> /// Initializes a new instance of the <see cref="DetachedContentApiController"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <param name="umbracoContext"> /// The <see cref="UmbracoContext"/>. /// </param> public DetachedContentApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext) : base(merchelloContext, umbracoContext) { if (ApplicationContext == null) throw new NotFiniteNumberException("Umbraco ApplicationContext is null"); _contentTypeService = ApplicationContext.Services.ContentTypeService; _detachedContentTypeService = ((ServiceContext)merchelloContext.Services).DetachedContentTypeService; this.Initialize(); }
/// <summary> /// public ctor - will generally just be used for unit testing /// </summary> /// <param name="contentService"></param> /// <param name="mediaService"></param> /// <param name="contentTypeService"></param> /// <param name="dataTypeService"></param> /// <param name="fileService"></param> /// <param name="localizationService"></param> /// <param name="packagingService"></param> /// <param name="entityService"></param> /// <param name="relationService"></param> public ServiceContext(IContentService contentService, IMediaService mediaService, IContentTypeService contentTypeService, IDataTypeService dataTypeService, IFileService fileService, ILocalizationService localizationService, PackagingService packagingService, IEntityService entityService, RelationService relationService) { _contentService = new Lazy<IContentService>(() => contentService); _mediaService = new Lazy<IMediaService>(() => mediaService); _contentTypeService = new Lazy<IContentTypeService>(() => contentTypeService); _dataTypeService = new Lazy<IDataTypeService>(() => dataTypeService); _fileService = new Lazy<IFileService>(() => fileService); _localizationService = new Lazy<ILocalizationService>(() => localizationService); _packagingService = new Lazy<PackagingService>(() => packagingService); _entityService = new Lazy<IEntityService>(() => entityService); _relationService = new Lazy<RelationService>(() => relationService); }
/// <summary> /// This method is called when the Content Type declared in the attribute hasn't been found in Umbraco /// </summary> /// <param name="contentTypeService"></param> /// <param name="fileService"></param> /// <param name="attribute"></param> /// <param name="type"></param> /// <param name="dataTypeService"></param> private static void CreateContentType(IContentTypeService contentTypeService, IFileService fileService, UmbracoContentTypeAttribute attribute, Type type, IDataTypeService dataTypeService) { IContentType newContentType; Type parentType = type.BaseType; if (parentType != null && parentType != typeof(UmbracoGeneratedBase) && parentType.GetBaseTypes(false).Any(x => x == typeof(UmbracoGeneratedBase))) { UmbracoContentTypeAttribute parentAttribute = parentType.GetCustomAttribute<UmbracoContentTypeAttribute>(); if (parentAttribute != null) { string parentAlias = parentAttribute.ContentTypeAlias; IContentType parentContentType = contentTypeService.GetContentType(parentAlias); newContentType = new ContentType(parentContentType); } else { throw new Exception("The given base class has no UmbracoContentTypeAttribute"); } } else { newContentType = new ContentType(-1); } newContentType.Name = attribute.ContentTypeName; newContentType.Alias = attribute.ContentTypeAlias; newContentType.Icon = attribute.Icon; newContentType.Description = attribute.Description; if (attribute.CreateMatchingView) { SetDefaultTemplateAndCreateIfNotExists(fileService, attribute.MasterTemplate, attribute.TemplateLocation, type, newContentType); } CreateAdditionalTemplates(newContentType, type, fileService, attribute.MasterTemplate, attribute.TemplateLocation); newContentType.AllowedAsRoot = attribute.AllowedAtRoot; newContentType.IsContainer = attribute.EnableListView; newContentType.AllowedContentTypes = FetchAllowedContentTypes(attribute.AllowedChildren, contentTypeService); //create tabs CreateTabs(newContentType, type, dataTypeService); //create properties on the generic tab var propertiesOfRoot = type.GetProperties().Where(x => x.GetCustomAttribute<UmbracoPropertyAttribute>() != null); foreach (var item in propertiesOfRoot) { CreateProperty(newContentType, null, dataTypeService, true, item); } //Save and persist the content Type contentTypeService.Save(newContentType, 0); }
public PackagingService(IContentService contentService, IContentTypeService contentTypeService, IMediaService mediaService, IDataTypeService dataTypeService, IFileService fileService, RepositoryFactory repositoryFactory, IDatabaseUnitOfWorkProvider uowProvider) { _contentService = contentService; _contentTypeService = contentTypeService; _mediaService = mediaService; _dataTypeService = dataTypeService; _fileService = fileService; _repositoryFactory = repositoryFactory; _uowProvider = uowProvider; _importedContentTypes = new Dictionary<string, IContentType>(); }
public PackageDeliverable( TextReader reader, TextWriter writer, IFileSystem fileSystem, IChauffeurSettings settings, IPackagingService packagingService, IContentTypeService contentTypeService) : base(reader, writer) { this.fileSystem = fileSystem; this.settings = settings; this.packagingService = packagingService; this.contentTypeService = contentTypeService; }
/// <summary> /// Initializes a new instance of the <see cref="DetachedValuesConverter"/> class. /// </summary> /// <param name="applicationContext"> /// The <see cref="ApplicationContext"/>. /// </param> /// <param name="values"> /// The resolved DefaultValueCorrection types. /// </param> internal DetachedValuesConverter(ApplicationContext applicationContext, IEnumerable<Type> values) { if (applicationContext != null) { _contentTypeService = applicationContext.Services.ContentTypeService; _dataTypeService = applicationContext.Services.DataTypeService; _ready = true; } else { _ready = false; } // Instantiate the corrector _corrector = new DetachedValueCorrector(values); }
public ContentTypeDeliverable( TextReader reader, TextWriter writer, IContentTypeService contentTypeService, IDatabaseUnitOfWorkProvider uowProvider, IPackagingService packagingService, IFileSystem fileSystem, IChauffeurSettings settings ) : base(reader, writer) { this.contentTypeService = contentTypeService; this.uowProvider = uowProvider; this.packagingService = packagingService; this.fileSystem = fileSystem; this.settings = settings; }
/// <summary> /// Private method to create new content /// </summary> /// <param name="contentService"></param> /// <param name="contentTypeService"></param> private static void CreateNewContent(IContentService contentService, IContentTypeService contentTypeService) { //We find all ContentTypes so we can show a nice list of everything that is available var contentTypes = contentTypeService.GetAllContentTypes(); var contentTypeAliases = string.Join(", ", contentTypes.Select(x => x.Alias)); Console.WriteLine("Please enter the Alias of the ContentType ({0}):", contentTypeAliases); var contentTypeAlias = Console.ReadLine(); Console.WriteLine("Please enter the Id of the Parent:"); var strParentId = Console.ReadLine(); int parentId; if (int.TryParse(strParentId, out parentId) == false) parentId = -1;//Default to -1 which is the root Console.WriteLine("Please enter the name of the Content to create:"); var name = Console.ReadLine(); //Create the Content var content = contentService.CreateContent(name, parentId, contentTypeAlias); foreach (var property in content.Properties) { Console.WriteLine("Please enter the value for the Property with Alias '{0}':", property.Alias); var value = Console.ReadLine(); var isValid = property.IsValid(value); if (isValid) { property.Value = value; } else { Console.WriteLine("The entered value was not valid and thus not saved"); } } //Save the Content contentService.Save(content); Console.WriteLine("Content was saved: " + content.HasIdentity); }
public void GenerateModelAndDependants(IContentTypeService service, IContentTypeComposition umbracoContentType) { var contentType = ContentTypeMapping.Map(umbracoContentType); var allContentTypes = service.GetAllContentTypes().ToList(); GenerateDependencies(umbracoContentType, allContentTypes); var composedOfThis = GetDependants(umbracoContentType, allContentTypes); var isMixin = composedOfThis.Any(); if (isMixin) { contentType.IsMixin = true; } GenerateClass(contentType); if (isMixin) { GenerateInterface(contentType); GenerateDependants(composedOfThis); } }
static ContentTypeSyncProvider() { _packService = ApplicationContext.Current.Services.PackagingService; _contentTypeService = ApplicationContext.Current.Services.ContentTypeService; }
static void ContentTypeService_SavedMediaType(IContentTypeService sender, Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IMediaType> e) { helpers.uSyncLog.DebugLog("SaveContent Type Fired for {0} types", e.SavedEntities.Count()); foreach (var mediaType in e.SavedEntities) { SaveToDisk(new MediaType(mediaType.Id)); } }
internal static IContent GetOrCreateContent(IContentType contentType, string contentName, IContentTypeService contentTypeService, IContentService contentService, IContent parentContent, List<IContent> contentList) { var content = contentService.GetContentOfContentType(contentType.Id).FirstOrDefault(x => !x.Trashed); if (content == null) { if (parentContent == null) { content = contentService.CreateContent(contentName, -1, contentType.Alias); } else { content = contentService.CreateContent(contentName, parentContent, contentType.Alias); } contentList.Add(content); } return content; }
public uSyncContentTypes() { _contentTypeService = ApplicationContext.Current.Services.ContentTypeService; }
/// <summary> /// Fires when a content type is saved /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void ContentTypeServiceSavedContentType(IContentTypeService sender, Core.Events.SaveEventArgs <IContentType> e) { e.SavedEntities.ForEach(contentType => DistributedCache.Instance.RefreshContentTypeCache(contentType)); }
public UmbracoDocumentTypeInstaller(IContentService contentService, IContentTypeService contentTypeService) { _contentService = contentService; _contentTypeService = contentTypeService; }
/// <summary> /// Creates a partial service context with only some services (for tests). /// </summary> /// <remarks> /// <para>Using a true constructor for this confuses DI containers.</para> /// </remarks> public static ServiceContext CreatePartial( IContentService contentService = null, IMediaService mediaService = null, IContentTypeService contentTypeService = null, IMediaTypeService mediaTypeService = null, IDataTypeService dataTypeService = null, IFileService fileService = null, ILocalizationService localizationService = null, IPackagingService packagingService = null, IEntityService entityService = null, IRelationService relationService = null, IMemberGroupService memberGroupService = null, IMemberTypeService memberTypeService = null, IMemberService memberService = null, IUserService userService = null, ITagService tagService = null, INotificationService notificationService = null, ILocalizedTextService localizedTextService = null, IAuditService auditService = null, IDomainService domainService = null, IMacroService macroService = null, IPublicAccessService publicAccessService = null, IExternalLoginService externalLoginService = null, IServerRegistrationService serverRegistrationService = null, IRedirectUrlService redirectUrlService = null, IConsentService consentService = null, IKeyValueService keyValueService = null, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider = null) { Lazy <T> Lazy <T>(T service) => service == null ? null : new Lazy <T>(() => service); return(new ServiceContext( Lazy(publicAccessService), Lazy(domainService), Lazy(auditService), Lazy(localizedTextService), Lazy(tagService), Lazy(contentService), Lazy(userService), Lazy(memberService), Lazy(mediaService), Lazy(contentTypeService), Lazy(mediaTypeService), Lazy(dataTypeService), Lazy(fileService), Lazy(localizationService), Lazy(packagingService), Lazy(serverRegistrationService), Lazy(entityService), Lazy(relationService), Lazy(macroService), Lazy(memberTypeService), Lazy(memberGroupService), Lazy(notificationService), Lazy(externalLoginService), Lazy(redirectUrlService), Lazy(consentService), Lazy(keyValueService), Lazy(contentTypeBaseServiceProvider) )); }
public ContentTypeTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, UmbracoTreeSearcher treeSearcher, IMenuItemCollectionFactory menuItemCollectionFactory, IContentTypeService contentTypeService, IEntityService entityService, IEventAggregator eventAggregator) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator) { _treeSearcher = treeSearcher; _menuItemCollectionFactory = menuItemCollectionFactory; _contentTypeService = contentTypeService; _entityService = entityService; }
public ContentCdnService(IEnumerable <ICdnApi> cdnApis, IConfigService configService, IContentTypeService contentTypeService, IUmbracoContextFactory umbracoContextFactory) { _cdnApis = cdnApis; _configService = configService; _contentTypeService = contentTypeService; _umbracoContextFactory = umbracoContextFactory; }
public override object ConvertDbToEditor(Property property, PropertyType propertyType, IDataTypeService dataTypeService) { string value = property.Value?.ToString(); if (string.IsNullOrEmpty(value)) { return(Enumerable.Empty <object>()); } try { ServiceContext services = ApplicationContext.Current.Services; IEntityService entityService = services.EntityService; IContentTypeService contentTypeService = services.ContentTypeService; var links = JsonConvert.DeserializeObject <List <LinkDto> >(value); var documentLinks = links.FindAll(link => link.Id.HasValue && false == link.IsMedia.GetValueOrDefault() || link.Udi != null && link.Udi.EntityType == Constants.UdiEntityType.Document ); var mediaLinks = links.FindAll(link => link.Id.HasValue && true == link.IsMedia.GetValueOrDefault() || link.Udi != null && link.Udi.EntityType == Constants.UdiEntityType.Media ); List <IUmbracoEntity> entities = new List <IUmbracoEntity>(); if (documentLinks.Count > 0) { if (documentLinks[0].Id.HasValue) { entities.AddRange( entityService.GetAll(UmbracoObjectTypes.Document, documentLinks.Select(link => link.Id.Value).ToArray()) ); } else { entities.AddRange( entityService.GetAll(UmbracoObjectTypes.Document, documentLinks.Select(link => link.Udi.Guid).ToArray()) ); } } if (mediaLinks.Count > 0) { if (mediaLinks[0].Id.HasValue) { entities.AddRange( entityService.GetAll(UmbracoObjectTypes.Media, mediaLinks.Select(link => link.Id.Value).ToArray()) ); } else { entities.AddRange( entityService.GetAll(UmbracoObjectTypes.Media, mediaLinks.Select(link => link.Udi.Guid).ToArray()) ); } } var result = new List <LinkDisplay>(); foreach (LinkDto dto in links) { if (dto.Id.HasValue || dto.Udi != null) { IUmbracoEntity entity = entities.Find(e => e.Key == dto.Udi?.Guid || e.Id == dto.Id); if (entity == null) { continue; } string entityType = Equals(entity.AdditionalData["NodeObjectTypeId"], Constants.ObjectTypes.MediaGuid) ? Constants.UdiEntityType.Media : Constants.UdiEntityType.Document; var udi = new GuidUdi(entityType, entity.Key); string contentTypeAlias = entity.AdditionalData["ContentTypeAlias"] as string; string icon; bool isMedia = false; bool published = Equals(entity.AdditionalData["IsPublished"], true); string url = dto.Url; if (string.IsNullOrEmpty(contentTypeAlias)) { continue; } if (udi.EntityType == Constants.UdiEntityType.Document) { IContentType contentType = contentTypeService.GetContentType(contentTypeAlias); if (contentType == null) { continue; } icon = contentType.Icon; if (UmbracoContext.Current != null) { url = UmbracoContext.Current.UrlProvider.GetUrl(entity.Id); } } else { IMediaType mediaType = contentTypeService.GetMediaType(contentTypeAlias); if (mediaType == null) { continue; } icon = mediaType.Icon; isMedia = true; published = true; if (UmbracoContext.Current != null) { url = UmbracoContext.Current.MediaCache.GetById(entity.Id)?.Url; } } result.Add(new LinkDisplay { Icon = icon, Id = entity.Id, IsMedia = isMedia, Name = dto.Name, Target = dto.Target, Published = published, Udi = udi, Url = url, }); } else { result.Add(new LinkDisplay { Icon = "icon-link", Name = dto.Name, Published = true, Target = dto.Target, Url = dto.Url }); } } return(result); } catch (Exception ex) { ApplicationContext.Current.ProfilingLogger.Logger.Error <MultiUrlPickerPropertyValueEditor>("Error getting links", ex); } return(base.ConvertDbToEditor(property, propertyType, dataTypeService)); }
public ContentListConnector(IContentTypeService contentTypeService, Lazy <ValueConnectorCollection> valueConnectors) : base(contentTypeService, valueConnectors) { }
/// <summary> /// Initializes a new instance of the <see cref="ContentListParser"/> class. /// </summary> /// <param name="contentTypeService"> /// The content type service. /// </param> /// <param name="dataTypeService"> /// The data Type Service. /// </param> public ContentListParser(IContentTypeService contentTypeService, IDataTypeService dataTypeService) : base(contentTypeService, dataTypeService) { }
public PropertyEditorTelemetryProvider(IContentTypeService contentTypeService) => _contentTypeService = contentTypeService;
public LockedCompositionsResolver(IContentTypeService contentTypeService) { _contentTypeService = contentTypeService; }
public ElementTypeController(IContentTypeService contentTypeService) => _contentTypeService = contentTypeService;
public void Get_Paged_Mixed_Entities_By_Ids() { // Create content IContentService contentService = GetRequiredService <IContentService>(); IContentTypeService contentTypeService = GetRequiredService <IContentTypeService>(); var createdContent = new List <IContent>(); ContentType contentType = ContentTypeBuilder.CreateBasicContentType("blah"); contentTypeService.Save(contentType); for (int i = 0; i < 10; i++) { Content c1 = ContentBuilder.CreateBasicContent(contentType); contentService.Save(c1); createdContent.Add(c1); } // Create media IMediaService mediaService = GetRequiredService <IMediaService>(); IMediaTypeService mediaTypeService = GetRequiredService <IMediaTypeService>(); var createdMedia = new List <IMedia>(); MediaType imageType = MediaTypeBuilder.CreateImageMediaType("myImage"); mediaTypeService.Save(imageType); for (int i = 0; i < 10; i++) { Media c1 = MediaBuilder.CreateMediaImage(imageType, -1); mediaService.Save(c1); createdMedia.Add(c1); } // Create members IMemberService memberService = GetRequiredService <IMemberService>(); IMemberTypeService memberTypeService = GetRequiredService <IMemberTypeService>(); MemberType memberType = MemberTypeBuilder.CreateSimpleMemberType("simple"); memberTypeService.Save(memberType); var createdMembers = MemberBuilder.CreateMultipleSimpleMembers(memberType, 10).ToList(); memberService.Save(createdMembers); IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { EntityRepository repo = CreateRepository((IScopeAccessor)provider); IEnumerable <int> ids = createdContent.Select(x => x.Id).Concat(createdMedia.Select(x => x.Id)).Concat(createdMembers.Select(x => x.Id)); System.Guid[] objectTypes = new[] { Constants.ObjectTypes.Document, Constants.ObjectTypes.Media, Constants.ObjectTypes.Member }; IQuery <IUmbracoEntity> query = provider.CreateQuery <IUmbracoEntity>() .WhereIn(e => e.Id, ids); var entities = repo.GetPagedResultsByQuery(query, objectTypes, 0, 20, out long totalRecords, null, null).ToList(); Assert.AreEqual(20, entities.Count); Assert.AreEqual(30, totalRecords); // add the next page entities.AddRange(repo.GetPagedResultsByQuery(query, objectTypes, 1, 20, out totalRecords, null, null)); Assert.AreEqual(30, entities.Count); Assert.AreEqual(30, totalRecords); var contentEntities = entities.OfType <IDocumentEntitySlim>().ToList(); var mediaEntities = entities.OfType <IMediaEntitySlim>().ToList(); var memberEntities = entities.OfType <IMemberEntitySlim>().ToList(); Assert.AreEqual(10, contentEntities.Count); Assert.AreEqual(10, mediaEntities.Count); Assert.AreEqual(10, memberEntities.Count); } }
public ContentTypeFacade(IContentTypeService service) { this.service = service; }
public DocTypePickerApiController(IContentTypeService contentTypeService) { _contentTypeService = contentTypeService; }
public ContentTypeBaseServiceProvider(IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService) { _contentTypeService = contentTypeService; _mediaTypeService = mediaTypeService; _memberTypeService = memberTypeService; }
private static void ContentService_Saved(IContentTypeService contentTypeService, SaveEventArgs <IContentType> e) { foreach (IContentType content in e.SavedEntities) { List <string> itemDoctypeCompositionAliases = new List <string>(); IEnumerable <IDataType> bentoItemDataTypes = DataTypeService.GetByEditorAlias(BentoItemDataEditor.EditorAlias); itemDoctypeCompositionAliases.AddRange(bentoItemDataTypes .Select(dataType => (BentoItemConfiguration)dataType.Configuration) .Select(config => config.ItemDoctypeCompositionAlias)); IEnumerable <IDataType> bentoStackDataTypes = DataTypeService.GetByEditorAlias(BentoStackDataEditor.EditorAlias); itemDoctypeCompositionAliases .AddRange(bentoStackDataTypes.Select(dataType => (BentoStackConfiguration)dataType.Configuration) .Select(config => config.ItemDoctypeCompositionAlias)); IEnumerable <string> compositionAliases = content.ContentTypeComposition.Select(x => x.Alias); IEnumerable <string> result = compositionAliases.Where(x => itemDoctypeCompositionAliases.Any(y => y == x)); if (!result.Any()) { continue; } string websiteViewMessage = string.Empty; string backofficeViewMessage = string.Empty; StringBuilder view = new StringBuilder(); view.AppendLine("@inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedElement>"); string contentAlias = content.Alias.First().ToString().ToUpper() + content.Alias.Substring(1); if (!Directory.Exists(IOHelper.MapPath("~\\Views\\Partials\\Bento"))) { Directory.CreateDirectory(IOHelper.MapPath("~\\Views\\Partials\\Bento")); } if (!Directory.Exists(IOHelper.MapPath("~\\Views\\Partials\\Bento\\Layouts"))) { Directory.CreateDirectory(IOHelper.MapPath("~\\Views\\Partials\\Bento\\Layouts")); } if (!File.Exists(IOHelper.MapPath($"~\\Views\\Partials\\Bento\\{contentAlias}.cshtml"))) { StringBuilder websiteView = new StringBuilder(); websiteView.Append(view); websiteView.AppendLine($"<p>View for Bento doctype '{content.Name}' (alias: {content.Alias})</p>"); File.WriteAllText(IOHelper.MapPath($"~\\Views\\Partials\\Bento\\{contentAlias}.cshtml"), websiteView.ToString()); websiteViewMessage = $"'~/Views/Bento/{contentAlias}.cshtml'"; } if (!File.Exists(IOHelper.MapPath($"~\\Views\\Partials\\Bento\\{contentAlias}BackOffice.cshtml"))) { StringBuilder backOfficeView = new StringBuilder(); backOfficeView.Append(view); backOfficeView.AppendLine("<div class=\"card hero\">"); backOfficeView.AppendLine("\t<div class=\"card-content\">"); backOfficeView.AppendLine( $"\t\t<div class=\"title\">Backoffice Bento view for '{content.Name}' (alias: {content.Alias})</div>"); backOfficeView.AppendLine( $"\t\t<div class=\"sub-title\">To edit, please open the file at: ~/Views/Partials/Bento/{contentAlias}BackOffice.cshtml</div>"); backOfficeView.AppendLine("\t</div>"); backOfficeView.AppendLine("</div>"); File.WriteAllText(IOHelper.MapPath($"~\\Views\\Partials\\Bento\\{contentAlias}BackOffice.cshtml"), backOfficeView.ToString()); backofficeViewMessage = $"'~/Views/Partials/Bento/{contentAlias}BackOffice.cshtml'"; } if (!string.IsNullOrWhiteSpace(websiteViewMessage) || !string.IsNullOrWhiteSpace(backofficeViewMessage)) { //todo: spent an hour trying to get this to work... //from what i can gather online, this has never been implemented... //bit of a shame as the user has no idea that the views have been created?! e.Messages.Add(new EventMessage("Bento setup", $"Bento view(s) created ({websiteViewMessage}{(string.IsNullOrWhiteSpace(backofficeViewMessage) ? string.Empty : " and ")}{backofficeViewMessage}).", EventMessageType.Info)); } } }
public EntityService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, IContentService contentService, IContentTypeService contentTypeService, IMediaService mediaService, IDataTypeService dataTypeService) { _uowProvider = provider; _repositoryFactory = repositoryFactory; _contentService = contentService; _contentTypeService = contentTypeService; _mediaService = mediaService; _dataTypeService = dataTypeService; _supportedObjectTypes = new Dictionary <string, Tuple <UmbracoObjectTypes, Func <int, IUmbracoEntity> > > { { typeof(IDataTypeDefinition).FullName, new Tuple <UmbracoObjectTypes, Func <int, IUmbracoEntity> >(UmbracoObjectTypes.DataType, _dataTypeService.GetDataTypeDefinitionById) }, { typeof(IContent).FullName, new Tuple <UmbracoObjectTypes, Func <int, IUmbracoEntity> >(UmbracoObjectTypes.Document, _contentService.GetById) }, { typeof(IContentType).FullName, new Tuple <UmbracoObjectTypes, Func <int, IUmbracoEntity> >(UmbracoObjectTypes.DocumentType, _contentTypeService.GetContentType) }, { typeof(IMedia).FullName, new Tuple <UmbracoObjectTypes, Func <int, IUmbracoEntity> >(UmbracoObjectTypes.Media, _mediaService.GetById) }, { typeof(IMediaType).FullName, new Tuple <UmbracoObjectTypes, Func <int, IUmbracoEntity> >(UmbracoObjectTypes.MediaType, _contentTypeService.GetMediaType) } }; }
internal static IContent GetOrCreateContent(string alias, string contentName, IContentTypeService contentTypeService, IContentService contentService, IContent parentContent, List<IContent> contentList) { var contentType = contentTypeService.GetContentType(alias); return GetOrCreateContent(contentType, contentName, contentTypeService, contentService, parentContent, contentList); }
public DocumentTypeModule(IPropertyModule propertyModule, IContentTypeService service) : base(propertyModule, Timing.DocTypeModuleTimer) { _service = service; _propertyModule = propertyModule; }
public ContentPartHandler(IEnumerable<IContentPartDriver> contentPartDrivers, IContentTypeService contentTypeService) { _contentPartDrivers = contentPartDrivers; _contentTypeService = contentTypeService; }
/// <summary> /// Initializes a new instance of the <see cref="NestedContentParser"/> class. /// </summary> public NestedContentParser() { this.contentTypeService = ApplicationContext.Current.Services.ContentTypeService; this.dataTypeService = ApplicationContext.Current.Services.DataTypeService; }
public TemplateModule(IDocumentTypeModule documentTypeModule, IFileService fileService, IContentTypeService contentTypeService) { _fileService = fileService; _contentTypeService = contentTypeService; _documentTypeModule = documentTypeModule; }
/// <summary> /// Initializes a new instance of the <see cref="NestedContentParser"/> class. /// </summary> /// <param name="contentTypeService"> /// The content type service. /// </param> /// <param name="dataTypeService"> /// The data type service. /// </param> public NestedContentParser(IContentTypeService contentTypeService, IDataTypeService dataTypeService) { this.contentTypeService = contentTypeService; this.dataTypeService = dataTypeService; }
static void ContentTypeService_DeletingMediaType(IContentTypeService sender, Umbraco.Core.Events.DeleteEventArgs<Umbraco.Core.Models.IMediaType> e) { helpers.uSyncLog.DebugLog("DeletingMediaType for {0} items", e.DeletedEntities.Count()); foreach (var mediaType in e.DeletedEntities) { helpers.XmlDoc.ArchiveFile("MediaType", GetMediaPath(new MediaType(mediaType.Id)), "def"); } }
// TODO: Move registration to another place public UmbracoSchema( IContentTypeService contentTypeService, IMemberTypeService memberTypeService, GraphQLServerOptions options) { if (contentTypeService == null) { throw new ArgumentNullException(nameof(contentTypeService)); } FieldNameConverter = new DefaultFieldNameConverter(); var resolveName = options.PublishedContentNameResolver; var documentTypes = CreateGraphTypes(contentTypeService.GetAllContentTypes(), PublishedItemType.Content, resolveName).ToList(); var mediaTypes = CreateGraphTypes(contentTypeService.GetAllMediaTypes(), PublishedItemType.Media, resolveName); //foreach (var documentType in documentTypes.OfType<ComplexGraphType<IPublishedContent>>()) //{ // var allowedChildren = documentType.GetMetadata<string[]>("allowedChildren"); // if (allowedChildren == null || allowedChildren.Length == 0) continue; // var childTypes = // documentTypes.FindAll(x => // allowedChildren.Contains(x.GetMetadata<string>("documentTypeAlias"))); // IGraphType childrenGraphType; // if (childTypes.Count == 1) // { // childrenGraphType = childTypes[0]; // } // else // { // var unionType = new UnionGraphType() // { // Name = $"{documentType.Name}Children", // }; // foreach (var childType in childTypes.OfType<IObjectGraphType>()) // { // unionType.AddPossibleType(childType); // } // childrenGraphType = unionType; // RegisterTypes(unionType); // } // documentType.AddField( // new FieldType // { // Name = "children", // Description = "Children of the content.", // Resolver = new FuncFieldResolver<IPublishedContent, object>(context => context.Source.Children), // ResolvedType = new ListGraphType(childrenGraphType) // } // ); //} RegisterTypes(documentTypes.ToArray()); RegisterTypes(mediaTypes.ToArray()); // RegisterTypes(memberTypeService.GetAll().CreateGraphTypes(PublishedItemType.Member, resolveName).ToArray()); var query = new UmbracoQuery(); foreach (var type in documentTypes.FindAll(x => x.GetMetadata <bool>("allowedAtRoot"))) { string documentTypeAlias = type.GetMetadata <string>("documentTypeAlias"); query.AddField( new FieldType { Name = type.GetMetadata <string>("documentTypeAlias"), ResolvedType = new ListGraphType(type), Resolver = new FuncFieldResolver <object>(context => { var userContext = (UmbracoGraphQLContext)context.UserContext; return(userContext.Umbraco.TypedContentAtXPath($"/root/{documentTypeAlias}")); }) } ); } Query = query; }
public MetaDataController(IOrchardServices services, IContentTypeService contentTypeService) { _contentTypeService = contentTypeService; Services = services; T = NullLocalizer.Instance; }
public TemplateModule(IDocumentTypeModule documentTypeModule, IFileService fileService, IContentTypeService contentTypeService) { _fileService = fileService; _contentTypeService = contentTypeService; _documentTypeModule = documentTypeModule; }
public UnusedDataTypesHealthCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext) { _dataTypeService = healthCheckContext.ApplicationContext.Services.DataTypeService; _contentTypeService = healthCheckContext.ApplicationContext.Services.ContentTypeService; }
public ContentTypesController(IContentTypeService contentTypeService) { _contentTypeService = contentTypeService; }
public BlockListMapper(IEntityService entityService, IContentTypeService contentTypeService, IDataTypeService dataTypeService) : base(entityService, contentTypeService, dataTypeService) { }
public ValidateContentTypeFilterAttribute(IContentTypeService contentTypeService) { EnsureArg.IsNotNull(contentTypeService, nameof(contentTypeService)); _contentTypeService = contentTypeService; }
/// <summary> /// Ensure list view is enabled for certain doc types when created /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ContentTypeService_SavingContentType(IContentTypeService sender, SaveEventArgs<IContentType> e) { foreach (var c in e.SavedEntities .Where(c => c.Alias.InvariantEquals("ArticulateArchive") || c.Alias.InvariantEquals("ArticulateAuthors")) .Where(c => c.IsNewEntity())) { c.IsContainer = true; } }
/// <summary> /// Fires when a content type is deleted /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void ContentTypeServiceDeletedContentType(IContentTypeService sender, Core.Events.DeleteEventArgs<IContentType> e) { e.DeletedEntities.ForEach(contentType => DistributedCache.Instance.RemoveContentTypeCache(contentType)); }
protected DefaultImporter(IContentTypeService contentTypeService, IDataTypeService dataTypeService, IFileService fileService) { ContentTypeService = contentTypeService; DataTypeService = dataTypeService; FileService = fileService; }
/// <summary> /// Update the existing content Type based on the data in the attributes /// </summary> /// <param name="contentTypeService"></param> /// <param name="fileService"></param> /// <param name="attribute"></param> /// <param name="contentType"></param> /// <param name="type"></param> /// <param name="dataTypeService"></param> private static void UpdateContentType(IContentTypeService contentTypeService, IFileService fileService, UmbracoContentTypeAttribute attribute, IContentType contentType, Type type, IDataTypeService dataTypeService) { contentType.Name = attribute.ContentTypeName; contentType.Alias = attribute.ContentTypeAlias; contentType.Icon = attribute.Icon; contentType.IsContainer = attribute.EnableListView; contentType.AllowedContentTypes = FetchAllowedContentTypes(attribute.AllowedChildren, contentTypeService); contentType.AllowedAsRoot = attribute.AllowedAtRoot; Type parentType = type.BaseType; if (parentType != null && parentType != typeof(UmbracoGeneratedBase) && parentType.GetBaseTypes(false).Any(x => x == typeof(UmbracoGeneratedBase))) { UmbracoContentTypeAttribute parentAttribute = parentType.GetCustomAttribute<UmbracoContentTypeAttribute>(); if (parentAttribute != null) { string parentAlias = parentAttribute.ContentTypeAlias; IContentType parentContentType = contentTypeService.GetContentType(parentAlias); contentType.ParentId = parentContentType.Id; } else { throw new Exception("The given base class has no UmbracoContentTypeAttribute"); } } if (attribute.CreateMatchingView) { Template currentTemplate = fileService.GetTemplate(attribute.ContentTypeAlias) as Template; if (currentTemplate == null) { //there should be a template but there isn't so we create one currentTemplate = new Template("~/Views/" + attribute.ContentTypeAlias + ".cshtml", attribute.ContentTypeName, attribute.ContentTypeAlias); CreateViewFile(attribute.ContentTypeAlias, attribute.MasterTemplate, currentTemplate, type, fileService); fileService.SaveTemplate(currentTemplate, 0); } contentType.AllowedTemplates = new ITemplate[] { currentTemplate }; contentType.SetDefaultTemplate(currentTemplate); } VerifyProperties(contentType, type, dataTypeService); //verify if a tab has no properties, if so remove var propertyGroups = contentType.PropertyGroups.ToArray(); int length = propertyGroups.Length; for (int i = 0; i < length; i++) { if (propertyGroups[i].PropertyTypes.Count == 0) { //remove contentType.RemovePropertyGroup(propertyGroups[i].Name); } } //persist contentTypeService.Save(contentType, 0); }
public ContentMapDefinition(CommonMapper commonMapper, ILocalizedTextService localizedTextService, IContentService contentService, IContentTypeService contentTypeService, IFileService fileService, IUmbracoContextAccessor umbracoContextAccessor, IPublishedRouter publishedRouter, ILocalizationService localizationService, ILogger logger, IUserService userService, IEntityService entityService) { _commonMapper = commonMapper; _localizedTextService = localizedTextService; _contentService = contentService; _contentTypeService = contentTypeService; _fileService = fileService; _umbracoContextAccessor = umbracoContextAccessor; _publishedRouter = publishedRouter; _localizationService = localizationService; _logger = logger; _userService = userService; _entityService = entityService; _tabsAndPropertiesMapper = new TabsAndPropertiesMapper <IContent>(localizedTextService); _stateMapper = new ContentSavedStateMapper <ContentPropertyDisplay>(); _basicStateMapper = new ContentBasicSavedStateMapper <ContentPropertyBasic>(); _contentVariantMapper = new ContentVariantMapper(_localizationService, localizedTextService); }
static SyncDocType() { _packageService = ApplicationContext.Current.Services.PackagingService; _contentTypeService = ApplicationContext.Current.Services.ContentTypeService; }
/// <summary> /// Gets the allowed children /// </summary> /// <param name="types"></param> /// <param name="contentTypeService"></param> /// <returns></returns> private static IEnumerable<ContentTypeSort> FetchAllowedContentTypes(Type[] types, IContentTypeService contentTypeService) { if (types == null) return new ContentTypeSort[0]; List<ContentTypeSort> contentTypeSorts = new List<ContentTypeSort>(); List<string> aliases = GetAliasesFromTypes(types); var contentTypes = contentTypeService.GetAllContentTypes().Where(x => aliases.Contains(x.Alias)).ToArray(); int length = contentTypes.Length; for (int i = 0; i < length; i++) { ContentTypeSort sort = new ContentTypeSort(); sort.Alias = contentTypes[i].Alias; int id = contentTypes[i].Id; sort.Id = new Lazy<int>(() => { return id; }); sort.SortOrder = i; contentTypeSorts.Add(sort); } return contentTypeSorts; }
public BlockEditorPropertyEditor(ILogger logger, Lazy <PropertyEditorCollection> propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILocalizedTextService localizedTextService) : base(logger) { _localizedTextService = localizedTextService; _propertyEditors = propertyEditors; _dataTypeService = dataTypeService; _contentTypeService = contentTypeService; }
public AllowedTemplatesResolver(IContentTypeService contentTypeService, ILocalizedTextService localizedTextService) { _contentTypeService = contentTypeService; _localizedTextService = localizedTextService; }
/// <summary> /// Fires when a content type is deleted /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void ContentTypeServiceDeletedContentType(IContentTypeService sender, Core.Events.DeleteEventArgs <IContentType> e) { e.DeletedEntities.ForEach(contentType => DistributedCache.Instance.RemoveContentTypeCache(contentType)); }
/// <summary> /// Fires when a content type is saved /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void ContentTypeServiceSavedContentType(IContentTypeService sender, Core.Events.SaveEventArgs<IContentType> e) { e.SavedEntities.ForEach(contentType => DistributedCache.Instance.RefreshContentTypeCache(contentType)); }
public ContentMapperProfile( ContentUrlResolver contentUrlResolver, ContentTreeNodeUrlResolver <IContent, ContentTreeController> contentTreeNodeUrlResolver, TabsAndPropertiesResolver <IContent, ContentVariantDisplay> tabsAndPropertiesResolver, ContentAppResolver contentAppResolver, IUserService userService, IContentService contentService, IContentTypeService contentTypeService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, ILocalizationService localizationService, ILocalizedTextService localizedTextService) { // create, capture, cache var contentOwnerResolver = new OwnerResolver <IContent>(userService); var creatorResolver = new CreatorResolver(userService); var actionButtonsResolver = new ActionButtonsResolver(userService, contentService); var childOfListViewResolver = new ContentChildOfListViewResolver(contentService, contentTypeService); var contentTypeBasicResolver = new ContentTypeBasicResolver <IContent, ContentItemDisplay>(contentTypeBaseServiceProvider); var allowedTemplatesResolver = new AllowedTemplatesResolver(contentTypeService, localizedTextService); var defaultTemplateResolver = new DefaultTemplateResolver(); var variantResolver = new ContentVariantResolver(localizationService); var schedPublishReleaseDateResolver = new ScheduledPublishDateResolver(ContentScheduleAction.Release); var schedPublishExpireDateResolver = new ScheduledPublishDateResolver(ContentScheduleAction.Expire); //FROM IContent TO ContentItemDisplay CreateMap <IContent, ContentItemDisplay>() .ForMember(dest => dest.Udi, opt => opt.MapFrom(src => Udi.Create(src.Blueprint ? Constants.UdiEntityType.DocumentBlueprint : Constants.UdiEntityType.Document, src.Key))) .ForMember(dest => dest.Owner, opt => opt.MapFrom(src => contentOwnerResolver.Resolve(src))) .ForMember(dest => dest.Updater, opt => opt.MapFrom(src => creatorResolver.Resolve(src))) .ForMember(dest => dest.Variants, opt => opt.MapFrom(variantResolver)) .ForMember(dest => dest.ContentApps, opt => opt.MapFrom(contentAppResolver)) .ForMember(dest => dest.Icon, opt => opt.MapFrom(src => src.ContentType.Icon)) .ForMember(dest => dest.ContentTypeAlias, opt => opt.MapFrom(src => src.ContentType.Alias)) .ForMember(dest => dest.ContentTypeName, opt => opt.MapFrom(src => localizedTextService.UmbracoDictionaryTranslate(src.ContentType.Name))) .ForMember(dest => dest.IsContainer, opt => opt.MapFrom(src => src.ContentType.IsContainer)) .ForMember(dest => dest.IsElement, opt => opt.MapFrom(src => src.ContentType.IsElement)) .ForMember(dest => dest.IsBlueprint, opt => opt.MapFrom(src => src.Blueprint)) .ForMember(dest => dest.IsChildOfListView, opt => opt.MapFrom(childOfListViewResolver)) .ForMember(dest => dest.Trashed, opt => opt.MapFrom(src => src.Trashed)) .ForMember(dest => dest.TemplateAlias, opt => opt.MapFrom(defaultTemplateResolver)) .ForMember(dest => dest.Urls, opt => opt.MapFrom(contentUrlResolver)) .ForMember(dest => dest.AllowPreview, opt => opt.Ignore()) .ForMember(dest => dest.TreeNodeUrl, opt => opt.MapFrom(contentTreeNodeUrlResolver)) .ForMember(dest => dest.Notifications, opt => opt.Ignore()) .ForMember(dest => dest.Errors, opt => opt.Ignore()) .ForMember(dest => dest.DocumentType, opt => opt.MapFrom(contentTypeBasicResolver)) .ForMember(dest => dest.AllowedTemplates, opt => opt.MapFrom(allowedTemplatesResolver)) .ForMember(dest => dest.AllowedActions, opt => opt.MapFrom(src => actionButtonsResolver.Resolve(src))) .ForMember(dest => dest.AdditionalData, opt => opt.Ignore()); CreateMap <IContent, ContentVariantDisplay>() .ForMember(dest => dest.PublishDate, opt => opt.MapFrom(src => src.PublishDate)) .ForMember(dest => dest.ReleaseDate, opt => opt.MapFrom(schedPublishReleaseDateResolver)) .ForMember(dest => dest.ExpireDate, opt => opt.MapFrom(schedPublishExpireDateResolver)) .ForMember(dest => dest.Segment, opt => opt.Ignore()) .ForMember(dest => dest.Language, opt => opt.Ignore()) .ForMember(dest => dest.Notifications, opt => opt.Ignore()) .ForMember(dest => dest.State, opt => opt.MapFrom <ContentSavedStateResolver <ContentPropertyDisplay> >()) .ForMember(dest => dest.Tabs, opt => opt.MapFrom(tabsAndPropertiesResolver)); //FROM IContent TO ContentItemBasic<ContentPropertyBasic, IContent> CreateMap <IContent, ContentItemBasic <ContentPropertyBasic> >() .ForMember(dest => dest.Udi, opt => opt.MapFrom(src => Udi.Create(src.Blueprint ? Constants.UdiEntityType.DocumentBlueprint : Constants.UdiEntityType.Document, src.Key))) .ForMember(dest => dest.Owner, opt => opt.MapFrom(src => contentOwnerResolver.Resolve(src))) .ForMember(dest => dest.Updater, opt => opt.MapFrom(src => creatorResolver.Resolve(src))) .ForMember(dest => dest.Icon, opt => opt.MapFrom(src => src.ContentType.Icon)) .ForMember(dest => dest.Trashed, opt => opt.MapFrom(src => src.Trashed)) .ForMember(dest => dest.ContentTypeAlias, opt => opt.MapFrom(src => src.ContentType.Alias)) .ForMember(dest => dest.Alias, opt => opt.Ignore()) .ForMember(dest => dest.AdditionalData, opt => opt.Ignore()) .ForMember(dest => dest.UpdateDate, opt => opt.MapFrom <UpdateDateResolver>()) .ForMember(dest => dest.Name, opt => opt.MapFrom <NameResolver>()) .ForMember(dest => dest.State, opt => opt.MapFrom <ContentBasicSavedStateResolver <ContentPropertyBasic> >()) .ForMember(dest => dest.VariesByCulture, opt => opt.MapFrom(src => src.ContentType.VariesByCulture())); //FROM IContent TO ContentPropertyCollectionDto //NOTE: the property mapping for cultures relies on a culture being set in the mapping context CreateMap <IContent, ContentPropertyCollectionDto>(); }