mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
Adding FieldDriver.Describe to let content fields expose their storage properties
--HG-- branch : 1.x
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
d0cf85644ff34b0630a12eed746a66a8d88eb5cf src/Orchard.Web/Modules/Orchard.Forms
|
53d2172cf326b72801dcb5418d25fff394cd22bb src/Orchard.Web/Modules/Orchard.Forms
|
||||||
b571876d276f9022c12b8b464d5e138f5ce06c14 src/Orchard.Web/Modules/Orchard.Projections
|
ef9e924d76d610da862d952f1f0bf3e28c007138 src/Orchard.Web/Modules/Orchard.Projections
|
||||||
108ae2f95c8bf9bf0d4d06d0e31b5b77f855cba3 src/Orchard.Web/Modules/Orchard.Rules
|
108ae2f95c8bf9bf0d4d06d0e31b5b77f855cba3 src/Orchard.Web/Modules/Orchard.Rules
|
||||||
65057c6a5cd71f7994ba9bcbeece50dbb737620e src/Orchard.Web/Modules/Orchard.TaskLease
|
65057c6a5cd71f7994ba9bcbeece50dbb737620e src/Orchard.Web/Modules/Orchard.TaskLease
|
||||||
9496e39d3bab7655114d8dfc75290954856ec567 src/Orchard.Web/Modules/Orchard.Tokens
|
9496e39d3bab7655114d8dfc75290954856ec567 src/Orchard.Web/Modules/Orchard.Tokens
|
||||||
|
@@ -3,14 +3,17 @@ using Orchard.ContentManagement;
|
|||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Core.Common.Fields;
|
using Orchard.Core.Common.Fields;
|
||||||
|
using Orchard.Localization;
|
||||||
|
|
||||||
namespace Orchard.Core.Common.Drivers {
|
namespace Orchard.Core.Common.Drivers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class TextFieldDriver : ContentFieldDriver<TextField> {
|
public class TextFieldDriver : ContentFieldDriver<TextField> {
|
||||||
public TextFieldDriver(IOrchardServices services) {
|
public TextFieldDriver(IOrchardServices services) {
|
||||||
Services = services;
|
Services = services;
|
||||||
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Localizer T { get; set; }
|
||||||
public IOrchardServices Services { get; set; }
|
public IOrchardServices Services { get; set; }
|
||||||
|
|
||||||
private static string GetPrefix(TextField field, ContentPart part) {
|
private static string GetPrefix(TextField field, ContentPart part) {
|
||||||
@@ -46,5 +49,10 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
protected override void Exporting(ContentPart part, TextField field, ExportContentContext context) {
|
protected override void Exporting(ContentPart part, TextField field, ExportContentContext context) {
|
||||||
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Value);
|
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Describe(DescribeMembersContext context) {
|
||||||
|
context
|
||||||
|
.Member(null, typeof(string), T("Value"), T("The text associated with the field."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -6,6 +6,7 @@ using Orchard.DisplayManagement;
|
|||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Events;
|
using Orchard.Events;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
using Orchard.Tags.Models;
|
||||||
using Orchard.Tags.Services;
|
using Orchard.Tags.Services;
|
||||||
|
|
||||||
namespace Orchard.Tags.Projections {
|
namespace Orchard.Tags.Projections {
|
||||||
@@ -38,7 +39,7 @@ namespace Orchard.Tags.Projections {
|
|||||||
if (!String.IsNullOrEmpty(tags)) {
|
if (!String.IsNullOrEmpty(tags)) {
|
||||||
var ids = tags.Split(new[] { ',' }).Select(Int32.Parse).ToArray();
|
var ids = tags.Split(new[] { ',' }).Select(Int32.Parse).ToArray();
|
||||||
var query = (IContentQuery<ContentItem>)context.Query;
|
var query = (IContentQuery<ContentItem>)context.Query;
|
||||||
context.Query = query.Where(x => x.WithRecord("TagsPartRecord").WithRelationship("Tags.TagRecord").In("Id", ids));
|
context.Query = query.Join<TagsPartRecord>().Where(x => x.Tags.Any(t => ids.Contains(t.TagRecord.Id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -474,6 +474,11 @@ namespace Orchard.ContentManagement {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ISortFactory WithRelationship(string path) {
|
||||||
|
Criteria = _query.BindCriteriaByPath(Criteria, path);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public void Asc(string propertyName) {
|
public void Asc(string propertyName) {
|
||||||
Order = Order.Asc(propertyName);
|
Order = Order.Asc(propertyName);
|
||||||
}
|
}
|
||||||
|
@@ -82,6 +82,8 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
protected virtual void Exporting(ContentPart part, TField field, ExportContentContext context) { }
|
protected virtual void Exporting(ContentPart part, TField field, ExportContentContext context) { }
|
||||||
protected virtual void Exported(ContentPart part, TField field, ExportContentContext context) { }
|
protected virtual void Exported(ContentPart part, TField field, ExportContentContext context) { }
|
||||||
|
|
||||||
|
public virtual void Describe(DescribeMembersContext context) { }
|
||||||
|
|
||||||
public ContentShapeResult ContentShape(string shapeType, Func<dynamic> factory) {
|
public ContentShapeResult ContentShape(string shapeType, Func<dynamic> factory) {
|
||||||
return ContentShapeImplementation(shapeType, null, ctx => factory());
|
return ContentShapeImplementation(shapeType, null, ctx => factory());
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
void Imported(ImportContentContext context);
|
void Imported(ImportContentContext context);
|
||||||
void Exporting(ExportContentContext context);
|
void Exporting(ExportContentContext context);
|
||||||
void Exported(ExportContentContext context);
|
void Exported(ExportContentContext context);
|
||||||
|
void Describe(DescribeMembersContext context);
|
||||||
IEnumerable<ContentFieldInfo> GetFieldInfo();
|
IEnumerable<ContentFieldInfo> GetFieldInfo();
|
||||||
void GetContentItemMetadata(GetContentItemMetadataContext context);
|
void GetContentItemMetadata(GetContentItemMetadataContext context);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using Orchard.Localization;
|
||||||
|
|
||||||
|
namespace Orchard.ContentManagement.Handlers {
|
||||||
|
public class DescribeMembersContext {
|
||||||
|
private readonly Action<string, Type, LocalizedString, LocalizedString> _processMember;
|
||||||
|
|
||||||
|
public DescribeMembersContext(Action<string, Type, LocalizedString, LocalizedString> processMember) {
|
||||||
|
_processMember = processMember;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescribeMembersContext Member(string storageName, Type storageType) {
|
||||||
|
return Member(storageName, storageType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescribeMembersContext Member(string storageName, Type storageType, LocalizedString displayName) {
|
||||||
|
return Member(storageName, storageType, displayName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescribeMembersContext Member(string storageName, Type storageType, LocalizedString displayName, LocalizedString description) {
|
||||||
|
_processMember(storageName, storageType, displayName, description);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -2,6 +2,7 @@
|
|||||||
public interface ISortFactory {
|
public interface ISortFactory {
|
||||||
ISortFactory WithRecord(string recordName);
|
ISortFactory WithRecord(string recordName);
|
||||||
ISortFactory WithVersionRecord(string recordName);
|
ISortFactory WithVersionRecord(string recordName);
|
||||||
|
ISortFactory WithRelationship(string propertyName);
|
||||||
|
|
||||||
void Asc(string propertyName);
|
void Asc(string propertyName);
|
||||||
void Desc(string propertyName);
|
void Desc(string propertyName);
|
||||||
|
@@ -169,6 +169,7 @@
|
|||||||
<Compile Include="ContentManagement\ContentIdentity.cs" />
|
<Compile Include="ContentManagement\ContentIdentity.cs" />
|
||||||
<Compile Include="ContentManagement\ContentItemBehavior.cs" />
|
<Compile Include="ContentManagement\ContentItemBehavior.cs" />
|
||||||
<Compile Include="ContentManagement\ContentPartBehavior.cs" />
|
<Compile Include="ContentManagement\ContentPartBehavior.cs" />
|
||||||
|
<Compile Include="ContentManagement\Handlers\DescribeMembersContext.cs" />
|
||||||
<Compile Include="ContentManagement\ISortFactory.cs" />
|
<Compile Include="ContentManagement\ISortFactory.cs" />
|
||||||
<Compile Include="ContentManagement\DefaultContentDisplay.cs" />
|
<Compile Include="ContentManagement\DefaultContentDisplay.cs" />
|
||||||
<Compile Include="ContentManagement\Drivers\ContentShapeResult.cs" />
|
<Compile Include="ContentManagement\Drivers\ContentShapeResult.cs" />
|
||||||
|
Reference in New Issue
Block a user