mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge 1.x
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
Copyright (C) 2012 by Robert Moore
|
||||
|
||||
The source code for NHibernate.SqlAzure is available under an MIT license as
|
||||
per below. If you are using the version of NHibernate.SqlAzure that is combined
|
||||
with the EnterpriseLibrary dlls then it is available under the Microsoft Public
|
||||
License (Ms-PL) as per http://entlib.codeplex.com/license.
|
||||
|
||||
-----
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,6 +2,7 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Common.Utilities;
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Localization.Services;
|
||||
@@ -51,7 +52,11 @@ namespace Orchard.Core.Common.DateEditor {
|
||||
|
||||
var itemHasNeverBeenPublished = part.PublishedUtc == null;
|
||||
var thisIsTheInitialVersionRecord = part.ContentItem.Version < 2;
|
||||
var theDatesHaveNotBeenModified = part.CreatedUtc == part.VersionCreatedUtc;
|
||||
|
||||
// Dates are assumed the same if the millisecond part is the only difference.
|
||||
// This is because SqlCe doesn't support high precision times (Datetime2) and the infoset does
|
||||
// implying some discrepancies between values read from different storage mechanism.
|
||||
var theDatesHaveNotBeenModified = DateUtils.DatesAreEquivalent(part.CreatedUtc, part.VersionCreatedUtc);
|
||||
|
||||
var theEditorShouldBeBlank =
|
||||
itemHasNeverBeenPublished &&
|
||||
@@ -71,7 +76,6 @@ namespace Orchard.Core.Common.DateEditor {
|
||||
try {
|
||||
var utcDateTime = _dateLocalizationServices.ConvertFromLocalizedString(model.Editor.Date, model.Editor.Time);
|
||||
part.CreatedUtc = utcDateTime;
|
||||
part.VersionCreatedUtc = utcDateTime;
|
||||
}
|
||||
catch (FormatException) {
|
||||
updater.AddModelError(Prefix, T("'{0} {1}' could not be parsed as a valid date and time.", model.Editor.Date, model.Editor.Time));
|
||||
@@ -87,5 +91,6 @@ namespace Orchard.Core.Common.DateEditor {
|
||||
return model;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Core.Common.Utilities;
|
||||
|
||||
namespace Orchard.Core.Common.DateEditor {
|
||||
[UsedImplicitly]
|
||||
@@ -13,7 +14,7 @@ namespace Orchard.Core.Common.DateEditor {
|
||||
}
|
||||
|
||||
var thisIsTheInitialVersionRecord = part.ContentItem.Version < 2;
|
||||
var theDatesHaveNotBeenModified = part.CreatedUtc == part.VersionCreatedUtc;
|
||||
var theDatesHaveNotBeenModified = DateUtils.DatesAreEquivalent(part.CreatedUtc, part.VersionCreatedUtc);
|
||||
var theContentDateShouldBeUpdated = thisIsTheInitialVersionRecord && theDatesHaveNotBeenModified;
|
||||
|
||||
if (theContentDateShouldBeUpdated) {
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Common.Fields {
|
||||
public class ItemReferenceContentField : ContentField {
|
||||
public ContentItemRecord ContentItemReference { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -49,18 +49,20 @@ namespace Orchard.Core.Common.Handlers {
|
||||
OnPublishing<CommonPart>(AssignPublishingDates);
|
||||
|
||||
OnIndexing<CommonPart>((context, commonPart) => {
|
||||
var utcNow = _clock.UtcNow;
|
||||
|
||||
context.DocumentIndex
|
||||
.Add("type", commonPart.ContentItem.ContentType).Store()
|
||||
.Add("created", commonPart.CreatedUtc ?? _clock.UtcNow).Store()
|
||||
.Add("published", commonPart.PublishedUtc ?? _clock.UtcNow).Store()
|
||||
.Add("modified", commonPart.ModifiedUtc ?? _clock.UtcNow).Store();
|
||||
.Add("created", commonPart.CreatedUtc ?? utcNow).Store()
|
||||
.Add("published", commonPart.PublishedUtc ?? utcNow).Store()
|
||||
.Add("modified", commonPart.ModifiedUtc ?? utcNow).Store();
|
||||
|
||||
if (commonPart.Container != null) {
|
||||
context.DocumentIndex.Add("container-id", commonPart.Container.Id).Store();
|
||||
}
|
||||
|
||||
if (commonPart.Owner != null) {
|
||||
context.DocumentIndex.Add("author", commonPart.Owner.UserName).Analyze().Store();
|
||||
context.DocumentIndex.Add("author", commonPart.Owner.UserName).Store();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -93,6 +95,7 @@ namespace Orchard.Core.Common.Handlers {
|
||||
protected void AssignCreatingDates(InitializingContentContext context, CommonPart part) {
|
||||
// assign default create/modified dates
|
||||
var utcNow = _clock.UtcNow;
|
||||
|
||||
part.CreatedUtc = utcNow;
|
||||
part.ModifiedUtc = utcNow;
|
||||
part.VersionCreatedUtc = utcNow;
|
||||
@@ -101,6 +104,7 @@ namespace Orchard.Core.Common.Handlers {
|
||||
|
||||
private void AssignUpdateDates(UpdateEditorContext context, CommonPart part) {
|
||||
var utcNow = _clock.UtcNow;
|
||||
|
||||
part.ModifiedUtc = utcNow;
|
||||
part.VersionModifiedUtc = utcNow;
|
||||
}
|
||||
@@ -116,16 +120,17 @@ namespace Orchard.Core.Common.Handlers {
|
||||
building.VersionPublishedUtc = null;
|
||||
|
||||
// assign the created
|
||||
building.CreatedUtc = existing.CreatedUtc ?? _clock.UtcNow;
|
||||
building.CreatedUtc = existing.CreatedUtc ?? utcNow;
|
||||
// persist any published dates
|
||||
building.PublishedUtc = existing.PublishedUtc;
|
||||
// assign modified date for the new version
|
||||
building.ModifiedUtc = _clock.UtcNow;
|
||||
building.ModifiedUtc = utcNow;
|
||||
}
|
||||
|
||||
|
||||
protected void AssignPublishingDates(PublishContentContext context, CommonPart part) {
|
||||
var utcNow = _clock.UtcNow;
|
||||
|
||||
part.PublishedUtc = utcNow;
|
||||
part.VersionPublishedUtc = utcNow;
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Orchard.Core.Common.Settings {
|
||||
public class LocationSettings {
|
||||
public string Zone { get; set; }
|
||||
public string Position { get; set; }
|
||||
}
|
||||
}
|
||||
44
src/Orchard.Web/Core/Common/Utilities/DateUtils.cs
Normal file
44
src/Orchard.Web/Core/Common/Utilities/DateUtils.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Orchard.Core.Common.Utilities {
|
||||
public class DateUtils {
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="DateTime" /> instance without their milliseconds portion.
|
||||
/// </summary>
|
||||
/// <param name="a">The first <see cref="DateTime" /> to compare.</param>
|
||||
/// <param name="b">The second <see cref="DateTime" /> to compare.</param>
|
||||
/// <returns><c>True</c> if the two instances are in the same second, <c>False</c> otherwise.</returns>
|
||||
public static bool DatesAreEquivalent(DateTime a, DateTime b) {
|
||||
a = a.ToUniversalTime();
|
||||
b = b.ToUniversalTime();
|
||||
|
||||
return
|
||||
new DateTime(a.Year, a.Month, a.Day, a.Hour, a.Minute, a.Second) ==
|
||||
new DateTime(b.Year, b.Month, b.Day, b.Hour, b.Minute, b.Second);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="DateTime?" /> instance without their milliseconds portion.
|
||||
/// </summary>
|
||||
/// <param name="a">The first <see cref="DateTime?" /> to compare.</param>
|
||||
/// <param name="b">The second <see cref="DateTime?" /> to compare.</param>
|
||||
/// <returns><c>True</c> if the two instances are in the same second, <c>False</c> otherwise.</returns>
|
||||
public static bool DatesAreEquivalent(DateTime? a, DateTime? b) {
|
||||
if (!a.HasValue && !b.HasValue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (a.HasValue != b.HasValue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return DatesAreEquivalent(a.Value, b.Value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,11 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
// /Contents/Item/Display/72
|
||||
public ActionResult Display(int id) {
|
||||
var contentItem = _contentManager.Get(id, VersionOptions.Published);
|
||||
public ActionResult Display(int? id) {
|
||||
if (id == null)
|
||||
return HttpNotFound();
|
||||
|
||||
var contentItem = _contentManager.Get(id.Value, VersionOptions.Published);
|
||||
|
||||
if (contentItem == null)
|
||||
return HttpNotFound();
|
||||
@@ -38,13 +41,16 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
|
||||
// /Contents/Item/Preview/72
|
||||
// /Contents/Item/Preview/72?version=5
|
||||
public ActionResult Preview(int id, int? version) {
|
||||
public ActionResult Preview(int? id, int? version) {
|
||||
if (id == null)
|
||||
return HttpNotFound();
|
||||
|
||||
var versionOptions = VersionOptions.Latest;
|
||||
|
||||
if (version != null)
|
||||
versionOptions = VersionOptions.Number((int)version);
|
||||
|
||||
var contentItem = _contentManager.Get(id, versionOptions);
|
||||
var contentItem = _contentManager.Get(id.Value, versionOptions);
|
||||
if (contentItem == null)
|
||||
return HttpNotFound();
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@
|
||||
<Compile Include="Common\DateEditor\DateEditorViewModel.cs" />
|
||||
<Compile Include="Common\Settings\TextFieldSettingsEvents.cs" />
|
||||
<Compile Include="Common\Settings\TextFieldSettings.cs" />
|
||||
<Compile Include="Common\Utilities\DateUtils.cs" />
|
||||
<Compile Include="Common\ViewModels\DateTimeEditor.cs" />
|
||||
<Compile Include="Common\ViewModels\TextFieldDriverViewModel.cs" />
|
||||
<Compile Include="Common\ViewModels\TextFieldSettingsEventsViewModel.cs" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Core.Settings.Descriptor.Records;
|
||||
using Orchard.Data;
|
||||
@@ -8,13 +7,14 @@ using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.Core.Settings.Descriptor {
|
||||
public class ShellDescriptorManager : IShellDescriptorManager {
|
||||
public class ShellDescriptorManager : Component, IShellDescriptorManager {
|
||||
private readonly IRepository<ShellDescriptorRecord> _shellDescriptorRepository;
|
||||
private readonly IShellDescriptorManagerEventHandler _events;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private ShellDescriptorRecord _shellDescriptorRecord;
|
||||
|
||||
public ShellDescriptorManager(
|
||||
IRepository<ShellDescriptorRecord> shellDescriptorRepository,
|
||||
@@ -23,11 +23,8 @@ namespace Orchard.Core.Settings.Descriptor {
|
||||
_shellDescriptorRepository = shellDescriptorRepository;
|
||||
_events = events;
|
||||
_shellSettings = shellSettings;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ShellDescriptor GetShellDescriptor() {
|
||||
ShellDescriptorRecord shellDescriptorRecord = GetDescriptorRecord();
|
||||
if (shellDescriptorRecord == null) return null;
|
||||
@@ -56,11 +53,7 @@ namespace Orchard.Core.Settings.Descriptor {
|
||||
}
|
||||
|
||||
private ShellDescriptorRecord GetDescriptorRecord() {
|
||||
if (_shellDescriptorRecord == null) {
|
||||
return _shellDescriptorRecord = _shellDescriptorRepository.Table.ToList().SingleOrDefault();
|
||||
}
|
||||
|
||||
return _shellDescriptorRecord;
|
||||
return _shellDescriptorRepository.Get(x => x != null);
|
||||
}
|
||||
|
||||
public void UpdateShellDescriptor(int priorSerialNumber, IEnumerable<ShellFeature> enabledFeatures, IEnumerable<ShellParameter> parameters) {
|
||||
@@ -69,6 +62,8 @@ namespace Orchard.Core.Settings.Descriptor {
|
||||
if (priorSerialNumber != serialNumber)
|
||||
throw new InvalidOperationException(T("Invalid serial number for shell descriptor").ToString());
|
||||
|
||||
Logger.Information("Updating shell descriptor for shell '{0}'...", _shellSettings.Name);
|
||||
|
||||
if (shellDescriptorRecord == null) {
|
||||
shellDescriptorRecord = new ShellDescriptorRecord { SerialNumber = 1 };
|
||||
_shellDescriptorRepository.Create(shellDescriptorRecord);
|
||||
@@ -76,13 +71,12 @@ namespace Orchard.Core.Settings.Descriptor {
|
||||
else {
|
||||
shellDescriptorRecord.SerialNumber++;
|
||||
}
|
||||
|
||||
_shellDescriptorRecord = shellDescriptorRecord;
|
||||
|
||||
shellDescriptorRecord.Features.Clear();
|
||||
foreach (var feature in enabledFeatures) {
|
||||
shellDescriptorRecord.Features.Add(new ShellFeatureRecord { Name = feature.Name, ShellDescriptorRecord = shellDescriptorRecord });
|
||||
}
|
||||
Logger.Debug("Enabled features for shell '{0}' set: {1}.", _shellSettings.Name, String.Join(", ", enabledFeatures.Select(feature => feature.Name)));
|
||||
|
||||
|
||||
shellDescriptorRecord.Parameters.Clear();
|
||||
@@ -94,6 +88,9 @@ namespace Orchard.Core.Settings.Descriptor {
|
||||
ShellDescriptorRecord = shellDescriptorRecord
|
||||
});
|
||||
}
|
||||
Logger.Debug("Parameters for shell '{0}' set: {1}.", _shellSettings.Name, String.Join(", ", parameters.Select(parameter => parameter.Name + "-" + parameter.Value)));
|
||||
|
||||
Logger.Information("Shell descriptor updated for shell '{0}'.", _shellSettings.Name);
|
||||
|
||||
_events.Changed(GetShellDescriptorFromRecord(shellDescriptorRecord), _shellSettings.Name);
|
||||
}
|
||||
|
||||
@@ -137,28 +137,25 @@
|
||||
var _this = $(this);
|
||||
var _controllees = $("[data-controllerid=" + _this.attr("id") + "]");
|
||||
|
||||
var hide = true;
|
||||
|
||||
|
||||
_controllees.each(function () {
|
||||
var _controllee = $(this);
|
||||
var hidden = _controllee.attr("data-defaultstate") == "hidden";
|
||||
var _controlleeIsHidden = _controllee.is(":hidden");
|
||||
|
||||
if (_this.is(":checked") || _this.is(":selected")) {
|
||||
hide = hidden;
|
||||
}
|
||||
else {
|
||||
hide = !hidden;
|
||||
}
|
||||
var hiddenByDefault = _controllee.attr("data-defaultstate") == "hidden";
|
||||
var checkedOrSelected = _this.is(":checked") || _this.is(":selected");
|
||||
|
||||
if (!hide) {
|
||||
if (_controlleeIsHidden) {
|
||||
if (checkedOrSelected) {
|
||||
if (!hiddenByDefault) {
|
||||
_controllee.hide().show(); // <- unhook this when the following comment applies
|
||||
// _controllees.slideUp(200); // <- hook this back up when chrome behaves, or when I care less...or when chrome behaves
|
||||
} else {
|
||||
_controllee.hide();
|
||||
}
|
||||
} else {
|
||||
if (!hiddenByDefault) {
|
||||
_controllee.hide();
|
||||
} else {
|
||||
_controllee.show();
|
||||
}
|
||||
} else if (!_controlleeIsHidden) {
|
||||
// _controllees.slideUp(200); // <- hook this back up when chrome behaves, or when I care less...or when chrome behaves
|
||||
_controllee.hide()
|
||||
}
|
||||
});
|
||||
|
||||
@@ -175,26 +172,16 @@
|
||||
return;
|
||||
}
|
||||
controller.data("isControlling", 1);
|
||||
if (!controller.is(":checked") && !controller.is(":selected")) {
|
||||
$("[data-controllerid=" + controller.attr("id") + "]").hide();
|
||||
}
|
||||
if (controller.is(":checkbox")) {
|
||||
controller.click($(this).toggleWhatYouControl);
|
||||
controller.click($(this).toggleWhatYouControl).each($(this).toggleWhatYouControl);
|
||||
} else if (controller.is(":radio")) {
|
||||
$("[name=" + controller.attr("name") + "]").click(function () { $("[name=" + $(this).attr("name") + "]").each($(this).toggleWhatYouControl); });
|
||||
}
|
||||
else if (controller.is("option")) {
|
||||
controller.parent().change(function () {
|
||||
controller.toggleWhatYouControl();
|
||||
});
|
||||
}).each($(this).toggleWhatYouControl);
|
||||
}
|
||||
|
||||
// if data-defaultstate is 'hidden' hide it by default
|
||||
var hidden = $(this).attr("data-defaultstate") == "hidden";
|
||||
if (hidden) {
|
||||
$(this).hide();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
// inline form link buttons (form.inline.link button) swapped out for a link that submits said form
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Alias.Implementation.Holder;
|
||||
using Orchard.Alias.Implementation.Storage;
|
||||
using Orchard.Mvc.Routes;
|
||||
using Orchard.Utility.Extensions;
|
||||
@@ -13,12 +14,15 @@ namespace Orchard.Alias.Implementation {
|
||||
private readonly IAliasStorage _aliasStorage;
|
||||
private readonly IEnumerable<IRouteProvider> _routeProviders;
|
||||
private readonly Lazy<IEnumerable<RouteDescriptor>> _routeDescriptors;
|
||||
private readonly IAliasHolder _aliasHolder;
|
||||
|
||||
public DefaultAliasService(
|
||||
IAliasStorage aliasStorage,
|
||||
IEnumerable<IRouteProvider> routeProviders) {
|
||||
IEnumerable<IRouteProvider> routeProviders,
|
||||
IAliasHolder aliasHolder) {
|
||||
_aliasStorage = aliasStorage;
|
||||
_routeProviders = routeProviders;
|
||||
_aliasHolder = aliasHolder;
|
||||
|
||||
_routeDescriptors = new Lazy<IEnumerable<RouteDescriptor>>(GetRouteDescriptors);
|
||||
}
|
||||
@@ -79,7 +83,37 @@ namespace Orchard.Alias.Implementation {
|
||||
}
|
||||
|
||||
public IEnumerable<string> Lookup(RouteValueDictionary routeValues) {
|
||||
return List().Where(item => item.Item2.Match(routeValues)).Select(item=>item.Item1).ToList();
|
||||
object area;
|
||||
|
||||
if (routeValues.TryGetValue("area", out area)) {
|
||||
// the route has an area, lookup in the specific alias map
|
||||
|
||||
var map = _aliasHolder.GetMap(area.ToString());
|
||||
|
||||
if (map == null) {
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
var locate = map.Locate(routeValues);
|
||||
|
||||
if (locate == null) {
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
return new[] { locate.Item2 };
|
||||
}
|
||||
|
||||
// no specific area, lookup in all alias maps
|
||||
var result = new List<string>();
|
||||
foreach (var map in _aliasHolder.GetMaps()) {
|
||||
var locate = map.Locate(routeValues);
|
||||
|
||||
if (locate != null) {
|
||||
result.Add(locate.Item2);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<Tuple<string, RouteValueDictionary>> List() {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Orchard.Alias.Implementation.Holder;
|
||||
using Orchard.Alias.Implementation.Storage;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Tasks;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Alias.Implementation.Updater {
|
||||
public class AliasHolderUpdaterTask : IOrchardShellEvents, IBackgroundTask {
|
||||
private readonly IAliasHolderUpdater _aliasHolderUpdater;
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public AliasHolderUpdaterTask(IAliasHolderUpdater aliasHolderUpdater) {
|
||||
_aliasHolderUpdater = aliasHolderUpdater;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
void IOrchardShellEvents.Activated() {
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void IOrchardShellEvents.Terminating() {
|
||||
}
|
||||
|
||||
private void Refresh() {
|
||||
try {
|
||||
_aliasHolderUpdater.Refresh();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Error(ex, "Exception during Alias refresh");
|
||||
}
|
||||
}
|
||||
|
||||
public void Sweep() {
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,7 @@
|
||||
<Content Include="Views\Admin\Edit.cshtml" />
|
||||
<Content Include="Views\Admin\Index.cshtml" />
|
||||
<Content Include="Web.config" />
|
||||
<Compile Include="Implementation\Updater\AliasHolderUpdater.cs" />
|
||||
<Compile Include="Implementation\Updater\AliasUpdateCursor.cs" />
|
||||
<Compile Include="Implementation\Updater\AliasUpdaterBackgroundTask.cs" />
|
||||
<Compile Include="Implementation\Updater\IAliasUpdateCursor.cs" />
|
||||
@@ -103,7 +104,7 @@
|
||||
<Compile Include="Implementation\Holder\IAliasHolder.cs" />
|
||||
<Compile Include="Implementation\Map\AliasMap.cs" />
|
||||
<Compile Include="Implementation\Storage\AliasStorage.cs" />
|
||||
<Compile Include="Implementation\Updater\AliasHolderUpdater.cs" />
|
||||
<Compile Include="Implementation\Updater\AliasHolderUpdaterTask.cs" />
|
||||
<Compile Include="Implementation\Utils.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Records\ActionRecord.cs" />
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Core.Common.ViewModels {
|
||||
public class ItemReferenceContentFieldDisplayViewModel {
|
||||
private ContentItem _item;
|
||||
|
||||
public ContentItem Item {
|
||||
get { return _item; }
|
||||
set { _item = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Core.Common.ViewModels {
|
||||
public class ItemReferenceContentFieldEditorViewModel {
|
||||
private ContentItem _item;
|
||||
|
||||
public ContentItem Item {
|
||||
get { return _item; }
|
||||
set { _item = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,13 @@ namespace Orchard.Autoroute.Handlers {
|
||||
part.DisplayAlias = _autorouteService.Value.GenerateAlias(part);
|
||||
}
|
||||
|
||||
// if the generated alias is empty, compute a new one
|
||||
if (String.IsNullOrWhiteSpace(part.DisplayAlias)) {
|
||||
_autorouteService.Value.ProcessPath(part);
|
||||
_orchardServices.Notifier.Warning(T("The permalink could not be generated, a new slug has been defined: \"{0}\"", part.Path));
|
||||
return;
|
||||
}
|
||||
|
||||
// should it become the home page ?
|
||||
if (part.DisplayAlias != "/" && _orchardServices.Authorizer.Authorize(Permissions.SetHomePage)) {
|
||||
// if it's the current home page, do nothing
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</system.web.webPages.razor>
|
||||
|
||||
<system.web>
|
||||
<compilation targetFramework="4.5">
|
||||
<compilation targetFramework="4.5.1">
|
||||
<assemblies>
|
||||
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
using System.Linq;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.Core.Common.Records;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.Core.Feeds.Models;
|
||||
using Orchard.Data;
|
||||
|
||||
namespace Orchard.Comments.Feeds {
|
||||
public class CommentScopeFeedQuery : IFeedQueryProvider, IFeedQuery {
|
||||
private readonly IRepository<CommonRecord> _commonRepository;
|
||||
private readonly IRepository<Comment> _commentRepository;
|
||||
|
||||
public CommentScopeFeedQuery(
|
||||
IRepository<CommonRecord> commonRepository,
|
||||
IRepository<Comment> commentRepository) {
|
||||
_commonRepository = commonRepository;
|
||||
_commentRepository = commentRepository;
|
||||
}
|
||||
|
||||
public FeedQueryMatch Match(FeedContext context) {
|
||||
if (context.ValueProvider.ContainsPrefix("commentscopeid")) {
|
||||
return new FeedQueryMatch { Priority = -1, FeedQuery = this };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Execute(FeedContext context) {
|
||||
var scopeContainerId = (int)context.ValueProvider.GetValue("commentscopeid").ConvertTo(typeof (int));
|
||||
_commonRepository.Fetch(x => x.Container.Id == scopeContainerId).Select(x => x.Id);
|
||||
var comments = _commentRepository.Fetch(x=>x.)
|
||||
context.FeedFormatter.AddItem(context, new Comment());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace Orchard.Comments.Models {
|
||||
set { Record.UserName = value; }
|
||||
}
|
||||
|
||||
[RegularExpression(@"^(?![\.@])(""([^""\r\\]|\\[""\r\\])*""|([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$")]
|
||||
[RegularExpression(@"^(?![\.@])(""([^""\r\\]|\\[""\r\\])*""|([-\w!#$%&'*+/=?^`{|}~]|(?<!\.)\.)*)(?<!\.)@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")]
|
||||
public string Email {
|
||||
get { return Record.Email; }
|
||||
set { Record.Email = value; }
|
||||
|
||||
@@ -139,7 +139,13 @@ namespace Orchard.DesignerTools.Services {
|
||||
}
|
||||
|
||||
foreach (var member in members) {
|
||||
if (o is ContentItem && member.Name == "ContentManager"
|
||||
if ((o is ContentItem && (member.Name == "ContentManager"
|
||||
|| member.Name == "Parts"
|
||||
|| member.Name == "Record"
|
||||
|| member.Name == "VersionRecord"
|
||||
|| member.Name == "TypeDefinition"
|
||||
|| member.Name == "TypePartDefinition"
|
||||
|| member.Name == "PartDefinition"))
|
||||
|| o is Delegate
|
||||
|| o is Type
|
||||
) {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,13 +0,0 @@
|
||||
namespace Orchard.Fields.ViewModels {
|
||||
|
||||
public class BooleanFieldViewModel {
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public bool? Value { get; set; }
|
||||
|
||||
public string NotSetLabel { get; set; }
|
||||
public string OnLabel { get; set; }
|
||||
public string OffLabel { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ namespace Orchard.Indexing.Services {
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly ILockFileManager _lockFileManager;
|
||||
private readonly IClock _clock;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private const int ContentItemsPerLoop = 50;
|
||||
private IndexingStatus _indexingStatus = IndexingStatus.Idle;
|
||||
|
||||
@@ -44,7 +45,8 @@ namespace Orchard.Indexing.Services {
|
||||
IAppDataFolder appDataFolder,
|
||||
ShellSettings shellSettings,
|
||||
ILockFileManager lockFileManager,
|
||||
IClock clock) {
|
||||
IClock clock,
|
||||
ITransactionManager transactionManager) {
|
||||
_taskRepository = taskRepository;
|
||||
_contentRepository = contentRepository;
|
||||
_indexManager = indexManager;
|
||||
@@ -52,6 +54,7 @@ namespace Orchard.Indexing.Services {
|
||||
_appDataFolder = appDataFolder;
|
||||
_shellSettings = shellSettings;
|
||||
_lockFileManager = lockFileManager;
|
||||
_transactionManager = transactionManager;
|
||||
_clock = clock;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
@@ -143,34 +146,38 @@ namespace Orchard.Indexing.Services {
|
||||
private bool BatchIndex(string indexName, string settingsFilename, IndexSettings indexSettings) {
|
||||
var addToIndex = new List<IDocumentIndex>();
|
||||
var deleteFromIndex = new List<int>();
|
||||
bool loop = false;
|
||||
|
||||
// Rebuilding the index ?
|
||||
if (indexSettings.Mode == IndexingMode.Rebuild) {
|
||||
Logger.Information("Rebuilding index");
|
||||
_indexingStatus = IndexingStatus.Rebuilding;
|
||||
|
||||
// load all content items
|
||||
var contentItems = _contentRepository
|
||||
do {
|
||||
loop = true;
|
||||
|
||||
// load all content items
|
||||
var contentItems = _contentRepository
|
||||
.Table.Where(versionRecord => versionRecord.Latest && versionRecord.Id > indexSettings.LastContentId)
|
||||
.OrderBy(versionRecord => versionRecord.Id)
|
||||
.Take(ContentItemsPerLoop)
|
||||
.ToList()
|
||||
.Select(versionRecord => _contentManager.Get(versionRecord.ContentItemRecord.Id, VersionOptions.VersionRecord(versionRecord.Id)))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
.OrderBy(versionRecord => versionRecord.Id)
|
||||
.Take(ContentItemsPerLoop)
|
||||
.ToList()
|
||||
.Select(versionRecord => _contentManager.Get(versionRecord.ContentItemRecord.Id, VersionOptions.VersionRecord(versionRecord.Id)))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
// if no more elements to index, switch to update mode
|
||||
if (contentItems.Count == 0) {
|
||||
indexSettings.Mode = IndexingMode.Update;
|
||||
}
|
||||
// if no more elements to index, switch to update mode
|
||||
if (contentItems.Count == 0) {
|
||||
indexSettings.Mode = IndexingMode.Update;
|
||||
}
|
||||
|
||||
foreach (var item in contentItems) {
|
||||
try {
|
||||
foreach (var item in contentItems) {
|
||||
try {
|
||||
|
||||
var settings = GetTypeIndexingSettings(item);
|
||||
var settings = GetTypeIndexingSettings(item);
|
||||
|
||||
// skip items from types which are not indexed
|
||||
if (settings.List.Contains(indexName)) {
|
||||
if (settings.List.Contains(indexName)) {
|
||||
if (item.HasPublished()) {
|
||||
var published = _contentManager.Get(item.Id, VersionOptions.Published);
|
||||
IDocumentIndex documentIndex = ExtractDocumentIndex(published);
|
||||
@@ -181,66 +188,86 @@ namespace Orchard.Indexing.Services {
|
||||
}
|
||||
}
|
||||
else if (settings.List.Contains(indexName + ":latest")) {
|
||||
IDocumentIndex documentIndex = ExtractDocumentIndex(item);
|
||||
IDocumentIndex documentIndex = ExtractDocumentIndex(item);
|
||||
|
||||
if (documentIndex != null && documentIndex.IsDirty) {
|
||||
addToIndex.Add(documentIndex);
|
||||
if (documentIndex != null && documentIndex.IsDirty) {
|
||||
addToIndex.Add(documentIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
indexSettings.LastContentId = item.VersionRecord.Id;
|
||||
indexSettings.LastContentId = item.VersionRecord.Id;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Warning(ex, "Unable to index content item #{0} during rebuild", item.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Warning(ex, "Unable to index content item #{0} during rebuild", item.Id);
|
||||
|
||||
if (contentItems.Count < ContentItemsPerLoop) {
|
||||
loop = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_transactionManager.RequireNew();
|
||||
}
|
||||
|
||||
|
||||
} while (loop);
|
||||
}
|
||||
|
||||
if (indexSettings.Mode == IndexingMode.Update) {
|
||||
Logger.Information("Updating index");
|
||||
_indexingStatus = IndexingStatus.Updating;
|
||||
|
||||
var indexingTasks = _taskRepository
|
||||
.Table.Where(x => x.Id > indexSettings.LastIndexedId)
|
||||
.OrderBy(x => x.Id)
|
||||
.Take(ContentItemsPerLoop)
|
||||
.ToList()
|
||||
.GroupBy(x => x.ContentItemRecord.Id)
|
||||
do {
|
||||
var indexingTasks = _taskRepository
|
||||
.Table.Where(x => x.Id > indexSettings.LastIndexedId)
|
||||
.OrderBy(x => x.Id)
|
||||
.Take(ContentItemsPerLoop)
|
||||
.ToList()
|
||||
.GroupBy(x => x.ContentItemRecord.Id)
|
||||
.Select(group => new { TaskId = group.Max(task => task.Id), Delete = group.Last().Action == IndexingTaskRecord.Delete, Id = group.Key, ContentItem = _contentManager.Get(group.Key, VersionOptions.Latest) })
|
||||
.OrderBy(x => x.TaskId)
|
||||
.ToArray();
|
||||
.OrderBy(x => x.TaskId)
|
||||
.ToArray();
|
||||
|
||||
foreach (var item in indexingTasks) {
|
||||
try {
|
||||
foreach (var item in indexingTasks) {
|
||||
try {
|
||||
|
||||
IDocumentIndex documentIndex = null;
|
||||
IDocumentIndex documentIndex = null;
|
||||
|
||||
// item.ContentItem can be null if the content item has been deleted
|
||||
if (item.ContentItem != null) {
|
||||
// skip items from types which are not indexed
|
||||
var settings = GetTypeIndexingSettings(item.ContentItem);
|
||||
if (settings.List.Contains(indexName)) {
|
||||
documentIndex = ExtractDocumentIndex(item.ContentItem);
|
||||
}
|
||||
// item.ContentItem can be null if the content item has been deleted
|
||||
if (item.ContentItem != null) {
|
||||
// skip items from types which are not indexed
|
||||
var settings = GetTypeIndexingSettings(item.ContentItem);
|
||||
if (settings.List.Contains(indexName)) {
|
||||
documentIndex = ExtractDocumentIndex(item.ContentItem);
|
||||
}
|
||||
else if (settings.List.Contains(indexName + ":latest")) {
|
||||
var latest = _contentManager.Get(item.Id, VersionOptions.Latest);
|
||||
documentIndex = ExtractDocumentIndex(latest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (documentIndex == null || item.Delete) {
|
||||
deleteFromIndex.Add(item.Id);
|
||||
}
|
||||
else if (documentIndex.IsDirty) {
|
||||
addToIndex.Add(documentIndex);
|
||||
}
|
||||
if (documentIndex == null || item.Delete) {
|
||||
deleteFromIndex.Add(item.Id);
|
||||
}
|
||||
else if (documentIndex.IsDirty) {
|
||||
addToIndex.Add(documentIndex);
|
||||
}
|
||||
|
||||
indexSettings.LastIndexedId = item.TaskId;
|
||||
indexSettings.LastIndexedId = item.TaskId;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Warning(ex, "Unable to index content item #{0} during update", item.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Warning(ex, "Unable to index content item #{0} during update", item.Id);
|
||||
|
||||
if (indexingTasks.Length < ContentItemsPerLoop) {
|
||||
loop = false;
|
||||
}
|
||||
else {
|
||||
_transactionManager.RequireNew();
|
||||
}
|
||||
}
|
||||
while (loop);
|
||||
}
|
||||
|
||||
// save current state of the index
|
||||
|
||||
@@ -26,10 +26,16 @@ namespace Orchard.Indexing.Services {
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
private void CreateTask(ContentItem contentItem, int action) {
|
||||
if ( contentItem == null ) {
|
||||
if (contentItem == null) {
|
||||
throw new ArgumentNullException("contentItem");
|
||||
}
|
||||
|
||||
if (contentItem.Record == null) {
|
||||
// ignore that case, when Update is called on a content item which has not be "created" yet
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var task in _repository.Table.Where(task => task.ContentItemRecord == contentItem.Record)) {
|
||||
_repository.Delete(task);
|
||||
}
|
||||
|
||||
@@ -78,10 +78,22 @@ namespace Orchard.Indexing.Settings {
|
||||
}
|
||||
|
||||
private void CreateTasksForType(string type) {
|
||||
var index = 0;
|
||||
bool contentItemProcessed;
|
||||
|
||||
// todo: load ids only, or create a queued job
|
||||
// we create a task even for draft items, and the executor will filter based on the settings
|
||||
foreach (var contentItem in _contentManager.Query(VersionOptions.Latest, new [] { type }).List()) {
|
||||
_indexingTaskManager.CreateUpdateIndexTask(contentItem);
|
||||
}
|
||||
|
||||
do {
|
||||
contentItemProcessed = false;
|
||||
var contentItemsToIndex = _contentManager.Query(VersionOptions.Latest, new [] { type }).Slice(index, 50);
|
||||
|
||||
foreach (var contentItem in contentItemsToIndex) {
|
||||
contentItemProcessed = true;
|
||||
_indexingTaskManager.CreateUpdateIndexTask(contentItem);
|
||||
}
|
||||
|
||||
} while (contentItemProcessed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ namespace Orchard.MediaLibrary.Services {
|
||||
private readonly IStorageProvider _storageProvider;
|
||||
private readonly IEnumerable<IMediaFactorySelector> _mediaFactorySelectors;
|
||||
|
||||
private static char[] HttpUnallowed = new char[] { '<', '>', '*', '%', '&', ':', '\\', '?' };
|
||||
|
||||
public MediaLibraryService(
|
||||
IOrchardServices orchardServices,
|
||||
IMimeTypeProvider mimeTypeProvider,
|
||||
@@ -125,6 +127,12 @@ namespace Orchard.MediaLibrary.Services {
|
||||
}
|
||||
|
||||
public string GetUniqueFilename(string folderPath, string filename) {
|
||||
|
||||
// remove any char which is unallowed in an HTTP request
|
||||
foreach (var unallowedChar in HttpUnallowed) {
|
||||
filename = filename.Replace(unallowedChar.ToString(), "");
|
||||
}
|
||||
|
||||
// compute a unique filename
|
||||
var uniqueFilename = filename;
|
||||
var index = 1;
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
.overlay h3 {
|
||||
padding-right:5px;
|
||||
font-size: 12px;
|
||||
height: 40px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.media-thumbnail {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
@using Orchard.MediaLibrary.Settings;
|
||||
@{
|
||||
var settings = Model.Field.PartFieldDefinition.Settings.GetModel<MediaLibraryPickerFieldSettings>();
|
||||
<div class="thumbnail" title="@Html.ItemDisplayText(contentItem)">
|
||||
<h3>@Html.ItemDisplayText(contentItem)</h3>
|
||||
}
|
||||
@Display.MediaLibraryPicker(
|
||||
FieldName: Html.FieldNameFor(m => m.SelectedIds),
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Orchard.MediaProcessing.Services {
|
||||
descriptor.Filter(filterContext);
|
||||
}
|
||||
|
||||
_fileNameProvider.UpdateFileName(profileName, path, filterContext.FilePath);
|
||||
_fileNameProvider.UpdateFileName(profileName, System.Web.HttpUtility.UrlDecode(path), filterContext.FilePath);
|
||||
|
||||
if (!filterContext.Saved) {
|
||||
try {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.None, T("Choose action...").ToString())
|
||||
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Enable, T("Enable").ToString())
|
||||
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Disable, T("Disable").ToString())
|
||||
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Update, T("Update").ToString())
|
||||
@Html.SelectOption(Model.BulkAction, FeaturesBulkAction.Toggle, T("Toggle").ToString())
|
||||
</select>
|
||||
<button type="submit" name="submit.BulkExecute" value="yes">@T("Execute")</button>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Orchard.Commands;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.MultiTenancy.Services;
|
||||
@@ -42,6 +44,16 @@ namespace Orchard.MultiTenancy.Commands {
|
||||
[OrchardSwitches("Host,UrlPrefix")]
|
||||
public void Create(string tenantName) {
|
||||
Context.Output.WriteLine(T("Creating tenant"));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(tenantName) || !Regex.IsMatch(tenantName, @"^\w+$")) {
|
||||
Context.Output.WriteLine(T("Invalid tenant name. Must contain characters only and no spaces."));
|
||||
return;
|
||||
}
|
||||
if (_tenantService.GetTenants().Any(tenant => string.Equals(tenant.Name, tenantName, StringComparison.OrdinalIgnoreCase))) {
|
||||
Context.Output.WriteLine(T("Could not create tenant \"{0}\". A tenant with the same name already exists.", tenantName));
|
||||
return;
|
||||
}
|
||||
|
||||
_tenantService.CreateTenant(
|
||||
new ShellSettings {
|
||||
Name = tenantName,
|
||||
|
||||
@@ -9,7 +9,6 @@ using Orchard.MultiTenancy.Services;
|
||||
using Orchard.MultiTenancy.ViewModels;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.MultiTenancy.Controllers {
|
||||
[ValidateInput(false)]
|
||||
@@ -52,11 +51,17 @@ namespace Orchard.MultiTenancy.Controllers {
|
||||
|
||||
[HttpPost, ActionName("Add")]
|
||||
public ActionResult AddPOST(TenantAddViewModel viewModel) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Couldn't create tenant")))
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Couldn't create tenant"))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
if (!EnsureDefaultTenant())
|
||||
if (!EnsureDefaultTenant()) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
if (_tenantService.GetTenants().Any(tenant => string.Equals(tenant.Name, viewModel.Name, StringComparison.OrdinalIgnoreCase))) {
|
||||
ModelState.AddModelError("Name", T("A tenant with the same name already exists.", viewModel.Name).Text);
|
||||
}
|
||||
|
||||
// ensure tenants name are valid
|
||||
if (!String.IsNullOrEmpty(viewModel.Name) && !Regex.IsMatch(viewModel.Name, @"^\w+$")) {
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Orchard.Projections.Services {
|
||||
var contentItems = new List<ContentItem>();
|
||||
|
||||
// aggregate the result for each group query
|
||||
foreach(var contentQuery in GetContentQueries(queryRecord, queryRecord.SortCriteria)) {
|
||||
foreach(var contentQuery in GetContentQueries(queryRecord, queryRecord.SortCriteria.OrderBy(sc => sc.Position))) {
|
||||
contentItems.AddRange(contentQuery.Slice(skip, count));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Core.Common.ViewModels {
|
||||
public class ItemReferenceContentFieldDisplayViewModel {
|
||||
private ContentItem _item;
|
||||
|
||||
public ContentItem Item {
|
||||
get { return _item; }
|
||||
set { _item = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Core.Common.ViewModels {
|
||||
public class ItemReferenceContentFieldEditorViewModel {
|
||||
private ContentItem _item;
|
||||
|
||||
public ContentItem Item {
|
||||
get { return _item; }
|
||||
set { _item = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
<fieldset class="publish-later-datetime">
|
||||
<legend>@T("Publish")</legend>
|
||||
@Html.HiddenFor(m => m.Editor.ShowDate)
|
||||
@Html.HiddenFor(m => m.Editor.ShowTime)
|
||||
@Html.EditorFor(m => m.Editor)
|
||||
<button type="submit" name="submit.Save" value="submit.PublishLater">@T("Publish Later")</button>
|
||||
</fieldset>
|
||||
|
||||
@@ -67,8 +67,9 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
};
|
||||
|
||||
foreach (var arg in args) {
|
||||
// Switch?
|
||||
if (arg[0] == '/') {
|
||||
if (arg.StartsWith("/")) {
|
||||
//If arg is not empty and starts with '/'
|
||||
|
||||
int index = arg.IndexOf(':');
|
||||
var switchName = (index < 0 ? arg.Substring(1) : arg.Substring(1, index - 1));
|
||||
var switchValue = (index < 0 || index >= arg.Length ? string.Empty : arg.Substring(index + 1));
|
||||
|
||||
@@ -62,7 +62,6 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
|
||||
//Create a new transaction for each batch
|
||||
if (startIndex < elementDictionary.Count) {
|
||||
_orchardServices.ContentManager.Clear();
|
||||
_transactionManager.RequireNew();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<Orchard>
|
||||
<Recipe>
|
||||
<Name>Search</Name>
|
||||
<Description>Configures a default search index and search settings using the Lucene engine.</Description>
|
||||
<Author>The Orchard Team</Author>
|
||||
<WebSite>http://orchardproject.net</WebSite>
|
||||
<Tags>developer</Tags>
|
||||
<Version>1.0</Version>
|
||||
</Recipe>
|
||||
<Recipe>
|
||||
<Name>Search</Name>
|
||||
<Description>Configures a default search index and search settings using the Lucene engine.</Description>
|
||||
<Author>The Orchard Team</Author>
|
||||
<WebSite>http://orchardproject.net</WebSite>
|
||||
<Tags>developer</Tags>
|
||||
<Version>1.0</Version>
|
||||
</Recipe>
|
||||
|
||||
<Feature enable="Orchard.Search,Lucene" />
|
||||
|
||||
<Metadata>
|
||||
<Types>
|
||||
<Page TypeIndexing.Indexes="Search">
|
||||
</Page>
|
||||
<BlogPost TypeIndexing.Indexes="Search">
|
||||
</BlogPost>
|
||||
</Types>
|
||||
</Metadata>
|
||||
<Feature enable="Orchard.Search,Lucene" />
|
||||
|
||||
<Migration features="*" />
|
||||
|
||||
<Command>
|
||||
index create Search
|
||||
index update Search
|
||||
search use Search
|
||||
</Command>
|
||||
<Metadata>
|
||||
<Types>
|
||||
<Page TypeIndexing.Indexes="Search">
|
||||
</Page>
|
||||
<BlogPost TypeIndexing.Indexes="Search">
|
||||
</BlogPost>
|
||||
</Types>
|
||||
</Metadata>
|
||||
|
||||
<Migration features="*" />
|
||||
|
||||
<Command>
|
||||
index create Search
|
||||
index update Search
|
||||
</Command>
|
||||
|
||||
<Settings>
|
||||
<SearchSettingsPart SearchedFields="body,title" FilterCulture="false" SearchIndex="Search" />
|
||||
</Settings>
|
||||
|
||||
</Orchard>
|
||||
|
||||
@@ -49,6 +49,10 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\nhibernate\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
||||
@@ -19,17 +19,20 @@ namespace Orchard.Tags.Services {
|
||||
private readonly INotifier _notifier;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly ISessionFactoryHolder _sessionFactoryHolder;
|
||||
|
||||
public TagService(IRepository<TagRecord> tagRepository,
|
||||
IRepository<ContentTagRecord> contentTagRepository,
|
||||
INotifier notifier,
|
||||
IAuthorizationService authorizationService,
|
||||
IOrchardServices orchardServices) {
|
||||
IOrchardServices orchardServices,
|
||||
ISessionFactoryHolder sessionFactoryHolder) {
|
||||
_tagRepository = tagRepository;
|
||||
_contentTagRepository = contentTagRepository;
|
||||
_notifier = notifier;
|
||||
_authorizationService = authorizationService;
|
||||
_orchardServices = orchardServices;
|
||||
_sessionFactoryHolder = sessionFactoryHolder;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -207,6 +210,11 @@ namespace Orchard.Tags.Services {
|
||||
}
|
||||
|
||||
contentItem.As<TagsPart>().CurrentTags = tagNamesForContentItem;
|
||||
|
||||
var sessionFactory = _sessionFactoryHolder.GetSessionFactory();
|
||||
|
||||
if (sessionFactory != null)
|
||||
sessionFactory.EvictCollection("Orchard.Tags.Models.TagsPartRecord.Tags", contentItem.As<TagsPart>().Record.Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using Orchard.Taxonomies.Models;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
using Orchard.Taxonomies.Settings;
|
||||
using System;
|
||||
|
||||
namespace Orchard.Taxonomies.Handlers {
|
||||
[UsedImplicitly]
|
||||
@@ -23,7 +24,7 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
OnPublished<TaxonomyPart>((context, part) => {
|
||||
var previousTermTypeName = part.TermTypeName;
|
||||
|
||||
if (previousName == null || part.Name == previousName) {
|
||||
if (previousName == null) {
|
||||
// is it a new taxonomy ?
|
||||
taxonomyService.CreateTermContentType(part);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ Features:
|
||||
Name: Templates
|
||||
Description: Provides a Template type that represents a shape template, stored as a content item.
|
||||
Category: Content
|
||||
Dependencies: Contents, Orchard.Tokens
|
||||
Dependencies: Contents, Orchard.Tokens, Orchard.Core
|
||||
Orchard.Templates.Razor:
|
||||
Name: Razor Templates
|
||||
Description: Extends Templates with Razor templates.
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
<Compile Include="Services\TemplateProcessorImpl.cs" />
|
||||
<Compile Include="Services\RazorTemplateProcessor.cs" />
|
||||
<Compile Include="Services\DefaultTemplateService.cs" />
|
||||
<Compile Include="Services\TemplateShapeDisplayEvent.cs" />
|
||||
<Compile Include="Services\TemplateShapeBindingResolver.cs" />
|
||||
<Compile Include="Settings\ShapePartSettings.cs" />
|
||||
<Compile Include="Settings\ShapePartSettingsEvents.cs" />
|
||||
<Compile Include="ViewModels\ShapePartSettingsViewModel.cs" />
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
using Orchard.Caching;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Templates.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
|
||||
namespace Orchard.Templates.Services {
|
||||
public class TemplateShapeBindingResolver : IShapeBindingResolver {
|
||||
private ICacheManager _cacheManager;
|
||||
private ISignals _signals;
|
||||
private IContentManager _contentManager;
|
||||
private ITemplateService _templateService;
|
||||
|
||||
public TemplateShapeBindingResolver(
|
||||
ICacheManager cacheManager,
|
||||
ISignals signals,
|
||||
IContentManager contentManager,
|
||||
ITemplateService templateService
|
||||
) {
|
||||
_cacheManager = cacheManager;
|
||||
_signals = signals;
|
||||
_contentManager = contentManager;
|
||||
_templateService = templateService;
|
||||
}
|
||||
|
||||
public bool TryGetDescriptorBinding(string shapeType, out ShapeBinding shapeBinding) {
|
||||
var processors = BuildShapeProcessors();
|
||||
|
||||
TemplateResult templateResult = null;
|
||||
if (processors.TryGetValue(shapeType, out templateResult)) {
|
||||
shapeBinding = new ShapeBinding {
|
||||
BindingName = "Templates",
|
||||
Binding = ctx => CoerceHtmlString(_templateService.Execute(
|
||||
templateResult.Template,
|
||||
templateResult.Name,
|
||||
templateResult.Processor, ctx.Value))
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
shapeBinding = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
private IDictionary<string, TemplateResult> BuildShapeProcessors() {
|
||||
return _cacheManager.Get("Template.ShapeProcessors", ctx => {
|
||||
ctx.Monitor(_signals.When(DefaultTemplateService.TemplatesSignal));
|
||||
|
||||
var allTemplates = _contentManager.Query<ShapePart>().List();
|
||||
|
||||
return allTemplates.Select(x => {
|
||||
var name = x.Name;
|
||||
var template = x.Template;
|
||||
var processorName = x.ProcessorName;
|
||||
|
||||
return new TemplateResult {
|
||||
Name = x.Name,
|
||||
Template = x.Template,
|
||||
Processor = x.ProcessorName
|
||||
};
|
||||
|
||||
}).ToDictionary(x => x.Name, x => x);
|
||||
});
|
||||
}
|
||||
|
||||
private static IHtmlString CoerceHtmlString(object invoke) {
|
||||
return invoke as IHtmlString ?? (invoke != null ? new HtmlString(invoke.ToString()) : null);
|
||||
}
|
||||
|
||||
private class TemplateResult {
|
||||
public string Name { get; set; }
|
||||
public string Processor { get; set; }
|
||||
public string Template { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using Orchard.Caching;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Templates.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.Templates.Services {
|
||||
public class TemplateShapeDisplayEvent : IShapeDisplayEvents {
|
||||
private ICacheManager _cacheManager;
|
||||
private ISignals _signals;
|
||||
private IContentManager _contentManager;
|
||||
private ITemplateService _templateService;
|
||||
|
||||
public TemplateShapeDisplayEvent(
|
||||
ICacheManager cacheManager,
|
||||
ISignals signals,
|
||||
IContentManager contentManager,
|
||||
ITemplateService templateService
|
||||
) {
|
||||
_cacheManager = cacheManager;
|
||||
_signals = signals;
|
||||
_contentManager = contentManager;
|
||||
_templateService = templateService;
|
||||
}
|
||||
|
||||
public void Displaying(ShapeDisplayingContext context) {
|
||||
var processors = BuildShapeProcessors();
|
||||
Func<dynamic, IHtmlString> processor;
|
||||
|
||||
if (processors.TryGetValue(context.ShapeMetadata.Type, out processor)) {
|
||||
context.ChildContent = processor(context.Shape);
|
||||
}
|
||||
}
|
||||
|
||||
public void Displayed(ShapeDisplayedContext context) {
|
||||
}
|
||||
|
||||
public IDictionary<string, Func<dynamic, IHtmlString>> BuildShapeProcessors() {
|
||||
return _cacheManager.Get("Template.ShapeProcessors", ctx => {
|
||||
ctx.Monitor(_signals.When(DefaultTemplateService.TemplatesSignal));
|
||||
|
||||
var allTemplates = _contentManager.Query<ShapePart>().List();
|
||||
|
||||
return allTemplates.Select(x => new KeyValuePair<string, Func<dynamic, IHtmlString>>(
|
||||
x.Name,
|
||||
d => CoerceHtmlString(_templateService.Execute(x.Template, x.Name, x.ProcessorName, d))
|
||||
)).ToDictionary(x => x.Key, x => x.Value);
|
||||
});
|
||||
}
|
||||
|
||||
private static IHtmlString CoerceHtmlString(object invoke) {
|
||||
return invoke as IHtmlString ?? (invoke != null ? new HtmlString(invoke.ToString()) : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace TinyMce {
|
||||
public class ResourceManifest : IResourceManifestProvider {
|
||||
public void BuildManifests(ResourceManifestBuilder builder) {
|
||||
var manifest = builder.Add();
|
||||
manifest.DefineScript("TinyMce").SetUrl("tinymce.min.js").SetVersion("4.1.4").SetDependencies("jQuery");
|
||||
manifest.DefineScript("TinyMce").SetUrl("tinymce.min.js").SetVersion("4.1.5").SetDependencies("jQuery");
|
||||
manifest.DefineScript("OrchardTinyMce").SetUrl("orchard-tinymce.js").SetDependencies("TinyMce");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce._beforeUnloadHandler=function(){var e;return tinymce.each(tinymce.editors,function(t){t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&t.getParam("autosave_ask_before_unload",!0)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))}),e},tinymce.PluginManager.add("autosave",function(e){function t(e,t){var n={s:1e3,m:6e4};return e=/^(\d+)([ms]?)$/.exec(""+(e||t)),(e[2]?n[e[2]]:1)*parseInt(e,10)}function n(){var e=parseInt(v.getItem(c+"time"),10)||0;return(new Date).getTime()-e>m.autosave_retention?(a(!1),!1):!0}function a(t){v.removeItem(c+"draft"),v.removeItem(c+"time"),t!==!1&&e.fire("RemoveDraft")}function r(){!f()&&e.isDirty()&&(v.setItem(c+"draft",e.getContent({format:"raw",no_events:!0})),v.setItem(c+"time",(new Date).getTime()),e.fire("StoreDraft"))}function o(){n()&&(e.setContent(v.getItem(c+"draft"),{format:"raw"}),e.fire("RestoreDraft"))}function i(){d||(setInterval(function(){e.removed||r()},m.autosave_interval),d=!0)}function s(){var t=this;t.disabled(!n()),e.on("StoreDraft RestoreDraft RemoveDraft",function(){t.disabled(!n())}),i()}function u(){e.undoManager.beforeChange(),o(),a(),e.undoManager.add()}function f(t){var n=e.settings.forced_root_block;return t=tinymce.trim("undefined"==typeof t?e.getBody().innerHTML:t),""===t||new RegExp("^<"+n+"[^>]*>(( | |[ ]|<br[^>]*>)+?|)</"+n+">|<br>$","i").test(t)}var c,d,m=e.settings,v=tinymce.util.LocalStorage;c=m.autosave_prefix||"tinymce-autosave-{path}{query}-{id}-",c=c.replace(/\{path\}/g,document.location.pathname),c=c.replace(/\{query\}/g,document.location.search),c=c.replace(/\{id\}/g,e.id),m.autosave_interval=t(m.autosave_interval,"30s"),m.autosave_retention=t(m.autosave_retention,"20m"),e.addButton("restoredraft",{title:"Restore last draft",onclick:u,onPostRender:s}),e.addMenuItem("restoredraft",{text:"Restore last draft",onclick:u,onPostRender:s,context:"file"}),e.settings.autosave_restore_when_empty!==!1&&(e.on("init",function(){n()&&f()&&o()}),e.on("saveContent",function(){a()})),window.onbeforeunload=tinymce._beforeUnloadHandler,this.hasDraft=n,this.storeDraft=r,this.restoreDraft=o,this.removeDraft=a,this.isEmpty=f});
|
||||
tinymce._beforeUnloadHandler=function(){var e;return tinymce.each(tinymce.editors,function(t){t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&t.getParam("autosave_ask_before_unload",!0)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))}),e},tinymce.PluginManager.add("autosave",function(e){function t(e,t){var n={s:1e3,m:6e4};return e=/^(\d+)([ms]?)$/.exec(""+(e||t)),(e[2]?n[e[2]]:1)*parseInt(e,10)}function n(){var e=parseInt(v.getItem(c+"time"),10)||0;return(new Date).getTime()-e>m.autosave_retention?(a(!1),!1):!0}function a(t){v.removeItem(c+"draft"),v.removeItem(c+"time"),t!==!1&&e.fire("RemoveDraft")}function r(){!f()&&e.isDirty()&&(v.setItem(c+"draft",e.getContent({format:"raw",no_events:!0})),v.setItem(c+"time",(new Date).getTime()),e.fire("StoreDraft"))}function o(){n()&&(e.setContent(v.getItem(c+"draft"),{format:"raw"}),e.fire("RestoreDraft"))}function i(){d||(setInterval(function(){e.removed||r()},m.autosave_interval),d=!0)}function s(){var t=this;t.disabled(!n()),e.on("StoreDraft RestoreDraft RemoveDraft",function(){t.disabled(!n())}),i()}function u(){e.undoManager.beforeChange(),o(),a(),e.undoManager.add()}function f(t){var n=e.settings.forced_root_block;return t=tinymce.trim("undefined"==typeof t?e.getBody().innerHTML:t),""===t||new RegExp("^<"+n+"[^>]*>((\xa0| |[ ]|<br[^>]*>)+?|)</"+n+">|<br>$","i").test(t)}var c,d,m=e.settings,v=tinymce.util.LocalStorage;c=m.autosave_prefix||"tinymce-autosave-{path}{query}-{id}-",c=c.replace(/\{path\}/g,document.location.pathname),c=c.replace(/\{query\}/g,document.location.search),c=c.replace(/\{id\}/g,e.id),m.autosave_interval=t(m.autosave_interval,"30s"),m.autosave_retention=t(m.autosave_retention,"20m"),e.addButton("restoredraft",{title:"Restore last draft",onclick:u,onPostRender:s}),e.addMenuItem("restoredraft",{text:"Restore last draft",onclick:u,onPostRender:s,context:"file"}),e.settings.autosave_restore_when_empty!==!1&&(e.on("init",function(){n()&&f()&&o()}),e.on("saveContent",function(){a()})),window.onbeforeunload=tinymce._beforeUnloadHandler,this.hasDraft=n,this.storeDraft=r,this.restoreDraft=o,this.removeDraft=a,this.isEmpty=f});
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("noneditable",function(e){function t(e){var t;if(1===e.nodeType){if(t=e.getAttribute(u),t&&"inherit"!==t)return t;if(t=e.contentEditable,"inherit"!==t)return t}return null}function n(e){for(var n;e;){if(n=t(e))return"false"===n?e:null;e=e.parentNode}}function r(){function r(e){for(;e;){if(e.id===g)return e;e=e.parentNode}}function a(e){var t;if(e)for(t=new f(e,e),e=t.current();e;e=t.next())if(3===e.nodeType)return e}function i(n,r){var a,i;return"false"===t(n)&&u.isBlock(n)?void s.select(n):(i=u.createRng(),"true"===t(n)&&(n.firstChild||n.appendChild(e.getDoc().createTextNode(" ")),n=n.firstChild,r=!0),a=u.create("span",{id:g,"data-mce-bogus":!0},m),r?n.parentNode.insertBefore(a,n):u.insertAfter(a,n),i.setStart(a.firstChild,1),i.collapse(!0),s.setRng(i),a)}function o(e){var t,n,i,o;if(e)t=s.getRng(!0),t.setStartBefore(e),t.setEndBefore(e),n=a(e),n&&n.nodeValue.charAt(0)==m&&(n=n.deleteData(0,1)),u.remove(e,!0),s.setRng(t);else for(i=r(s.getStart());(e=u.get(g))&&e!==o;)i!==e&&(n=a(e),n&&n.nodeValue.charAt(0)==m&&(n=n.deleteData(0,1)),u.remove(e,!0)),o=e}function l(){function e(e,n){var r,a,i,o,l;if(r=d.startContainer,a=d.startOffset,3==r.nodeType){if(l=r.nodeValue.length,a>0&&l>a||(n?a==l:0===a))return}else{if(!(a<r.childNodes.length))return n?null:e;var u=!n&&a>0?a-1:a;r=r.childNodes[u],r.hasChildNodes()&&(r=r.firstChild)}for(i=new f(r,e);o=i[n?"prev":"next"]();){if(3===o.nodeType&&o.nodeValue.length>0)return;if("true"===t(o))return o}return e}var r,a,l,d,u;o(),l=s.isCollapsed(),r=n(s.getStart()),a=n(s.getEnd()),(r||a)&&(d=s.getRng(!0),l?(r=r||a,(u=e(r,!0))?i(u,!0):(u=e(r,!1))?i(u,!1):s.select(r)):(d=s.getRng(!0),r&&d.setStartBefore(r),a&&d.setEndAfter(a),s.setRng(d)))}function d(a){function i(e,t){for(;e=e[t?"previousSibling":"nextSibling"];)if(3!==e.nodeType||e.nodeValue.length>0)return e}function d(e,t){s.select(e),s.collapse(t)}function g(a){function i(e){for(var t=d;t;){if(t===e)return;t=t.parentNode}u.remove(e),l()}function o(){var r,o,l=e.schema.getNonEmptyElements();for(o=new tinymce.dom.TreeWalker(d,e.getBody());(r=a?o.prev():o.next())&&!l[r.nodeName.toLowerCase()]&&!(3===r.nodeType&&tinymce.trim(r.nodeValue).length>0);)if("false"===t(r))return i(r),!0;return n(r)?!0:!1}var f,d,c,g;if(s.isCollapsed()){if(f=s.getRng(!0),d=f.startContainer,c=f.startOffset,d=r(d)||d,g=n(d))return i(g),!1;if(3==d.nodeType&&(a?c>0:c<d.nodeValue.length))return!0;if(1==d.nodeType&&(d=d.childNodes[c]||d),o())return!1}return!0}var m,p,v,E,h=a.keyCode;if(v=s.getStart(),E=s.getEnd(),m=n(v)||n(E),m&&(112>h||h>124)&&h!=c.DELETE&&h!=c.BACKSPACE){if((tinymce.isMac?a.metaKey:a.ctrlKey)&&(67==h||88==h||86==h))return;if(a.preventDefault(),h==c.LEFT||h==c.RIGHT){var y=h==c.LEFT;if(e.dom.isBlock(m)){var T=y?m.previousSibling:m.nextSibling,C=new f(T,T),b=y?C.prev():C.next();d(b,!y)}else d(m,y)}}else if(h==c.LEFT||h==c.RIGHT||h==c.BACKSPACE||h==c.DELETE){if(p=r(v)){if(h==c.LEFT||h==c.BACKSPACE)if(m=i(p,!0),m&&"false"===t(m)){if(a.preventDefault(),h!=c.LEFT)return void u.remove(m);d(m,!0)}else o(p);if(h==c.RIGHT||h==c.DELETE)if(m=i(p),m&&"false"===t(m)){if(a.preventDefault(),h!=c.RIGHT)return void u.remove(m);d(m,!1)}else o(p)}if((h==c.BACKSPACE||h==c.DELETE)&&!g(h==c.BACKSPACE))return a.preventDefault(),!1}}var u=e.dom,s=e.selection,g="mce_noneditablecaret",m="";e.on("mousedown",function(n){var r=e.selection.getNode();"false"===t(r)&&r==n.target&&l()}),e.on("mouseup keyup",l),e.on("keydown",d)}function a(t){var n=l.length,r=t.content,a=tinymce.trim(o);if("raw"!=t.format){for(;n--;)r=r.replace(l[n],function(t){var n=arguments,i=n[n.length-2];return i>0&&'"'==r.charAt(i-1)?t:'<span class="'+a+'" data-mce-content="'+e.dom.encode(n[0])+'">'+e.dom.encode("string"==typeof n[1]?n[1]:n[0])+"</span>"});t.content=r}}var i,o,l,f=tinymce.dom.TreeWalker,d="contenteditable",u="data-mce-"+d,c=tinymce.util.VK;i=" "+tinymce.trim(e.getParam("noneditable_editable_class","mceEditable"))+" ",o=" "+tinymce.trim(e.getParam("noneditable_noneditable_class","mceNonEditable"))+" ",l=e.getParam("noneditable_regexp"),l&&!l.length&&(l=[l]),e.on("PreInit",function(){r(),l&&e.on("BeforeSetContent",a),e.parser.addAttributeFilter("class",function(e){for(var t,n,r=e.length;r--;)n=e[r],t=" "+n.attr("class")+" ",-1!==t.indexOf(i)?n.attr(u,"true"):-1!==t.indexOf(o)&&n.attr(u,"false")}),e.serializer.addAttributeFilter(u,function(e){for(var t,n=e.length;n--;)t=e[n],l&&t.attr("data-mce-content")?(t.name="#text",t.type=3,t.raw=!0,t.value=t.attr("data-mce-content")):(t.attr(d,null),t.attr(u,null))}),e.parser.addAttributeFilter(d,function(e){for(var t,n=e.length;n--;)t=e[n],t.attr(u,t.attr(d)),t.attr(d,null)})}),e.on("drop",function(e){n(e.target)&&e.preventDefault()})});
|
||||
tinymce.PluginManager.add("noneditable",function(e){function t(e){var t;if(1===e.nodeType){if(t=e.getAttribute(u),t&&"inherit"!==t)return t;if(t=e.contentEditable,"inherit"!==t)return t}return null}function n(e){for(var n;e;){if(n=t(e))return"false"===n?e:null;e=e.parentNode}}function r(){function r(e){for(;e;){if(e.id===g)return e;e=e.parentNode}}function a(e){var t;if(e)for(t=new f(e,e),e=t.current();e;e=t.next())if(3===e.nodeType)return e}function i(n,r){var a,i;return"false"===t(n)&&u.isBlock(n)?void s.select(n):(i=u.createRng(),"true"===t(n)&&(n.firstChild||n.appendChild(e.getDoc().createTextNode("\xa0")),n=n.firstChild,r=!0),a=u.create("span",{id:g,"data-mce-bogus":!0},m),r?n.parentNode.insertBefore(a,n):u.insertAfter(a,n),i.setStart(a.firstChild,1),i.collapse(!0),s.setRng(i),a)}function o(e){var t,n,i,o;if(e)t=s.getRng(!0),t.setStartBefore(e),t.setEndBefore(e),n=a(e),n&&n.nodeValue.charAt(0)==m&&(n=n.deleteData(0,1)),u.remove(e,!0),s.setRng(t);else for(i=r(s.getStart());(e=u.get(g))&&e!==o;)i!==e&&(n=a(e),n&&n.nodeValue.charAt(0)==m&&(n=n.deleteData(0,1)),u.remove(e,!0)),o=e}function l(){function e(e,n){var r,a,i,o,l;if(r=d.startContainer,a=d.startOffset,3==r.nodeType){if(l=r.nodeValue.length,a>0&&l>a||(n?a==l:0===a))return}else{if(!(a<r.childNodes.length))return n?null:e;var u=!n&&a>0?a-1:a;r=r.childNodes[u],r.hasChildNodes()&&(r=r.firstChild)}for(i=new f(r,e);o=i[n?"prev":"next"]();){if(3===o.nodeType&&o.nodeValue.length>0)return;if("true"===t(o))return o}return e}var r,a,l,d,u;o(),l=s.isCollapsed(),r=n(s.getStart()),a=n(s.getEnd()),(r||a)&&(d=s.getRng(!0),l?(r=r||a,(u=e(r,!0))?i(u,!0):(u=e(r,!1))?i(u,!1):s.select(r)):(d=s.getRng(!0),r&&d.setStartBefore(r),a&&d.setEndAfter(a),s.setRng(d)))}function d(a){function i(e,t){for(;e=e[t?"previousSibling":"nextSibling"];)if(3!==e.nodeType||e.nodeValue.length>0)return e}function d(e,t){s.select(e),s.collapse(t)}function g(a){function i(e){for(var t=d;t;){if(t===e)return;t=t.parentNode}u.remove(e),l()}function o(){var r,o,l=e.schema.getNonEmptyElements();for(o=new tinymce.dom.TreeWalker(d,e.getBody());(r=a?o.prev():o.next())&&!l[r.nodeName.toLowerCase()]&&!(3===r.nodeType&&tinymce.trim(r.nodeValue).length>0);)if("false"===t(r))return i(r),!0;return n(r)?!0:!1}var f,d,c,g;if(s.isCollapsed()){if(f=s.getRng(!0),d=f.startContainer,c=f.startOffset,d=r(d)||d,g=n(d))return i(g),!1;if(3==d.nodeType&&(a?c>0:c<d.nodeValue.length))return!0;if(1==d.nodeType&&(d=d.childNodes[c]||d),o())return!1}return!0}var m,p,v,E,h=a.keyCode;if(v=s.getStart(),E=s.getEnd(),m=n(v)||n(E),m&&(112>h||h>124)&&h!=c.DELETE&&h!=c.BACKSPACE){if((tinymce.isMac?a.metaKey:a.ctrlKey)&&(67==h||88==h||86==h))return;if(a.preventDefault(),h==c.LEFT||h==c.RIGHT){var y=h==c.LEFT;if(e.dom.isBlock(m)){var T=y?m.previousSibling:m.nextSibling,C=new f(T,T),b=y?C.prev():C.next();d(b,!y)}else d(m,y)}}else if(h==c.LEFT||h==c.RIGHT||h==c.BACKSPACE||h==c.DELETE){if(p=r(v)){if(h==c.LEFT||h==c.BACKSPACE)if(m=i(p,!0),m&&"false"===t(m)){if(a.preventDefault(),h!=c.LEFT)return void u.remove(m);d(m,!0)}else o(p);if(h==c.RIGHT||h==c.DELETE)if(m=i(p),m&&"false"===t(m)){if(a.preventDefault(),h!=c.RIGHT)return void u.remove(m);d(m,!1)}else o(p)}if((h==c.BACKSPACE||h==c.DELETE)&&!g(h==c.BACKSPACE))return a.preventDefault(),!1}}var u=e.dom,s=e.selection,g="mce_noneditablecaret",m="\ufeff";e.on("mousedown",function(n){var r=e.selection.getNode();"false"===t(r)&&r==n.target&&l()}),e.on("mouseup keyup",l),e.on("keydown",d)}function a(t){var n=l.length,r=t.content,a=tinymce.trim(o);if("raw"!=t.format){for(;n--;)r=r.replace(l[n],function(t){var n=arguments,i=n[n.length-2];return i>0&&'"'==r.charAt(i-1)?t:'<span class="'+a+'" data-mce-content="'+e.dom.encode(n[0])+'">'+e.dom.encode("string"==typeof n[1]?n[1]:n[0])+"</span>"});t.content=r}}var i,o,l,f=tinymce.dom.TreeWalker,d="contenteditable",u="data-mce-"+d,c=tinymce.util.VK;i=" "+tinymce.trim(e.getParam("noneditable_editable_class","mceEditable"))+" ",o=" "+tinymce.trim(e.getParam("noneditable_noneditable_class","mceNonEditable"))+" ",l=e.getParam("noneditable_regexp"),l&&!l.length&&(l=[l]),e.on("PreInit",function(){r(),l&&e.on("BeforeSetContent",a),e.parser.addAttributeFilter("class",function(e){for(var t,n,r=e.length;r--;)n=e[r],t=" "+n.attr("class")+" ",-1!==t.indexOf(i)?n.attr(u,"true"):-1!==t.indexOf(o)&&n.attr(u,"false")}),e.serializer.addAttributeFilter(u,function(e){for(var t,n=e.length;n--;)t=e[n],l&&t.attr("data-mce-content")?(t.name="#text",t.type=3,t.raw=!0,t.value=t.attr("data-mce-content")):(t.attr(d,null),t.attr(u,null))}),e.parser.addAttributeFilter(d,function(e){for(var t,n=e.length;n--;)t=e[n],t.attr(u,t.attr(d)),t.attr(d,null)})}),e.on("drop",function(e){n(e.target)&&e.preventDefault()})});
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("tabfocus",function(e){function n(e){9!==e.keyCode||e.ctrlKey||e.altKey||e.metaKey||e.preventDefault()}function t(n){function t(n){function t(e){return"BODY"===e.nodeName||"hidden"!=e.type&&"none"!=e.style.display&&"hidden"!=e.style.visibility&&t(e.parentNode)}function r(e){return e.tabIndex||"INPUT"==e.nodeName||"TEXTAREA"==e.nodeName}function c(e){return!r(e)&&"-1"!=e.getAttribute("tabindex")&&t(e)}if(u=i.select(":input:enabled,*[tabindex]:not(iframe)"),o(u,function(n,t){return n.id==e.id?(a=t,!1):void 0}),n>0){for(d=a+1;d<u.length;d++)if(c(u[d]))return u[d]}else for(d=a-1;d>=0;d--)if(c(u[d]))return u[d];return null}var a,u,c,d;if(!(9!==n.keyCode||n.ctrlKey||n.altKey||n.metaKey)&&(c=r(e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))),1==c.length&&(c[1]=c[0],c[0]=":prev"),u=n.shiftKey?":prev"==c[0]?t(-1):i.get(c[0]):":next"==c[1]?t(1):i.get(c[1]))){var y=tinymce.get(u.id||u.name);u.id&&y?y.focus():window.setTimeout(function(){tinymce.Env.webkit||window.focus(),u.focus()},10),n.preventDefault()}}var i=tinymce.DOM,o=tinymce.each,r=tinymce.explode;e.on("init",function(){e.inline&&tinymce.DOM.setAttrib(e.getBody(),"tabIndex",null)}),e.on("keyup",n),tinymce.Env.gecko?e.on("keypress keydown",t):e.on("keydown",t)});
|
||||
tinymce.PluginManager.add("tabfocus",function(e){function t(e){9!==e.keyCode||e.ctrlKey||e.altKey||e.metaKey||e.preventDefault()}function n(t){function n(n){function a(e){return"BODY"===e.nodeName||"hidden"!=e.type&&"none"!=e.style.display&&"hidden"!=e.style.visibility&&a(e.parentNode)}function c(e){return/INPUT|TEXTAREA|BUTTON/.test(e.tagName)&&tinymce.get(t.id)&&-1!=e.tabIndex&&a(e)}if(u=i.select(":input:enabled,*[tabindex]:not(iframe)"),o(u,function(t,n){return t.id==e.id?(r=n,!1):void 0}),n>0){for(d=r+1;d<u.length;d++)if(c(u[d]))return u[d]}else for(d=r-1;d>=0;d--)if(c(u[d]))return u[d];return null}var r,u,c,d;if(!(9!==t.keyCode||t.ctrlKey||t.altKey||t.metaKey||t.isDefaultPrevented())&&(c=a(e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))),1==c.length&&(c[1]=c[0],c[0]=":prev"),u=t.shiftKey?":prev"==c[0]?n(-1):i.get(c[0]):":next"==c[1]?n(1):i.get(c[1]))){var y=tinymce.get(u.id||u.name);u.id&&y?y.focus():window.setTimeout(function(){tinymce.Env.webkit||window.focus(),u.focus()},10),t.preventDefault()}}var i=tinymce.DOM,o=tinymce.each,a=tinymce.explode;e.on("init",function(){e.inline&&tinymce.DOM.setAttrib(e.getBody(),"tabIndex",null),e.on("keyup",t),tinymce.Env.gecko?e.on("keypress keydown",n):e.on("keydown",n)})});
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("template",function(e){function t(t){return function(){var a=e.settings.templates;"string"==typeof a?tinymce.util.XHR.send({url:a,success:function(e){t(tinymce.util.JSON.parse(e))}}):t(a)}}function a(t){function a(t){function a(t){if(-1==t.indexOf("<html>")){var a="";tinymce.each(e.contentCSS,function(t){a+='<link type="text/css" rel="stylesheet" href="'+e.documentBaseURI.toAbsolute(t)+'">'}),t="<!DOCTYPE html><html><head>"+a+"</head><body>"+t+"</body></html>"}t=r(t,"template_preview_replace_values");var l=n.find("iframe")[0].getEl().contentWindow.document;l.open(),l.write(t),l.close()}var c=t.control.value();c.url?tinymce.util.XHR.send({url:c.url,success:function(e){l=e,a(l)}}):(l=c.content,a(l)),n.find("#description")[0].text(t.control.value().description)}var n,l,i=[];return t&&0!==t.length?(tinymce.each(t,function(e){i.push({selected:!i.length,text:e.title,value:{url:e.url,content:e.content,description:e.description}})}),n=e.windowManager.open({title:"Insert template",layout:"flex",direction:"column",align:"stretch",padding:15,spacing:10,items:[{type:"form",flex:0,padding:0,items:[{type:"container",label:"Templates",items:{type:"listbox",label:"Templates",name:"template",values:i,onselect:a}}]},{type:"label",name:"description",label:"Description",text:" "},{type:"iframe",flex:1,border:1}],onsubmit:function(){c(!1,l)},width:e.getParam("template_popup_width",600),height:e.getParam("template_popup_height",500)}),void n.find("listbox")[0].fire("select")):void e.windowManager.alert("No templates defined")}function n(t,a){function n(e,t){if(e=""+e,e.length<t)for(var a=0;a<t-e.length;a++)e="0"+e;return e}var l="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),r="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),c="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),i="January February March April May June July August September October November December".split(" ");return a=a||new Date,t=t.replace("%D","%m/%d/%Y"),t=t.replace("%r","%I:%M:%S %p"),t=t.replace("%Y",""+a.getFullYear()),t=t.replace("%y",""+a.getYear()),t=t.replace("%m",n(a.getMonth()+1,2)),t=t.replace("%d",n(a.getDate(),2)),t=t.replace("%H",""+n(a.getHours(),2)),t=t.replace("%M",""+n(a.getMinutes(),2)),t=t.replace("%S",""+n(a.getSeconds(),2)),t=t.replace("%I",""+((a.getHours()+11)%12+1)),t=t.replace("%p",""+(a.getHours()<12?"AM":"PM")),t=t.replace("%B",""+e.translate(i[a.getMonth()])),t=t.replace("%b",""+e.translate(c[a.getMonth()])),t=t.replace("%A",""+e.translate(r[a.getDay()])),t=t.replace("%a",""+e.translate(l[a.getDay()])),t=t.replace("%%","%")}function l(t){var a=e.dom,n=e.getParam("template_replace_values");i(a.select("*",t),function(e){i(n,function(t,l){a.hasClass(e,l)&&"function"==typeof n[l]&&n[l](e)})})}function r(t,a){return i(e.getParam(a),function(e,a){"function"!=typeof e&&(t=t.replace(new RegExp("\\{\\$"+a+"\\}","g"),e))}),t}function c(t,a){function c(e,t){return new RegExp("\\b"+t+"\\b","g").test(e.className)}var o,s,p=e.dom,m=e.selection.getContent();a=r(a,"template_replace_values"),o=p.create("div",null,a),s=p.select(".mceTmpl",o),s&&s.length>0&&(o=p.create("div",null),o.appendChild(s[0].cloneNode(!0))),i(p.select("*",o),function(t){c(t,e.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))&&(t.innerHTML=n(e.getParam("template_cdate_format",e.getLang("template.cdate_format")))),c(t,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(t.innerHTML=n(e.getParam("template_mdate_format",e.getLang("template.mdate_format")))),c(t,e.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))&&(t.innerHTML=m)}),l(o),e.execCommand("mceInsertContent",!1,o.innerHTML),e.addVisual()}var i=tinymce.each;e.addCommand("mceInsertTemplate",c),e.addButton("template",{title:"Insert template",onclick:t(a)}),e.addMenuItem("template",{text:"Insert template",onclick:t(a),context:"insert"}),e.on("PreProcess",function(t){var a=e.dom;i(a.select("div",t.node),function(t){a.hasClass(t,"mceTmpl")&&(i(a.select("*",t),function(t){a.hasClass(t,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(t.innerHTML=n(e.getParam("template_mdate_format",e.getLang("template.mdate_format"))))}),l(t))})})});
|
||||
tinymce.PluginManager.add("template",function(e){function t(t){return function(){var a=e.settings.templates;"string"==typeof a?tinymce.util.XHR.send({url:a,success:function(e){t(tinymce.util.JSON.parse(e))}}):t(a)}}function a(t){function a(t){function a(t){if(-1==t.indexOf("<html>")){var a="";tinymce.each(e.contentCSS,function(t){a+='<link type="text/css" rel="stylesheet" href="'+e.documentBaseURI.toAbsolute(t)+'">'}),t="<!DOCTYPE html><html><head>"+a+"</head><body>"+t+"</body></html>"}t=r(t,"template_preview_replace_values");var l=n.find("iframe")[0].getEl().contentWindow.document;l.open(),l.write(t),l.close()}var c=t.control.value();c.url?tinymce.util.XHR.send({url:c.url,success:function(e){l=e,a(l)}}):(l=c.content,a(l)),n.find("#description")[0].text(t.control.value().description)}var n,l,i=[];return t&&0!==t.length?(tinymce.each(t,function(e){i.push({selected:!i.length,text:e.title,value:{url:e.url,content:e.content,description:e.description}})}),n=e.windowManager.open({title:"Insert template",layout:"flex",direction:"column",align:"stretch",padding:15,spacing:10,items:[{type:"form",flex:0,padding:0,items:[{type:"container",label:"Templates",items:{type:"listbox",label:"Templates",name:"template",values:i,onselect:a}}]},{type:"label",name:"description",label:"Description",text:"\xa0"},{type:"iframe",flex:1,border:1}],onsubmit:function(){c(!1,l)},width:e.getParam("template_popup_width",600),height:e.getParam("template_popup_height",500)}),void n.find("listbox")[0].fire("select")):void e.windowManager.alert("No templates defined")}function n(t,a){function n(e,t){if(e=""+e,e.length<t)for(var a=0;a<t-e.length;a++)e="0"+e;return e}var l="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),r="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),c="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),i="January February March April May June July August September October November December".split(" ");return a=a||new Date,t=t.replace("%D","%m/%d/%Y"),t=t.replace("%r","%I:%M:%S %p"),t=t.replace("%Y",""+a.getFullYear()),t=t.replace("%y",""+a.getYear()),t=t.replace("%m",n(a.getMonth()+1,2)),t=t.replace("%d",n(a.getDate(),2)),t=t.replace("%H",""+n(a.getHours(),2)),t=t.replace("%M",""+n(a.getMinutes(),2)),t=t.replace("%S",""+n(a.getSeconds(),2)),t=t.replace("%I",""+((a.getHours()+11)%12+1)),t=t.replace("%p",""+(a.getHours()<12?"AM":"PM")),t=t.replace("%B",""+e.translate(i[a.getMonth()])),t=t.replace("%b",""+e.translate(c[a.getMonth()])),t=t.replace("%A",""+e.translate(r[a.getDay()])),t=t.replace("%a",""+e.translate(l[a.getDay()])),t=t.replace("%%","%")}function l(t){var a=e.dom,n=e.getParam("template_replace_values");i(a.select("*",t),function(e){i(n,function(t,l){a.hasClass(e,l)&&"function"==typeof n[l]&&n[l](e)})})}function r(t,a){return i(e.getParam(a),function(e,a){"function"!=typeof e&&(t=t.replace(new RegExp("\\{\\$"+a+"\\}","g"),e))}),t}function c(t,a){function c(e,t){return new RegExp("\\b"+t+"\\b","g").test(e.className)}var o,s,p=e.dom,m=e.selection.getContent();a=r(a,"template_replace_values"),o=p.create("div",null,a),s=p.select(".mceTmpl",o),s&&s.length>0&&(o=p.create("div",null),o.appendChild(s[0].cloneNode(!0))),i(p.select("*",o),function(t){c(t,e.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))&&(t.innerHTML=n(e.getParam("template_cdate_format",e.getLang("template.cdate_format")))),c(t,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(t.innerHTML=n(e.getParam("template_mdate_format",e.getLang("template.mdate_format")))),c(t,e.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))&&(t.innerHTML=m)}),l(o),e.execCommand("mceInsertContent",!1,o.innerHTML),e.addVisual()}var i=tinymce.each;e.addCommand("mceInsertTemplate",c),e.addButton("template",{title:"Insert template",onclick:t(a)}),e.addMenuItem("template",{text:"Insert template",onclick:t(a),context:"insert"}),e.on("PreProcess",function(t){var a=e.dom;i(a.select("div",t.node),function(t){a.hasClass(t,"mceTmpl")&&(i(a.select("*",t),function(t){a.hasClass(t,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(t.innerHTML=n(e.getParam("template_mdate_format",e.getLang("template.mdate_format"))))}),l(t))})})});
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("visualchars",function(e){function a(a){var t,s,i,r,c,d,l=e.getBody(),m=e.selection;if(n=!n,o.state=n,e.fire("VisualChars",{state:n}),a&&(d=m.getBookmark()),n)for(s=[],tinymce.walk(l,function(e){3==e.nodeType&&e.nodeValue&&-1!=e.nodeValue.indexOf(" ")&&s.push(e)},"childNodes"),i=0;i<s.length;i++){for(r=s[i].nodeValue,r=r.replace(/(\u00a0)/g,'<span data-mce-bogus="1" class="mce-nbsp">$1</span>'),c=e.dom.create("div",null,r);t=c.lastChild;)e.dom.insertAfter(t,s[i]);e.dom.remove(s[i])}else for(s=e.dom.select("span.mce-nbsp",l),i=s.length-1;i>=0;i--)e.dom.remove(s[i],1);m.moveToBookmark(d)}function t(){var a=this;e.on("VisualChars",function(e){a.active(e.state)})}var n,o=this;e.addCommand("mceVisualChars",a),e.addButton("visualchars",{title:"Show invisible characters",cmd:"mceVisualChars",onPostRender:t}),e.addMenuItem("visualchars",{text:"Show invisible characters",cmd:"mceVisualChars",onPostRender:t,selectable:!0,context:"view",prependToContext:!0}),e.on("beforegetcontent",function(e){n&&"raw"!=e.format&&!e.draft&&(n=!0,a(!1))})});
|
||||
tinymce.PluginManager.add("visualchars",function(e){function a(a){var t,s,i,r,c,d,l=e.getBody(),m=e.selection;if(n=!n,o.state=n,e.fire("VisualChars",{state:n}),a&&(d=m.getBookmark()),n)for(s=[],tinymce.walk(l,function(e){3==e.nodeType&&e.nodeValue&&-1!=e.nodeValue.indexOf("\xa0")&&s.push(e)},"childNodes"),i=0;i<s.length;i++){for(r=s[i].nodeValue,r=r.replace(/(\u00a0)/g,'<span data-mce-bogus="1" class="mce-nbsp">$1</span>'),c=e.dom.create("div",null,r);t=c.lastChild;)e.dom.insertAfter(t,s[i]);e.dom.remove(s[i])}else for(s=e.dom.select("span.mce-nbsp",l),i=s.length-1;i>=0;i--)e.dom.remove(s[i],1);m.moveToBookmark(d)}function t(){var a=this;e.on("VisualChars",function(e){a.active(e.state)})}var n,o=this;e.addCommand("mceVisualChars",a),e.addButton("visualchars",{title:"Show invisible characters",cmd:"mceVisualChars",onPostRender:t}),e.addMenuItem("visualchars",{text:"Show invisible characters",cmd:"mceVisualChars",onPostRender:t,selectable:!0,context:"view",prependToContext:!0}),e.on("beforegetcontent",function(e){n&&"raw"!=e.format&&!e.draft&&(n=!0,a(!1))})});
|
||||
File diff suppressed because one or more lines are too long
@@ -69,6 +69,7 @@
|
||||
<Content Include="TheAdmin\Styles\ie7.css" />
|
||||
<Content Include="TheAdmin\Styles\ie8.css" />
|
||||
<Content Include="TheAdmin\Styles\images\adminNavBackground.gif" />
|
||||
<Content Include="TheAdmin\Styles\images\error.gif" />
|
||||
<Content Include="TheAdmin\Styles\images\icon-advisory.png" />
|
||||
<Content Include="TheAdmin\Styles\images\icon-contribute.png" />
|
||||
<Content Include="TheAdmin\Styles\images\icon-docs.png" />
|
||||
|
||||
@@ -649,9 +649,6 @@ namespace Orchard.ContentManagement {
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
var session = _sessionLocator.Value.For(typeof(ContentItemRecord));
|
||||
session.Clear();
|
||||
_contentManagerSession().Clear();
|
||||
}
|
||||
|
||||
public IContentQuery<ContentItem> Query() {
|
||||
|
||||
27
src/Orchard/Data/Conventions/UtcDateTimeConvention.cs
Normal file
27
src/Orchard/Data/Conventions/UtcDateTimeConvention.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentNHibernate.Conventions;
|
||||
using FluentNHibernate.Conventions.AcceptanceCriteria;
|
||||
using FluentNHibernate.Conventions.Inspections;
|
||||
using FluentNHibernate.Conventions.Instances;
|
||||
using NHibernate.Type;
|
||||
|
||||
namespace Orchard.Data.Conventions {
|
||||
public class UtcDateTimeConvention : IPropertyConvention, IPropertyConventionAcceptance {
|
||||
public void Apply(IPropertyInstance instance) {
|
||||
instance.CustomType<UtcDateTimeType>();
|
||||
}
|
||||
|
||||
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria) {
|
||||
criteria.Expect(x =>
|
||||
x.Property.Name.EndsWith("Utc", StringComparison.OrdinalIgnoreCase) && (
|
||||
x.Property.PropertyType.Equals(typeof(DateTime)) ||
|
||||
x.Property.PropertyType.Equals(typeof(DateTime?))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,8 @@ namespace Orchard.Data.Migration {
|
||||
|
||||
// apply update methods to each migration class for the module
|
||||
foreach (var migration in migrations) {
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
// copy the object for the Linq query
|
||||
var tempMigration = migration;
|
||||
|
||||
@@ -102,8 +104,6 @@ namespace Orchard.Data.Migration {
|
||||
}
|
||||
|
||||
try {
|
||||
_transactionManager.RequireNew();
|
||||
|
||||
// do we need to call Create() ?
|
||||
if (current == 0) {
|
||||
// try to resolve a Create method
|
||||
|
||||
@@ -91,6 +91,7 @@ namespace Orchard.Data.Providers {
|
||||
.Conventions.Setup(x => x.Add(AutoImport.Never()))
|
||||
.Conventions.Add(new RecordTableNameConvention(recordDescriptors))
|
||||
.Conventions.Add(new CacheConventions(recordDescriptors))
|
||||
.Conventions.Add(new UtcDateTimeConvention())
|
||||
.Alterations(alt => {
|
||||
foreach (var recordAssembly in recordDescriptors.Select(x => x.Type.Assembly).Distinct()) {
|
||||
alt.Add(new AutoMappingOverrideAlteration(recordAssembly));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using FluentNHibernate.Cfg.Db;
|
||||
using NHibernate.Cfg;
|
||||
using NHibernate.SqlAzure;
|
||||
|
||||
namespace Orchard.Data.Providers {
|
||||
public class SqlServerDataServicesProvider : AbstractDataServicesProvider {
|
||||
@@ -26,13 +25,8 @@ namespace Orchard.Data.Providers {
|
||||
|
||||
persistence = persistence.ConnectionString(_connectionString);
|
||||
|
||||
// when using Sql Server Azure, use a specific driver, c.f. https://orchard.codeplex.com/workitem/19315
|
||||
if (IsAzureSql()) {
|
||||
persistence = persistence.Driver<SqlAzureClientDriver>();
|
||||
}
|
||||
|
||||
// use MsSql2012Dialect if on Azure or if specified in the connection string
|
||||
if (IsAzureSql() || _connectionString.IndexOf(";Dialect=MsSql2012Dialect", StringComparison.OrdinalIgnoreCase) > 0) {
|
||||
if (IsAzureSql()) {
|
||||
persistence = persistence.Dialect<NHibernate.Dialect.MsSql2012Dialect>();
|
||||
}
|
||||
|
||||
@@ -41,10 +35,6 @@ namespace Orchard.Data.Providers {
|
||||
|
||||
protected override void AlterConfiguration(Configuration config) {
|
||||
config.SetProperty(NHibernate.Cfg.Environment.PrepareSql, Boolean.TrueString);
|
||||
|
||||
if (IsAzureSql()) {
|
||||
config.SetProperty(NHibernate.Cfg.Environment.TransactionStrategy, typeof(ReliableAdoNetWithDistributedTransactionFactory).AssemblyQualifiedName);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsAzureSql() {
|
||||
|
||||
@@ -142,6 +142,10 @@ namespace Orchard.Data {
|
||||
var pathName = GetPathName(_shellSettings.Name);
|
||||
hash.AddString(_appDataFolder.MapPath(pathName).ToLowerInvariant());
|
||||
|
||||
// Orchard version, to rebuild the mappings for each new version
|
||||
var orchardVersion = new System.Reflection.AssemblyName(typeof(Orchard.ContentManagement.ContentItem).Assembly.FullName).Version.ToString();
|
||||
hash.AddString(orchardVersion);
|
||||
|
||||
// Shell settings data
|
||||
hash.AddString(_shellSettings.DataProvider);
|
||||
hash.AddString(_shellSettings.DataTablePrefix);
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using NHibernate;
|
||||
using NHibernate.SqlCommand;
|
||||
using NHibernate.Type;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Exceptions;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Security;
|
||||
@@ -14,15 +15,19 @@ namespace Orchard.Data {
|
||||
public class SessionLocator : ISessionLocator, ITransactionManager, IDisposable {
|
||||
private readonly ISessionFactoryHolder _sessionFactoryHolder;
|
||||
private readonly IEnumerable<ISessionInterceptor> _interceptors;
|
||||
private Func<IContentManagerSession> _contentManagerSessionFactory;
|
||||
|
||||
private ISession _session;
|
||||
private ITransaction _transaction;
|
||||
private bool _cancelled;
|
||||
private IContentManagerSession _contentManagerSession;
|
||||
|
||||
public SessionLocator(
|
||||
ISessionFactoryHolder sessionFactoryHolder,
|
||||
ISessionFactoryHolder sessionFactoryHolder,
|
||||
Func<IContentManagerSession> contentManagerSessionFactory,
|
||||
IEnumerable<ISessionInterceptor> interceptors) {
|
||||
_sessionFactoryHolder = sessionFactoryHolder;
|
||||
_interceptors = interceptors;
|
||||
_contentManagerSessionFactory = contentManagerSessionFactory;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
IsolationLevel = IsolationLevel.ReadCommitted;
|
||||
}
|
||||
@@ -32,19 +37,13 @@ namespace Orchard.Data {
|
||||
|
||||
public ISession For(Type entityType) {
|
||||
Logger.Debug("Acquiring session for {0}", entityType);
|
||||
|
||||
((ITransactionManager)this).Demand();
|
||||
Demand();
|
||||
|
||||
return _session;
|
||||
}
|
||||
|
||||
public void Demand() {
|
||||
EnsureSession();
|
||||
|
||||
if (_transaction == null) {
|
||||
Logger.Debug("Creating transaction on Demand");
|
||||
_transaction = _session.BeginTransaction(IsolationLevel);
|
||||
}
|
||||
EnsureSession(IsolationLevel);
|
||||
}
|
||||
|
||||
public void RequireNew() {
|
||||
@@ -52,71 +51,51 @@ namespace Orchard.Data {
|
||||
}
|
||||
|
||||
public void RequireNew(IsolationLevel level) {
|
||||
EnsureSession();
|
||||
|
||||
if (_cancelled) {
|
||||
if (_transaction != null) {
|
||||
_transaction.Rollback();
|
||||
_transaction.Dispose();
|
||||
_transaction = null;
|
||||
}
|
||||
|
||||
_cancelled = false;
|
||||
}
|
||||
else {
|
||||
if (_transaction != null) {
|
||||
_transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Debug("Creating new transaction with isolation level {0}", level);
|
||||
_transaction = _session.BeginTransaction(level);
|
||||
DisposeSession();
|
||||
EnsureSession(level);
|
||||
}
|
||||
|
||||
public void Cancel() {
|
||||
Logger.Debug("Transaction cancelled flag set");
|
||||
_cancelled = true;
|
||||
if (_session!= null && !_session.Transaction.WasRolledBack && _session.Transaction.IsActive) {
|
||||
Logger.Debug("Rolling back transaction");
|
||||
_session.Transaction.Rollback();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
if (_transaction != null) {
|
||||
try {
|
||||
if (!_cancelled) {
|
||||
Logger.Debug("Marking transaction as complete");
|
||||
_transaction.Commit();
|
||||
}
|
||||
else {
|
||||
Logger.Debug("Reverting operations from transaction");
|
||||
_transaction.Rollback();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.Error(e, "Error while disposing the transaction.");
|
||||
}
|
||||
finally {
|
||||
_transaction.Dispose();
|
||||
Logger.Debug("Transaction disposed");
|
||||
|
||||
_transaction = null;
|
||||
_cancelled = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_session != null) {
|
||||
_session.Dispose();
|
||||
_session = null;
|
||||
}
|
||||
|
||||
DisposeSession();
|
||||
}
|
||||
|
||||
private void EnsureSession() {
|
||||
private void DisposeSession() {
|
||||
if (_session != null) {
|
||||
|
||||
try {
|
||||
if (!_session.Transaction.WasRolledBack && _session.Transaction.IsActive) {
|
||||
Logger.Debug("Committing transaction");
|
||||
_session.Transaction.Commit();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
_contentManagerSession.Clear();
|
||||
|
||||
Logger.Debug("Disposing session");
|
||||
_session.Close();
|
||||
_session.Dispose();
|
||||
_session = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureSession(IsolationLevel level) {
|
||||
if (_session != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var sessionFactory = _sessionFactoryHolder.GetSessionFactory();
|
||||
Logger.Information("Opening database session");
|
||||
Logger.Debug("Opening NHibernate session");
|
||||
_session = sessionFactory.OpenSession(new OrchardSessionInterceptor(_interceptors.ToArray(), Logger));
|
||||
_session.BeginTransaction(level);
|
||||
_contentManagerSession = _contentManagerSessionFactory();
|
||||
}
|
||||
|
||||
class OrchardSessionInterceptor : IInterceptor {
|
||||
|
||||
9
src/Orchard/DisplayManagement/IShapeBindingResolver.cs
Normal file
9
src/Orchard/DisplayManagement/IShapeBindingResolver.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
|
||||
namespace Orchard.DisplayManagement {
|
||||
public interface IShapeBindingResolver : IDependency {
|
||||
bool TryGetDescriptorBinding(string shapeType, out ShapeBinding shapeBinding);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ namespace Orchard.DisplayManagement.Implementation {
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private readonly IEnumerable<IShapeDisplayEvents> _shapeDisplayEvents;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IEnumerable<IShapeBindingResolver> _shapeBindingResolvers;
|
||||
|
||||
// this need to be Shape instead of IShape - cast to interface throws error on clr types like HtmlString
|
||||
private static readonly CallSite<Func<CallSite, object, Shape>> _convertAsShapeCallsite = CallSite<Func<CallSite, object, Shape>>.Create(
|
||||
@@ -30,12 +31,15 @@ namespace Orchard.DisplayManagement.Implementation {
|
||||
public DefaultDisplayManager(
|
||||
IWorkContextAccessor workContextAccessor,
|
||||
IEnumerable<IShapeDisplayEvents> shapeDisplayEvents,
|
||||
IEnumerable<IShapeBindingResolver> shapeBindingResolvers,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
Lazy<IShapeTableLocator> shapeTableLocator) {
|
||||
_shapeTableLocator = shapeTableLocator;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_shapeDisplayEvents = shapeDisplayEvents;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_shapeBindingResolvers = shapeBindingResolvers;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
@@ -135,12 +139,19 @@ namespace Orchard.DisplayManagement.Implementation {
|
||||
return shape.Metadata.ChildContent;
|
||||
}
|
||||
|
||||
static bool TryGetDescriptorBinding(string shapeType, IEnumerable<string> shapeAlternates, ShapeTable shapeTable, out ShapeBinding shapeBinding) {
|
||||
private bool TryGetDescriptorBinding(string shapeType, IEnumerable<string> shapeAlternates, ShapeTable shapeTable, out ShapeBinding shapeBinding) {
|
||||
// shape alternates are optional, fully qualified binding names
|
||||
// the earliest added alternates have the lowest priority
|
||||
// the descriptor returned is based on the binding that is matched, so it may be an entirely
|
||||
// different descriptor if the alternate has a different base name
|
||||
foreach (var shapeAlternate in shapeAlternates.Reverse()) {
|
||||
|
||||
foreach (var shapeBindingResolver in _shapeBindingResolvers) {
|
||||
if(shapeBindingResolver.TryGetDescriptorBinding(shapeAlternate, out shapeBinding)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shapeTable.Bindings.TryGetValue(shapeAlternate, out shapeBinding)) {
|
||||
return true;
|
||||
}
|
||||
@@ -151,6 +162,12 @@ namespace Orchard.DisplayManagement.Implementation {
|
||||
// so the shapetype itself may contain a longer alternate forms that falls back to a shorter one
|
||||
var shapeTypeScan = shapeType;
|
||||
for (; ; ) {
|
||||
foreach (var shapeBindingResolver in _shapeBindingResolvers) {
|
||||
if (shapeBindingResolver.TryGetDescriptorBinding(shapeTypeScan, out shapeBinding)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shapeTable.Bindings.TryGetValue(shapeTypeScan, out shapeBinding)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ namespace Orchard.Environment.Configuration {
|
||||
}
|
||||
|
||||
IEnumerable<ShellSettings> IShellSettingsManager.LoadSettings() {
|
||||
Logger.Debug("Reading ShellSettings...");
|
||||
Logger.Information("Reading ShellSettings...");
|
||||
var settingsList = LoadSettingsInternal().ToArray();
|
||||
|
||||
var tenantNamesQuery =
|
||||
from settings in settingsList
|
||||
select settings.Name;
|
||||
Logger.Debug("Returning {0} ShellSettings objects for tenants {1}.", tenantNamesQuery.Count(), String.Join(", ", tenantNamesQuery));
|
||||
Logger.Information("Returning {0} ShellSettings objects for tenants {1}.", tenantNamesQuery.Count(), String.Join(", ", tenantNamesQuery));
|
||||
|
||||
return settingsList;
|
||||
}
|
||||
@@ -36,11 +36,11 @@ namespace Orchard.Environment.Configuration {
|
||||
if (String.IsNullOrEmpty(settings.Name))
|
||||
throw new ArgumentException("The Name property of the supplied ShellSettings object is null or empty; the settings cannot be saved.", "settings");
|
||||
|
||||
Logger.Debug("Saving ShellSettings for tenant '{0}'...", settings.Name);
|
||||
Logger.Information("Saving ShellSettings for tenant '{0}'...", settings.Name);
|
||||
var filePath = Path.Combine(Path.Combine("Sites", settings.Name), _settingsFileName);
|
||||
_appDataFolder.CreateFile(filePath, ShellSettingsSerializer.ComposeSettings(settings));
|
||||
|
||||
Logger.Debug("ShellSettings saved successfully; flagging tenant '{0}' for restart.", settings.Name);
|
||||
Logger.Information("ShellSettings saved successfully; flagging tenant '{0}' for restart.", settings.Name);
|
||||
_events.Saved(settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,9 @@ namespace Orchard.FileSystems.Dependencies {
|
||||
/// </summary>
|
||||
public class DynamicModuleVirtualPathProvider : VirtualPathProvider, ICustomVirtualPathProvider {
|
||||
private readonly IExtensionDependenciesManager _extensionDependenciesManager;
|
||||
private readonly IEnumerable<IExtensionLoader> _loaders;
|
||||
|
||||
public DynamicModuleVirtualPathProvider(IExtensionDependenciesManager extensionDependenciesManager, IEnumerable<IExtensionLoader> loaders) {
|
||||
public DynamicModuleVirtualPathProvider(IExtensionDependenciesManager extensionDependenciesManager) {
|
||||
_extensionDependenciesManager = extensionDependenciesManager;
|
||||
_loaders = loaders;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
|
||||
34
src/Orchard/FileSystems/Media/StorageProviderExtensions.cs
Normal file
34
src/Orchard/FileSystems/Media/StorageProviderExtensions.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Orchard.FileSystems.Media {
|
||||
public static class StorageProviderExtensions {
|
||||
public static void WriteAllText(this IStorageProvider storageProvider, string path, string contents) {
|
||||
if (storageProvider.FileExists(path)) {
|
||||
storageProvider.DeleteFile(path);
|
||||
}
|
||||
|
||||
var file = storageProvider.CreateFile(path);
|
||||
using (var stream = file.OpenWrite())
|
||||
using (var streamWriter = new StreamWriter(stream)) {
|
||||
streamWriter.Write(contents);
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadAllText(this IStorageProvider storageProvider, string path) {
|
||||
if (!storageProvider.FileExists(path)) {
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var file = storageProvider.GetFile(path);
|
||||
using (var stream = file.OpenRead())
|
||||
using (var streamReader = new StreamReader(stream)) {
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,9 +94,6 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nhibernate.linq\NHibernate.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate.SqlAzure">
|
||||
<HintPath>..\..\lib\nhibernate.sqlazure\NHibernate.SqlAzure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
@@ -174,6 +171,7 @@
|
||||
<Compile Include="ContentManagement\Utilities\ComputedField.cs" />
|
||||
<Compile Include="Data\AbstractSessionInterceptor.cs" />
|
||||
<Compile Include="Data\Bags\SArray.cs" />
|
||||
<Compile Include="Data\Conventions\UtcDateTimeConvention.cs" />
|
||||
<Compile Include="Data\FetchRequest.cs" />
|
||||
<Compile Include="Data\Migration\Interpreters\MySqlCommandInterpreter.cs" />
|
||||
<Compile Include="Data\Providers\MySqlStatementProvider.cs" />
|
||||
@@ -210,6 +208,7 @@
|
||||
<Compile Include="DisplayManagement\Implementation\IShapeDisplayEvents.cs" />
|
||||
<Compile Include="DisplayManagement\Implementation\IShapeFactoryEvents.cs" />
|
||||
<Compile Include="DisplayManagement\INamedEnumerable.cs" />
|
||||
<Compile Include="DisplayManagement\IShapeBindingResolver.cs" />
|
||||
<Compile Include="DisplayManagement\IShapeDisplay.cs" />
|
||||
<Compile Include="DisplayManagement\ShapeDisplay.cs" />
|
||||
<Compile Include="DisplayManagement\Shapes\Composite.cs" />
|
||||
@@ -259,6 +258,7 @@
|
||||
<Compile Include="FileSystems\Media\ConfigurationMimeTypeProvider.cs" />
|
||||
<Compile Include="FileSystems\Media\FileSystemStorageProvider.cs" />
|
||||
<Compile Include="FileSystems\Media\IMimeTypeProvider.cs" />
|
||||
<Compile Include="FileSystems\Media\StorageProviderExtensions.cs" />
|
||||
<Compile Include="Indexing\ISearchBits.cs" />
|
||||
<Compile Include="Localization\LocalizationExtensions.cs" />
|
||||
<Compile Include="Localization\Models\DateLocalizationOptions.cs" />
|
||||
|
||||
@@ -2,7 +2,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Tasks {
|
||||
|
||||
@@ -14,10 +16,18 @@ namespace Orchard.Tasks {
|
||||
public class BackgroundService : IBackgroundService {
|
||||
private readonly IEnumerable<IBackgroundTask> _tasks;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private readonly string _shellName;
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public BackgroundService(IEnumerable<IBackgroundTask> tasks, ITransactionManager transactionManager) {
|
||||
public BackgroundService(
|
||||
IEnumerable<IBackgroundTask> tasks,
|
||||
ITransactionManager transactionManager,
|
||||
ShellSettings shellSettings,
|
||||
IContentManager contentManager) {
|
||||
_tasks = tasks;
|
||||
_transactionManager = transactionManager;
|
||||
_shellName = shellSettings.Name;
|
||||
_contentManager = contentManager;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
@@ -31,9 +41,8 @@ namespace Orchard.Tasks {
|
||||
}
|
||||
catch (Exception e) {
|
||||
_transactionManager.Cancel();
|
||||
Logger.Error(e, "Error while processing background task");
|
||||
Logger.Error(e, "Error while processing background task on tenant '{0}'.", _shellName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Orchard.UI.Navigation {
|
||||
public class NavigationBuilder {
|
||||
IEnumerable<MenuItem> Contained { get; set; }
|
||||
|
||||
public NavigationBuilder Add(string caption, string position, Action<NavigationItemBuilder> itemBuilder) {
|
||||
var childBuilder = new NavigationItemBuilder();
|
||||
|
||||
if (!string.IsNullOrEmpty(caption))
|
||||
childBuilder.Caption(caption);
|
||||
|
||||
if (!string.IsNullOrEmpty(position))
|
||||
childBuilder.Position(position);
|
||||
|
||||
itemBuilder(childBuilder);
|
||||
Contained = (Contained ?? Enumerable.Empty<MenuItem>()).Concat(childBuilder.Build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public NavigationBuilder Add(string caption, Action<NavigationItemBuilder> itemBuilder) {
|
||||
return Add(caption, null, itemBuilder);
|
||||
}
|
||||
public NavigationBuilder Add(Action<NavigationItemBuilder> itemBuilder) {
|
||||
return Add(null, null, itemBuilder);
|
||||
}
|
||||
public NavigationBuilder Add(string caption, string position) {
|
||||
return Add(caption, position, x=> { });
|
||||
}
|
||||
public NavigationBuilder Add(string caption) {
|
||||
return Add(caption, null, x => { });
|
||||
}
|
||||
|
||||
public IEnumerable<MenuItem> Build() {
|
||||
return (Contained ?? Enumerable.Empty<MenuItem>()).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public class NavigationItemBuilder : NavigationBuilder {
|
||||
private readonly MenuItem _item;
|
||||
|
||||
public NavigationItemBuilder() {
|
||||
_item = new MenuItem();
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Caption(string caption) {
|
||||
_item.Text = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Position(string position) {
|
||||
_item.Position = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
public new IEnumerable<MenuItem> Build() {
|
||||
_item.Contained = base.Build();
|
||||
return new[] { _item };
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName) {
|
||||
return Action(actionName, null, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName, string controllerName) {
|
||||
return Action(actionName, controllerName, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName, string controllerName, object values) {
|
||||
return Action(actionName, controllerName, new RouteValueDictionary(values));
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName, string controllerName, RouteValueDictionary values) {
|
||||
_item.RouteValues = new RouteValueDictionary(values);
|
||||
if (!string.IsNullOrEmpty(actionName))
|
||||
_item.RouteValues["action"] = actionName;
|
||||
if (!string.IsNullOrEmpty(controllerName))
|
||||
_item.RouteValues["controller"] = controllerName;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user