Ejemplo n.º 1
0
        public string RenderTemplate(HtmlHelper htmlHelper, ContentItem item, IContentItemContainer container, string action)
        {
            RouteValueDictionary routeValues = new RouteValueDictionary();
            routeValues.Add(ContentRoute.ContentItemKey, item);
            routeValues.Add(ContentRoute.AreaKey, _controllerMapper.GetAreaName(item.GetType()));

            return htmlHelper.Action(action,
                _controllerMapper.GetControllerName(item.GetType()),
                routeValues).ToString();
        }
Ejemplo n.º 2
0
        public static MvcHtmlString RenderControl(HtmlHelper htmlHelper, dynamic control)
        {
            try
            {
                var config = control.editor?.config;
                if (config == null || config.action == null || config.controller == null)
                {
                    string editor = EditorPath(control);
                    return(htmlHelper.Partial(editor, (object)control));
                }

                string action     = config.action;
                string controller = config.controller;

                if (config.includeUmbracoValues != null && (bool)config.includeUmbracoValues)
                {
                    var controllerParams = new RouteValueDictionary(ParseUmbracoValues(control));
                    return(htmlHelper.Action(action, controller, controllerParams));
                }

                if (config.includeParams != null && (bool)config.includeParams)
                {
                    var controllerParams = new RouteValueDictionary(ParseParams(config));
                    return(htmlHelper.Action(action, controller, controllerParams));
                }

                return(htmlHelper.Action(action, controller));
            }
            catch (Exception ex)
            {
                if (HttpContext.Current.IsDebuggingEnabled)
                {
                    return(MvcHtmlString.Create($"<pre>{ex}</pre>"));
                }
                else
                {
                    TransferRequestToErrorPage();
                }
            }

            return(MvcHtmlString.Empty);
        }
Ejemplo n.º 3
0
 private static MvcHtmlString Widget(HtmlHelper htmlHelper,string actionName,RouteValueDictionary routeValueDictionary)
 {
     return htmlHelper.Action(actionName, "Widget", routeValueDictionary);
 }
        private static MvcHtmlString RenderComponentPresentation(IComponentPresentation cp, HtmlHelper htmlHelper)
        {
            string controller = ConfigurationHelper.ComponentPresentationController;
            string action = ConfigurationHelper.ComponentPresentationAction;


            if (cp.ComponentTemplate.MetadataFields != null && cp.ComponentTemplate.MetadataFields.ContainsKey("controller"))
            {
                controller = cp.ComponentTemplate.MetadataFields["controller"].Value;
            }
            if (cp.ComponentTemplate.MetadataFields != null && cp.ComponentTemplate.MetadataFields.ContainsKey("action"))
            {
                action = cp.ComponentTemplate.MetadataFields["action"].Value;
            }


            LoggerService.Debug("about to render component presentation with controller {0} and action {1}", LoggingCategory.Performance, controller, action);
            //return ChildActionExtensions.Action(htmlHelper, action, controller, new { componentPresentation = ((ComponentPresentation)cp) });
            MvcHtmlString result = htmlHelper.Action(action, controller, new { componentPresentation = ((ComponentPresentation)cp) });
            LoggerService.Debug("finished rendering component presentation with controller {0} and action {1}", LoggingCategory.Performance, controller, action);
            return result;
        }
Ejemplo n.º 5
0
        public static MvcHtmlString Action(this HtmlHelper htmlHelper, ActionResult result)
        {
            var callInfo = result.GetT4MVCResult();

            return(htmlHelper.Action(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary));
        }
        // todo all calls must provide helper!
        public static MvcHtmlString BBCode(this HtmlHelper helper, string str)
        {
            if (str == null)
            {
                return(null);
            }

            str = HttpUtility.HtmlEncode(str);
            str = ProcessAtSignTags(str);

            Regex exp;

            // format the bold tags: [b][/b]
            // becomes: <strong></strong>
            exp = new Regex(@"\[b\]((.|\n)+?)\[/b\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<strong>$1</strong>");

            // format the quote tags: [quote][/quote]
            // becomes: stuff
            exp = new Regex(@"\[quote\]((.|\n)+?)\[/quote\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str,
                              "<table border=\"0\" cellpadding=\"6\" cellspacing=\"0\" width=\"100%\"><tbody><tr><td style=\"border: 1px inset;\"><em>quote:<br>$1</em></td></tr></tbody></table>");

            // format the italic tags: [i][/i]
            // becomes: <em></em>
            exp = new Regex(@"\[i\]((.|\n)+?)\[/i\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<em>$1</em>");

            // format the underline tags: [u][/u]
            // becomes: <u></u>
            exp = new Regex(@"\[u\]((.|\n)+?)\[/u\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<u>$1</u>");

            // format the strike tags: [s][/s]
            // becomes: <strike></strike>
            exp = new Regex(@"\[s\]((.|\n)+?)\[/s\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<strike>$1</strike>");

            // format the url tags: [url=www.website.com]my site[/url]
            // becomes: <a href="www.website.com">my site</a>
            exp = new Regex(@"\[url\=([^\]]+)\]([^\]]+)\[/url\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<a href=\"$1\">$2</a>");

            // format the img tags: [img]www.website.com/img/image.jpeg[/img]
            // becomes: <img src="www.website.com/img/image.jpeg" />
            exp = new Regex(@"\[img\]([^\[]+)\[/img\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<img src=\"$1\" />");

            // format img tags with alt: [img=www.website.com/img/image.jpeg]this is the alt text[/img]
            // becomes: <img src="www.website.com/img/image.jpeg" alt="this is the alt text" />
            exp = new Regex(@"\[img\=([^\]]+)\]([^\]]+)\[/img\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<img src=\"$1\" alt=\"$2\" />");

            //format the colour tags: [color=red][/color]
            // becomes: <font color="red"></font>
            // supports UK English and US English spelling of colour/color
            exp = new Regex(@"\[color\=([^\]]+)\]([^\]]+)\[/color\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<font color=\"$1\">$2</font>");
            exp = new Regex(@"\[colour\=([^\]]+)\]([^\]]+)\[/colour\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<font color=\"$1\">$2</font>");

            // format the size tags: [size=3][/size]
            // becomes: <font size="+3"></font>
            exp = new Regex(@"\[size\=([^\]]+)\]([^\]]+)\[/size\]", RegexOptions.IgnoreCase);
            str = exp.Replace(str, "<font size=\"+$1\">$2</font>");

            str = Regex.Replace(str, @"(^|[\s])((mailto|spring|http|https|ftp|ftps)\://\S+)", @"$1<a href='$2'>$2</a>");

            // lastly, replace any new line characters with <br />
            str = str.Replace("\r\n", "<br />\r\n");

            if (helper != null)
            {
                // todo remove condition in the future
                exp = new Regex(@"\[poll\]([0-9]+)\[/poll\]", RegexOptions.IgnoreCase);
                str = exp.Replace(str, m => helper.Action("Index", "Poll", new { pollID = m.Groups[1].Value }).ToHtmlString());
            }

            return(new MvcHtmlString(str));
        }
Ejemplo n.º 7
0
 public static MvcHtmlString Widget(this HtmlHelper helper, string widgetZone, object additionalData = null)
 {
     return(helper.Action("WidgetsByZone", "Widget", new { widgetZone = widgetZone, additionalData = additionalData }));
 }
Ejemplo n.º 8
0
        public static MvcHtmlString Action(this HtmlHelper htmlHelper, ActionResult result)
        {
            var callInfo = (IT4MVCActionResult)result;

            return(htmlHelper.Action(callInfo.Action, callInfo.Controller, callInfo.RouteValues));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 挂件
 /// </summary>
 /// <param name="helper">HtmlHelper</param>
 /// <param name="containerName">区域标识</param>
 /// <returns></returns>
 public static MvcHtmlString Widget(this HtmlHelper helper, string containerName)
 {
     return(helper.Action("Index", "Widget", new { containerName, area = string.Empty }));
 }
Ejemplo n.º 10
0
 public static MvcHtmlString Action(this HtmlHelper htmlHelper, Task <ActionResult> taskResult)
 {
     return(htmlHelper.Action(taskResult.Result));
 }