Merge branch '1.x' into feature/audittrail

This commit is contained in:
Sipke Schoorstra
2014-07-15 20:48:48 -07:00
20 changed files with 103 additions and 60 deletions

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Orchard.Caching;
using Orchard.DisplayManagement.Descriptors;
using Orchard.Utility.Extensions;
namespace Orchard.Core.Common.Services {
public class FlavorService : IFlavorService {
private readonly Func<IShapeTableLocator> _shapeTableLocator;
private readonly IWorkContextAccessor _wca;
private readonly ICacheManager _cacheManager;
public FlavorService(Func<IShapeTableLocator> shapeTableLocator, IWorkContextAccessor wca, ICacheManager cacheManager) {
_shapeTableLocator = shapeTableLocator;
_wca = wca;
_cacheManager = cacheManager;
}
public IList<string> GetFlavors() {
return _cacheManager.Get("Flavors", context => {
var shapeTable = _shapeTableLocator().Lookup(_wca.GetContext().CurrentTheme.Id);
var flavors = shapeTable.Bindings.Keys
.Where(x => x.StartsWith("Body_Editor__", StringComparison.OrdinalIgnoreCase))
.Select(x => x.Substring("Body_Editor__".Length))
.Where(x => !String.IsNullOrWhiteSpace(x))
.Select(x => x[0].ToString(CultureInfo.InvariantCulture).ToUpper() + x.Substring(1))
.Select(x => x.CamelFriendly());
return flavors.ToList();
});
}
}
}

View File

@@ -0,0 +1,7 @@
using System.Collections.Generic;
namespace Orchard.Core.Common.Services {
public interface IFlavorService : IDependency {
IList<string> GetFlavors();
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
@@ -9,6 +10,8 @@ namespace Orchard.Core.Common.Settings {
public class BodyPartSettings {
public const string FlavorDefaultDefault = "html";
private string _flavorDefault;
[DataType("Flavor")]
public string FlavorDefault {
get { return !string.IsNullOrWhiteSpace(_flavorDefault)
? _flavorDefault
@@ -18,6 +21,7 @@ namespace Orchard.Core.Common.Settings {
}
public class BodyTypePartSettings {
[DataType("Flavor")]
public string Flavor { get; set; }
}

View File

@@ -1,6 +1,9 @@
namespace Orchard.Core.Common.Settings {
using System.ComponentModel.DataAnnotations;
namespace Orchard.Core.Common.Settings {
public class TextFieldSettings {
[DataType("Flavor")]
public string Flavor { get; set; }
public bool Required { get; set; }
public string Hint { get; set; }

View File

@@ -1,41 +1,19 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.ViewModels;
using Orchard.Core.Common.ViewModels;
using Orchard.DisplayManagement.Descriptors;
using Orchard.Utility.Extensions;
namespace Orchard.Core.Common.Settings {
public class TextFieldSettingsEvents : ContentDefinitionEditorEventsBase {
private readonly IOrchardServices _orchardServices;
private readonly Func<IShapeTableLocator> _shapeTableLocator;
public TextFieldSettingsEvents(IOrchardServices orchardServices, Func<IShapeTableLocator> shapeTableLocator) {
_orchardServices = orchardServices;
_shapeTableLocator = shapeTableLocator;
}
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) {
if (definition.FieldDefinition.Name == "TextField") {
var shapeTable = _shapeTableLocator().Lookup(_orchardServices.WorkContext.CurrentTheme.Id);
var flavors = shapeTable.Bindings.Keys
.Where(x => x.StartsWith("Body_Editor__", StringComparison.OrdinalIgnoreCase))
.Select(x => x.Substring("Body_Editor__".Length))
.Where(x => !String.IsNullOrWhiteSpace(x))
.Select(x => x[0].ToString(CultureInfo.InvariantCulture).ToUpper() + x.Substring(1) )
.Select(x => x.CamelFriendly())
;
var model = new TextFieldSettingsEventsViewModel {
Settings = definition.Settings.GetModel<TextFieldSettings>(),
Flavors = flavors.ToArray()
};
yield return DefinitionTemplate(model);

View File

@@ -2,11 +2,6 @@
namespace Orchard.Core.Common.ViewModels {
public class TextFieldSettingsEventsViewModel {
public TextFieldSettingsEventsViewModel() {
Flavors = new string[0];
}
public TextFieldSettings Settings { get; set; }
public string[] Flavors { get; set; }
}
}

View File

@@ -1,16 +1,9 @@
@using Orchard.Utility.Extensions
@model Orchard.Core.Common.ViewModels.TextFieldSettingsEventsViewModel
@model Orchard.Core.Common.ViewModels.TextFieldSettingsEventsViewModel
<fieldset>
<div>
<label for="@Html.FieldIdFor(m => m.Settings.Flavor)" class="forcheckbox">@T("Display options")</label>
<select id="@Html.FieldIdFor(m => m.Settings.Flavor)" name="@Html.FieldNameFor(m => m.Settings.Flavor)">
@Html.SelectOption("", String.IsNullOrWhiteSpace(Model.Settings.Flavor), T("Default flavor").ToString())
@foreach(string flavor in Model.Flavors) {
@Html.SelectOption(flavor, flavor.Equals(Model.Settings.Flavor, StringComparison.OrdinalIgnoreCase), flavor.CamelFriendly())
}
</select>
@Html.EditorFor(m => m.Settings.Flavor)
@Html.ValidationMessageFor(m => m.Settings.Flavor)
</div>
</fieldset>
@@ -23,6 +16,6 @@
<fieldset>
<label for="@Html.FieldIdFor(m => m.Settings.Hint)">@T("Help text")</label>
@Html.TextAreaFor(m => m.Settings.Hint, new { @class = "text medium", rows = "5" })
<span class="hint">@T("The help text is written under the field when authors are editing the content item.")</span>
<span class="hint">@T("The help text is written under the field when authors are editing the content item.")</span>
@Html.ValidationMessageFor(m => m.Settings.Hint)
</fieldset>

View File

@@ -0,0 +1,8 @@
@using Orchard.Core.Common.Services
@using Orchard.Utility.Extensions
@{
var flavors = WorkContext.Resolve<IFlavorService>().GetFlavors();
var selectedFlavor = ViewData.TemplateInfo.FormattedModelValue as string;
var options = flavors.Select(x => new SelectListItem {Text = x.CamelFriendly(), Value = x, Selected = String.Equals(x, selectedFlavor, StringComparison.OrdinalIgnoreCase)}).ToArray();
}
@Html.DropDownList("", options, T("Default Flavor").Text)

View File

@@ -86,7 +86,9 @@
<Compile Include="Common\Models\IdentityPart.cs" />
<Compile Include="Common\ResourceManifest.cs" />
<Compile Include="Common\Routes.cs" />
<Compile Include="Common\Services\FlavorService.cs" />
<Compile Include="Common\Services\IdentifierResolverSelector.cs" />
<Compile Include="Common\Services\IFlavorService.cs" />
<Compile Include="Common\Services\TextFieldFilter.cs" />
<Compile Include="Common\Services\XmlRpcHandler.cs" />
<Compile Include="Common\DateEditor\DateEditorViewModel.cs" />
@@ -559,6 +561,9 @@
<Content Include="Containers\Views\EditorTemplates\ContainerWidget.cshtml" />
<Content Include="Containers\Views\Parts.ContainerWidget.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Common\Views\EditorTemplates\Flavor.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -1,6 +1,6 @@
(function($) {
$(function() {
$("#search-box").focus().on("keyup", function (e) {
$("#search-box").on("keyup", function (e) {
var text = $(this).val();
if (e.keyCode == 13) {

View File

@@ -11,7 +11,7 @@
</div>
<fieldset class="bulk-actions">
<label for="search-box">@T("Filter:")</label>
<input id="search-box" class="text" type="text" />
<input id="search-box" class="text" type="text" autofocus="autofocus" />
</fieldset>
<ul class="contentItems">
@foreach (var type in Model.Types) {

View File

@@ -9,7 +9,7 @@
</div>
<fieldset class="bulk-actions">
<label for="search-box">@T("Filter:")</label>
<input id="search-box" class="text" type="text" />
<input id="search-box" class="text" type="text" autofocus="autofocus" />
</fieldset>
<ul class="contentItems">
@foreach (var type in Model.Parts) {

View File

@@ -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.0").SetDependencies("jQuery");
manifest.DefineScript("TinyMce").SetUrl("tinymce.min.js").SetVersion("4.1.1").SetDependencies("jQuery");
manifest.DefineScript("OrchardTinyMce").SetUrl("orchard-tinymce.js").SetDependencies("TinyMce");
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -92,8 +92,8 @@
var allListItems = $("ul.menu-admin li ul li").not("#NavFilter");
var itemHeading = $("ul.menu-admin li h3");
$("#adminfilter").keyup(function () {
var a = $(this).val();
$("#adminfilter").keyup(function (e) {
var a = $(this).val().toLowerCase();
var filteredItemHeading = itemHeading.filter(function (b, c) {
return $(c).text().toLowerCase().indexOf(a) !== -1;
@@ -114,6 +114,17 @@
} else {
allListItems.show();
}
if (e.keyCode == 13) {
var visibleItems = adminMenu.find("li a").filter(":visible");
if (visibleItems.length > 0) {
var hit = visibleItems.filter(function(b, c) {
return $(c).text().toLowerCase().indexOf(a) !== -1;
});
location.href = hit.attr("href");
}
}
});
};

View File

@@ -11,7 +11,7 @@
}
Model.Attributes.Add("role", "navigation");
Model.Attributes.Add("data-filter-watermark", T("filter").Text);
Model.Attributes.Add("data-filter-watermark", T("Filter").Text);
var tag = Tag(Model, "ul");
}
@tag.StartElement

View File

@@ -75,6 +75,10 @@ namespace Orchard.ContentManagement.Drivers {
if(String.IsNullOrEmpty(location) || location == "-") {
return editor;
}
if ((editor.GetGroup() ?? string.Empty) != (context.GroupId ?? string.Empty)) {
return editor;
}
}
}