Merge branch '1.8.x' into 1.x

Conflicts:
	src/Orchard.Web/Modules/Orchard.Scripting.CSharp/Activities/DecisionActivity.cs
This commit is contained in:
Sebastien Ros
2014-06-13 15:50:33 -07:00
11 changed files with 58 additions and 19 deletions

View File

@@ -71,7 +71,7 @@ namespace Orchard.Core.Containers.Services {
public IContentQuery<ContainerPart> GetContainersQuery(VersionOptions options = null) {
options = options ?? VersionOptions.Published;
return _contentManager.Query<ContainerPart>(options);
return _contentManager.Query<ContainerPart, ContainerPartRecord>(options);
}
public ContainerPart Get(int id, VersionOptions options = null) {

View File

@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Collections.Generic;
using Orchard.Core.Settings.Descriptor.Records;
using Orchard.Data;
@@ -13,6 +14,7 @@ namespace Orchard.Core.Settings.Descriptor {
private readonly IRepository<ShellDescriptorRecord> _shellDescriptorRepository;
private readonly IShellDescriptorManagerEventHandler _events;
private readonly ShellSettings _shellSettings;
private ShellDescriptorRecord _shellDescriptorRecord;
public ShellDescriptorManager(
IRepository<ShellDescriptorRecord> shellDescriptorRepository,
@@ -54,7 +56,11 @@ namespace Orchard.Core.Settings.Descriptor {
}
private ShellDescriptorRecord GetDescriptorRecord() {
return _shellDescriptorRepository.Get(x => x != null);
if (_shellDescriptorRecord == null) {
return _shellDescriptorRepository.Table.ToList().SingleOrDefault();
}
return _shellDescriptorRecord;
}
public void UpdateShellDescriptor(int priorSerialNumber, IEnumerable<ShellFeature> enabledFeatures, IEnumerable<ShellParameter> parameters) {
@@ -66,6 +72,7 @@ namespace Orchard.Core.Settings.Descriptor {
if (shellDescriptorRecord == null) {
shellDescriptorRecord = new ShellDescriptorRecord { SerialNumber = 1 };
_shellDescriptorRepository.Create(shellDescriptorRecord);
_shellDescriptorRecord = shellDescriptorRecord;
}
else {
shellDescriptorRecord.SerialNumber++;

View File

@@ -121,5 +121,14 @@ namespace Orchard.MediaLibrary {
return 4;
}
public int UpdateFrom4() {
SchemaBuilder.AlterTable("MediaPartRecord", t => t
.CreateIndex("IDX_MediaPartRecord_FolderPath", "FolderPath")
);
return 5;
}
}
}

View File

@@ -111,7 +111,7 @@ namespace Orchard.MediaProcessing.Services {
using (var image = GetImage(path)) {
var filterContext = new FilterContext { Media = image, FilePath = _storageProvider.Combine("_Profiles", FormatProfilePath(profileName, path)) };
var filterContext = new FilterContext { Media = image, FilePath = _storageProvider.Combine("_Profiles", FormatProfilePath(profileName, System.Web.HttpUtility.UrlDecode(path))) };
if (image == null) {
return filterContext.FilePath;

View File

@@ -35,6 +35,8 @@ namespace Orchard.Scripting.CSharp.Drivers {
if (!String.IsNullOrWhiteSpace(script)) {
script = "// #{ }" + System.Environment.NewLine + script;
_csharpService.SetParameter("Services", _orchardServices);
_csharpService.SetParameter("ContentItem", (dynamic)part.ContentItem);
_csharpService.SetParameter("WorkContext", _workContextAccessor.GetContext());

View File

@@ -84,8 +84,8 @@ namespace Orchard.Tags.Services {
// initialize centroids with a linear distribution
var centroids = new int[buckets];
var maxCount = tagCounts.Max(tc => tc.Count);
var minCount = tagCounts.Min(tc => tc.Count);
var maxCount = tagCounts.Any() ? tagCounts.Max(tc => tc.Count) : 0;
var minCount = tagCounts.Any() ? tagCounts.Min(tc => tc.Count) : 0;
var maxDistance = maxCount - minCount;
for (int i = 0; i < centroids.Length; i++) {
centroids[i] = maxDistance/buckets * (i+1);

View File

@@ -53,19 +53,33 @@ namespace Orchard.Taxonomies.Handlers {
return;
}
var queryHint = new QueryHints()
.ExpandRecords("ContentTypeRecord", "CommonPartRecord", "TermsPartRecord");
foreach (var field in part.ContentItem.Parts.SelectMany(p => p.Fields).OfType<TaxonomyField>()) {
var tempField = field.Name;
field.TermsField.Loader(value => {
var fieldTermRecordIds = part.Record.Terms.Where(t => t.Field == tempField).Select(tci => tci.TermRecord.Id);
return fieldTermRecordIds.Select(id => _contentManager.Get<TermPart>(id)).ToList();
var terms = _contentManager.GetMany<TermPart>(fieldTermRecordIds, VersionOptions.Published, queryHint);
return terms.ToList();
});
}
part._termParts = new LazyField<IEnumerable<TermContentItemPart>>();
part._termParts.Loader(value =>
part.Terms.Select(
x => new TermContentItemPart { Field = x.Field, TermPart = _contentManager.Get<TermPart>(x.TermRecord.Id) }
));
part._termParts.Loader(value => {
var ids = part.Terms.Select(t => t.TermRecord.Id);
var terms = _contentManager.GetMany<TermPart>(ids, VersionOptions.Published, queryHint)
.ToDictionary(t => t.Id, t => t);
return
part.Terms.Select(
x =>
new TermContentItemPart {
Field = x.Field,
TermPart = terms[x.TermRecord.Id]
}
);
});
}
// Retrieve the number of associated content items, for the whole hierarchy

View File

@@ -14,6 +14,7 @@ namespace Orchard.Taxonomies.Projections {
public class TermsFilter : IFilterProvider {
private readonly ITaxonomyService _taxonomyService;
private int _termsFilterId;
public TermsFilter(ITaxonomyService taxonomyService) {
_taxonomyService = taxonomyService;
@@ -55,14 +56,13 @@ namespace Orchard.Taxonomies.Projections {
var allIds = allChildren.Select(x => x.Id).ToList();
switch(op) {
case 0:
// is one of
Action<IAliasFactory> s = alias => alias.ContentPartRecord<TermsPartRecord>().Property("Terms", "terms").Property("TermRecord", "termRecord");
Action<IHqlExpressionFactory> f = x => x.InG("Id", allIds);
case 0: // is one of
// Unique alias so we always get a unique join everytime so can have > 1 HasTerms filter on a query.
Action<IAliasFactory> s = alias => alias.ContentPartRecord<TermsPartRecord>().Property("Terms", "terms" + _termsFilterId++);
Action<IHqlExpressionFactory> f = x => x.InG("TermRecord.Id", allIds);
context.Query.Where(s, f);
break;
case 1:
// is all of
case 1: // is all of
foreach (var id in allIds) {
var termId = id;
Action<IAliasFactory> selector =

View File

@@ -46,11 +46,11 @@ namespace Orchard.Taxonomies.Services {
public Localizer T { get; set; }
public IEnumerable<TaxonomyPart> GetTaxonomies() {
return _contentManager.Query<TaxonomyPart, TaxonomyPartRecord>().WithQueryHints(new QueryHints().ExpandParts<AutoroutePart, TitlePart>()).List();
return _contentManager.Query<TaxonomyPart, TaxonomyPartRecord>().List();
}
public TaxonomyPart GetTaxonomy(int id) {
return _contentManager.Get(id, VersionOptions.Published, new QueryHints().ExpandParts<TaxonomyPart, AutoroutePart, TitlePart>()).As<TaxonomyPart>();
return _contentManager.Get(id, VersionOptions.Published, new QueryHints().ExpandParts<TaxonomyPart>()).As<TaxonomyPart>();
}
public TaxonomyPart GetTaxonomyByName(string name) {

View File

@@ -43,18 +43,21 @@ namespace Orchard.Widgets.Services {
public IEnumerable<LayerPart> GetLayers() {
return _contentManager
.Query<LayerPart, LayerPartRecord>()
.WithQueryHints(new QueryHints().ExpandParts<CommonPart>())
.List();
}
public IEnumerable<WidgetPart> GetWidgets() {
return _contentManager
.Query<WidgetPart, WidgetPartRecord>()
.WithQueryHints(new QueryHints().ExpandParts<CommonPart>())
.List();
}
public IEnumerable<WidgetPart> GetOrphanedWidgets() {
return _contentManager
.Query<WidgetPart, WidgetPartRecord>()
.WithQueryHints(new QueryHints().ExpandParts<CommonPart>())
.Where<CommonPartRecord>(x => x.Container == null)
.List();
}
@@ -62,6 +65,7 @@ namespace Orchard.Widgets.Services {
public IEnumerable<WidgetPart> GetWidgets(int layerId) {
return _contentManager
.Query<WidgetPart, WidgetPartRecord>()
.WithQueryHints(new QueryHints().ExpandParts<CommonPart>())
.Where<CommonPartRecord>(x => x.Container.Id == layerId)
.List();
}
@@ -69,6 +73,7 @@ namespace Orchard.Widgets.Services {
public IEnumerable<WidgetPart> GetWidgets(int[] layerIds) {
return _contentManager
.Query<WidgetPart>()
.WithQueryHints(new QueryHints().ExpandParts<CommonPart>())
.Where<CommonPartRecord>(x => layerIds.Contains(x.Container.Id))
.List();
}

View File

@@ -54,7 +54,9 @@ namespace Orchard.Data.Providers {
.SetProperty(NHibernate.Cfg.Environment.StatementFetchSize, "100")
.SetProperty(NHibernate.Cfg.Environment.UseProxyValidator, Boolean.FalseString)
.SetProperty(NHibernate.Cfg.Environment.UseSqlComments, Boolean.FalseString)
.SetProperty(NHibernate.Cfg.Environment.WrapResultSets, Boolean.TrueString);
.SetProperty(NHibernate.Cfg.Environment.WrapResultSets, Boolean.TrueString)
.SetProperty(NHibernate.Cfg.Environment.BatchSize, "256")
;
cfg.EventListeners.LoadEventListeners = new ILoadEventListener[] {new OrchardLoadEventListener()};
cfg.EventListeners.PostLoadEventListeners = new IPostLoadEventListener[0];