More admin menu adjustments.

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2011-02-23 16:56:14 -08:00
parent 44a56126a4
commit 13f3ca08bd
10 changed files with 57 additions and 10 deletions

View File

@@ -1,5 +1,4 @@
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Security; using Orchard.Security;
using Orchard.Settings; using Orchard.Settings;

View File

@@ -17,6 +17,8 @@ namespace Orchard.Comments.Handlers {
public Localizer T { get; set; } public Localizer T { get; set; }
protected override void GetItemMetadata(GetContentItemMetadataContext context) { protected override void GetItemMetadata(GetContentItemMetadataContext context) {
if (context.ContentItem.ContentType != "Site")
return;
base.GetItemMetadata(context); base.GetItemMetadata(context);
context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Comments"))); context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Comments")));
} }

View File

@@ -1,4 +1,5 @@
using Orchard.ContentManagement; using System;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Email.Models; using Orchard.Email.Models;
using Orchard.Localization; using Orchard.Localization;
@@ -19,12 +20,18 @@ namespace Orchard.Email.Drivers {
protected override string Prefix { get { return "SmtpSettings"; } } protected override string Prefix { get { return "SmtpSettings"; } }
protected override DriverResult Editor(SmtpSettingsPart part, dynamic shapeHelper) { protected override DriverResult Editor(SmtpSettingsPart part, string groupInfoId, dynamic shapeHelper) {
if (!string.Equals(groupInfoId, "email", StringComparison.OrdinalIgnoreCase))
return null;
return ContentShape("Parts_SmtpSettings_Edit", return ContentShape("Parts_SmtpSettings_Edit",
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix)); () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix));
} }
protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater, dynamic shapeHelper) { protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater, string groupInfoId, dynamic shapeHelper) {
if (!string.Equals(groupInfoId, "email", StringComparison.OrdinalIgnoreCase))
return null;
var previousPassword = part.Password; var previousPassword = part.Password;
updater.TryUpdateModel(part, Prefix, null, null); updater.TryUpdateModel(part, Prefix, null, null);

View File

@@ -1,9 +1,11 @@
using System; using System;
using System.Text; using System.Text;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Email.Models; using Orchard.Email.Models;
using Orchard.Data; using Orchard.Data;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.Localization;
using Orchard.Security; using Orchard.Security;
namespace Orchard.Email.Handlers { namespace Orchard.Email.Handlers {
@@ -12,6 +14,7 @@ namespace Orchard.Email.Handlers {
private readonly IEncryptionService _encryptionService; private readonly IEncryptionService _encryptionService;
public SmtpSettingsPartHandler(IRepository<SmtpSettingsPartRecord> repository, IEncryptionService encryptionService) { public SmtpSettingsPartHandler(IRepository<SmtpSettingsPartRecord> repository, IEncryptionService encryptionService) {
T = NullLocalizer.Instance;
_encryptionService = encryptionService; _encryptionService = encryptionService;
Filters.Add(new ActivatingFilter<SmtpSettingsPart>("Site")); Filters.Add(new ActivatingFilter<SmtpSettingsPart>("Site"));
Filters.Add(StorageFilter.For(repository)); Filters.Add(StorageFilter.For(repository));
@@ -23,5 +26,14 @@ namespace Orchard.Email.Handlers {
part.PasswordField.Getter(() => String.IsNullOrWhiteSpace(part.Record.Password) ? String.Empty : Encoding.UTF8.GetString(_encryptionService.Decode(Convert.FromBase64String(part.Record.Password)))); part.PasswordField.Getter(() => String.IsNullOrWhiteSpace(part.Record.Password) ? String.Empty : Encoding.UTF8.GetString(_encryptionService.Decode(Convert.FromBase64String(part.Record.Password))));
part.PasswordField.Setter(value => part.Record.Password = String.IsNullOrWhiteSpace(value) ? String.Empty : Convert.ToBase64String(_encryptionService.Encode(Encoding.UTF8.GetBytes(value)))); part.PasswordField.Setter(value => part.Record.Password = String.IsNullOrWhiteSpace(value) ? String.Empty : Convert.ToBase64String(_encryptionService.Encode(Encoding.UTF8.GetBytes(value))));
} }
public Localizer T { get; set; }
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
if (context.ContentItem.ContentType != "Site")
return;
base.GetItemMetadata(context);
context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Email")));
}
} }
} }

View File

@@ -8,9 +8,8 @@ namespace Orchard.Indexing {
public string MenuName { get { return "admin"; } } public string MenuName { get { return "admin"; } }
public void GetNavigation(NavigationBuilder builder) { public void GetNavigation(NavigationBuilder builder) {
builder.AddImageSet("search") builder.Add(T("Settings"),
.Add(T("Settings"), menu => menu.Add(T("Search Index"), "5", item => item.Action("Index", "Admin", new {area = "Orchard.Indexing"})
menu => menu.Add(T("Search"), "15", item => item.Action("Index", "Admin", new {area = "Orchard.Indexing"})
.Permission(StandardPermissions.SiteOwner))); .Permission(StandardPermissions.SiteOwner)));
} }
} }

View File

@@ -18,6 +18,8 @@ namespace Orchard.Media.Handlers {
public Localizer T { get; set; } public Localizer T { get; set; }
protected override void GetItemMetadata(GetContentItemMetadataContext context) { protected override void GetItemMetadata(GetContentItemMetadataContext context) {
if (context.ContentItem.ContentType != "Site")
return;
base.GetItemMetadata(context); base.GetItemMetadata(context);
context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Media"))); context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Media")));
} }

View File

@@ -23,7 +23,10 @@ namespace Orchard.Search.Drivers {
protected override string Prefix { get { return "SearchSettings"; } } protected override string Prefix { get { return "SearchSettings"; } }
protected override DriverResult Editor(SearchSettingsPart part, dynamic shapeHelper) { protected override DriverResult Editor(SearchSettingsPart part, string groupInfoId, dynamic shapeHelper) {
if (!string.Equals(groupInfoId, "search", StringComparison.OrdinalIgnoreCase))
return null;
SearchSettingsViewModel model = new SearchSettingsViewModel(); SearchSettingsViewModel model = new SearchSettingsViewModel();
String [] searchedFields = part.SearchedFields; String [] searchedFields = part.SearchedFields;
@@ -38,7 +41,10 @@ namespace Orchard.Search.Drivers {
() => shapeHelper.EditorTemplate(TemplateName: "Parts/Search.SiteSettings", Model: model, Prefix: Prefix)); () => shapeHelper.EditorTemplate(TemplateName: "Parts/Search.SiteSettings", Model: model, Prefix: Prefix));
} }
protected override DriverResult Editor(SearchSettingsPart part, IUpdateModel updater, dynamic shapeHelper) { protected override DriverResult Editor(SearchSettingsPart part, IUpdateModel updater, string groupInfoId, dynamic shapeHelper) {
if (!string.Equals(groupInfoId, "search", StringComparison.OrdinalIgnoreCase))
return null;
SearchSettingsViewModel model = new SearchSettingsViewModel(); SearchSettingsViewModel model = new SearchSettingsViewModel();
if (updater.TryUpdateModel(model, Prefix, null, null)) { if (updater.TryUpdateModel(model, Prefix, null, null)) {

View File

@@ -1,4 +1,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Localization;
using Orchard.Search.Models; using Orchard.Search.Models;
using Orchard.Data; using Orchard.Data;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
@@ -7,8 +9,18 @@ namespace Orchard.Search.Handlers {
[UsedImplicitly] [UsedImplicitly]
public class SearchSettingsPartHandler : ContentHandler { public class SearchSettingsPartHandler : ContentHandler {
public SearchSettingsPartHandler(IRepository<SearchSettingsPartRecord> repository) { public SearchSettingsPartHandler(IRepository<SearchSettingsPartRecord> repository) {
T = NullLocalizer.Instance;
Filters.Add(new ActivatingFilter<SearchSettingsPart>("Site")); Filters.Add(new ActivatingFilter<SearchSettingsPart>("Site"));
Filters.Add(StorageFilter.For(repository)); Filters.Add(StorageFilter.For(repository));
} }
public Localizer T { get; set; }
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
if (context.ContentItem.ContentType != "Site")
return;
base.GetItemMetadata(context);
context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Search")));
}
} }
} }

View File

@@ -18,6 +18,8 @@ namespace Orchard.Users.Handlers {
public Localizer T { get; set; } public Localizer T { get; set; }
protected override void GetItemMetadata(GetContentItemMetadataContext context) { protected override void GetItemMetadata(GetContentItemMetadataContext context) {
if (context.ContentItem.ContentType != "Site")
return;
base.GetItemMetadata(context); base.GetItemMetadata(context);
context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Users"))); context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Users")));
} }

View File

@@ -110,8 +110,14 @@ namespace Orchard.UI.Navigation {
var orderer = new FlatPositionComparer(); var orderer = new FlatPositionComparer();
return sources.SelectMany(x => x).ToArray() return sources.SelectMany(x => x).ToArray()
// group same menus
.GroupBy(key => key, (key, items) => Join(items), comparer) .GroupBy(key => key, (key, items) => Join(items), comparer)
.OrderBy(item => item.Position, orderer); // group same position
.GroupBy(item => item.Position)
// order position groups by position
.OrderBy(positionGroup => positionGroup.Key, orderer)
// ordered by item text in the postion group
.SelectMany(positionGroup => positionGroup.OrderBy(item => item.Text));
} }
static MenuItem Join(IEnumerable<MenuItem> items) { static MenuItem Join(IEnumerable<MenuItem> items) {