Moves EnableCanvasDesigner to HtmlHelperRenderExtensions because it's for rendering html, obsoletes the old ones and fixes up the canvasdesigner to use
the correct umbraco paths instead of hard coded absolute paths.
This commit is contained in:
@@ -87,7 +87,7 @@ namespace Umbraco.Web
|
||||
}
|
||||
|
||||
|
||||
//[Obsolete("This should not be used, GetGridHtml methods accepting HtmlHelper as a parameter or GetGridHtml extensions on HtmlHelper should be used instead")]
|
||||
[Obsolete("This should not be used, GetGridHtml methods accepting HtmlHelper as a parameter or GetGridHtml extensions on HtmlHelper should be used instead")]
|
||||
public static MvcHtmlString GetGridHtml(this IPublishedProperty property, string framework = "bootstrap3")
|
||||
{
|
||||
var asString = property.Value as string;
|
||||
@@ -97,13 +97,13 @@ namespace Umbraco.Web
|
||||
return htmlHelper.GetGridHtml(property, framework);
|
||||
}
|
||||
|
||||
//[Obsolete("This should not be used, GetGridHtml methods accepting HtmlHelper as a parameter or GetGridHtml extensions on HtmlHelper should be used instead")]
|
||||
[Obsolete("This should not be used, GetGridHtml methods accepting HtmlHelper as a parameter or GetGridHtml extensions on HtmlHelper should be used instead")]
|
||||
public static MvcHtmlString GetGridHtml(this IPublishedContent contentItem)
|
||||
{
|
||||
return GetGridHtml(contentItem, "bodyText", "bootstrap3");
|
||||
}
|
||||
|
||||
//[Obsolete("This should not be used, GetGridHtml methods accepting HtmlHelper as a parameter or GetGridHtml extensions on HtmlHelper should be used instead")]
|
||||
[Obsolete("This should not be used, GetGridHtml methods accepting HtmlHelper as a parameter or GetGridHtml extensions on HtmlHelper should be used instead")]
|
||||
public static MvcHtmlString GetGridHtml(this IPublishedContent contentItem, string propertyAlias)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(propertyAlias, "propertyAlias");
|
||||
@@ -111,7 +111,7 @@ namespace Umbraco.Web
|
||||
return GetGridHtml(contentItem, propertyAlias, "bootstrap3");
|
||||
}
|
||||
|
||||
//[Obsolete("This should not be used, GetGridHtml methods accepting HtmlHelper as a parameter or GetGridHtml extensions on HtmlHelper should be used instead")]
|
||||
[Obsolete("This should not be used, GetGridHtml methods accepting HtmlHelper as a parameter or GetGridHtml extensions on HtmlHelper should be used instead")]
|
||||
public static MvcHtmlString GetGridHtml(this IPublishedContent contentItem, string propertyAlias, string framework)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(propertyAlias, "propertyAlias");
|
||||
@@ -127,7 +127,7 @@ namespace Umbraco.Web
|
||||
return htmlHelper.GetGridHtml(contentItem, propertyAlias, framework);
|
||||
}
|
||||
|
||||
//[Obsolete("This shouldn't need to be used but because the obsolete extension methods above don't have access to the current HtmlHelper, we need to create a fake one, unfortunately however this will not pertain the current views viewdata, tempdata or model state so should not be used")]
|
||||
[Obsolete("This shouldn't need to be used but because the obsolete extension methods above don't have access to the current HtmlHelper, we need to create a fake one, unfortunately however this will not pertain the current views viewdata, tempdata or model state so should not be used")]
|
||||
private static HtmlHelper CreateHtmlHelper(object model)
|
||||
{
|
||||
var cc = new ControllerContext
|
||||
|
||||
@@ -756,8 +756,7 @@ namespace Umbraco.Web
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Wrap
|
||||
|
||||
public static HtmlTagWrapper Wrap(this HtmlHelper html, string tag, string innerText, params IHtmlTagWrapper[] children)
|
||||
@@ -823,7 +822,71 @@ namespace Umbraco.Web
|
||||
return item;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
#region canvasdesigner
|
||||
|
||||
public static IHtmlString EnableCanvasDesigner(this HtmlHelper html,
|
||||
UrlHelper url,
|
||||
UmbracoContext umbCtx)
|
||||
{
|
||||
return html.EnableCanvasDesigner(url, umbCtx, string.Empty, string.Empty);
|
||||
}
|
||||
|
||||
public static IHtmlString EnableCanvasDesigner(this HtmlHelper html,
|
||||
UrlHelper url,
|
||||
UmbracoContext umbCtx, string canvasdesignerConfigPath)
|
||||
{
|
||||
return html.EnableCanvasDesigner(url, umbCtx, canvasdesignerConfigPath, string.Empty);
|
||||
}
|
||||
|
||||
public static IHtmlString EnableCanvasDesigner(this HtmlHelper html,
|
||||
UrlHelper url,
|
||||
UmbracoContext umbCtx, string canvasdesignerConfigPath, string canvasdesignerPalettesPath)
|
||||
{
|
||||
|
||||
var umbracoPath = url.Content(SystemDirectories.Umbraco);
|
||||
|
||||
string previewLink = @"<script src=""{0}/lib/jquery/jquery.min.js"" type=""text/javascript""></script>" +
|
||||
@"<script src=""{1}"" type=""text/javascript""></script>" +
|
||||
@"<script src=""{2}"" type=""text/javascript""></script>" +
|
||||
@"<script type=""text/javascript"">var pageId = '{3}'</script>" +
|
||||
@"<script src=""{0}/js/canvasdesigner.front.js"" type=""text/javascript""></script>";
|
||||
|
||||
string noPreviewLinks = @"<link href=""{1}"" type=""text/css"" rel=""stylesheet"" data-title=""canvasdesignerCss"" />";
|
||||
|
||||
// Get page value
|
||||
int pageId = umbCtx.PublishedContentRequest.UmbracoPage.PageID;
|
||||
string[] path = umbCtx.PublishedContentRequest.UmbracoPage.SplitPath;
|
||||
string result = string.Empty;
|
||||
string cssPath = CanvasDesignerUtility.GetStylesheetPath(path, false);
|
||||
|
||||
if (umbCtx.InPreviewMode)
|
||||
{
|
||||
canvasdesignerConfigPath = string.IsNullOrEmpty(canvasdesignerConfigPath) == false
|
||||
? canvasdesignerConfigPath
|
||||
: string.Format("{0}/js/canvasdesigner.config.js", umbracoPath);
|
||||
canvasdesignerPalettesPath = string.IsNullOrEmpty(canvasdesignerPalettesPath) == false
|
||||
? canvasdesignerPalettesPath
|
||||
: string.Format("{0}/js/canvasdesigner.palettes.js", umbracoPath);
|
||||
|
||||
if (string.IsNullOrEmpty(cssPath) == false)
|
||||
result = string.Format(noPreviewLinks, cssPath) + Environment.NewLine;
|
||||
|
||||
result = result + string.Format(previewLink, umbracoPath, canvasdesignerConfigPath, canvasdesignerPalettesPath, pageId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get css path for current page
|
||||
if (string.IsNullOrEmpty(cssPath) == false)
|
||||
result = string.Format(noPreviewLinks, cssPath);
|
||||
}
|
||||
|
||||
return new HtmlString(result);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ using Umbraco.Core.Xml;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Security;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Umbraco.Core.Cache;
|
||||
|
||||
namespace Umbraco.Web
|
||||
@@ -1170,52 +1173,44 @@ namespace Umbraco.Web
|
||||
|
||||
#region canvasdesigner
|
||||
|
||||
public HtmlString EnableCanvasDesigner()
|
||||
[Obsolete("Use EnableCanvasDesigner on the HtmlHelper extensions instead")]
|
||||
public IHtmlString EnableCanvasDesigner()
|
||||
{
|
||||
return EnableCanvasDesigner(string.Empty, string.Empty);
|
||||
}
|
||||
|
||||
public HtmlString EnableCanvasDesigner(string canvasdesignerConfigPath)
|
||||
[Obsolete("Use EnableCanvasDesigner on the HtmlHelper extensions instead")]
|
||||
public IHtmlString EnableCanvasDesigner(string canvasdesignerConfigPath)
|
||||
{
|
||||
return EnableCanvasDesigner(canvasdesignerConfigPath, string.Empty);
|
||||
}
|
||||
|
||||
public HtmlString EnableCanvasDesigner(string canvasdesignerConfigPath, string canvasdesignerPalettesPath)
|
||||
[Obsolete("Use EnableCanvasDesigner on the HtmlHelper extensions instead")]
|
||||
public IHtmlString EnableCanvasDesigner(string canvasdesignerConfigPath, string canvasdesignerPalettesPath)
|
||||
{
|
||||
var html = CreateHtmlHelper("");
|
||||
var urlHelper = new UrlHelper(UmbracoContext.HttpContext.Request.RequestContext);
|
||||
return html.EnableCanvasDesigner(urlHelper, UmbracoContext, canvasdesignerConfigPath, canvasdesignerPalettesPath);
|
||||
}
|
||||
|
||||
string previewLink = @"<script src=""/Umbraco/lib/jquery/jquery.min.js"" type=""text/javascript""></script>" +
|
||||
@"<script src=""{0}"" type=""text/javascript""></script>" +
|
||||
@"<script src=""{1}"" type=""text/javascript""></script>" +
|
||||
@"<script type=""text/javascript"">var pageId = '{2}'</script>" +
|
||||
@"<script src=""/umbraco/js/canvasdesigner.front.js"" type=""text/javascript""></script>";
|
||||
|
||||
string noPreviewLinks = @"<link href=""{0}"" type=""text/css"" rel=""stylesheet"" data-title=""canvasdesignerCss"" />";
|
||||
|
||||
// Get page value
|
||||
int pageId = UmbracoContext.PublishedContentRequest.UmbracoPage.PageID;
|
||||
string[] path = UmbracoContext.PublishedContentRequest.UmbracoPage.SplitPath;
|
||||
string result = string.Empty;
|
||||
string cssPath = CanvasDesignerUtility.GetStylesheetPath(path, false);
|
||||
|
||||
if (UmbracoContext.Current.InPreviewMode)
|
||||
[Obsolete("This shouldn't need to be used but because the obsolete extension methods above don't have access to the current HtmlHelper, we need to create a fake one, unfortunately however this will not pertain the current views viewdata, tempdata or model state so should not be used")]
|
||||
private HtmlHelper CreateHtmlHelper(object model)
|
||||
{
|
||||
var cc = new ControllerContext
|
||||
{
|
||||
canvasdesignerConfigPath = !string.IsNullOrEmpty(canvasdesignerConfigPath) ? canvasdesignerConfigPath : "/umbraco/js/canvasdesigner.config.js";
|
||||
canvasdesignerPalettesPath = !string.IsNullOrEmpty(canvasdesignerPalettesPath) ? canvasdesignerPalettesPath : "/umbraco/js/canvasdesigner.palettes.js";
|
||||
|
||||
if (!string.IsNullOrEmpty(cssPath))
|
||||
result = string.Format(noPreviewLinks, cssPath) + Environment.NewLine;
|
||||
RequestContext = UmbracoContext.HttpContext.Request.RequestContext
|
||||
};
|
||||
var viewContext = new ViewContext(cc, new FakeView(), new ViewDataDictionary(model), new TempDataDictionary(), new StringWriter());
|
||||
var htmlHelper = new HtmlHelper(viewContext, new ViewPage());
|
||||
return htmlHelper;
|
||||
}
|
||||
|
||||
result = result + string.Format(previewLink, canvasdesignerConfigPath, canvasdesignerPalettesPath, pageId);
|
||||
}
|
||||
else
|
||||
[Obsolete("This shouldn't need to be used but because the obsolete extension methods above don't have access to the current HtmlHelper, we need to create a fake one, unfortunately however this will not pertain the current views viewdata, tempdata or model state so should not be used")]
|
||||
private class FakeView : IView
|
||||
{
|
||||
public void Render(ViewContext viewContext, TextWriter writer)
|
||||
{
|
||||
// Get css path for current page
|
||||
if (!string.IsNullOrEmpty(cssPath))
|
||||
result = string.Format(noPreviewLinks, cssPath);
|
||||
}
|
||||
|
||||
return new HtmlString(result);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user