public ContentLogic(IContentService contentService, IAttachmentService attachmentService, ILegacyContentService legacyContentService, IFileViewerService fileViewerService)
        {
            if (contentService == null)
            {
                throw new ArgumentNullException("contentService");
            }

            if (attachmentService == null)
            {
                throw new ArgumentNullException("attachmentService");
            }

            if (fileViewerService == null)
            {
                throw new ArgumentNullException("fileViewerService");
            }

            if (legacyContentService == null)
            {
                throw new ArgumentNullException("legacyContentService");
            }

            ContentService = contentService;
            AttachmentService = attachmentService;
            LegacyContentService = legacyContentService;
            FileViewerService = fileViewerService;
        }
예제 #2
0
        private void Album_saved(IContentService sender, SaveEventArgs<IContent> e)
        {
            foreach (IContent node in e.SavedEntities)
              {
            if (node.ContentType.ContentTypeCompositionExists("Album") || node.ContentType.Alias == "Album")
            {
              IMediaService ms = UmbracoContext.Current.Application.Services.MediaService;
              IContent parent = node.Parent();
              int media_parentId;
              if (parent.ContentType.ContentTypeCompositionExists("Album") || parent.ContentType.Alias == "Album")
              {
            IMedia media_parent = ms.GetRootMedia().Where(x => x.Name == parent.Name).First(x => x.ContentType.Alias == "Folder");
            if (media_parent == null)
            {
              media_parent = ms.CreateMedia(parent.Name, -1, "Folder");
              ms.Save(media_parent);
            }
            media_parentId = media_parent.Id;
              }
              else
            media_parentId = -1;

              IMedia media_album = ms.CreateMedia(node.Name, media_parentId, "Folder");
              ms.Save(media_album);
            }
              }
        }
예제 #3
0
 private void ContentServiceOnDeleted(IContentService sender, DeleteEventArgs<IContent> deleteEventArgs)
 {
     foreach(var deletedEntity in deleteEventArgs.DeletedEntities)
     {
         DeleteEntityIndex(deletedEntity);
     }
 }
예제 #4
0
        static void ContentService_Created(IContentService sender, NewEventArgs<IContent> e)
        {
            if (UmbracoContext.Current == null) return;

            if (e.Entity.ContentType.Alias.InvariantEquals("ArticulateRichText")
                || e.Entity.ContentType.Alias.InvariantEquals("ArticulateMarkdown"))
            {
                if (UmbracoContext.Current.Security.CurrentUser != null)
                {
                    e.Entity.SetValue("author", UmbracoContext.Current.Security.CurrentUser.Name);
                }
                e.Entity.SetValue("publishedDate", DateTime.Now);
                e.Entity.SetValue("enableComments", 1);
            }
            else if (e.Entity.ContentType.Alias.InvariantEquals("Articulate"))
            {
                e.Entity.SetValue("theme", "VAPOR");
                e.Entity.SetValue("pageSize", 10);
                e.Entity.SetValue("categoriesUrlName", "categories");
                e.Entity.SetValue("tagsUrlName", "tags");
                e.Entity.SetValue("searchUrlName", "search");
                e.Entity.SetValue("categoriesPageName", "Categories");
                e.Entity.SetValue("tagsPageName", "Tags");
                e.Entity.SetValue("searchPageName", "Search results");
            }
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the ContentController class.
 /// </summary>
 /// <param name="contentService">Instance of Content Service</param>
 /// <param name="profileService">Instance of profile Service</param>
 public ContentController(IContentService contentService, IProfileService profileService, INotificationService queueService, ICommunityService communityService)
     : base(profileService)
 {
     _contentService = contentService;
     _notificationService = queueService;
     _communityService = communityService;
 }
예제 #6
0
 /// <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 ApiController(
     IEntitiesContext entitiesContext,
     IPackageService packageService,
     IPackageFileService packageFileService,
     IUserService userService,
     INuGetExeDownloaderService nugetExeDownloaderService,
     IContentService contentService,
     IIndexingService indexingService,
     ISearchService searchService,
     IAutomaticallyCuratePackageCommand autoCuratePackage,
     IStatusService statusService,
     IAppConfiguration config)
 {
     EntitiesContext = entitiesContext;
     PackageService = packageService;
     PackageFileService = packageFileService;
     UserService = userService;
     NugetExeDownloaderService = nugetExeDownloaderService;
     ContentService = contentService;
     StatisticsService = null;
     IndexingService = indexingService;
     SearchService = searchService;
     AutoCuratePackage = autoCuratePackage;
     StatusService = statusService;
     _config = config;
 }
예제 #8
0
파일: VIdeoService.cs 프로젝트: bgadiel/tt
 // private readonly IMemberService _memberService;
 public VideoService(IContentService content)
 {
     _content = content;
     _context = new UmbracoContextProvider();
     //var umbracoConextProvider = DependencyResolver.Current.GetService<IUmbracoConextProvider>();
     _umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
 }
예제 #9
0
        public ContentTypeService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, IContentService contentService, IMediaService mediaService)
        {
            _uowProvider = provider;
	        _repositoryFactory = repositoryFactory;
	        _contentService = contentService;
            _mediaService = mediaService;
        }
예제 #10
0
        /// <summary>
        ///  our save routine, checks to see if the item has been renamed, or if it's been moved
        ///  then saves. 
        /// </summary>
        void SaveContentItemsToDisk(IContentService sender, IEnumerable<IContent> items)
        {
            SourceInfo.Load(); 

            ContentExporter w = new ContentExporter();
            foreach (var item in items)
            {
                LogHelper.Info<ContentExporter>("Saving {0} [{1}]", () => item.Name, () => item.Name.ToSafeAlias());
                string sourceName = SourceInfo.GetName(item.Key);
                if ( (sourceName!= null) && (item.Name != sourceName ) )
                {
                    LogHelper.Info<ContentExporter>("Rename {0}", () => item.Name);
                    w.RenameContent(item, SourceInfo.GetName(item.Key));
                }
                
                int? parent = SourceInfo.GetParent(item.Key) ; 
                if ( (parent != null) && (item.ParentId != parent.Value))
                {
                    LogHelper.Info<ContentExporter>("Move {0}", () => item.Name);
                    w.MoveContent(item, parent.Value);
                }

                w.SaveContent(item); 

            }
            SourceInfo.Save(); 
        }
 /// <summary>
 /// Set auto-properties on content saving
 /// We can't do these properties on create as the source values will not exist
 /// </summary>
 /// <param name="sender">The content service</param>
 /// <param name="e">The save event arguments</param>
 protected void ContentServiceOnSaving(IContentService sender, SaveEventArgs<IContent> e)
 {
     foreach (IContent entity in e.SavedEntities)
     {
         entity.SetDefaultValue("headTitle", entity.Name);
     }
 }
 private void ContentService_Creating(IContentService sender, Umbraco.Core.Events.NewEventArgs<IContent> e)
 {
     //if (e.Alias == "SOSU-Nyhed")
     //{
     //    e.Entity.SetValue("contentDate", DateTime.Now);
     //    //                e.Entity.SetValue("umbracoNaviHide", true);
     //}
 }
 public RelationsController()
 {
     relationService = ApplicationContext.Services.RelationService;
     contentService = ApplicationContext.Services.ContentService;
     mediaService = ApplicationContext.Services.MediaService;
     contentTypeService = ApplicationContext.Services.ContentTypeService;
     entityService = ApplicationContext.Services.EntityService;
 }
 public PagesController(IContentService contentService,
     IMessageService messageService,
     ISupportRequestService supportRequestService)
 {
     _contentService = contentService;
     _messageService = messageService;
     _supportRequestService = supportRequestService;
 }
예제 #15
0
        /// <summary>
        ///  when something is deleted it's plopped in the recycle bin
        /// </summary>
        void ContentService_Trashing(IContentService sender, Umbraco.Core.Events.MoveEventArgs<IContent> e)
        {
            LogHelper.Info<ContentEvents>("Trashing {0}", () => e.Entity.Name);
            ArchiveContentItem(e.Entity);



        }
예제 #16
0
        int importCount = 0; // used just to say how many things we imported

        public ContentImporter()
        {
            _contentService = ApplicationContext.Current.Services.ContentService;
            _mediaService = ApplicationContext.Current.Services.MediaService    ; 

            // load the import table (from disk)
            ImportPairs.LoadFromDisk(); 
        }
예제 #17
0
 public CommonController(IUnitOfWork unitOfWork, ICategoryService categoryService, IStoreService storeService,
     IContentService contentService)
 {
     this._unitOfWork = unitOfWork;
     this._categoryService = categoryService;
     this._storeService = storeService;
     this._contentService = contentService;
 }
        public MemberInformationService()
        {
            _contentService = ApplicationContext.Current.Services.ContentService;

            // Get ahold of the root/home node
            var root = _contentService.GetRootContent().First();
            // Get the API uri
            apiUri = root.GetValue<string>("apiUri");
        }
 public ContentPostValidateAttribute(IContentService contentService, IUserService userService, WebSecurity security)
 {
     if (contentService == null) throw new ArgumentNullException("contentService");
     if (userService == null) throw new ArgumentNullException("userService");
     if (security == null) throw new ArgumentNullException("security");
     _contentService = contentService;
     _userService = userService;
     _security = security;
 }
        public ConfigurationBuilder(IContentService contentService)
        {
            if (contentService == null)
            {
                throw new ArgumentNullException("contentService", "Configuration builder requires a content service to configure.");
            }

            ContentService = contentService;
        }
예제 #21
0
        void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e)
        {
            var ContentService = sender;
            IContent content = ContentService.GetById(e.SavedEntities.First().Id);
            var pubDate = (e.SavedEntities.First().ReleaseDate != null) ? e.SavedEntities.First().ReleaseDate : e.SavedEntities.First().UpdateDate;

            content.SetValue("publishedDate", pubDate);
            ContentService.Save(content, raiseEvents: false);
        }
 void ContentServiceMoving(IContentService sender, MoveEventArgs<IContent> e)
 {
     Logger.Info("Received moved event");
     var runtimeContentModel = RuntimeUmbracoContext.Instance.UmbracoContentSerialiser.Remove(e.Entity);
     foreach (var adapter in RuntimeUmbracoContext.Instance.DeploymentAdapters)
     {
         adapter.DeployContent(runtimeContentModel, DeploymentAction.Delete);
     }
 }
 private void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e)
 {
     foreach (var doc in e.SavedEntities)
     {
         var mapping = MapProvider.Mappings.SingleOrDefault(n => n.DocumentType.Equals(doc.ContentType.Alias, StringComparison.CurrentCultureIgnoreCase));
         if (mapping != null)
             SaveDocument(mapping, sender, doc);
     }
 }
예제 #24
0
 private void ContentService_Creating(IContentService sender, Umbraco.Core.Events.NewEventArgs<IContent> e)
 {
     //Bruges til at udføre custom-handlinger når et dokument oprettes
     //Eksempel: sæt en default dato på egenskaben "contentDate"
     //if (e.Alias == "Kunde-Nyhed")
     //{
     //    e.Entity.SetValue("contentDate", DateTime.Now);
     //}
 }
 ///Constructors needed for testability and DI
 public CommentSurfaceController(UmbracoContext umbracoContext, 
     IContentService _contentService, 
     IMemberService _memberService, 
     IRelationService _relationServices)
     : base(umbracoContext)
 {
     this._contentService = _contentService;
     this._memberService = _memberService;
     this._relationService = _relationServices;
 }
 private void ContentService_Deleting(IContentService sender, DeleteEventArgs<IContent> e)
 {
     foreach (var entity in e.DeletedEntities)
     {
         string documentType = entity.ContentType.Alias;
         var mapping = MapProvider.Mappings.SingleOrDefault(n => n.DocumentType == documentType);
         if (mapping != null)
             DeleteDocument(mapping, sender, entity);
     }
 }
예제 #27
0
 public void LoadContent(IContentService content)
 {
     if (!_contentLoaded)
     {
         foreach (var entity in _entities)
         {
             entity.LoadContent(content);
         }
         _contentLoaded = true;
     }
 }
예제 #28
0
		public DefinedContent(string configDirectory = "")
		{
			_contentService = UmbracoContext.Current.Application.Services.ContentService;

			if (string.IsNullOrEmpty(configDirectory))
				_configDirectory = HttpContext.Current.Server.MapPath("~/") + Constants.CONFIG_DIRECTORY;
			else
				_configDirectory = configDirectory;

			FullRefresh();
		}
예제 #29
0
        void ContentService_Deleted(IContentService sender, Umbraco.Core.Events.DeleteEventArgs<Umbraco.Core.Models.IContent> e)
        {
            var fs = new ForumService(ApplicationContext.Current.DatabaseContext);
            foreach (var ent in e.DeletedEntities.Where(x => x.ContentType.Alias == "Forum"))
            {

                var f = fs.GetById(ent.Id);
                if (f != null)
                    fs.Delete(f);
            }
        }
 /// <summary>
 /// Ensures that node name is the same as post title.
 /// </summary>
 void ContentService_Saved(IContentService sender, SaveEventArgs<IContent> e)
 {
     foreach (var entity in e.SavedEntities)
     {
         if (entity.ContentType.Alias == "uBlogsyPost" && entity.ParentId != -20)
         {
             PostService.Instance.EnsureCorrectPostTitle(entity);
             PostService.Instance.EnsureCorrectPostNodeName(entity);
             PostService.Instance.EnsureNavigationTitle(entity);
         }
     }
 }
예제 #31
0
 public TeamApiController(IContentService contentService, IContentTypeService contentTypeService, IMapper mapper)
 {
     _contentService     = contentService;
     _contentTypeService = contentTypeService;
     _mapper             = mapper;
 }
예제 #32
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="api">The current api</param>
 /// <param name="db">The current db context</param>
 /// <param name="factory">The content service factory</param>
 /// <param name="cache">The optional model cache</param>
 public SiteRepository(Api api, IDb db, IContentServiceFactory factory, ICache cache = null)
     : base(db, cache)
 {
     this.api            = api;
     this.contentService = factory.CreateSiteService();
 }
예제 #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GetServerControlWidgetForEditCommand" /> class.
 /// </summary>
 /// <param name="categoryService">The category service.</param>
 /// <param name="contentService">The content service.</param>
 /// <param name="optionService">The option service.</param>
 public GetServerControlWidgetForEditCommand(ICategoryService categoryService, IContentService contentService, IOptionService optionService)
 {
     this.contentService  = contentService;
     this.categoryService = categoryService;
     this.optionService   = optionService;
 }
 public SitecoreContentNodeConverter(IContentService contentService, ISitecoreContext sitecoreContext)
 {
     _contentService  = contentService;
     _sitecoreContext = sitecoreContext;
 }
 public ConfirmEmailContentNode(IContentService contentService, IContentTypeService contentTypeService, ILogger logger)
 {
     this.contentService     = contentService;
     this.contentTypeService = contentTypeService;
     this.logger             = logger;
 }
예제 #36
0
        /// <summary>
        ///     Gets the URLs of the content item.
        /// </summary>
        /// <remarks>
        ///     <para>Use when displaying URLs. If errors occur when generating the URLs, they will show in the list.</para>
        ///     <para>Contains all the URLs that we can figure out (based upon domains, etc).</para>
        /// </remarks>
        public static async Task <IEnumerable <UrlInfo> > GetContentUrlsAsync(
            this IContent content,
            IPublishedRouter publishedRouter,
            IUmbracoContext umbracoContext,
            ILocalizationService localizationService,
            ILocalizedTextService textService,
            IContentService contentService,
            IVariationContextAccessor variationContextAccessor,
            ILogger <IContent> logger,
            UriUtility uriUtility,
            IPublishedUrlProvider publishedUrlProvider)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            if (publishedRouter == null)
            {
                throw new ArgumentNullException(nameof(publishedRouter));
            }

            if (umbracoContext == null)
            {
                throw new ArgumentNullException(nameof(umbracoContext));
            }

            if (localizationService == null)
            {
                throw new ArgumentNullException(nameof(localizationService));
            }

            if (textService == null)
            {
                throw new ArgumentNullException(nameof(textService));
            }

            if (contentService == null)
            {
                throw new ArgumentNullException(nameof(contentService));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (publishedUrlProvider == null)
            {
                throw new ArgumentNullException(nameof(publishedUrlProvider));
            }

            if (uriUtility == null)
            {
                throw new ArgumentNullException(nameof(uriUtility));
            }

            if (variationContextAccessor == null)
            {
                throw new ArgumentNullException(nameof(variationContextAccessor));
            }

            var result = new List <UrlInfo>();

            if (content.Published == false)
            {
                result.Add(UrlInfo.Message(textService.Localize("content", "itemNotPublished")));
                return(result);
            }

            // build a list of URLs, for the back-office
            // which will contain
            // - the 'main' URLs, which is what .Url would return, for each culture
            // - the 'other' URLs we know (based upon domains, etc)
            //
            // need to work through each installed culture:
            // on invariant nodes, each culture returns the same URL segment but,
            // we don't know if the branch to this content is invariant, so we need to ask
            // for URLs for all cultures.
            // and, not only for those assigned to domains in the branch, because we want
            // to show what GetUrl() would return, for every culture.
            var urls     = new HashSet <UrlInfo>();
            var cultures = localizationService.GetAllLanguages().Select(x => x.IsoCode).ToList();

            // get all URLs for all cultures
            // in a HashSet, so de-duplicates too
            foreach (UrlInfo cultureUrl in await GetContentUrlsByCultureAsync(content, cultures, publishedRouter,
                                                                              umbracoContext, contentService, textService, variationContextAccessor, logger, uriUtility,
                                                                              publishedUrlProvider))
            {
                urls.Add(cultureUrl);
            }

            // return the real URLs first, then the messages
            foreach (IGrouping <bool, UrlInfo> urlGroup in urls.GroupBy(x => x.IsUrl).OrderByDescending(x => x.Key))
            {
                // in some cases there will be the same URL for multiple cultures:
                // * The entire branch is invariant
                // * If there are less domain/cultures assigned to the branch than the number of cultures/languages installed

                if (urlGroup.Key)
                {
                    result.AddRange(urlGroup.DistinctBy(x => x.Text.ToUpperInvariant())
                                    .OrderBy(x => x.Text).ThenBy(x => x.Culture));
                }
                else
                {
                    result.AddRange(urlGroup);
                }
            }

            // get the 'other' URLs - ie not what you'd get with GetUrl() but URLs that would route to the document, nevertheless.
            // for these 'other' URLs, we don't check whether they are routable, collide, anything - we just report them.
            foreach (UrlInfo otherUrl in publishedUrlProvider.GetOtherUrls(content.Id).OrderBy(x => x.Text)
                     .ThenBy(x => x.Culture))
            {
                // avoid duplicates
                if (urls.Add(otherUrl))
                {
                    result.Add(otherUrl);
                }
            }

            return(result);
        }
예제 #37
0
        /// <summary>
        ///     Tries to return a <see cref="UrlInfo" /> for each culture for the content while detecting collisions/errors
        /// </summary>
        private static async Task <IEnumerable <UrlInfo> > GetContentUrlsByCultureAsync(
            IContent content,
            IEnumerable <string> cultures,
            IPublishedRouter publishedRouter,
            IUmbracoContext umbracoContext,
            IContentService contentService,
            ILocalizedTextService textService,
            IVariationContextAccessor variationContextAccessor,
            ILogger logger,
            UriUtility uriUtility,
            IPublishedUrlProvider publishedUrlProvider)
        {
            var result = new List <UrlInfo>();

            foreach (var culture in cultures)
            {
                // if content is variant, and culture is not published, skip
                if (content.ContentType.VariesByCulture() && !content.IsCulturePublished(culture))
                {
                    continue;
                }

                // if it's variant and culture is published, or if it's invariant, proceed
                string url;
                try
                {
                    url = publishedUrlProvider.GetUrl(content.Id, culture: culture);
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, "GetUrl exception.");
                    url = "#ex";
                }

                switch (url)
                {
                // deal with 'could not get the URL'
                case "#":
                    result.Add(HandleCouldNotGetUrl(content, culture, contentService, textService));
                    break;

                // deal with exceptions
                case "#ex":
                    result.Add(UrlInfo.Message(textService.Localize("content", "getUrlException"), culture));
                    break;

                // got a URL, deal with collisions, add URL
                default:
                    // detect collisions, etc
                    Attempt <UrlInfo> hasCollision = await DetectCollisionAsync(logger, content, url, culture,
                                                                                umbracoContext, publishedRouter, textService, variationContextAccessor, uriUtility);

                    if (hasCollision)
                    {
                        result.Add(hasCollision.Result);
                    }
                    else
                    {
                        result.Add(UrlInfo.Url(url, culture));
                    }

                    break;
                }
            }

            return(result);
        }
예제 #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeletePageContentCommand" /> class.
 /// </summary>
 /// <param name="contentService">The content service.</param>
 public DeletePageContentCommand(IContentService contentService)
 {
     this.contentService = contentService;
 }
예제 #39
0
        /// <summary>
        /// Gets the culture that would be selected to render a specified content,
        /// within the context of a specified current request.
        /// </summary>
        /// <param name="umbracoContext">An <see cref="UmbracoContext"/> instance.</param>
        /// <param name="domainService">An <see cref="IDomainService"/> implementation.</param>
        /// <param name="localizationService">An <see cref="ILocalizationService"/> implementation.</param>
        /// <param name="contentService">An <see cref="IContentService"/> implementation.</param>
        /// <param name="contentId">The content identifier.</param>
        /// <param name="contentPath">The content path.</param>
        /// <param name="current">The request Uri.</param>
        /// <returns>The culture that would be selected to render the content.</returns>
        internal static CultureInfo GetCulture(UmbracoContext umbracoContext,
                                               IDomainService domainService, ILocalizationService localizationService, IContentService contentService,
                                               int contentId, string contentPath, Uri current)
        {
            var route = umbracoContext == null
                ? null                                                 // for tests only
                : umbracoContext.ContentCache.GetRouteById(contentId); // may be cached

            var     domainHelper = new DomainHelper(domainService);
            IDomain domain;

            if (route == null)
            {
                // if content is not published then route is null and we have to work
                // on non-published content (note: could optimize by checking routes?)

                var content = contentService.GetById(contentId);
                if (content == null)
                {
                    return(GetDefaultCulture(localizationService));
                }

                var hasDomain = domainHelper.NodeHasDomains(content.Id);
                while (hasDomain == false && content != null)
                {
                    content   = content.Parent();
                    hasDomain = content != null && domainHelper.NodeHasDomains(content.Id);
                }

                domain = hasDomain ? domainHelper.DomainForNode(content.Id, current).UmbracoDomain : null;
            }
            else
            {
                // if content is published then we have a route
                // from which we can figure out the domain

                var pos = route.IndexOf('/');
                domain = pos == 0
                    ? null
                    : domainHelper.DomainForNode(int.Parse(route.Substring(0, pos)), current).UmbracoDomain;
            }

            var rootContentId = domain == null ? -1 : domain.RootContentId;
            var wcDomain      = DomainHelper.FindWildcardDomainInPath(domainService.GetAll(true), contentPath, rootContentId);

            if (wcDomain != null)
            {
                return(new CultureInfo(wcDomain.LanguageIsoCode));
            }
            if (domain != null)
            {
                return(new CultureInfo(domain.LanguageIsoCode));
            }
            return(GetDefaultCulture(localizationService));
        }
예제 #40
0
 private void Content_Deleted(IContentService sender, DeleteEventArgs <IContent> e)
 {
     ClearCache();
 }
예제 #41
0
 private void Content_Moved(IContentService sender, MoveEventArgs <IContent> e)
 {
     ClearCache();
 }
예제 #42
0
 public ContentController(IContentService contentService)
 {
     _contentService = contentService;
 }
예제 #43
0
 public ContentController(IContentService service)
 {
     this.service = service;
 }
예제 #44
0
        private static void ContentService_Saved(IContentService contentService, ContentSavedEventArgs e)
        {
            foreach (IContent content in e.SavedEntities)
            {
                List <string> editors = new List <string>
                {
                    Umbraco.Core.Constants.PropertyEditors.Aliases.Grid,
                    BentoItemDataEditor.EditorAlias,
                    BentoStackDataEditor.EditorAlias
                };

                foreach (Property contentProperty in content.Properties.Where(x => editors.Contains(x.PropertyType.PropertyEditorAlias)))
                {
                    IDataType editor = DataTypeService.GetDataType(contentProperty.PropertyType.DataTypeId);

                    IRelationType bentoBlocksRelationType = RelationService.GetRelationTypeByAlias(RelationTypes.BentoItemsAlias);

                    if (bentoBlocksRelationType == null)
                    {
                        RelationType relationType = new RelationType(
                            RelationTypes.BentoItemsAlias,
                            RelationTypes.BentoItemsName,
                            true,
                            UmbracoObjectTypes.Document.GetGuid(),
                            UmbracoObjectTypes.Document.GetGuid());

                        RelationService.Save(relationType);

                        bentoBlocksRelationType = RelationService.GetRelationTypeByAlias(RelationTypes.BentoItemsAlias);
                    }

                    //todo: this does work but it's a bit brute force...
                    //i guess we could store the current relationships and then store the ones we're creating and compare them and then
                    //delete the ones from the old list that arent in the new list? but that's a lot of db hits...
                    IEnumerable <IRelation> rels = RelationService.GetByParentId(content.Id);
                    foreach (IRelation currentRelation in rels.Where(x => x.RelationType.Id == bentoBlocksRelationType.Id))
                    {
                        RelationService.Delete(currentRelation);
                    }

                    if (contentProperty.PropertyType.PropertyEditorAlias == BentoItemDataEditor.EditorAlias)
                    {
                        foreach (Property.PropertyValue value in contentProperty.Values)
                        {
                            if (value.PublishedValue == null)
                            {
                                break;
                            }

                            var area = JsonConvert.DeserializeObject <Area>(value.PublishedValue.ToString());

                            if (area.Id <= 0)
                            {
                                continue;
                            }

                            var bentoContent = contentService.GetById(area.Id);

                            if (bentoContent == null)
                            {
                                continue;
                            }

                            BentoItemConfiguration config = (BentoItemConfiguration)editor.Configuration;

                            ProcessRelationship(contentService, bentoContent, content, bentoBlocksRelationType, config.ItemDoctypeCompositionAlias);
                        }
                    }
                    else
                    {
                        foreach (Property.PropertyValue value in contentProperty.Values)
                        {
                            if (value.PublishedValue == null)
                            {
                                break;
                            }

                            string valueString = value.PublishedValue?.ToString();

                            if (string.IsNullOrWhiteSpace(valueString))
                            {
                                continue;
                            }

                            IEnumerable <StackItem> items = JsonConvert.DeserializeObject <IEnumerable <StackItem> >(valueString, new StackItemConverter());

                            var itemList = items.Where(x => x.Areas != null && x.Areas.Any())
                                           .SelectMany(stackItem => stackItem.Areas.Where(x => x.Id > 0), (stackItem, x) => contentService.GetById(x.Id))
                                           .Where(bentoContent => bentoContent != null)
                                           .Distinct();

                            BentoStackConfiguration config = (BentoStackConfiguration)editor.Configuration;

                            foreach (IContent item in itemList)
                            {
                                ProcessRelationship(contentService, item, content, bentoBlocksRelationType, config.ItemDoctypeCompositionAlias);
                            }
                        }
                    }
                }
            }
        }
 public PublishMethodologyFunction(IContentService contentService)
 {
     _contentService = contentService;
 }
예제 #46
0
 public HomeController(ApplicationDbContext context, IContentService service, ICarService carService)
 {
     _conService = service;
     _ctx        = context;
     _carService = carService;
 }
예제 #47
0
        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);
            }
        }
예제 #48
0
 public NearConetntViewComponent(IContentService contentService)
 {
     this._contentService = contentService;
 }
예제 #49
0
        private static UrlInfo HandleCouldNotGetUrl(IContent content, string culture, IContentService contentService,
                                                    ILocalizedTextService textService)
        {
            // document has a published version yet its URL is "#" => a parent must be
            // unpublished, walk up the tree until we find it, and report.
            IContent parent = content;

            do
            {
                parent = parent.ParentId > 0 ? contentService.GetParent(parent) : null;
            } while (parent != null && parent.Published &&
                     (!parent.ContentType.VariesByCulture() || parent.IsCulturePublished(culture)));

            if (parent == null)
            {
                // oops, internal error
                return(UrlInfo.Message(textService.Localize("content", "parentNotPublishedAnomaly"), culture));
            }

            if (!parent.Published)
            {
                // totally not published
                return(UrlInfo.Message(textService.Localize("content", "parentNotPublished", new[] { parent.Name }),
                                       culture));
            }

            // culture not published
            return(UrlInfo.Message(textService.Localize("content", "parentCultureNotPublished", new[] { parent.Name }),
                                   culture));
        }
예제 #50
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="db">The current db connection</param>
 /// <param name="factory">The current content service factory</param>
 public PostRepository(IDb db, IContentServiceFactory factory)
 {
     _db             = db;
     _contentService = factory.CreatePostService();
 }
예제 #51
0
 public StreamController(IContentService contentService,
                         IAutorizationService autorizationService)
 {
     _contentService      = contentService;
     _autorizationService = autorizationService;
 }
예제 #52
0
 public CertificateFacade(Web3 web3, IContentService contentService, IAccountService accountService) : base(web3, accountService)
 {
     _contentService = contentService;
 }
예제 #53
0
 public ContentReaderContext(Stream stream, GraphicsDevice device, IContentService content)
 {
     _stream  = stream;
     _device  = device;
     _content = content;
 }
 public PublishTaxonomyFunction(IContentService contentService)
 {
     _contentService = contentService;
 }
예제 #55
0
 public ContentController(IContentService contentService, IContentTypeService contentTypeService, IFileService fileService)
 {
     this._fileService        = fileService;
     this._contentTypeService = contentTypeService;
     _contentService          = contentService;
 }
예제 #56
0
 public TemplateService(IContentService contentService, ISearcher templateSearcher)
 {
     _contentService   = contentService;
     _templateSearcher = templateSearcher;
 }
예제 #57
0
 private void OnPublishedAssert(IContentService sender, PublishEventArgs <IContent> args)
 {
     _onPublishedAssertAction?.Invoke();
 }
예제 #58
0
 public TagController(IContentService contentService, ITagQuery tagService)
 {
     _contentService = contentService;
     _tagService     = tagService;
 }
예제 #59
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="api">The current api</param>
 /// <param name="factory">The content service factory</param>
 public BlockController(IApi api, IContentServiceFactory factory) : base(api)
 {
     // Block transformation is not dependent on which content
     // type is actually selected, so let's create a page service.
     _contentService = factory.CreatePageService();
 }
예제 #60
0
 public PagesController(IContentService contentService)
 {
     ContentService = contentService;
 }