mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 20:16:15 +08:00
Merge from Orchard/dev.
This commit is contained in:
@@ -11,9 +11,9 @@ namespace Orchard.Layouts {
|
||||
builder
|
||||
.AddImageSet("layouts")
|
||||
.Add(T("Layouts"), "8.5", layouts => layouts
|
||||
.Action("List", "Admin", new {id = "Layout", area = "Contents"})
|
||||
.Action("List", "Admin", new {id = "Layout", area = "Contents"}).Permission(Permissions.ManageLayouts)
|
||||
.LinkToFirstChild(false)
|
||||
.Add(T("Elements"), "1", elements => elements.Action("Index", "BlueprintAdmin", new {area = "Orchard.Layouts"})));
|
||||
.Add(T("Elements"), "1", elements => elements.Action("Index", "BlueprintAdmin", new {area = "Orchard.Layouts"}).Permission(Permissions.ManageLayouts)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,45 +74,6 @@
|
||||
return host.addElement(contentType);
|
||||
};
|
||||
|
||||
$scope.toggleInlineEditing = function () {
|
||||
if (!$scope.element.inlineEditingIsActive) {
|
||||
$scope.element.inlineEditingIsActive = true;
|
||||
$element.find(".layout-toolbar-container").show();
|
||||
var selector = "#layout-editor-" + $scope.$id + " .layout-html .layout-content-markup[data-templated=false]";
|
||||
var firstContentEditorId = $(selector).first().attr("id");
|
||||
tinymce.init({
|
||||
selector: selector,
|
||||
theme: "modern",
|
||||
schema: "html5",
|
||||
plugins: [
|
||||
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
|
||||
"searchreplace wordcount visualblocks visualchars code fullscreen",
|
||||
"insertdatetime media nonbreaking table contextmenu directionality",
|
||||
"emoticons template paste textcolor colorpicker textpattern",
|
||||
"fullscreen autoresize"
|
||||
],
|
||||
toolbar: "undo redo cut copy paste | bold italic | bullist numlist outdent indent formatselect | alignleft aligncenter alignright alignjustify ltr rtl | link unlink charmap | code fullscreen close",
|
||||
convert_urls: false,
|
||||
valid_elements: "*[*]",
|
||||
// Shouldn't be needed due to the valid_elements setting, but TinyMCE would strip script.src without it.
|
||||
extended_valid_elements: "script[type|defer|src|language]",
|
||||
statusbar: false,
|
||||
skin: "orchardlightgray",
|
||||
inline: true,
|
||||
fixed_toolbar_container: "#layout-editor-" + $scope.$id + " .layout-toolbar-container",
|
||||
init_instance_callback: function (editor) {
|
||||
if (editor.id == firstContentEditorId)
|
||||
tinymce.execCommand("mceFocus", false, editor.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
tinymce.remove("#layout-editor-" + $scope.$id + " .layout-content-markup");
|
||||
$element.find(".layout-toolbar-container").hide();
|
||||
$scope.element.inlineEditingIsActive = false;
|
||||
}
|
||||
};
|
||||
|
||||
$(document).on("cut copy paste", function (e) {
|
||||
// If the pseudo clipboard was already invoked (which happens on the first clipboard
|
||||
// operation after page load even if native clipboard support exists) then sit this
|
||||
@@ -164,23 +125,12 @@
|
||||
element.find(".layout-toolbar-container").click(function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
// Intercept mousedown on editor while in inline editing mode to
|
||||
// prevent current editor from losing focus.
|
||||
element.mousedown(function (e) {
|
||||
if (scope.element.inlineEditingIsActive) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
})
|
||||
// Unfocus and unselect everything on click outside of canvas.
|
||||
$(window).click(function (e) {
|
||||
// Except when in inline editing mode.
|
||||
if (!scope.element.inlineEditingIsActive) {
|
||||
scope.$apply(function () {
|
||||
scope.element.activeElement = null;
|
||||
scope.element.focusedElement = null;
|
||||
});
|
||||
}
|
||||
scope.$apply(function () {
|
||||
scope.element.activeElement = null;
|
||||
scope.element.focusedElement = null;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,13 +35,6 @@
|
||||
templateUrl: environment.templateUrl("Html"),
|
||||
replace: true,
|
||||
link: function (scope, element) {
|
||||
// Mouse down events must not be intercepted by drag and drop while inline editing is active,
|
||||
// otherwise clicks in inline editors will have no effect.
|
||||
element.find(".layout-content-markup").mousedown(function (e) {
|
||||
if (scope.element.editor.inlineEditingIsActive) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
var resetFocus = false;
|
||||
var element = $scope.element;
|
||||
|
||||
if (element.editor.isDragging || element.editor.inlineEditingIsActive)
|
||||
if (element.editor.isDragging)
|
||||
return;
|
||||
|
||||
// If native clipboard support exists, the pseudo-clipboard will have been disabled.
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
this.focusedElement = null;
|
||||
this.dropTargetElement = null;
|
||||
this.isDragging = false;
|
||||
this.inlineEditingIsActive = false;
|
||||
this.isResizing = false;
|
||||
|
||||
this.resetToolboxElements = function () {
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
this.setIsActive = function (value) {
|
||||
if (!this.editor)
|
||||
return;
|
||||
if (this.editor.isDragging || this.editor.inlineEditingIsActive || this.editor.isResizing)
|
||||
if (this.editor.isDragging || this.editor.isResizing)
|
||||
return;
|
||||
|
||||
if (value)
|
||||
@@ -77,7 +77,7 @@
|
||||
return;
|
||||
if (!this.children && this.isTemplated)
|
||||
return;
|
||||
if (this.editor.isDragging || this.editor.inlineEditingIsActive || this.editor.isResizing)
|
||||
if (this.editor.isDragging || this.editor.isResizing)
|
||||
return;
|
||||
|
||||
this.editor.focusedElement = this;
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,8 @@ namespace Orchard.Layouts.Controllers {
|
||||
ICultureAccessor cultureAccessor,
|
||||
IShapeFactory shapeFactory,
|
||||
ITransactionManager transactionManager,
|
||||
ISignals signals) {
|
||||
ISignals signals,
|
||||
IOrchardServices orchardServices) {
|
||||
|
||||
_elementBlueprintService = elementBlueprintService;
|
||||
_notifier = notifier;
|
||||
@@ -43,12 +44,19 @@ namespace Orchard.Layouts.Controllers {
|
||||
_shapeFactory = shapeFactory;
|
||||
_transactionManager = transactionManager;
|
||||
_signals = signals;
|
||||
Services = orchardServices;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var blueprints = _elementBlueprintService.GetBlueprints().ToArray();
|
||||
var viewModel = new BlueprintsIndexViewModel {
|
||||
Blueprints = blueprints
|
||||
@@ -57,6 +65,10 @@ namespace Orchard.Layouts.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult Browse() {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var categories = RemoveBlueprints(_elementManager.GetCategories(DescribeElementsContext.Empty)).ToArray();
|
||||
var viewModel = new BrowseElementsViewModel {
|
||||
Categories = categories
|
||||
@@ -65,6 +77,10 @@ namespace Orchard.Layouts.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult Create(string id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(id))
|
||||
return RedirectToAction("Browse");
|
||||
|
||||
@@ -80,6 +96,10 @@ namespace Orchard.Layouts.Controllers {
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Create(string id, CreateElementBlueprintViewModel model) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var describeContext = DescribeElementsContext.Empty;
|
||||
var descriptor = _elementManager.GetElementDescriptorByTypeName(describeContext, id);
|
||||
var baseElement = _elementManager.ActivateElement(descriptor);
|
||||
@@ -100,7 +120,11 @@ namespace Orchard.Layouts.Controllers {
|
||||
return RedirectToAction("Edit", new { id = blueprint.Id });
|
||||
}
|
||||
|
||||
public ViewResult Edit(int id) {
|
||||
public ActionResult Edit(int id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var blueprint = _elementBlueprintService.GetBlueprint(id);
|
||||
var describeContext = DescribeElementsContext.Empty;
|
||||
var descriptor = _elementManager.GetElementDescriptorByTypeName(describeContext, blueprint.BaseElementTypeName);
|
||||
@@ -125,6 +149,10 @@ namespace Orchard.Layouts.Controllers {
|
||||
[HttpPost]
|
||||
[ValidateInput(false)]
|
||||
public ActionResult Edit(int id, ElementDataViewModel model) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var blueprint = _elementBlueprintService.GetBlueprint(id);
|
||||
var describeContext = DescribeElementsContext.Empty;
|
||||
var descriptor = _elementManager.GetElementDescriptorByTypeName(describeContext, blueprint.BaseElementTypeName);
|
||||
@@ -154,6 +182,10 @@ namespace Orchard.Layouts.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult Properties(int id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var blueprint = _elementBlueprintService.GetBlueprint(id);
|
||||
var describeContext = DescribeElementsContext.Empty;
|
||||
var descriptor = _elementManager.GetElementDescriptorByTypeName(describeContext, blueprint.BaseElementTypeName);
|
||||
@@ -171,6 +203,10 @@ namespace Orchard.Layouts.Controllers {
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Properties(int id, ElementBlueprintPropertiesViewModel model) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var blueprint = _elementBlueprintService.GetBlueprint(id);
|
||||
var describeContext = DescribeElementsContext.Empty;
|
||||
var descriptor = _elementManager.GetElementDescriptorByTypeName(describeContext, blueprint.BaseElementTypeName);
|
||||
@@ -191,7 +227,12 @@ namespace Orchard.Layouts.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Delete(int id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
var blueprint = _elementBlueprintService.GetBlueprint(id);
|
||||
|
||||
if (blueprint == null)
|
||||
@@ -204,7 +245,12 @@ namespace Orchard.Layouts.Controllers {
|
||||
|
||||
[FormValueRequired("submit.BulkEdit")]
|
||||
[ActionName("Index")]
|
||||
[HttpPost]
|
||||
public ActionResult BulkDelete(IEnumerable<int> blueprintIds) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageLayouts, T("Not authorized to manage layouts."))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
if (blueprintIds == null || !blueprintIds.Any()) {
|
||||
_notifier.Error(T("Please select the blueprints to delete."));
|
||||
}
|
||||
|
||||
@@ -142,18 +142,7 @@ namespace Orchard.Layouts.Controllers {
|
||||
_objectStore.Set(session, state);
|
||||
return RedirectToAction("Edit", new {session = session});
|
||||
}
|
||||
|
||||
public RedirectToRouteResult Add(string session, string typeName, int? contentId = null, string contentType = null) {
|
||||
var state = new ElementSessionState {
|
||||
TypeName = typeName,
|
||||
ContentId = contentId,
|
||||
ContentType = contentType
|
||||
};
|
||||
|
||||
_objectStore.Set(session, state);
|
||||
return RedirectToAction("Edit", new { session = session });
|
||||
}
|
||||
|
||||
|
||||
public ViewResult Edit(string session) {
|
||||
var sessionState = _objectStore.Get<ElementSessionState>(session);
|
||||
var contentId = sessionState.ContentId;
|
||||
|
||||
@@ -6,6 +6,7 @@ using Orchard.ContentManagement;
|
||||
using Orchard.Layouts.Elements;
|
||||
using Orchard.Layouts.Framework.Elements;
|
||||
using Orchard.Layouts.Services;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Admin;
|
||||
|
||||
namespace Orchard.Layouts.Controllers {
|
||||
@@ -15,15 +16,25 @@ namespace Orchard.Layouts.Controllers {
|
||||
private readonly ILayoutManager _layoutManager;
|
||||
private readonly ILayoutModelMapper _mapper;
|
||||
|
||||
public LayoutController(IContentManager contentManager, ILayoutManager layoutManager, ILayoutModelMapper mapper) {
|
||||
public LayoutController(
|
||||
IContentManager contentManager,
|
||||
ILayoutManager layoutManager,
|
||||
ILayoutModelMapper mapper,
|
||||
IOrchardServices orchardServices) {
|
||||
|
||||
_contentManager = contentManager;
|
||||
_layoutManager = layoutManager;
|
||||
_mapper = mapper;
|
||||
Services = orchardServices;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
[HttpPost, ValidateInput(enableValidation: false)]
|
||||
public ContentResult ApplyTemplate(int? templateId = null, string layoutData = null, int? contentId = null, string contentType = null) {
|
||||
public ActionResult ApplyTemplate(int? templateId = null, string layoutData = null, int? contentId = null, string contentType = null) {
|
||||
var template = templateId != null ? _layoutManager.GetLayout(templateId.Value) : null;
|
||||
var templateElements = template != null ? _layoutManager.LoadElements(template).ToList() : default(IEnumerable<Element>);
|
||||
var describeContext = CreateDescribeElementsContext(contentId, contentType);
|
||||
|
||||
@@ -90,9 +90,18 @@ namespace Orchard.Layouts.Drivers {
|
||||
|
||||
protected override DriverResult Editor(LayoutPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_Layout_Edit", () => {
|
||||
|
||||
if (part.Id == 0 && String.IsNullOrWhiteSpace(part.LayoutData)) {
|
||||
part.LayoutData = part.TypePartDefinition.Settings.GetModel<LayoutTypePartSettings>().DefaultLayoutData;
|
||||
|
||||
var settings = part.TypePartDefinition.Settings.GetModel<LayoutTypePartSettings>();
|
||||
|
||||
// If the default layout setting is left empty, use the one from the service
|
||||
if (String.IsNullOrWhiteSpace(settings.DefaultLayoutData)) {
|
||||
var defaultData = _serializer.Serialize(_layoutManager.CreateDefaultLayout());
|
||||
part.LayoutData = defaultData;
|
||||
}
|
||||
else {
|
||||
part.LayoutData = settings.DefaultLayoutData;
|
||||
}
|
||||
}
|
||||
|
||||
var viewModel = new LayoutPartViewModel {
|
||||
@@ -140,6 +149,11 @@ namespace Orchard.Layouts.Drivers {
|
||||
}
|
||||
|
||||
protected override void Importing(LayoutPart part, ImportContentContext context) {
|
||||
// Don't do anything if the tag is not specified.
|
||||
if (context.Data.Element(part.PartDefinition.Name) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.ImportChildEl(part.PartDefinition.Name, "LayoutData", s => {
|
||||
part.LayoutData = s;
|
||||
_layoutManager.Importing(new ImportLayoutContext {
|
||||
|
||||
@@ -290,11 +290,11 @@ namespace Orchard.Layouts.Drivers {
|
||||
var query = element.QueryId != null ? _contentManager.Get<QueryPart>(element.QueryId.Value) : default(QueryPart);
|
||||
var layout = query != null && element.LayoutId != null ? _layoutRepository.Get(element.LayoutId.Value) : default(LayoutRecord);
|
||||
var queryIdentity = query != null ? _contentManager.GetItemMetadata(query).Identity.ToString() : default(string);
|
||||
var layoutIndex = layout != null ? query.Layouts.IndexOf(layout) : default(int?);
|
||||
var layoutIndex = layout != null ? query.Layouts.IndexOf(layout) : -1; // -1 is the Default Layout.
|
||||
|
||||
if (queryIdentity != null && layoutIndex != null) {
|
||||
if (queryIdentity != null) {
|
||||
context.ExportableData["QueryId"] = queryIdentity;
|
||||
context.ExportableData["LayoutIndex"] = layoutIndex.Value.ToString();
|
||||
context.ExportableData["LayoutIndex"] = layoutIndex.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,10 +307,9 @@ namespace Orchard.Layouts.Drivers {
|
||||
|
||||
var queryPart = query.As<QueryPart>();
|
||||
var layoutIndex = XmlHelper.Parse<int>(context.ExportableData.Get("LayoutIndex"));
|
||||
var layout = queryPart.Layouts[layoutIndex];
|
||||
|
||||
element.QueryId = queryPart.Id;
|
||||
element.LayoutId = layout.Id;
|
||||
element.LayoutId = layoutIndex != -1 ? queryPart.Layouts[layoutIndex].Id : -1;
|
||||
}
|
||||
|
||||
private static string GetLayoutDescription(IEnumerable<LayoutDescriptor> layouts, LayoutRecord l) {
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Orchard.Layouts.Elements {
|
||||
}
|
||||
|
||||
public int? Width {
|
||||
get { return this.Retrieve<int?>("Width") ?? this.Retrieve<int?>("ColumnSpan") ?? 0; } // Falling back on "ColumnSpan" for backward compatibility.
|
||||
get { return this.Retrieve<int?>("Width") ?? this.Retrieve<int?>("ColumnSpan") ?? 12; } // Falling back on "ColumnSpan" for backward compatibility.
|
||||
set { this.Store(x => x.Width, value); }
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ using Orchard.Localization;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Layouts.Framework.Elements {
|
||||
public abstract class Element {
|
||||
public abstract class Element : IElement {
|
||||
protected Element() {
|
||||
T = NullLocalizer.Instance;
|
||||
Data = new ElementDataDictionary();
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Orchard.Layouts.Framework.Elements {
|
||||
public interface IElement : ITransientDependency {}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ namespace Orchard.Layouts.Handlers {
|
||||
private readonly IContentPartDisplay _contentPartDisplay;
|
||||
private readonly IShapeDisplay _shapeDisplay;
|
||||
private readonly ILayoutSerializer _serializer;
|
||||
private readonly IStaticHttpContextScopeFactory _staticHttpContextScopeFactory;
|
||||
private readonly IAliasService _aliasService;
|
||||
|
||||
public LayoutPartHandler(
|
||||
@@ -26,7 +25,6 @@ namespace Orchard.Layouts.Handlers {
|
||||
IContentPartDisplay contentPartDisplay,
|
||||
IShapeDisplay shapeDisplay,
|
||||
ILayoutSerializer serializer,
|
||||
IStaticHttpContextScopeFactory staticHttpContextScopeFactory,
|
||||
IAliasService aliasService) {
|
||||
|
||||
_layoutManager = layoutManager;
|
||||
@@ -34,7 +32,6 @@ namespace Orchard.Layouts.Handlers {
|
||||
_contentPartDisplay = contentPartDisplay;
|
||||
_shapeDisplay = shapeDisplay;
|
||||
_serializer = serializer;
|
||||
_staticHttpContextScopeFactory = staticHttpContextScopeFactory;
|
||||
_aliasService = aliasService;
|
||||
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
@@ -44,22 +41,13 @@ namespace Orchard.Layouts.Handlers {
|
||||
|
||||
private void IndexLayout(IndexContentContext context, LayoutPart part) {
|
||||
var layoutShape = _contentPartDisplay.BuildDisplay(part);
|
||||
var layoutHtml = RenderShape(layoutShape);
|
||||
var layoutHtml = _shapeDisplay.Display(layoutShape);
|
||||
|
||||
context.DocumentIndex
|
||||
.Add("body", layoutHtml).RemoveTags().Analyze()
|
||||
.Add("format", "html").Store();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method of rendering is safe even in background tasks.
|
||||
/// </summary>
|
||||
private string RenderShape(dynamic shape) {
|
||||
using (_staticHttpContextScopeFactory.CreateStaticScope()) {
|
||||
return _shapeDisplay.Display(shape);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTemplateClients(PublishContentContext context, LayoutPart part) {
|
||||
UpdateTemplateClients(part);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace Orchard.Layouts {
|
||||
.WithPart("LayoutPart", p => p
|
||||
.WithSetting("LayoutTypePartSettings.IsTemplate", "True"))
|
||||
.DisplayedAs("Layout")
|
||||
.Listable()
|
||||
.Draftable());
|
||||
|
||||
ContentDefinitionManager.AlterTypeDefinition("LayoutWidget", type => type
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Orchard.Layouts.Models {
|
||||
public class ElementSessionState {
|
||||
[Serializable]
|
||||
public class ElementSessionState {
|
||||
public string TypeName { get; set; }
|
||||
public string ElementData { get; set; }
|
||||
public string ElementEditorData { get; set; }
|
||||
public int? ContentId { get; set; }
|
||||
public string ContentType { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ Features:
|
||||
Orchard.Layouts:
|
||||
Name: Layouts
|
||||
Description: Provides tools to create layouts.
|
||||
Dependencies: Common, Orchard.jQuery, Orchard.Forms, Orchard.Tokens, Orchard.MediaLibrary, TinyMce, Orchard.Widgets
|
||||
Dependencies: Common, Orchard.jQuery, Orchard.Forms, Orchard.Tokens, Orchard.MediaLibrary, Orchard.Widgets
|
||||
Category: Layout
|
||||
Orchard.Layouts.Snippets:
|
||||
Name: Layout Snippets
|
||||
|
||||
@@ -358,6 +358,7 @@
|
||||
<Compile Include="Framework\Display\ElementCreatingDisplayShapeContext.cs" />
|
||||
<Compile Include="Framework\Drivers\ImportElementContext.cs" />
|
||||
<Compile Include="Framework\Drivers\ImportLayoutContext.cs" />
|
||||
<Compile Include="Framework\Elements\IElement.cs" />
|
||||
<Compile Include="Handlers\ElementDriversCoordinator.cs" />
|
||||
<Compile Include="Handlers\ElementRuleCoordinator.cs" />
|
||||
<Compile Include="Helpers\DictionaryExtensions.cs" />
|
||||
@@ -367,6 +368,7 @@
|
||||
<Compile Include="Helpers\PrefixHelper.cs" />
|
||||
<Compile Include="Helpers\JsonHelper.cs" />
|
||||
<Compile Include="Helpers\StringHelper.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Recipes\Builders\CustomElementsStep.cs" />
|
||||
<Compile Include="Recipes\Executors\CustomElementsStep.cs" />
|
||||
<Compile Include="Providers\BlueprintElementHarvester.cs" />
|
||||
|
||||
40
src/Orchard.Web/Modules/Orchard.Layouts/Permissions.cs
Normal file
40
src/Orchard.Web/Modules/Orchard.Layouts/Permissions.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Layouts {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageLayouts = new Permission { Description = "Managing Layouts", Name = "ManageLayouts" };
|
||||
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new[] {
|
||||
ManageLayouts,
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
|
||||
return new[] {
|
||||
new PermissionStereotype {
|
||||
Name = "Administrator",
|
||||
Permissions = new[] { ManageLayouts }
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Editor",
|
||||
Permissions = new[] { ManageLayouts }
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Moderator",
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Author"
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Contributor",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -5,16 +5,19 @@ using Orchard.Localization;
|
||||
namespace Orchard.Layouts.Services {
|
||||
public class ElementFactory : IElementFactory {
|
||||
private readonly IElementEventHandler _elementEventHandler;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
|
||||
public ElementFactory(IElementEventHandler elementEventHandler) {
|
||||
public ElementFactory(IElementEventHandler elementEventHandler, IWorkContextAccessor workContextAccessor) {
|
||||
_elementEventHandler = elementEventHandler;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public Element Activate(Type elementType, Action<Element> initialize = null) {
|
||||
var element = (Element)Activator.CreateInstance(elementType);
|
||||
var workContext = _workContextAccessor.GetContext();
|
||||
var element = (Element)workContext.Resolve(elementType);
|
||||
|
||||
if (initialize != null)
|
||||
initialize(element);
|
||||
@@ -23,7 +26,8 @@ namespace Orchard.Layouts.Services {
|
||||
}
|
||||
|
||||
public T Activate<T>(Action<T> initialize = null) where T : Element {
|
||||
var element = (T)Activator.CreateInstance(typeof(T));
|
||||
var workContext = _workContextAccessor.GetContext();
|
||||
var element = workContext.Resolve<T>();
|
||||
|
||||
if (initialize != null)
|
||||
initialize(element);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Orchard.Layouts.Services {
|
||||
public IEnumerable<ElementDescriptor> DescribeElements(DescribeElementsContext context) {
|
||||
var contentType = context.Content != null ? context.Content.ContentItem.ContentType : default(string);
|
||||
var cacheKey = String.Format("LayoutElementTypes-{0}-{1}", contentType ?? "AnyType", context.CacheVaryParam);
|
||||
return _cacheManager.Get(cacheKey, acquireContext => {
|
||||
return _cacheManager.Get(cacheKey, true, acquireContext => {
|
||||
var harvesterContext = new HarvestElementsContext {
|
||||
Content = context.Content
|
||||
};
|
||||
@@ -55,7 +55,7 @@ namespace Orchard.Layouts.Services {
|
||||
|
||||
public IEnumerable<CategoryDescriptor> GetCategories(DescribeElementsContext context) {
|
||||
var contentType = context.Content != null ? context.Content.ContentItem.ContentType : default(string);
|
||||
return _cacheManager.Get(String.Format("ElementCategories-{0}-{1}", contentType ?? "AnyType", context.CacheVaryParam), acquireContext => {
|
||||
return _cacheManager.Get(String.Format("ElementCategories-{0}-{1}", contentType ?? "AnyType", context.CacheVaryParam), true, acquireContext => {
|
||||
var elements = DescribeElements(context);
|
||||
var categoryDictionary = GetCategories();
|
||||
var categoryDescriptorDictionary = new Dictionary<string, CategoryDescriptor>();
|
||||
|
||||
@@ -22,12 +22,7 @@ namespace Orchard.Layouts.Settings {
|
||||
yield break;
|
||||
|
||||
var model = definition.Settings.GetModel<LayoutTypePartSettings>();
|
||||
|
||||
if (String.IsNullOrWhiteSpace(model.DefaultLayoutData)) {
|
||||
var defaultData = _serializer.Serialize(_layoutManager.CreateDefaultLayout());
|
||||
model.DefaultLayoutData = defaultData;
|
||||
}
|
||||
|
||||
|
||||
yield return DefinitionTemplate(model);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -17,7 +17,6 @@
|
||||
Script.Require("jQueryUI_Resizable");
|
||||
Script.Require("jQueryUI_Position");
|
||||
Script.Require("jQueryUI_Dialog");
|
||||
Script.Require("TinyMce");
|
||||
Script.Require("Layouts.LayoutEditor");
|
||||
Script.Include("jquery.deserialize.js");
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@foreach (var contentItemShape in Model.ContentItems) {
|
||||
var contentItem = (ContentItem)contentItemShape.ContentItem;
|
||||
var displayTextHtmlString = Html.ItemDisplayText(contentItem);
|
||||
var displayText = displayTextHtmlString != null ? displayTextHtmlString.ToString() : T("-").ToString();
|
||||
var displayText = displayTextHtmlString != null ? (IHtmlString)displayTextHtmlString : T("-");
|
||||
<div class="layout-snippet">
|
||||
@displayText
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
<div class="layout-toolbox-wrapper">
|
||||
<div class="layout-toolbox">
|
||||
<label>
|
||||
<input type="checkbox" ng-checked="element.inlineEditingIsActive" ng-click="toggleInlineEditing()" />
|
||||
@T("Edit HTML content inline")
|
||||
</label>
|
||||
<ul class="layout-toolbox-groups" ng-hide="element.inlineEditingIsActive">
|
||||
<ul class="layout-toolbox-groups">
|
||||
<li class="layout-toolbox-group" ng-class="{collapsed: layoutIsCollapsed}">
|
||||
<a href="#" class="layout-toolbox-group-heading" ng-click="toggleLayoutIsCollapsed($event)">@T("Layout")</a>
|
||||
<ul class="layout-toolbox-items">
|
||||
|
||||
Reference in New Issue
Block a user