Exemplo n.º 1
0
        public virtual IHtmlString ViewUrl(string viewName, object values)
        {
            RouteValueDictionary routeValues = RouteValuesHelpers.GetRouteValues(values);

            routeValues["ViewName"] = viewName;
            return(this.WrapperUrl(this.Url.Action("ViewEntry", "Page", routeValues)));
        }
Exemplo n.º 2
0
        public virtual IHtmlString PageLink(object linkText, string urlMapKey, object routeValues, object htmlAttributes)
        {
#if Page_Trace
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            var    htmlValues = RouteValuesHelpers.GetRouteValues(htmlAttributes);
            Page   page;
            string url = this.PageContext.FrontUrl.PageUrl(urlMapKey, routeValues, out page).ToString();

            page = Kooboo.CMS.Sites.Models.IPersistableExtensions.AsActual(page);

            TagBuilder builder = new TagBuilder("a")
            {
                InnerHtml = linkText == null ? string.Empty : HttpUtility.HtmlEncode(linkText)
            };
            builder.MergeAttributes <string, object>(htmlValues);
            builder.MergeAttribute("href", url);
            if (page != null && page.Route != null && page.Route.LinkTarget != null)
            {
                builder.MergeAttribute("target", page.Route.LinkTarget.ToString());
            }

            var html = new HtmlString(builder.ToString(TagRenderMode.Normal));

#if Page_Trace
            stopwatch.Stop();
            HttpContext.Current.Response.Write(string.Format("PageLink,{0}.</br>", stopwatch.Elapsed));
#endif
            return(html);
        }
Exemplo n.º 3
0
        public virtual IHtmlString SubmissionUrl(string submissionName, object routeValues)
        {
            System.Diagnostics.Contracts.Contract.Requires(!string.IsNullOrEmpty(submissionName));

            var routes = RouteValuesHelpers.GetRouteValues(routeValues);

            routes["SubmissionName"] = submissionName;
            return(this.WrapperUrl(this.Url.Action("Submit", "Submission", routes)));
        }
Exemplo n.º 4
0
        public static IHtmlString GeneratePageUrl(UrlHelper urlHelper, Site site, Page page, object values, FrontRequestChannel channel)
        {
            RouteValueDictionary routeValues = RouteValuesHelpers.GetRouteValues(values);

            page = page.AsActual();

            if (page == null)
            {
                return(new HtmlString(""));
            }
            if (page.Route != null && !string.IsNullOrEmpty(page.Route.ExternalUrl))
            {
                return(new HtmlString(page.Route.ExternalUrl));
            }

            var pageRoute = page.Route.ToMvcRoute();

            routeValues = RouteValuesHelpers.MergeRouteValues(pageRoute.Defaults, routeValues);

            var routeVirtualPath = pageRoute.GetVirtualPath(urlHelper.RequestContext, routeValues);

            if (routeVirtualPath == null)
            {
                throw new InvalidPageRouteException(page);
            }
            //string contentUrl = routeVirtualPath.VirtualPath;//don't decode the url. why??
            //if do not decode the url, the route values contains Chinese character will cause bad request.
            string contentUrl = HttpUtility.UrlDecode(routeVirtualPath.VirtualPath);
            string pageUrl    = contentUrl;

            if (!string.IsNullOrEmpty(contentUrl) || (string.IsNullOrEmpty(pageUrl) && !page.IsDefault))
            {
                pageUrl = Kooboo.Web.Url.UrlUtility.Combine(page.VirtualPath, contentUrl);
            }
            if (string.IsNullOrEmpty(pageUrl))
            {
                pageUrl = urlHelper.Content("~/");
            }
            else
            {
                pageUrl = HttpUtility.UrlDecode(
                    urlHelper.RouteUrl("Page", new { PageUrl = new HtmlString(pageUrl) }));
            }
            var url = FrontUrlHelper.WrapperUrl(pageUrl, site, channel, page.RequireHttps);

            return(url);
        }
Exemplo n.º 5
0
        public virtual IHtmlString ViewLink(object linkText, string viewName, object routeValues, object htmlAttributes)
        {
            var htmlValues = RouteValuesHelpers.GetRouteValues(htmlAttributes);

            string url = this.PageContext.FrontUrl.ViewUrl(viewName, routeValues).ToString();


            TagBuilder builder = new TagBuilder("a")
            {
                InnerHtml = linkText != null?HttpUtility.HtmlEncode(linkText) : string.Empty
            };

            builder.MergeAttributes <string, object>(htmlValues);
            builder.MergeAttribute("href", url);
            var html = new HtmlString(builder.ToString(TagRenderMode.Normal));

            return(html);
        }
Exemplo n.º 6
0
        //Optional parameter does not support NVelocity
        public virtual IHtmlString Pager(object model, object routeValues, PagerOptions options, object htmlAttributes)
        {
            options = options ?? new PagerOptions();

            if ((model is DataRulePagedList))
            {
                options.PageIndexParameterName = ((DataRulePagedList)model).PageIndexParameterName;
            }

            var pagedList = (IPagedList)model;

            var builder = new CmsPagerBuilder
                          (
                this,
                pagedList,
                options,
                RouteValuesHelpers.GetRouteValues(routeValues),
                RouteValuesHelpers.GetRouteValues(htmlAttributes)
                          );

            return(new HtmlString(builder.RenderPager().ToString()));
        }