diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/AdminMenu.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/AdminMenu.cs index 2010cae4c..5616de8c9 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentTypes/AdminMenu.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/AdminMenu.cs @@ -7,13 +7,14 @@ namespace Orchard.ContentTypes { public Localizer T { get; set; } public string MenuName { get { return "admin"; } } - public void GetNavigation(NavigationBuilder builder) - { - builder.Add(T("Content"), - menu => menu - .Add(T("Content Types"), "3", item => item.Action("Index", "Admin", new {area = "Orchard.ContentTypes"}).LocalNav()) - .Add(T("Content Parts"), "4", item => item.Action("ListParts", "Admin", new {area = "Orchard.ContentTypes"}).LocalNav())); + public void GetNavigation(NavigationBuilder builder) { + builder.AddImageSet("contenttypes"); + builder.Add(T("Content Schema"), "1.4.1", menu => { + menu.LinkToFirstChild(true); + menu.Add(T("Content Types"), "1", item => item.Action("Index", "Admin", new { area = "Orchard.ContentTypes" }).LocalNav()); + menu.Add(T("Content Parts"), "2", item => item.Action("ListParts", "Admin", new { area = "Orchard.ContentTypes" }).LocalNav()); + }); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Orchard.ContentTypes.csproj b/src/Orchard.Web/Modules/Orchard.ContentTypes/Orchard.ContentTypes.csproj index aa7266286..cf517764d 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentTypes/Orchard.ContentTypes.csproj +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Orchard.ContentTypes.csproj @@ -64,8 +64,11 @@ + + + @@ -93,7 +96,9 @@ + + diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/DefaultStereotypesProvider.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/DefaultStereotypesProvider.cs new file mode 100644 index 000000000..426043ba3 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/DefaultStereotypesProvider.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Orchard.ContentTypes.Services { + public class DefaultStereotypesProvider : IStereotypesProvider { + private readonly Lazy _contentDefinitionService; + public DefaultStereotypesProvider(Lazy contentDefinitionService) { + _contentDefinitionService = contentDefinitionService; + } + + public IEnumerable GetStereotypes() { + // Harvest all available stereotypes by finding out about the stereotype of all content types + var stereotypes = _contentDefinitionService.Value.GetTypes().Where(x => x.Settings.ContainsKey("Stereotype")).Select(x => x.Settings["Stereotype"]).Distinct(); + return stereotypes.Select(x => new StereotypeDescription {DisplayName = x, Stereotype = x}); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/IStereotypesProvider.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/IStereotypesProvider.cs new file mode 100644 index 000000000..f5e3db796 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/IStereotypesProvider.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace Orchard.ContentTypes.Services { + public interface IStereotypesProvider : IDependency { + IEnumerable GetStereotypes(); + } + + public class StereotypeDescription { + public string Stereotype { get; set; } + public string DisplayName { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/StereotypeService.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/StereotypeService.cs new file mode 100644 index 000000000..c00221328 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/StereotypeService.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Linq; +using Orchard.Caching; +using Orchard.Services; + +namespace Orchard.ContentTypes.Services { + public interface IStereotypeService : IDependency { + IEnumerable GetStereotypes(); + } + + public class StereotypeService : IStereotypeService { + private readonly IEnumerable _providers; + private readonly ICacheManager _cacheManager; + private readonly ISignals _signals; + private readonly IClock _clock; + + public StereotypeService(IEnumerable providers, ICacheManager cacheManager, ISignals signals, IClock clock) { + _providers = providers; + _cacheManager = cacheManager; + _signals = signals; + _clock = clock; + } + + public IEnumerable GetStereotypes() { + return _cacheManager.Get("ContentType.Stereotypes", context => { + + // TODO: Implement a signal in ContentDefinitionManager that gets raised whenever a type definition is updated. + // For now, we'll just cache the stereotypes for 1 minute. + //context.Monitor(_signals.When("ContentType.Stereotypes")); + context.Monitor(_clock.WhenUtc(_clock.UtcNow.AddMinutes(1))); + return _providers.SelectMany(x => x.GetStereotypes()); + }); + + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/Images/menu.contenttypes.png b/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/Images/menu.contenttypes.png new file mode 100644 index 000000000..70b140395 Binary files /dev/null and b/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/Images/menu.contenttypes.png differ diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/menu.contenttypes-admin.css b/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/menu.contenttypes-admin.css new file mode 100644 index 000000000..174e06b62 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/menu.contenttypes-admin.css @@ -0,0 +1,6 @@ +.navicon-content-schema { +background-image:url(images/menu.contenttypes.png) !important; +} +.navicon-content-schema:hover { +background-position:0 -30px !important; +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/orchard-contenttypes-admin.css b/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/orchard-contenttypes-admin.css index c28d37b44..fee43020a 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/orchard-contenttypes-admin.css +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Styles/orchard-contenttypes-admin.css @@ -3,6 +3,14 @@ border-bottom:1px solid #ccc; } +.orchard-contenttypes .summary .properties h3 { + display: inline; +} + +.orchard-contenttypes .summary .properties .stereotype { + color: #7c7c7c; +} + #main .properties p { margin:0; } @@ -68,7 +76,7 @@ } .manage-part .description { - color: #333; + color: #7c7c7c; font-size: 0.8em; } diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/EditTypeViewModel.cshtml b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/EditTypeViewModel.cshtml index 19d636de7..bfe7535cc 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/EditTypeViewModel.cshtml +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/DisplayTemplates/EditTypeViewModel.cshtml @@ -1,8 +1,13 @@ @model Orchard.ContentTypes.ViewModels.EditTypeViewModel @using Orchard.Core.Contents.Settings; +@{ + var settings = Model.Settings.GetModel(); + var creatable = settings.Creatable; + var stereotype = Model.Settings.ContainsKey("Stereotype") ? Model.Settings["Stereotype"] : default(string); +}
-

@Model.DisplayName

@{ var creatable = Model.Settings.GetModel().Creatable; } +

@Model.DisplayName

@if (!string.IsNullOrWhiteSpace(stereotype)) { - @stereotype} @if (creatable) {

@Html.ActionLink(T("Create New {0}", Model.DisplayName).Text, "Create", new {area = "Contents", id = Model.Name})

}