public FindMyContentController(
     IContentTypeRepository contentTypeRepository,
     IContentFinder contentFinder)
 {
     _contentTypeRepository = contentTypeRepository;
     _contentFinder         = contentFinder;
 }
Esempio n. 2
0
 public ContentItemProvider(IContentTypeProvider contentTypeProvider, IContentFinder contentFinder, IContentGetter contentGetter, IAncestorProvider ancestorProvider, IPrimaryKeyGetter primaryKeyGetter)
 {
     ContentTypeProvider = contentTypeProvider;
     ContentFinder       = contentFinder;
     ContentGetter       = contentGetter;
     AncestorProvider    = ancestorProvider;
     PrimaryKeyGetter    = primaryKeyGetter;
 }
Esempio n. 3
0
        public void SearchCityFinderTest()
        {
            var finders      = new IContentFinder[] { new CityFinder() };
            var foundContent = SearchEngine.Parse(_html, finders).ToList();

            Assert.AreEqual(7, foundContent.Count);
            Assert.IsTrue(foundContent.All(x => x.Type == FoundContentType.City));
        }
Esempio n. 4
0
        public void SearchNameFinderTest()
        {
            var finders      = new IContentFinder[] { new NameFinder() };
            var foundContent = SearchEngine.Parse(_html, finders).ToList();

            Assert.AreEqual(1, foundContent.Count);
            Assert.AreEqual(FoundContentType.Name, foundContent[0].Type);
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RoutingContext"/> class.
 /// </summary>
 /// <param name="contentFinders">The document lookups resolver.</param>
 /// <param name="contentLastChanceFinder"> </param>
 /// <param name="urlProvider">The nice urls provider.</param>
 internal RoutingContext(
     IEnumerable<IContentFinder> contentFinders,
     IContentFinder contentLastChanceFinder,
     UrlProvider urlProvider)
 {
     _publishedContentFinders = new Lazy<IEnumerable<IContentFinder>>(() => contentFinders, false);
     _publishedContentLastChanceFinder = new Lazy<IContentFinder>(() => contentLastChanceFinder, false);
     _urlProvider = new Lazy<UrlProvider>(() => urlProvider, false);
 }
Esempio n. 6
0
 public ContentRepository(
     ISerializationHelper serializationHelper,
     IFileSystemHelper fileSystemHelper,
     IContentFinder contentFinder)
 {
     this.serializationHelper = serializationHelper;
     this.fileSystemHelper    = fileSystemHelper;
     this.contentFinder       = contentFinder;
 }
Esempio n. 7
0
        public void SearchPhoneFinderTest()
        {
            var finders      = new IContentFinder[] { new PhoneNumberFinder() };
            var foundContent = SearchEngine.Parse(_html, finders).ToList();

            Assert.AreEqual(1, foundContent.Count);
            Assert.AreEqual(FoundContentType.PhoneNumber, foundContent[0].Type);
            Assert.AreEqual("0341-3000", foundContent[0].Content);
        }
Esempio n. 8
0
        public void SearchEMailFinderTest()
        {
            var finders      = new IContentFinder[] { new EMailAddressFinder() };
            var foundContent = SearchEngine.Parse(_html, finders).ToList();

            Assert.AreEqual(1, foundContent.Count);
            Assert.AreEqual(FoundContentType.EMailAdress, foundContent[0].Type);
            Assert.AreEqual("*****@*****.**", foundContent[0].Content);
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RoutingContext"/> class.
 /// </summary>
 /// <param name="contentFinders">The document lookups resolver.</param>
 /// <param name="contentLastChanceFinder"> </param>
 /// <param name="urlProvider">The nice urls provider.</param>
 internal RoutingContext(
     IEnumerable <IContentFinder> contentFinders,
     IContentFinder contentLastChanceFinder,
     UrlProvider urlProvider)
 {
     _publishedContentFinders          = new Lazy <IEnumerable <IContentFinder> >(() => contentFinders, false);
     _publishedContentLastChanceFinder = new Lazy <IContentFinder>(() => contentLastChanceFinder, false);
     _urlProvider = new Lazy <UrlProvider>(() => urlProvider, false);
 }
Esempio n. 10
0
 public ContentRepository(
     ISerializationHelper serializationHelper,
     IFileSystemHelper fileSystemHelper,
     IContentFinder contentFinder)
 {
     this.serializationHelper = serializationHelper;
     this.fileSystemHelper = fileSystemHelper;
     this.contentFinder = contentFinder;
 }
 public ContentListController(IContentTypeProvider contentTypeRepository, IContentFinder contentFinder, IPrimaryKeyGetter primaryKeyGetter, IContentChildrenCounter contentChildrenCounter, IPropertyDefinitionProvider propertyDefinitionProvider, PolymorphicFormConverter polymorphicFormConverter)
 {
     ContentTypeProvider        = contentTypeRepository;
     ContentFinder              = contentFinder;
     PrimaryKeyGetter           = primaryKeyGetter;
     ContentChildrenCounter     = contentChildrenCounter;
     PropertyDefinitionProvider = propertyDefinitionProvider;
     PolymorphicFormConverter   = polymorphicFormConverter;
 }
Esempio n. 12
0
        public void SearchTaxNumberFinderTest()
        {
            var finders      = new IContentFinder[] { new TaxNumberFinder() };
            var foundContent = SearchEngine.Parse(_html, finders).ToList();

            Assert.AreEqual(1, foundContent.Count);
            Assert.AreEqual(FoundContentType.TaxIdentifiactionNumber, foundContent[0].Type);
            Assert.AreEqual("DE141510836", foundContent[0].Content);
        }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RoutingContext"/> class.
 /// </summary>
 /// <param name="umbracoContext"> </param>
 /// <param name="contentFinders">The document lookups resolver.</param>
 /// <param name="contentLastChanceFinder"> </param>
 /// <param name="urlProvider">The nice urls provider.</param>
 internal RoutingContext(
     UmbracoContext umbracoContext,
     IEnumerable <IContentFinder> contentFinders,
     IContentFinder contentLastChanceFinder,
     UrlProvider urlProvider)
 {
     UmbracoContext                   = umbracoContext;
     PublishedContentFinders          = contentFinders;
     PublishedContentLastChanceFinder = contentLastChanceFinder;
     UrlProvider = urlProvider;
 }
Esempio n. 14
0
	    /// <summary>
	    /// Initializes a new instance of the <see cref="RoutingContext"/> class.
	    /// </summary>
	    /// <param name="umbracoContext"> </param>
	    /// <param name="contentFinders">The document lookups resolver.</param>
	    /// <param name="contentLastChanceFinder"> </param>
	    /// <param name="urlProvider">The nice urls provider.</param>
	    internal RoutingContext(
			UmbracoContext umbracoContext,
			IEnumerable<IContentFinder> contentFinders,
			IContentFinder contentLastChanceFinder,
            UrlProvider urlProvider)
        {
			UmbracoContext = umbracoContext;
			PublishedContentFinders = contentFinders;
			PublishedContentLastChanceFinder = contentLastChanceFinder;
        	UrlProvider = urlProvider;
        }
        public static IContentFinder SubsituteFinder(INotFoundHandler handler)
        {
            IContentFinder finder = null;

            if (handler is global::umbraco.SearchForAlias)
            {
                finder = new ContentFinderByUrlAlias();
            }
            else if (handler is global::umbraco.SearchForProfile)
            {
                finder = new ContentFinderByProfile();
            }
            else if (handler is global::umbraco.SearchForTemplate)
            {
                finder = new ContentFinderByNiceUrlAndTemplate();
            }
            else if (handler is global::umbraco.handle404)
            {
                finder = new ContentFinderByLegacy404();
            }

            return(finder);
        }
        public ContentListApiResult(ProtoCmsRuntimeContext cmsContext, ContentType contentType, string search,
                                    string sortColumn, bool?isDescending, int offset, int limit, ContentListShape?shape,
                                    IContentFinder finder = null)
        {
            finder = finder ?? contentType.Finder();
            var contentShape = shape ?? ContentListShape.Normal;

            if (!string.IsNullOrWhiteSpace(search))
            {
                finder = finder.Search(search.Trim());
            }
            if (!string.IsNullOrWhiteSpace(sortColumn))
            {
                SortColumn = sortColumn;
                if (isDescending.HasValue)
                {
                    SortIsDescending = isDescending.Value;
                    finder           = finder.Sort(sortColumn, isDescending.Value);
                }
                else
                {
                    SortIsDescending = contentType.DefaultSortDescending;
                    finder           = finder.Sort(sortColumn, contentType.DefaultSortDescending);
                }
            }
            else
            {
                SortColumn = contentType.DefaultSortFieldName;
                if (isDescending.HasValue)
                {
                    SortIsDescending = isDescending.Value;
                    finder           = finder.Sort(contentType.DefaultSortFieldName, isDescending.Value);
                }
                else
                {
                    SortIsDescending = contentType.DefaultSortDescending;
                    finder           = finder.Sort(contentType.DefaultSortFieldName, contentType.DefaultSortDescending);
                }
            }

            if (offset < 0)
            {
                offset = 0;
            }
            if (limit < 1)
            {
                limit = 100;
            }
            var currentPage = offset / limit + 1;

            var paginated = new PaginatedQueryable <ProtoContent>(finder.AsQueryable(), currentPage, limit);
            var rawData   = paginated.CurrentPageQueryable.ToArray();

            CurrentPage    = paginated.CurrentPage;
            TotalPage      = paginated.TotalPage;
            StartNumbering = paginated.StartNumbering;
            GlobalCount    = paginated.Count;
            CurrentCount   = rawData.Length;
            Offset         = paginated.Offset;
            Limit          = paginated.Limit;
            SearchKeywords = search;
            ResultShape    = $"{contentShape.ToString()} ({(int) contentShape})";
            var data   = new List <dynamic>();
            var getter = new ContentShapedApiModelBuilder();

            foreach (var rd in rawData)
            {
                data.Add(getter.GetContentShaped(rd, contentType, cmsContext, contentShape));
            }
            Data = data.ToArray();
        }
Esempio n. 17
0
 public ParentOptionProvider(IContentFinder contentFinder, IContentTypeProvider contentTypeProvider, IPrimaryKeyGetter primaryKeyGetter)
 {
     ContentFinder       = contentFinder;
     ContentTypeProvider = contentTypeProvider;
     PrimaryKeyGetter    = primaryKeyGetter;
 }
        void HandlePageNotFound(PublishedContentRequest docRequest)
        {
            var url = NotFoundHandlerHelper.GetLegacyUrlForNotFoundHandlers();

            LogHelper.Debug <ContentFinderByNotFoundHandlers>("Running for legacy url='{0}'.", () => url);

            foreach (var handler in GetNotFoundHandlers())
            {
                IContentFinder finder      = null;
                var            handlerName = handler.GetType().FullName;

                LogHelper.Debug <ContentFinderByNotFoundHandlers>("Handler '{0}'.", () => handlerName);

                // replace with our own implementation
                if (handler is global::umbraco.SearchForAlias)
                {
                    finder = new ContentFinderByUrlAlias();
                }
                else if (handler is global::umbraco.SearchForProfile)
                {
                    finder = new ContentFinderByProfile();
                }
                else if (handler is global::umbraco.SearchForTemplate)
                {
                    finder = new ContentFinderByNiceUrlAndTemplate();
                }
                else if (handler is global::umbraco.handle404)
                {
                    finder = new ContentFinderByLegacy404();
                }

                if (finder != null)
                {
                    var finderName = finder.GetType().FullName;
                    LogHelper.Debug <ContentFinderByNotFoundHandlers>("Replace handler '{0}' by new finder '{1}'.", () => handlerName, () => finderName);
                    if (finder.TryFindContent(docRequest))
                    {
                        // do NOT set docRequest.PublishedContent again here as
                        // it would clear any template that the finder might have set
                        LogHelper.Debug <ContentFinderByNotFoundHandlers>("Finder '{0}' found node with id={1}.", () => finderName, () => docRequest.PublishedContent.Id);
                        if (docRequest.Is404)
                        {
                            LogHelper.Debug <ContentFinderByNotFoundHandlers>("Finder '{0}' set status to 404.", () => finderName);
                        }

                        // if we found a document, break, don't look at more handler -- we're done
                        break;
                    }

                    // if we did not find a document, continue, look at other handlers
                    continue;
                }

                // else it's a legacy handler, run

                if (handler.Execute(url) && handler.redirectID > 0)
                {
                    var redirectId = handler.redirectID;
                    docRequest.PublishedContent = docRequest.RoutingContext.UmbracoContext.ContentCache.GetById(redirectId);

                    if (!docRequest.HasPublishedContent)
                    {
                        LogHelper.Debug <ContentFinderByNotFoundHandlers>("Handler '{0}' found node with id={1} which is not valid.", () => handlerName, () => redirectId);
                        break;
                    }

                    LogHelper.Debug <ContentFinderByNotFoundHandlers>("Handler '{0}' found valid node with id={1}.", () => handlerName, () => redirectId);

                    if (docRequest.RoutingContext.UmbracoContext.HttpContext.Response.StatusCode == 404)
                    {
                        LogHelper.Debug <ContentFinderByNotFoundHandlers>("Handler '{0}' set status code to 404.", () => handlerName);
                        docRequest.Is404 = true;
                    }

                    //// check for caching
                    //if (handler.CacheUrl)
                    //{
                    //    if (url.StartsWith("/"))
                    //        url = "/" + url;

                    //    var cacheKey = (currentDomain == null ? "" : currentDomain.Name) + url;
                    //    var culture = currentDomain == null ? null : currentDomain.Language.CultureAlias;
                    //    SetCache(cacheKey, new CacheEntry(handler.redirectID.ToString(), culture));

                    //    HttpContext.Current.Trace.Write("NotFoundHandler",
                    //        string.Format("Added to cache '{0}', {1}.", url, handler.redirectID));
                    //}

                    // if we found a document, break, don't look at more handler -- we're done
                    break;
                }

                // if we did not find a document, continue, look at other handlers
            }
        }
Esempio n. 19
0
 public ContentRoute(IContentFinder contentFinder, ContentRouteHandler handler)
 {
     this.contentFinder = contentFinder;
     this.handler = handler;
 }