Exemple #1
0
        private SearchDocument FromData(IData data, CultureInfo culture)
        {
            using (new DataScope(culture))
            {
                string label = data.GetLabel();
                if (string.IsNullOrEmpty(label))
                {
                    // Having a label is a requirement for a data item to be searchable
                    return(null);
                }

                var docBuilder = new SearchDocumentBuilder();
                docBuilder.SetDataType(_interfaceType);

                string documentId = GetDocumentId(data);
                if (InternalUrls.DataTypeSupported(_interfaceType) &&
                    (!_isPublishable || data.DataSourceId.PublicationScope == PublicationScope.Published))
                {
                    docBuilder.Url = InternalUrls.TryBuildInternalUrl(data.ToDataReference());
                }

                docBuilder.CrawlData(data);

                var entityToken = GetConsoleEntityToken(data);
                if (entityToken == null)
                {
                    Log.LogWarning(LogTitle, $"Failed to obtain an entity token for a data item of type '{data.DataSourceId.InterfaceType}'");
                    return(null);
                }

                return(docBuilder.BuildDocument(Name, documentId, label, null, entityToken));
            }
        }
 /// <exclude />
 public string ConvertInternalLinks(string xhtml)
 {
     using (Profiler.Measure("Converting internal urls to public"))
     {
         return(InternalUrls.ConvertInternalUrlsToPublic(xhtml));
     }
 }
Exemple #3
0
        public void ConfigureUrls()
        {
            if (RegisteredUrls.Empty())
            {
                GetRegisteredUrls();
            }

            var localHostHttpUrls = BuildUrlAcls("http", "localhost", _configFileProvider.Port);
            var interfaceHttpUrls = BuildUrlAcls("http", _configFileProvider.BindAddress, _configFileProvider.Port);

            var localHostHttpsUrls = BuildUrlAcls("https", "localhost", _configFileProvider.SslPort);
            var interfaceHttpsUrls = BuildUrlAcls("https", _configFileProvider.BindAddress, _configFileProvider.SslPort);

            if (!_configFileProvider.EnableSsl)
            {
                localHostHttpsUrls.Clear();
                interfaceHttpsUrls.Clear();
            }

            if (OsInfo.IsWindows && !_runtimeInfo.IsAdmin)
            {
                var httpUrls  = interfaceHttpUrls.All(IsRegistered) ? interfaceHttpUrls : localHostHttpUrls;
                var httpsUrls = interfaceHttpsUrls.All(IsRegistered) ? interfaceHttpsUrls : localHostHttpsUrls;

                InternalUrls.AddRange(httpUrls);
                InternalUrls.AddRange(httpsUrls);

                if (_configFileProvider.BindAddress != "*")
                {
                    if (httpUrls.None(c => c.Address.Equals("localhost")))
                    {
                        InternalUrls.AddRange(localHostHttpUrls);
                    }

                    if (httpsUrls.None(c => c.Address.Equals("localhost")))
                    {
                        InternalUrls.AddRange(localHostHttpsUrls);
                    }
                }
            }
            else
            {
                InternalUrls.AddRange(interfaceHttpUrls);
                InternalUrls.AddRange(interfaceHttpsUrls);

                //Register localhost URLs so the IP Address doesn't need to be used from the local system
                if (_configFileProvider.BindAddress != "*")
                {
                    InternalUrls.AddRange(localHostHttpUrls);
                    InternalUrls.AddRange(localHostHttpsUrls);
                }

                if (OsInfo.IsWindows)
                {
                    RefreshRegistration();
                }
            }
        }
        private static void InitializeServices()
        {
            UrlToEntityTokenFacade.Register(new DataUrlToEntityTokenMapper());
            UrlToEntityTokenFacade.Register(new ServerLogUrlToEntityTokenMapper());

            RoutedData.ConfigureServices(ServiceLocator.ServiceCollection);

            InternalUrls.Register(new MediaInternalUrlConverter());
            InternalUrls.Register(new PageInternalUrlConverter());
        }
Exemple #5
0
        private void RemoveSimilar(UrlAcl urlAcl)
        {
            var similar = RegisteredUrls.Where(c => c.Scheme == urlAcl.Scheme &&
                                               InternalUrls.None(x => x.Address == c.Address) &&
                                               c.Port == urlAcl.Port &&
                                               c.UrlBase == urlAcl.UrlBase);

            foreach (var s in similar)
            {
                UnregisterUrl(s);
            }
        }
Exemple #6
0
        public virtual SearchResultsEntryViewModel GetSearchResultsEntryViewModel(SearchResultEntry entry)
        {
            var vm = new SearchResultsEntryViewModel
            {
                Title       = entry.Title,
                DetailsUrl  = InternalUrls.TryConvertInternalUrlToPublic(entry.Url),
                ImageUrl    = GetSearchEntryImage(entry),
                Description = GetSearchEntryDesc(entry),
                FieldsBag   = entry.FieldValues
            };

            return(vm);
        }
        internal static void ProcessXhtmlDocument(XhtmlDocument xhtmlDocument, IPage page)
        {
            using (Profiler.Measure("Normalizing XHTML document"))
            {
                NormalizeXhtmlDocument(xhtmlDocument);
            }

            using (Profiler.Measure("Resolving relative paths"))
            {
                ResolveRelativePaths(xhtmlDocument);
            }

            using (Profiler.Measure("Appending C1 meta tags"))
            {
                AppendC1MetaTags(page, xhtmlDocument);
            }

            using (Profiler.Measure("Sorting <head> elements"))
            {
                PrioritizeHeadNodes(xhtmlDocument);
            }

            using (Profiler.Measure("Parsing localization strings"))
            {
                LocalizationParser.Parse(xhtmlDocument);
            }

            using (Profiler.Measure("Converting URLs from internal to public format (XhtmlDocument)"))
            {
                InternalUrls.ConvertInternalUrlsToPublic(xhtmlDocument);
            }

            var filters = ServiceLocator.GetServices <IPageContentFilter>().OrderBy(f => f.Order).ToList();

            if (filters.Any())
            {
                using (Profiler.Measure("Executing page content filters"))
                {
                    filters.ForEach(filter =>
                    {
                        using (Profiler.Measure($"Filter: {filter.GetType().FullName}"))
                        {
                            filter.Filter(xhtmlDocument, page);
                        }
                    });
                }
            }
        }
Exemple #8
0
        private static void InitializeServices()
        {
            UrlToEntityTokenFacade.Register(new DataUrlToEntityTokenMapper());
            UrlToEntityTokenFacade.Register(new ServerLogUrlToEntityTokenMapper());

            RoutedData.ConfigureServices(ServiceLocator.ServiceCollection);


            using (new LogExecutionTime(_verboseLogEntryTitle, "Initializing dynamic data action tokens"))
            {
                DataActionTokenResolverRegistery.Register(ServiceLocator.ServiceCollection);
            }

            InternalUrls.Register(new MediaInternalUrlConverter());
            InternalUrls.Register(new PageInternalUrlConverter());
        }
        private static void InitializeServices()
        {
            UrlToEntityTokenFacade.Register(new DataUrlToEntityTokenMapper());
            UrlToEntityTokenFacade.Register(new ServerLogUrlToEntityTokenMapper());

            var services = ServiceLocator.ServiceCollection;

            services.AddLogging();
            services.AddRoutedData();
            services.AddDataActionTokenResolver();
            services.AddDefaultSearchDocumentSourceProviders();

            InternalUrls.Register(new MediaInternalUrlConverter());
            InternalUrls.Register(new PageInternalUrlConverter());


            VersionedDataHelper.Initialize();
        }
Exemple #10
0
        public static Tuple <string, string>[] GetSearchableDataTypeOptions()
        {
            var result = new List <Tuple <string, string> >();

            var dataTypes = DataFacade.GetAllInterfaces().Where(type =>
                                                                type.GetCustomAttributes(typeof(SearchableTypeAttribute), false).Length > 0 &&
                                                                InternalUrls.DataTypeSupported(type)).ToList();

            dataTypes.Add(typeof(IPage));
            dataTypes.Add(typeof(IMediaFile));

            foreach (var dataType in dataTypes)
            {
                var descriptor = DynamicTypeManager.GetDataTypeDescriptor(dataType);
                result.Add(new Tuple <string, string>(
                               dataType.FullName,
                               descriptor.Title ?? dataType.Name));
            }

            return(result.OrderBy(r => r.Item2).ToArray());
        }
        private static void InitializeServices()
        {
            UrlToEntityTokenFacade.Register(new DataUrlToEntityTokenMapper());
            UrlToEntityTokenFacade.Register(new MediaUrlToEntityTokenMapper());
            UrlToEntityTokenFacade.Register(new ServerLogUrlToEntityTokenMapper());
            UrlToEntityTokenFacade.Register(new WebsiteFileUrlToEntityTokenMapper());

            var services = ServiceLocator.ServiceCollection;

            services.AddLogging();
            services.AddRoutedData();
            services.AddDataActionTokenResolver();
            services.AddDefaultSearchDocumentSourceProviders();

            InternalUrls.Register(new MediaInternalUrlConverter());
            InternalUrls.Register(new PageInternalUrlConverter());

            services.AddSingleton <IMailer>(new SmtpMailer());

            services.AddTransient <ISiteMapPlugin, CmsPagesSiteMapPlugin>();

            VersionedDataHelper.Initialize();
        }
Exemple #12
0
        private Element CreateElement(IData data)
        {
            string label = data.GetLabel();

            var element = new Element(_elementProviderContext.CreateElementHandle(data.GetDataEntityToken()))
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = label,
                    ToolTip     = label,
                    HasChildren = false,
                    Icon        = data is IPublishControlled publishedControlled
                            ? DataIconLookup[publishedControlled.PublicationStatus]
                            : DataIconFacade.DataPublishedIcon
                }
            };

            AddEditAssociatedDataAction(element);
            AddDeleteAssociatedDataAction(element);
            AddDuplicateAssociatedDataAction(element);

            if (InternalUrls.DataTypeSupported(data.DataSourceId.InterfaceType))
            {
                var dataReference = data.ToDataReference();

                if (DataUrls.CanBuildUrlForData(dataReference))
                {
                    string internalUrl = InternalUrls.TryBuildInternalUrl(dataReference);
                    if (internalUrl != null)
                    {
                        element.PropertyBag.Add("Uri", internalUrl);
                    }
                }
            }

            return(element);
        }
Exemple #13
0
        private static void DoInitialize()
        {
            int startTime = Environment.TickCount;

            Guid installationId = InstallationInformationFacade.InstallationId;

            Log.LogVerbose(LogTitle, "Initializing the system core - installation id = " + installationId);

            using (new LogExecutionTime(LogTitle, "Initialization of the static data types"))
            {
                DataProviderRegistry.InitializeDataTypes();
            }


            using (new LogExecutionTime(LogTitle, "Auto update of static data types"))
            {
                bool typesUpdated = AutoUpdateStaticDataTypes();
                if (typesUpdated)
                {
                    using (new LogExecutionTime(LogTitle, "Reinitialization of the static data types"))
                    {
                        SqlTableInformationStore.Flush();
                        DataProviderRegistry.Flush();
                        DataProviderPluginFacade.Flush();


                        DataProviderRegistry.InitializeDataTypes();
                    }

                    CodeGenerationManager.GenerateCompositeGeneratedAssembly(true);
                }
            }


            using (new LogExecutionTime(LogTitle, "Ensure data stores"))
            {
                bool dataStoresCreated = DataStoreExistenceVerifier.EnsureDataStores();

                if (dataStoresCreated)
                {
                    Log.LogVerbose(LogTitle, "Initialization of the system was halted, performing a flush");
                    _initializing = false;
                    GlobalEventSystemFacade.FlushTheSystem();
                    return;
                }
            }



            using (new LogExecutionTime(LogTitle, "Initializing data process controllers"))
            {
                ProcessControllerFacade.Initialize_PostDataTypes();
            }


            using (new LogExecutionTime(LogTitle, "Initializing data type references"))
            {
                DataReferenceRegistry.Initialize_PostDataTypes();
            }


            using (new LogExecutionTime(LogTitle, "Initializing data type associations"))
            {
                DataAssociationRegistry.Initialize_PostDataTypes();
            }


            using (new LogExecutionTime(LogTitle, "Initializing internal urls"))
            {
                InternalUrls.Initialize_PostDataTypes();
            }


            using (new LogExecutionTime(LogTitle, "Initializing functions"))
            {
                MetaFunctionProviderRegistry.Initialize_PostDataTypes();
            }


            Log.LogVerbose(LogTitle, "Starting initialization of administrative secondaries");


            if (SystemSetupFacade.IsSystemFirstTimeInitialized && !SystemSetupFacade.SetupIsRunning)
            {
                using (new LogExecutionTime(LogTitle, "Initializing workflow runtime"))
                {
                    WorkflowFacade.EnsureInitialization();
                }
            }


            if (!RuntimeInformation.IsUnittest)
            {
                using (new LogExecutionTime(LogTitle, "Initializing flow system"))
                {
                    FlowControllerFacade.Initialize();
                }

                using (new LogExecutionTime(LogTitle, "Initializing console system"))
                {
                    ConsoleFacade.Initialize();
                }
            }


            using (new LogExecutionTime(LogTitle, "Auto installing packages"))
            {
                DoAutoInstallPackages();
            }


            using (new LogExecutionTime(LogTitle, "Loading element providers"))
            {
                ElementProviderLoader.LoadAllProviders();
            }


            int executionTime = Environment.TickCount - startTime;

            Log.LogVerbose(LogTitle, "Done initializing of the system core. ({0} ms)".FormatWith(executionTime));
        }
Exemple #14
0
        public virtual IHttpActionResult Body([FromBody] string body)
        {
            InitializeFullPageCaching(System.Web.HttpContext.Current);

            if (string.IsNullOrWhiteSpace(body))
            {
                NotFound();
            }

            var decrypted = LazyFunctionCallDataProvider.UnprotectFunctionCall(body);

            if (decrypted == null)
            {
                return(NotFound());
            }

            HttpContext.RewritePath(HttpContext.Request.FilePath, HttpContext.Request.PathInfo, decrypted.QueryString);

            using (var data = new DataConnection(PublicationScope.Published, ComposerContext.CultureInfo))
            {
                // Grab a function object to execute
                IFunction function = FunctionFacade.GetFunction(decrypted.FunctionName);

                PageRenderer.CurrentPage = PageManager.GetPageById(decrypted.PageId);;

                // Execute the function, passing all query string parameters as input parameters
                var functionResult = (XhtmlDocument)FunctionFacade.Execute <object>(function, decrypted.Parameters.ToDictionary(d => d.Key, d => (object)d.Value));


                // output result
                if (functionResult != null)
                {
                    var functionContext = new FunctionContextContainer();

                    PageRenderer.ExecuteEmbeddedFunctions(functionResult.Root, functionContext);

                    //PageRenderer.ProcessXhtmlDocument(functionResult, productPage);

                    using (Profiler.Measure("Normalizing XHTML document"))
                    {
                        PageRenderer.NormalizeXhtmlDocument(functionResult);
                    }

                    using (Profiler.Measure("Resolving relative paths"))
                    {
                        PageRenderer.ResolveRelativePaths(functionResult);
                    }


                    using (Profiler.Measure("Parsing localization strings"))
                    {
                        LocalizationParser.Parse(functionResult);
                    }

                    using (Profiler.Measure("Converting URLs from internal to public format (XhtmlDocument)"))
                    {
                        InternalUrls.ConvertInternalUrlsToPublic(functionResult);
                    }

                    //TODO: Update C1 Version
                    //PageRenderer.ProcessDocumentHead(functionResult);

                    StringBuilder sb = new StringBuilder();

                    foreach (var node in functionResult.Body.Nodes())
                    {
                        sb.Append(node.ToString());
                    }

                    return(Json(sb.ToString()));
                }
            }

            return(NotFound());
        }
Exemple #15
0
        private Element BuildElement(IData data,
                                     DynamicValuesHelperReplaceContext replaceContext,
                                     TreeNodeDynamicContext dynamicContext,
                                     bool localizationEnabled,
                                     List <object> itemKeys,
                                     ref IEnumerable <object> keysJoinedByParentFilters,
                                     EntityToken parentEntityToken
                                     )
        {
            replaceContext.CurrentDataItem = data;

            object keyValue = this.KeyPropertyInfo.GetValue(data, null);

            bool itemLocalizationEnabledAndForeign = localizationEnabled && !data.DataSourceId.LocaleScope.Equals(UserSettings.ActiveLocaleCultureInfo);

            if (itemLocalizationEnabledAndForeign && itemKeys.Contains(keyValue))
            {
                return(null);
            }

            var currentEntityToken = data.GetDataEntityToken();

            var element = new Element(new ElementHandle
                                      (
                                          dynamicContext.ElementProviderName,
                                          currentEntityToken,
                                          dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken)
                                      ));


            bool           hasChildren;
            bool           isDisabled = false;
            ResourceHandle icon, openedIcon;

            if (itemLocalizationEnabledAndForeign)
            {
                hasChildren = false;
                isDisabled  = !data.IsTranslatable();

                if (this.Icon != null)
                {
                    icon       = this.Icon;
                    openedIcon = this.OpenedIcon;
                }
                else
                {
                    icon       = data.GetForeignIcon();
                    openedIcon = icon;
                }
            }
            else
            {
                if (this.Display != LeafDisplayMode.Auto)
                {
                    hasChildren = ChildNodes.Any();
                }
                else
                {
                    hasChildren = ChildNodes.OfType <SimpleElementTreeNode>().Any();

                    if (!hasChildren)
                    {
                        if (keysJoinedByParentFilters != null)
                        {
                            keysJoinedByParentFilters = keysJoinedByParentFilters.Evaluate();

                            hasChildren = keysJoinedByParentFilters.Contains(keyValue);
                        }
                    }

                    // Checking children filtered by FunctionFilters
                    if (!hasChildren)
                    {
                        foreach (var childNode in this.ChildNodes.OfType <DataElementsTreeNode>()
                                 .Where(n => n.FilterNodes.OfType <FunctionFilterNode>().Any()))
                        {
                            var newDynamicContext = new TreeNodeDynamicContext(TreeNodeDynamicContextDirection.Down)
                            {
                                ElementProviderName = dynamicContext.ElementProviderName,
                                Piggybag            = dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken),
                                CurrentEntityToken  = currentEntityToken
                            };

                            if (childNode.GetDataset(newDynamicContext, false).DataItems.Any())
                            {
                                hasChildren = true;
                                break;
                            }
                        }
                    }
                }

                if (this.Icon != null)
                {
                    icon       = this.Icon;
                    openedIcon = this.OpenedIcon;
                }
                else
                {
                    openedIcon = icon = data.GetIcon();
                }
            }

            string label = this.Label.IsNullOrEmpty()
                            ? data.GetLabel()
                            : this.LabelDynamicValuesHelper.ReplaceValues(replaceContext);

            string toolTip = this.ToolTip.IsNullOrEmpty()
                            ? label
                            : this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext);

            if (itemLocalizationEnabledAndForeign)
            {
                label = string.Format("{0} ({1})", label, DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo));

                if (!data.IsTranslatable())
                {
                    toolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.DisabledData");
                }
                else
                {
                    toolTip = string.Format("{0} ({1})", toolTip, DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo));
                }
            }

            element.VisualData = new ElementVisualizedData
            {
                Label       = label,
                ToolTip     = toolTip,
                HasChildren = hasChildren,
                Icon        = icon,
                OpenedIcon  = openedIcon,
                IsDisabled  = isDisabled
            };


            if (InternalUrls.DataTypeSupported(data.DataSourceId.InterfaceType))
            {
                var dataReference = data.ToDataReference();

                if (DataUrls.CanBuildUrlForData(dataReference))
                {
                    string internalUrl = InternalUrls.TryBuildInternalUrl(dataReference);

                    if (internalUrl != null)
                    {
                        element.PropertyBag.Add("Uri", internalUrl);
                    }
                }
            }


            if (itemLocalizationEnabledAndForeign)
            {
                var actionToken = new WorkflowActionToken(
                    WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.LocalizeDataWorkflow"),
                    LocalizeDataPermissionTypes);

                element.AddAction(new ElementAction(new ActionHandle(actionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.LocalizeDataLabel"),
                        ToolTip        = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeDataWorkflow.LocalizeDataToolTip"),
                        Icon           = LocalizeDataTypeIcon,
                        Disabled       = false,
                        ActionLocation = ActionLocation.OtherPrimaryActionLocation
                    }
                });
            }

            return(element);
        }
Exemple #16
0
        public void ConfigureUrls()
        {
            var enableSsl = _configFileProvider.EnableSsl;
            var port      = _configFileProvider.Port;
            var sslPort   = _configFileProvider.SslPort;

            if (enableSsl && sslPort == port)
            {
                throw new LidarrStartupException("Cannot use the same port for HTTP and HTTPS. Port {0}", port);
            }

            if (RegisteredUrls.Empty())
            {
                GetRegisteredUrls();
            }

            var localHostHttpUrls = BuildUrlAcls("http", "localhost", port);
            var interfaceHttpUrls = BuildUrlAcls("http", _configFileProvider.BindAddress, port);

            var localHostHttpsUrls = BuildUrlAcls("https", "localhost", sslPort);
            var interfaceHttpsUrls = BuildUrlAcls("https", _configFileProvider.BindAddress, sslPort);

            if (!enableSsl)
            {
                localHostHttpsUrls.Clear();
                interfaceHttpsUrls.Clear();
            }

            if (OsInfo.IsWindows && !_runtimeInfo.IsAdmin)
            {
                var httpUrls  = interfaceHttpUrls.All(IsRegistered) ? interfaceHttpUrls : localHostHttpUrls;
                var httpsUrls = interfaceHttpsUrls.All(IsRegistered) ? interfaceHttpsUrls : localHostHttpsUrls;

                InternalUrls.AddRange(httpUrls);
                InternalUrls.AddRange(httpsUrls);

                if (_configFileProvider.BindAddress != "*")
                {
                    if (httpUrls.None(c => c.Address.Equals("localhost")))
                    {
                        InternalUrls.AddRange(localHostHttpUrls);
                    }

                    if (httpsUrls.None(c => c.Address.Equals("localhost")))
                    {
                        InternalUrls.AddRange(localHostHttpsUrls);
                    }
                }
            }
            else
            {
                InternalUrls.AddRange(interfaceHttpUrls);
                InternalUrls.AddRange(interfaceHttpsUrls);

                //Register localhost URLs so the IP Address doesn't need to be used from the local system
                if (_configFileProvider.BindAddress != "*")
                {
                    InternalUrls.AddRange(localHostHttpUrls);
                    InternalUrls.AddRange(localHostHttpsUrls);
                }

                if (OsInfo.IsWindows)
                {
                    RefreshRegistration();
                }
            }
        }
 /// <exclude />
 public static string ChangeInternalMediaUrlsToPublic(string content)
 {
     return(InternalUrls.ConvertInternalUrlsToPublic(content, new[] { new MediaInternalUrlConverter() }));
 }
        private static IEnumerable <SearchResultEntry> SearchInType <T>(string[] keywords, bool currentWebsiteOnly) where T : class, IData
        {
            var stringFields = typeof(T).GetPropertiesRecursively()
                               .Where(p => p.PropertyType == typeof(string) &&
                                      p.ReflectedType != typeof(IPublishControlled) &&
                                      p.ReflectedType != typeof(ILocalizedControlled) &&
                                      p.ReflectedType != typeof(IPageMetaData) &&
                                      !p.GetCustomAttributes <ForeignKeyAttribute>().Any()).ToList();

            if (stringFields.Count == 0)
            {
                return(null);
            }


            Expression searchExpr = null;
            var        parameter  = Expression.Parameter(typeof(T), "p");

            foreach (string keyword in keywords)
            {
                Expression keywordSearchExpr = null;

                foreach (var stringField in stringFields)
                {
                    // Building the following expression:
                    // p => (p.{stringField} != null && p.{stringField}.ToLower().Contains(keyword))

                    var propertyExpression = Expression.Property(parameter, stringField);

                    var notNullExpression = Expression.NotEqual(propertyExpression, Expression.Constant(null, typeof(string)));

                    var toLowerExpression  = Expression.Call(propertyExpression, String_ToLower);
                    var containsExpression = Expression.Call(toLowerExpression, String_Contains,
                                                             new Expression[] { Expression.Constant(keyword) });

                    var andExpression = Expression.AndAlso(notNullExpression, containsExpression);

                    keywordSearchExpr = keywordSearchExpr.OrElse(andExpression);
                }

                searchExpr = searchExpr.AndAlso(keywordSearchExpr);
            }

            if (searchExpr == null)
            {
                return(null);
            }

            var searchPredicate = Expression.Lambda <Func <T, bool> >(searchExpr, parameter);

            HashSet <Guid> pagesIdsOfCurrentSite = null;

            if (currentWebsiteOnly)
            {
                using (var c = new DataConnection())
                {
                    pagesIdsOfCurrentSite = new HashSet <Guid>(c.SitemapNavigator.CurrentPageNode
                                                               .GetPageIds(SitemapScope.Level1AndDescendants));
                }
            }

            var result = new List <SearchResultEntry>();

            foreach (var data in DataFacade.GetData(searchPredicate))
            {
                if (currentWebsiteOnly &&
                    data is IPageRelatedData &&
                    !pagesIdsOfCurrentSite.Contains((data as IPageRelatedData).PageId))
                {
                    continue;
                }

                var dataReference = data.ToDataReference();

                string url;

                if (currentWebsiteOnly && !(data is IPageRelatedData))
                {
                    // Getting public url data to see if it is pointing to the website
                    var pageUrlData = DataUrls.TryGetPageUrlData(dataReference);
                    if (pageUrlData == null || !pagesIdsOfCurrentSite.Contains(pageUrlData.PageId))
                    {
                        continue;
                    }

                    url = PageUrls.BuildUrl(pageUrlData);
                }
                else
                {
                    url = InternalUrls.TryBuildInternalUrl(dataReference);
                }

                if (url == null)
                {
                    continue;
                }

                string label = data.GetLabel();

                // TODO: support for current website only for global data types
                result.Add(new SearchResultEntry
                {
                    Url   = url,
                    Title = label
                });
            }

            return(result);
        }
 /// <exclude />
 public static string ChangeRenderingPageUrlsToPublic(string html)
 {
     return(InternalUrls.ConvertInternalUrlsToPublic(html, new[] { new PageInternalUrlConverter() }));
 }