Removing ContentsLocation

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-10-18 13:47:46 -07:00
parent 2f9f07d8f8
commit 650d1422c7
17 changed files with 19 additions and 347 deletions

View File

@@ -1,8 +0,0 @@
using Orchard.Localization;
namespace Orchard.Core.ContentsLocation.Models {
public class LocationDefinition {
public string Name { get; set; }
public LocalizedString DisplayName { get; set; }
}
}

View File

@@ -1,69 +0,0 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
namespace Orchard.Core.ContentsLocation.Models {
public class LocationSettings : Dictionary<string, ContentLocation> {
public LocationSettings() { }
public LocationSettings(LocationSettings value)
: base(value) {
}
public ContentLocation Get(string location) {
return Get(location, null, null);
}
public ContentLocation Get(string location, string defaultZone, string defaultPosition) {
ContentLocation result;
if (this.TryGetValue(location, out result)) {
return result;
}
return new ContentLocation { Zone = defaultZone, Position = defaultPosition };
}
}
public static class LocationSettingsExtensions {
public static ContentLocation GetLocation<TContent>(this TContent part, string locationName) where TContent : ContentPart {
return part.GetLocation(locationName, null, null);
}
public static ContentLocation GetLocation(this ContentPart part, string locationName, string defaultZone, string defaultPosition) {
// Get the specific location from the part in the type context
var location = part.TypePartDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
if (location.Position != null || location.Zone != null)
return location;
// Get the "Default" location from the part in the type context
location = part.TypePartDefinition.Settings.GetModel<LocationSettings>().Get("Default");
if (location.Position != null || location.Zone != null)
return location;
// Get the specific location from the part definition
location = part.PartDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
if (location.Position != null || location.Zone != null)
return location;
// Get the "Default" location from the part definition
location = part.PartDefinition.Settings.GetModel<LocationSettings>().Get("Default");
if (location.Position != null || location.Zone != null)
return location;
return new ContentLocation { Zone = defaultZone, Position = defaultPosition };
}
public static ContentLocation GetLocation(this ContentField field, string locationName, string defaultZone, string defaultPosition) {
// Get the specific location from the part in the type context
var location = field.PartFieldDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
if (location.Position != null || location.Zone != null)
return location;
// Get the "Default" location from the part in the type context
location = field.PartFieldDefinition.Settings.GetModel<LocationSettings>().Get("Default");
if (location.Position != null || location.Zone != null)
return location;
return new ContentLocation { Zone = defaultZone, Position = defaultPosition };
}
}
}

View File

@@ -1,12 +0,0 @@
Name: ContentsLocation
AntiForgery: enabled
Author: The Orchard Team
Website: http://orchardproject.net
Version: 0.8.0
OrchardVersion: 0.8.0
Description: The "Contents Location" module introduces settings for part and field to fine tune the location of contents.
Features:
ContentsLocation:
Description: Contents location settings management
Dependencies: Settings
Category: Core

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.UI.Resources;
namespace Orchard.Core.ContentsLocation {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("ContentsLocationAdmin").SetUrl("admin.css");
}
}
}

View File

@@ -1,120 +0,0 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.ViewModels;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.ContentsLocation.ViewModels;
using Orchard.Localization;
namespace Orchard.Core.ContentsLocation.Settings {
public class LocationSettingsEditorEvents : ContentDefinitionEditorEventsBase {
public LocationSettingsEditorEvents() {
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
private IEnumerable<LocationDefinition> GetPredefinedLocations() {
yield return new LocationDefinition { Name = "Default", DisplayName = T("Default location (i.e. fallback if no specific override)") };
yield return new LocationDefinition { Name = "Detail", DisplayName = T("\"Detail\" display location") };
yield return new LocationDefinition { Name = "Editor", DisplayName = T("\"Editor\" display location") };
yield return new LocationDefinition { Name = "Summary", DisplayName = T("\"Summary\" (front-end) display location") };
yield return new LocationDefinition { Name = "SummaryAdmin", DisplayName = T("\"Summary\" (admin) display location") };
}
private LocationSettings MergeSettings(LocationSettings partSettings, LocationSettings partDefinitionSettings) {
return partSettings;
//var result = new LocationSettings(partSettings);
//foreach (var entry in partDefinitionSettings) {
// if (!partSettings.ContainsKey(entry.Key))
// partSettings[entry.Key] = entry.Value;
//}
//return result;
}
#region Standalone part definition
public override IEnumerable<TemplateViewModel> PartEditor(ContentPartDefinition definition) {
var settings = definition.Settings.GetModel<LocationSettings>();
foreach (var location in GetPredefinedLocations()) {
var viewModel = new LocationSettingsViewModel {
Definition = location,
Location = settings.Get(location.Name),
DefaultLocation = new ContentLocation()
};
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
}
}
public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
var settings = new LocationSettings();
foreach (var location in GetPredefinedLocations()) {
var viewModel = new LocationSettingsViewModel();
updateModel.TryUpdateModel(viewModel, location.Name, null, null);
settings[location.Name] = viewModel.Location;
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
}
builder.WithLocation(settings);
}
#endregion
#region Part in the context of a content type
public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypePartDefinition definition) {
// Look for the setting in the most specific settings first (part definition in type)
// then in the global part definition.
var partSettings = definition.Settings.GetModel<LocationSettings>();
var partDefinitionSettings = definition.PartDefinition.Settings.GetModel<LocationSettings>();
var settings = MergeSettings(partSettings, partDefinitionSettings);
foreach (var location in GetPredefinedLocations()) {
var viewModel = new LocationSettingsViewModel {
Definition = location,
Location = settings.Get(location.Name),
DefaultLocation = partDefinitionSettings.Get(location.Name)
};
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
}
}
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
var settings = new LocationSettings();
foreach (var location in GetPredefinedLocations()) {
var viewModel = new LocationSettingsViewModel();
updateModel.TryUpdateModel(viewModel, location.Name, null, null);
settings[location.Name] = viewModel.Location;
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
}
builder.WithLocation(settings);
}
#endregion
#region Field within a content part
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) {
var settings = definition.Settings.GetModel<LocationSettings>();
foreach (var location in GetPredefinedLocations()) {
var viewModel = new LocationSettingsViewModel {
Definition = location,
Location = settings.Get(location.Name),
DefaultLocation = new ContentLocation { Zone = "Primary", Position = "1" }
};
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
}
}
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
var settings = new LocationSettings();
foreach (var location in GetPredefinedLocations()) {
var viewModel = new LocationSettingsViewModel();
updateModel.TryUpdateModel(viewModel, location.Name, null, null);
settings[location.Name] = viewModel.Location;
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
}
builder.WithLocation(settings);
}
#endregion
}
}

View File

@@ -1,25 +0,0 @@
fieldset.location-setting {
overflow:auto;
}
fieldset.location-setting legend {
font-weight:normal;
margin:0;
padding-bottom:0;
}
fieldset.location-setting label {
display:inline;
}
fieldset.location-setting input.text-box {
display:block;
width:24em;
}
fieldset.location-setting fieldset {
clear:none;
float:left;
margin-right:1em;
margin-top:.5em;
}
fieldset.location-setting .default {
font-size:1.2em;
font-style:italic;
}

View File

@@ -1,10 +0,0 @@
using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Core.ContentsLocation.ViewModels {
public class LocationSettingsViewModel {
public LocationDefinition Definition { get; set; }
public ContentLocation Location { get; set; }
public ContentLocation DefaultLocation { get; set; }
}
}

View File

@@ -1,21 +0,0 @@
@model Orchard.Core.ContentsLocation.ViewModels.LocationSettingsViewModel
@{ Style.Require("ContentsLocationAdmin"); }
<fieldset class="location-setting">
<legend>@T("{0}", Model.Definition.DisplayName)</legend>
<fieldset>
<label for="@Html.FieldIdFor(m => m.Location.Zone)">@T("Zone name (e.g. body, primary)")</label>
@if (!string.IsNullOrWhiteSpace(Model.DefaultLocation.Zone)) {
<span class="default">@T(" - default: {0}", Model.DefaultLocation.Zone)</span>
}
@Html.EditorFor(m => m.Location.Zone)
@Html.ValidationMessageFor(m => m.Location.Zone)
</fieldset>
<fieldset>
<label for="@Html.FieldIdFor(m => m.Location.Position)">
@T("Position in zone (e.g. 1, 1.0, 2.5.1)")</label>
@if (!string.IsNullOrWhiteSpace(Model.DefaultLocation.Zone)) {
<span class="default">@T(" - default: {0}", Model.DefaultLocation.Position)</span>
}
@Html.EditorFor(m => m.Location.Position)
</fieldset>@Html.ValidationMessageFor(m => m.Location.Position)
</fieldset>

View File

@@ -1,42 +0,0 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*"
type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<controls>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -3,7 +3,6 @@ using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.Localization.Models;
using Orchard.Core.Localization.Services;
using Orchard.Core.Localization.ViewModels;
@@ -43,7 +42,8 @@ namespace Orchard.Core.Localization.Drivers {
ContentLocalizations = new ContentLocalizationsViewModel(part) { Localizations = localizations }
};
return ContentPartTemplate(model, "Parts/Localization.Translation", TemplatePrefix).Location(part.GetLocation("Editor"));
// TODO: andrerod convert to new shape API. Location code kept for reference.
return ContentPartTemplate(model, "Parts/Localization.Translation", TemplatePrefix); //.Location(part.GetLocation("Editor"));
}
protected override DriverResult Editor(LocalizationPart part, IUpdateModel updater, dynamic shapeHelper) {

View File

@@ -2,7 +2,6 @@
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.Navigation.Models;
using Orchard.Localization;
using Orchard.Security;
@@ -28,7 +27,8 @@ namespace Orchard.Core.Navigation.Drivers {
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
return null;
return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location(part.GetLocation("Editor"));
// TODO: andrerod convert to new shape API. Location code kept for reference.
return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart"); //.Location(part.GetLocation("Editor"));
}
protected override DriverResult Editor(MenuPart part, IUpdateModel updater, dynamic shapeHelper) {
@@ -46,7 +46,8 @@ namespace Orchard.Core.Navigation.Drivers {
updater.AddModelError("MenuText", T("The MenuText field is required"));
}
return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location(part.GetLocation("Editor"));
// TODO: andrerod convert to new shape API. Location code kept for reference.
return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart"); //.Location(part.GetLocation("Editor"));
}
}
}

View File

@@ -74,14 +74,9 @@
<Compile Include="Common\Fields\TextField.cs" />
<Compile Include="Contents\Security\AuthorizationEventHandler.cs" />
<Compile Include="Common\Services\BbcodeFilter.cs" />
<Compile Include="ContentsLocation\ResourceManifest.cs" />
<Compile Include="ContentsLocation\Models\LocationDefinition.cs" />
<Compile Include="Common\Services\ICommonService.cs" />
<Compile Include="Common\Services\CommonService.cs" />
<Compile Include="Common\Settings\BodySettings.cs" />
<Compile Include="ContentsLocation\Models\LocationSettings.cs" />
<Compile Include="ContentsLocation\Settings\LocationSettingsEditorEvents.cs" />
<Compile Include="ContentsLocation\ViewModels\LocationSettingsViewModel.cs" />
<Compile Include="Common\ViewModels\ContainerEditorViewModel.cs" />
<Compile Include="Common\ViewModels\TextContentFieldDisplayViewModel.cs" />
<Compile Include="Common\ViewModels\TextContentFieldEditorViewModel.cs" />
@@ -257,9 +252,6 @@
<Content Include="Common\Views\Parts\Common.Body.SummaryAdmin.cshtml" />
<Content Include="Common\Views\Parts\Common.Metadata.cshtml" />
<Content Include="Common\Views\Parts\Common.Metadata.SummaryAdmin.cshtml" />
<Content Include="ContentsLocation\Module.txt" />
<Content Include="ContentsLocation\Styles\admin.css" />
<Content Include="ContentsLocation\Views\DefinitionTemplates\LocationSettings.cshtml" />
<Content Include="Contents\Views\Admin\Create.cshtml" />
<Content Include="Contents\Views\Admin\Edit.cshtml" />
<Content Include="Contents\Views\Admin\List.cshtml" />
@@ -365,7 +357,6 @@
<Content Include="Localization\Views\Web.config" />
<Content Include="Reports\Views\Web.config" />
<Content Include="PublishLater\Views\Web.config" />
<Content Include="ContentsLocation\Views\Web.config" />
<Content Include="Messaging\Views\Web.config" />
<Content Include="Contents\Views\Items\Content.cshtml" />
<Content Include="Contents\Views\Items\Content.SummaryAdmin.cshtml" />

View File

@@ -5,7 +5,6 @@ using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Core.Routable.Models;
using Orchard.Core.Routable.Services;
using Orchard.Core.Routable.ViewModels;
@@ -70,9 +69,10 @@ namespace Orchard.Core.Routable.Drivers {
: "";
}
var location = part.GetLocation("Editor");
// TODO: andrerod convert to new shape API. Location code kept for reference.
//var location = part.GetLocation("Editor");
model.PromoteToHomePage = model.Id != 0 && part.Path != null && _routableHomePageProvider != null && CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id);
return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
return ContentPartTemplate(model, TemplateName, Prefix); //.Location(location);
}
protected override DriverResult Editor(RoutePart part, IUpdateModel updater, dynamic shapeHelper) {

View File

@@ -6,7 +6,6 @@ using Orchard.ArchiveLater.ViewModels;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Services;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Localization;
namespace ArchiveLater.Drivers {

View File

@@ -1,7 +1,6 @@
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Widgets.Models;
namespace Orchard.Widgets.Drivers {
@@ -10,8 +9,10 @@ namespace Orchard.Widgets.Drivers {
public class LayerPartDriver : ContentPartDriver<LayerPart> {
protected override DriverResult Editor(LayerPart layerPart, dynamic shapeHelper) {
ContentLocation location = layerPart.GetLocation("Editor");
return ContentPartTemplate(layerPart, "Parts/Widgets.LayerPart").Location(location);
// TODO: andrerod convert to new shape API. Location code kept for reference.
// ContentLocation location = layerPart.GetLocation("Editor");
return ContentPartTemplate(layerPart, "Parts/Widgets.LayerPart"); //.Location(location);
}
protected override DriverResult Editor(LayerPart layerPart, IUpdateModel updater, dynamic shapeHelper) {

View File

@@ -1,6 +1,5 @@
using JetBrains.Annotations;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Widgets.Models;
namespace Orchard.Widgets.Drivers {
@@ -9,8 +8,9 @@ namespace Orchard.Widgets.Drivers {
private const string TemplateName = "Parts/Widgets.WidgetBagPart";
protected override DriverResult Editor(WidgetBagPart part, dynamic shapeHelper) {
var location = part.GetLocation("Editor");
return ContentPartTemplate("", TemplateName, Prefix).Location(location);
//var location = part.GetLocation("Editor");
// TODO: andrerod convert to new shape API. Location code kept for reference.
return ContentPartTemplate("", TemplateName, Prefix); //.Location(location);
}
}
}

View File

@@ -1,7 +1,6 @@
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.ContentsLocation.Models;
using Orchard.Widgets.Models;
using Orchard.Widgets.Services;
@@ -18,8 +17,9 @@ namespace Orchard.Widgets.Drivers {
protected override DriverResult Editor(WidgetPart widgetPart, dynamic shapeHelper) {
widgetPart.AvailableZones = _widgetsService.GetZones();
ContentLocation location = widgetPart.GetLocation("Editor");
return ContentPartTemplate(widgetPart, "Parts/Widgets.WidgetPart").Location(location);
// TODO: andrerod convert to new shape API. Location code kept for reference.
//ContentLocation location = widgetPart.GetLocation("Editor");
return ContentPartTemplate(widgetPart, "Parts/Widgets.WidgetPart"); //.Location(location);
}
protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) {