private static string BuildInternalUrl(PageUrlData pageUrlData)
        {
            var cultureInfo      = pageUrlData.LocalizationScope;
            var publicationScope = pageUrlData.PublicationScope;

            var result = new UrlBuilder("~/page(" + pageUrlData.PageId + ")");

            string pathInfo = string.Empty;

            if (publicationScope == PublicationScope.Unpublished)
            {
                pathInfo = UrlMarker_Unpublished;
            }

            if (!pageUrlData.PathInfo.IsNullOrEmpty())
            {
                pathInfo += pageUrlData.PathInfo;
            }
            result.PathInfo = pathInfo;


            result["cultureInfo"] = cultureInfo.ToString();

            if (pageUrlData.QueryParameters != null)
            {
                result.AddQueryParameters(pageUrlData.QueryParameters);
            }

            return(result);
        }
        private string BuildPublicUrl(PageUrlData pageUrlData, UrlSpace urlSpace)
        {
            var cultureInfo      = pageUrlData.LocalizationScope;
            var publicationScope = pageUrlData.PublicationScope;

            var pageUrlPath = new StringBuilder();

            using (new DataScope(publicationScope, cultureInfo))
            {
                if (!BuildPageUrlPath(pageUrlData.PageId, cultureInfo, urlSpace, pageUrlPath))
                {
                    return(null);
                }
            }

            if (publicationScope == PublicationScope.Unpublished)
            {
                AppendUrlPart(pageUrlPath, UrlMarker_Unpublished);
            }

            if (urlSpace.ForceRelativeUrls)
            {
                AppendUrlPart(pageUrlPath, UrlMarker_RelativeUrl);
            }

            if (!string.IsNullOrEmpty(UrlSuffix) &&
                pageUrlPath[pageUrlPath.Length - 1] != '/')
            {
                pageUrlPath.Append(UrlSuffix);
            }

            if (!string.IsNullOrEmpty(pageUrlData.PathInfo))
            {
                AppendPathInfo(pageUrlPath, pageUrlData.PathInfo);
            }


            string url = pageUrlPath.ToString();

            if (pageUrlData.QueryParameters != null)
            {
                var urlWithQuery = new UrlBuilder(url);
                urlWithQuery.AddQueryParameters(pageUrlData.QueryParameters);

                return(urlWithQuery);
            }

            return(url);
        }
Example #3
0
        private static string BuildPublicUrl(MediaUrlData mediaUrlData)
        {
            IMediaUrlProvider urlProvider;

            if (!_mediaUrlProviders.TryGetValue(mediaUrlData.MediaStore, out urlProvider))
            {
                urlProvider = _defaultMediaUrlProvider.Value;
            }



            if (mediaUrlData.QueryParameters.Count > 0)
            {
                string mediaUrl;
                var    resizingOptions     = ResizingOptions.Parse(mediaUrlData.QueryParameters);
                var    noneResizingOptions = mediaUrlData.QueryParameters;

                if (!resizingOptions.IsEmpty)
                {
                    var imageResizableUrlProvider = urlProvider is IResizableImageUrlProvider
                        ? urlProvider as IResizableImageUrlProvider
                        : _defaultMediaUrlProvider.Value;

                    mediaUrl = imageResizableUrlProvider.GetResizedImageUrl(mediaUrlData.MediaStore, mediaUrlData.MediaId, resizingOptions);

                    foreach (var key in HttpUtility.ParseQueryString(resizingOptions.ToString()).AllKeys)
                    {
                        noneResizingOptions.Remove(key);
                    }
                }
                else
                {
                    mediaUrl = urlProvider.GetPublicMediaUrl(mediaUrlData.MediaStore, mediaUrlData.MediaId);
                }

                if (noneResizingOptions.Count > 0)
                {
                    var urlBuilder = new UrlBuilder(mediaUrl);

                    urlBuilder.AddQueryParameters(noneResizingOptions);

                    return(urlBuilder.ToString());
                }

                return(mediaUrl);
            }

            return(urlProvider.GetPublicMediaUrl(mediaUrlData.MediaStore, mediaUrlData.MediaId));
        }
Example #4
0
        private static string BuildInternalUrl(MediaUrlData mediaUrlData)
        {
            string storeId = mediaUrlData.MediaStore == DefaultMediaStore
                             ? ""
                             : mediaUrlData.MediaStore + ":";

            var urlBuilder = new UrlBuilder("~/media(" + storeId + mediaUrlData.MediaId + ")");

            if (mediaUrlData.QueryParameters != null)
            {
                urlBuilder.AddQueryParameters(mediaUrlData.QueryParameters);
            }

            return(urlBuilder.ToString());
        }
Example #5
0
        private static string BuildRendererUrl(MediaUrlData mediaUrlData)
        {
            var queryParams = new NameValueCollection(mediaUrlData.QueryParameters)
            {
                { "id", mediaUrlData.MediaId.ToString() }
            };

            if (mediaUrlData.MediaStore != null &&
                mediaUrlData.MediaStore != DefaultMediaStore)
            {
                queryParams.Add("store", mediaUrlData.MediaStore);
            }

            var url = new UrlBuilder(UrlUtils.PublicRootPath + "/Renderers/ShowMedia.ashx");

            url.AddQueryParameters(queryParams);

            return(url);
        }
        private static string BuildRenderUrl(PageUrlData pageUrlData)
        {
            var    cultureInfo     = pageUrlData.LocalizationScope;
            string legacyScopeName = GetLegacyPublicationScopeIdentifier(pageUrlData.PublicationScope);

            string basePath = UrlUtils.ResolvePublicUrl("Renderers/Page.aspx");
            var    result   = new UrlBuilder(basePath);

            result["pageId"]      = pageUrlData.PageId.ToString();
            result["cultureInfo"] = cultureInfo.ToString();
            result["dataScope"]   = legacyScopeName;

            result.PathInfo = pageUrlData.PathInfo;
            if (pageUrlData.QueryParameters != null)
            {
                result.AddQueryParameters(pageUrlData.QueryParameters);
            }

            return(result);
        }
Example #7
0
        /// <summary>
        ///     Redirect to page with query string parameter returnUrl
        /// </summary>
        /// <param name="pageId"></param>
        /// <param name="returnUrl"></param>
        public static bool Redirect(Guid pageId, string returnUrl)
        {
            string pageUrl;

            PageStructureInfo.TryGetPageUrl(pageId, out pageUrl);
            if (!string.IsNullOrEmpty(pageUrl))
            {
                if (!string.IsNullOrEmpty(returnUrl))
                {
                    var urlBuilder      = new UrlBuilder(pageUrl);
                    var queryParameters = new NameValueCollection();
                    queryParameters.Add("returnUrl", returnUrl);
                    urlBuilder.AddQueryParameters(queryParameters);
                    pageUrl = urlBuilder.ToString();
                }
                HttpContext.Current.Response.Redirect(pageUrl, false);
                return(true);
            }
            return(false);
        }
Example #8
0
        private static string BuildPublicUrl(MediaUrlData mediaUrlData)
        {
            IMediaUrlProvider urlProvider;
            if (!_mediaUrlProviders.TryGetValue(mediaUrlData.MediaStore, out urlProvider))
            {
                urlProvider = _defaultMediaUrlProvider.Value;
            }

             
            

            if (mediaUrlData.QueryParameters.Count > 0)
            {
                string mediaUrl;
                var resizingOptions = ResizingOptions.Parse(mediaUrlData.QueryParameters);
                var noneResizingOptions = mediaUrlData.QueryParameters;

                if (!resizingOptions.IsEmpty)
                {
                    var imageResizableUrlProvider = urlProvider is IResizableImageUrlProvider
                        ? urlProvider as IResizableImageUrlProvider
                        : _defaultMediaUrlProvider.Value;

                    mediaUrl = imageResizableUrlProvider.GetResizedImageUrl(mediaUrlData.MediaStore, mediaUrlData.MediaId, resizingOptions);

                    foreach (var key in HttpUtility.ParseQueryString(resizingOptions.ToString()).AllKeys)
                    {
                        noneResizingOptions.Remove(key);
                    }
                }
                else
                {
                    mediaUrl = urlProvider.GetPublicMediaUrl(mediaUrlData.MediaStore, mediaUrlData.MediaId);
                }

                if (noneResizingOptions.Count > 0)
                {
                    var urlBuilder = new UrlBuilder(mediaUrl);

                    urlBuilder.AddQueryParameters(noneResizingOptions);

                    return urlBuilder.ToString();
                }

                return mediaUrl;
            }

            return urlProvider.GetPublicMediaUrl(mediaUrlData.MediaStore, mediaUrlData.MediaId);
        }
Example #9
0
        private static string BuildRendererUrl(MediaUrlData mediaUrlData)
        {
            var queryParams = new NameValueCollection(mediaUrlData.QueryParameters)
            {
                {"id", mediaUrlData.MediaId.ToString()}
            };

            if (mediaUrlData.MediaStore != null 
                && mediaUrlData.MediaStore != DefaultMediaStore)
            {
                queryParams.Add("store", mediaUrlData.MediaStore);
            }

            var url = new UrlBuilder(UrlUtils.PublicRootPath + "/Renderers/ShowMedia.ashx");
            url.AddQueryParameters(queryParams);

            return url;
        }
Example #10
0
        private static string BuildInternalUrl(MediaUrlData mediaUrlData)
        {
            string storeId = mediaUrlData.MediaStore == DefaultMediaStore 
                             ? "" 
                             : mediaUrlData.MediaStore + ":";

            var urlBuilder = new UrlBuilder("~/media(" + storeId + mediaUrlData.MediaId + ")");

            if (mediaUrlData.QueryParameters != null)
            {
                urlBuilder.AddQueryParameters(mediaUrlData.QueryParameters);
            }

            return urlBuilder.ToString();
        }