@@ -0,0 +1,106 @@
|
||||
@using System.Web
|
||||
@using Microsoft.AspNetCore.Html
|
||||
@using Newtonsoft.Json.Linq
|
||||
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<dynamic>
|
||||
|
||||
@*
|
||||
Razor helpers located at the bottom of this file
|
||||
*@
|
||||
|
||||
@if (Model is JObject && Model?.sections is not null)
|
||||
{
|
||||
var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1;
|
||||
|
||||
<div class="umb-grid">
|
||||
@if (oneColumn)
|
||||
{
|
||||
foreach (var section in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
@foreach (var row in section.rows)
|
||||
{
|
||||
renderRow(row);
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row clearfix">
|
||||
@foreach (var sec in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
<div class="col-md-@sec.grid column">
|
||||
@foreach (var row in sec.rows)
|
||||
{
|
||||
renderRow(row);
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions{
|
||||
|
||||
private async Task renderRow(dynamic row)
|
||||
{
|
||||
<div @RenderElementAttributes(row)>
|
||||
<div class="row clearfix">
|
||||
@foreach (var area in row.areas)
|
||||
{
|
||||
<div class="col-md-@area.grid column">
|
||||
<div @RenderElementAttributes(area)>
|
||||
@foreach (var control in area.controls)
|
||||
{
|
||||
if (control?.editor?.view != null)
|
||||
{
|
||||
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@functions{
|
||||
|
||||
public static HtmlString RenderElementAttributes(dynamic contentItem)
|
||||
{
|
||||
var attrs = new List<string>();
|
||||
JObject cfg = contentItem.config;
|
||||
|
||||
if (cfg != null)
|
||||
{
|
||||
foreach (JProperty property in cfg.Properties())
|
||||
{
|
||||
var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString());
|
||||
attrs.Add(property.Name + "=\"" + propertyValue + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
JObject style = contentItem.styles;
|
||||
|
||||
if (style != null) {
|
||||
var cssVals = new List<string>();
|
||||
foreach (JProperty property in style.Properties())
|
||||
{
|
||||
var propertyValue = property.Value.ToString();
|
||||
if (string.IsNullOrWhiteSpace(propertyValue) == false)
|
||||
{
|
||||
cssVals.Add(property.Name + ":" + propertyValue + ";");
|
||||
}
|
||||
}
|
||||
|
||||
if (cssVals.Any())
|
||||
attrs.Add("style='" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "'");
|
||||
}
|
||||
|
||||
return new HtmlString(string.Join(" ", attrs));
|
||||
}
|
||||
}
|
112
umbraco-cms/app/umbracocms/Views/Partials/grid/bootstrap3.cshtml
Normal file
112
umbraco-cms/app/umbracocms/Views/Partials/grid/bootstrap3.cshtml
Normal file
@@ -0,0 +1,112 @@
|
||||
@using System.Web
|
||||
@using Microsoft.AspNetCore.Html
|
||||
@using Newtonsoft.Json.Linq
|
||||
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<dynamic>
|
||||
|
||||
@if (Model is JObject && Model?.sections is not null)
|
||||
{
|
||||
var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1;
|
||||
|
||||
<div class="umb-grid">
|
||||
@if (oneColumn)
|
||||
{
|
||||
foreach (var section in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
@foreach (var row in section.rows)
|
||||
{
|
||||
renderRow(row, true);
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="container">
|
||||
<div class="row clearfix">
|
||||
@foreach (var sec in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
<div class="col-md-@sec.grid column">
|
||||
@foreach (var row in sec.rows)
|
||||
{
|
||||
renderRow(row, false);
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions{
|
||||
|
||||
private async Task renderRow(dynamic row, bool singleColumn)
|
||||
{
|
||||
<div @RenderElementAttributes(row)>
|
||||
@if (singleColumn) {
|
||||
@:<div class="container">
|
||||
}
|
||||
<div class="row clearfix">
|
||||
@foreach (var area in row.areas)
|
||||
{
|
||||
<div class="col-md-@area.grid column">
|
||||
<div @RenderElementAttributes(area)>
|
||||
@foreach (var control in area.controls)
|
||||
{
|
||||
if (control?.editor?.view != null)
|
||||
{
|
||||
<text>@await Html.PartialAsync("grid/editors/base", (object)control)</text>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@if (singleColumn) {
|
||||
@:</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@functions{
|
||||
|
||||
public static HtmlString RenderElementAttributes(dynamic contentItem)
|
||||
{
|
||||
var attrs = new List<string>();
|
||||
JObject cfg = contentItem.config;
|
||||
|
||||
if (cfg != null)
|
||||
{
|
||||
foreach (JProperty property in cfg.Properties())
|
||||
{
|
||||
var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString());
|
||||
attrs.Add(property.Name + "=\"" + propertyValue + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
JObject style = contentItem.styles;
|
||||
|
||||
if (style != null)
|
||||
{
|
||||
var cssVals = new List<string>();
|
||||
foreach (JProperty property in style.Properties())
|
||||
{
|
||||
var propertyValue = property.Value.ToString();
|
||||
if (string.IsNullOrWhiteSpace(propertyValue) == false)
|
||||
{
|
||||
cssVals.Add(property.Name + ":" + propertyValue + ";");
|
||||
}
|
||||
}
|
||||
|
||||
if (cssVals.Any())
|
||||
attrs.Add("style=\"" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "\"");
|
||||
}
|
||||
|
||||
return new HtmlString(string.Join(" ", attrs));
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
@model dynamic
|
||||
|
||||
@try
|
||||
{
|
||||
string editor = EditorView(Model);
|
||||
<text>@await Html.PartialAsync(editor, Model as object)</text>
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
<pre>@ex.ToString()</pre>
|
||||
}
|
||||
|
||||
@functions{
|
||||
|
||||
public static string EditorView(dynamic contentItem)
|
||||
{
|
||||
string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString();
|
||||
view = view.Replace(".html", ".cshtml");
|
||||
|
||||
if (!view.Contains("/"))
|
||||
{
|
||||
view = "grid/editors/" + view;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<dynamic>
|
||||
|
||||
@if (Model is not null)
|
||||
{
|
||||
string embedValue = Convert.ToString(Model.value);
|
||||
embedValue = embedValue.DetectIsJson() ? Model.value.preview : Model.value;
|
||||
|
||||
<div class="video-wrapper">
|
||||
@Html.Raw(embedValue)
|
||||
</div>
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<dynamic>
|
||||
|
||||
@if (Model?.value is not null)
|
||||
{
|
||||
string macroAlias = Model.value.macroAlias.ToString();
|
||||
var parameters = new Dictionary<string,object>();
|
||||
foreach (var mpd in Model.value.macroParamsDictionary)
|
||||
{
|
||||
parameters.Add(mpd.Name, mpd.Value);
|
||||
}
|
||||
|
||||
<text>
|
||||
@await Umbraco.RenderMacroAsync(macroAlias, parameters)
|
||||
</text>
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Cms.Core.Media
|
||||
@using Umbraco.Cms.Core.PropertyEditors.ValueConverters
|
||||
@inject IImageUrlGenerator ImageUrlGenerator
|
||||
|
||||
@if (Model?.value is not null)
|
||||
{
|
||||
var url = Model.value.image;
|
||||
|
||||
if (Model.editor.config != null && Model.editor.config.size != null)
|
||||
{
|
||||
if (Model.value.coordinates != null)
|
||||
{
|
||||
url = ImageCropperTemplateCoreExtensions.GetCropUrl(
|
||||
(string)url,
|
||||
ImageUrlGenerator,
|
||||
width: (int)Model.editor.config.size.width,
|
||||
height: (int)Model.editor.config.size.height,
|
||||
cropAlias: "default",
|
||||
cropDataSet: new ImageCropperValue
|
||||
{
|
||||
Crops = new[]
|
||||
{
|
||||
new ImageCropperValue.ImageCropperCrop
|
||||
{
|
||||
Alias = "default",
|
||||
Coordinates = new ImageCropperValue.ImageCropperCropCoordinates
|
||||
{
|
||||
X1 = (decimal)Model.value.coordinates.x1,
|
||||
Y1 = (decimal)Model.value.coordinates.y1,
|
||||
X2 = (decimal)Model.value.coordinates.x2,
|
||||
Y2 = (decimal)Model.value.coordinates.y2
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
url = ImageCropperTemplateCoreExtensions.GetCropUrl(
|
||||
(string)url,
|
||||
ImageUrlGenerator,
|
||||
width: (int)Model.editor.config.size.width,
|
||||
height: (int)Model.editor.config.size.height,
|
||||
cropDataSet: new ImageCropperValue
|
||||
{
|
||||
FocalPoint = new ImageCropperValue.ImageCropperFocalPoint
|
||||
{
|
||||
Top = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.top,
|
||||
Left = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.left
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var altText = Model.value.altText ?? Model.value.caption ?? string.Empty;
|
||||
|
||||
<img src="@url" alt="@altText">
|
||||
|
||||
if (Model.value.caption != null)
|
||||
{
|
||||
<p class="caption">@Model.value.caption</p>
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
@using Umbraco.Cms.Core.Templates
|
||||
@model dynamic
|
||||
@inject HtmlLocalLinkParser HtmlLocalLinkParser;
|
||||
@inject HtmlUrlParser HtmlUrlParser;
|
||||
@inject HtmlImageSourceParser HtmlImageSourceParser;
|
||||
|
||||
@{
|
||||
var value = HtmlLocalLinkParser.EnsureInternalLinks(Model?.value.ToString());
|
||||
value = HtmlUrlParser.EnsureUrls(value);
|
||||
value = HtmlImageSourceParser.EnsureImageSources(value);
|
||||
}
|
||||
|
||||
@Html.Raw(value)
|
@@ -0,0 +1,23 @@
|
||||
@using System.Web
|
||||
@model dynamic
|
||||
|
||||
@if (Model?.editor.config.markup is not null)
|
||||
{
|
||||
string markup = Model.editor.config.markup.ToString();
|
||||
markup = markup.Replace("#value#", Html.ReplaceLineBreaks((string)Model.value.ToString()).ToString());
|
||||
|
||||
if (Model.editor.config.style != null)
|
||||
{
|
||||
markup = markup.Replace("#style#", Model.editor.config.style.ToString());
|
||||
}
|
||||
|
||||
<text>
|
||||
@Html.Raw(markup)
|
||||
</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>
|
||||
<div style="@Model?.editor.config.style">@Model?.value</div>
|
||||
</text>
|
||||
}
|
Reference in New Issue
Block a user