mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -109,7 +109,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
||||
var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
|
||||
var viewModel = new OwnerEditorViewModel() { Owner = "User" };
|
||||
updateModel.Setup(x => x.TryUpdateModel(viewModel, "", null, null)).Returns(true);
|
||||
contentManager.UpdateEditorModel(item.ContentItem, updateModel.Object);
|
||||
contentManager.UpdateEditor(item.ContentItem, updateModel.Object);
|
||||
}
|
||||
|
||||
class UpdatModelStub : IUpdateModel {
|
||||
@@ -148,7 +148,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
||||
|
||||
var updater = new UpdatModelStub() { Owner = null };
|
||||
|
||||
contentManager.UpdateEditorModel(item.ContentItem, updater);
|
||||
contentManager.UpdateEditor(item.ContentItem, updater);
|
||||
}
|
||||
|
||||
[Test, Ignore("Fix pending")]
|
||||
@@ -166,7 +166,7 @@ namespace Orchard.Core.Tests.Common.Providers {
|
||||
|
||||
var updater = new UpdatModelStub() {Owner = ""};
|
||||
|
||||
contentManager.UpdateEditorModel(item.ContentItem, updater);
|
||||
contentManager.UpdateEditor(item.ContentItem, updater);
|
||||
|
||||
Assert.That(updater.ModelErrors.ContainsKey("CommonPart.Owner"), Is.True);
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ namespace Orchard.Specs.Bindings {
|
||||
var webApp = Binding<WebAppHosting>();
|
||||
|
||||
webApp.GivenIHaveACleanSiteWith(TableData(
|
||||
new { extension = "module", names = "Orchard.Setup, Orchard.Modules, Orchard.Packaging, Orchard.Themes, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce" },
|
||||
new { extension = "module", names = "Orchard.Setup, Orchard.Modules, Orchard.Packaging, Orchard.Themes, Orchard.Widgets, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce" },
|
||||
new { extension = "core", names = "Common, Dashboard, Feeds, HomePage, Navigation, Contents, ContentsLocation, PublishLater, Routable, Scheduling, Settings, Shapes, XmlRpc" },
|
||||
new { extension = "theme", names = "SafeMode, Classic" }));
|
||||
|
||||
|
@@ -8,32 +8,32 @@
|
||||
\Windows\Microsoft.Net\Framework\v2.x\Config
|
||||
-->
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="system.razor.web" type="System.Razor.Web.Configuration.SystemRazorWebSectionGroup, System.Razor.Web">
|
||||
<section name="host" type="System.Razor.Web.Configuration.HostSection, System.Razor.Web" requirePermission="false" />
|
||||
<section name="pages" type="System.Razor.Web.Configuration.RazorPagesSection, System.Razor.Web" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<configSections>
|
||||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
|
||||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
|
||||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<appSettings/>
|
||||
<system.diagnostics configSource="Config\Diagnostics.config"/>
|
||||
<appSettings/>
|
||||
<system.diagnostics configSource="Config\Diagnostics.config"/>
|
||||
|
||||
<system.razor.web>
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc" />
|
||||
<add namespace="System.Web.Mvc.Ajax" />
|
||||
<add namespace="System.Web.Mvc.Html" />
|
||||
<add namespace="System.Web.Routing" />
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="Orchard.Mvc.Html"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.razor.web>
|
||||
<system.web.webPages.razor>
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc" />
|
||||
<add namespace="System.Web.Mvc.Ajax" />
|
||||
<add namespace="System.Web.Mvc.Html" />
|
||||
<add namespace="System.Web.Routing" />
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
<add namespace="Orchard.Mvc.Html"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.web.webPages.razor>
|
||||
|
||||
<!--
|
||||
<!--
|
||||
Set default transaction timeout to 30 minutes so that interactive debugging
|
||||
is easier (default timeout is less than one minute)
|
||||
-->
|
||||
|
@@ -39,7 +39,7 @@ Scenario: Some of the initial form values are required
|
||||
Scenario: Calling setup on a brand new install
|
||||
Given I have a clean site with
|
||||
| extension | names |
|
||||
| module | Orchard.Setup, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.Themes, Orchard.Modules, Orchard.jQuery, TinyMce |
|
||||
| module | Orchard.Setup, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.Themes, Orchard.Modules, Orchard.Widgets, Orchard.jQuery, TinyMce |
|
||||
| core | Common, Contents, ContentsLocation, Dashboard, Feeds, HomePage, Navigation, Routable, PublishLater, Scheduling, Settings, Shapes, XmlRpc |
|
||||
| theme | SafeMode, Classic |
|
||||
And I am on "/Setup"
|
||||
@@ -51,5 +51,4 @@ Scenario: Calling setup on a brand new install
|
||||
And I hit "Finish Setup"
|
||||
And I go to "/Default.aspx"
|
||||
Then I should see "My Site"
|
||||
And I should see "Welcome"
|
||||
And I should see "you've successfully set-up your Orchard site"
|
||||
And I should see "Welcome, <strong>admin</strong>!"
|
||||
|
10
src/Orchard.Specs/Setup.feature.cs
generated
10
src/Orchard.Specs/Setup.feature.cs
generated
@@ -1,7 +1,7 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by SpecFlow (http://www.specflow.org/).
|
||||
// SpecFlow Version:1.3.2.0
|
||||
// SpecFlow Version:1.3.5.2
|
||||
// Runtime Version:4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
@@ -14,7 +14,7 @@ namespace Orchard.Specs
|
||||
using TechTalk.SpecFlow;
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.2.0")]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.5.2")]
|
||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[NUnit.Framework.TestFixtureAttribute()]
|
||||
[NUnit.Framework.DescriptionAttribute("Setup")]
|
||||
@@ -177,7 +177,7 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table4.AddRow(new string[] {
|
||||
"module",
|
||||
"Orchard.Setup, Orchard.Users, Orchard.Roles, Orchard.Comments, Orchard.Themes, Or" +
|
||||
"chard.Modules, Orchard.jQuery, TinyMce"});
|
||||
"chard.Modules, Orchard.Widgets, Orchard.jQuery, TinyMce"});
|
||||
table4.AddRow(new string[] {
|
||||
"core",
|
||||
"Common, Contents, ContentsLocation, Dashboard, Feeds, HomePage, Navigation, Routa" +
|
||||
@@ -211,9 +211,7 @@ testRunner.And("I go to \"/Default.aspx\"");
|
||||
#line 53
|
||||
testRunner.Then("I should see \"My Site\"");
|
||||
#line 54
|
||||
testRunner.And("I should see \"Welcome\"");
|
||||
#line 55
|
||||
testRunner.And("I should see \"you\'ve successfully set-up your Orchard site\"");
|
||||
testRunner.And("I should see \"Welcome, <strong>admin</strong>!\"");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
}
|
||||
|
@@ -59,6 +59,7 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Castle.Core, Version=1.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL" />
|
||||
<Reference Include="FluentNHibernate, Version=1.0.0.593, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\fluentnhibernate\FluentNHibernate.dll</HintPath>
|
||||
@@ -127,9 +128,11 @@
|
||||
<Compile Include="Roles\Controllers\AdminControllerTests.cs" />
|
||||
<Compile Include="Roles\Services\RoleServiceTests.cs" />
|
||||
<Compile Include="Settings\Blueprint\ShellDescriptorManagerTests.cs" />
|
||||
<Compile Include="Themes\Services\ThemeServiceTests.cs" />
|
||||
<Compile Include="Values.cs" />
|
||||
<Compile Include="Users\Controllers\AdminControllerTests.cs" />
|
||||
<Compile Include="Users\Services\MembershipServiceTests.cs" />
|
||||
<Compile Include="Widgets\Services\WidgetsServiceTest.cs" />
|
||||
<Compile Include="Widgets\WidgetsTests.cs" />
|
||||
<Compile Include="XmlRpc\Controllers\HomeControllerTests.cs" />
|
||||
<Compile Include="XmlRpc\Services\XmlRpcReaderTests.cs" />
|
||||
@@ -148,6 +151,10 @@
|
||||
<Project>{C0C45321-B51D-4D8D-9B7B-AA4C2E0B2962}</Project>
|
||||
<Name>Orchard.CodeGeneration</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Modules\Orchard.Modules.csproj">
|
||||
<Project>{17F86780-9A1F-4AA1-86F1-875EEC2730C7}</Project>
|
||||
<Name>Orchard.Modules</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Roles\Orchard.Roles.csproj">
|
||||
<Project>{D10AD48F-407D-4DB5-A328-173EC7CB010F}</Project>
|
||||
<Name>Orchard.Roles</Name>
|
||||
@@ -156,6 +163,10 @@
|
||||
<Project>{8C7FCBC2-E6E1-405E-BFB5-D8D9E67A09C4}</Project>
|
||||
<Name>Orchard.Setup</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Themes\Orchard.Themes.csproj">
|
||||
<Project>{CDE24A24-01D3-403C-84B9-37722E18DFB7}</Project>
|
||||
<Name>Orchard.Themes</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Users\Orchard.Users.csproj">
|
||||
<Project>{79AED36E-ABD0-4747-93D3-8722B042454B}</Project>
|
||||
<Name>Orchard.Users</Name>
|
||||
|
243
src/Orchard.Tests.Modules/Themes/Services/ThemeServiceTests.cs
Normal file
243
src/Orchard.Tests.Modules/Themes/Services/ThemeServiceTests.cs
Normal file
@@ -0,0 +1,243 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Xml.Linq;
|
||||
using Autofac;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Caching;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Settings.Descriptor.Records;
|
||||
using Orchard.Core.Settings.Handlers;
|
||||
using Orchard.Core.Settings.Metadata;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Core.Settings.Services;
|
||||
using Orchard.Data;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.AutofacUtil.DynamicProxy2;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Modules;
|
||||
using Orchard.Modules.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Security.Permissions;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.Themes;
|
||||
using Orchard.Themes.Handlers;
|
||||
using Orchard.Themes.Models;
|
||||
using Orchard.Themes.Services;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Tests.Modules.Themes.Services {
|
||||
[TestFixture]
|
||||
public class ThemeServiceTests {
|
||||
private IThemeService _themeService;
|
||||
private IContainer _container;
|
||||
private ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void InitFixture() {
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(databaseFileName,
|
||||
typeof(ThemeSiteSettingsPartRecord),
|
||||
typeof(SiteSettingsPartRecord),
|
||||
typeof(ContentItemVersionRecord),
|
||||
typeof(ContentItemRecord),
|
||||
typeof(ContentTypeRecord));
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TermFixture() { }
|
||||
|
||||
[SetUp]
|
||||
public void Init() {
|
||||
var context = new DynamicProxyContext();
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterModule(new SettingsModule());
|
||||
builder.RegisterType<ThemeService>().EnableDynamicProxy(context).As<IThemeService>();
|
||||
builder.RegisterType<SettingsModuleInterceptor>().As<ISettingsModuleInterceptor>();
|
||||
builder.RegisterType<SiteService>().As<ISiteService>();
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
||||
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
|
||||
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterType<ShapeHelperFactory>().As<IShapeHelperFactory>();
|
||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
|
||||
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
|
||||
builder.RegisterType<SiteSettingsPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<ThemeSiteSettingsPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<ModuleService>().As<IModuleService>();
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
builder.RegisterType<StubShellDescriptorManager>().As<IShellDescriptorManager>();
|
||||
builder.RegisterType<TransactionManager>().As<ITransactionManager>();
|
||||
builder.RegisterType<Notifier>().As<INotifier>();
|
||||
builder.RegisterType<StubAuthorizer>().As<IAuthorizer>();
|
||||
builder.RegisterType(typeof(SettingsFormatter))
|
||||
.As(typeof(IMapper<XElement, SettingsDictionary>))
|
||||
.As(typeof(IMapper<SettingsDictionary, XElement>));
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
_container = builder.Build();
|
||||
_themeService = _container.Resolve<IThemeService>();
|
||||
}
|
||||
|
||||
//todo: test theme feature enablement
|
||||
|
||||
[Test]
|
||||
public void ThemeWithNoBaseThemeCanBeSetAsSiteTheme() {
|
||||
_themeService.SetSiteTheme("ThemeOne");
|
||||
var siteTheme = _themeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.ThemeName, Is.EqualTo("ThemeOne"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThemeWithAvailableBaseThemeCanBeSetAsSiteTheme() {
|
||||
_themeService.SetSiteTheme("ThemeTwo");
|
||||
var siteTheme = _themeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.ThemeName, Is.EqualTo("ThemeTwo"));
|
||||
Assert.That(siteTheme.BaseTheme, Is.EqualTo("ThemeOne"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThemeWithUnavailableBaseThemeCanBeSetAsSiteTheme() {
|
||||
_themeService.SetSiteTheme("ThemeOne");
|
||||
_themeService.SetSiteTheme("ThemeThree");
|
||||
var siteTheme = _themeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.ThemeName, Is.EqualTo("ThemeOne"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThemeWithCircularBaseDepTrowsExceptionOnActivation() {
|
||||
_themeService.SetSiteTheme("ThemeOne");
|
||||
try {
|
||||
_themeService.SetSiteTheme("ThemeFourBasedOnFive");
|
||||
} catch (InvalidOperationException ex) {
|
||||
Assert.That(ex.Message, Is.StringMatching("ThemeFiveBasedOnFour"));
|
||||
}
|
||||
var siteTheme = _themeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.ThemeName, Is.EqualTo("ThemeOne"));
|
||||
}
|
||||
|
||||
#region Stubs
|
||||
|
||||
public class TestSessionLocator : ISessionLocator {
|
||||
private readonly ISession _session;
|
||||
|
||||
public TestSessionLocator(ISession session) {
|
||||
_session = session;
|
||||
}
|
||||
|
||||
public ISession For(Type entityType) {
|
||||
return _session;
|
||||
}
|
||||
}
|
||||
|
||||
public class StubAuthorizer : IAuthorizer {
|
||||
public bool Authorize(Permission permission) {
|
||||
return true;
|
||||
}
|
||||
public bool Authorize(Permission permission, LocalizedString message) {
|
||||
return true;
|
||||
}
|
||||
public bool Authorize(Permission permission, IContent content, LocalizedString message) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class StubExtensionManager : IExtensionManager {
|
||||
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
|
||||
var extensions = new[] {
|
||||
new ExtensionDescriptor {Name = "ThemeOne", ExtensionType = "Theme"},
|
||||
new ExtensionDescriptor {Name = "ThemeTwo", BaseTheme = "ThemeOne", ExtensionType = "Theme"},
|
||||
new ExtensionDescriptor {Name = "ThemeThree", BaseTheme = "TheThemeThatIsntThere", ExtensionType = "Theme"},
|
||||
new ExtensionDescriptor {Name = "ThemeFourBasedOnFive", BaseTheme = "ThemeFiveBasedOnFour", ExtensionType = "Theme"},
|
||||
new ExtensionDescriptor {Name = "ThemeFiveBasedOnFour", BaseTheme = "ThemeFourBasedOnFive", ExtensionType = "Theme"},
|
||||
};
|
||||
|
||||
foreach (var extension in extensions) {
|
||||
extension.Features = new[] { new FeatureDescriptor { Extension = extension, Name = extension.Name } };
|
||||
yield return extension;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<FeatureDescriptor> AvailableFeatures() {
|
||||
return AvailableExtensions().SelectMany(ed => ed.Features);
|
||||
}
|
||||
|
||||
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
|
||||
return featureDescriptors.Select(FrameworkFeature);
|
||||
}
|
||||
|
||||
private static Feature FrameworkFeature(FeatureDescriptor descriptor) {
|
||||
return new Feature {
|
||||
Descriptor = descriptor
|
||||
};
|
||||
}
|
||||
|
||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UninstallExtension(string extensionType, string extensionName) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Monitor(Action<IVolatileToken> monitor) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class StubShellDescriptorManager : IShellDescriptorManager {
|
||||
private readonly ShellDescriptorRecord _shellDescriptorRecord = new ShellDescriptorRecord();
|
||||
public ShellDescriptor GetShellDescriptor() {
|
||||
return GetShellDescriptorFromRecord(_shellDescriptorRecord);
|
||||
}
|
||||
|
||||
public void UpdateShellDescriptor(int priorSerialNumber, IEnumerable<ShellFeature> enabledFeatures, IEnumerable<ShellParameter> parameters) {
|
||||
_shellDescriptorRecord.Features.Clear();
|
||||
foreach (var feature in enabledFeatures) {
|
||||
_shellDescriptorRecord.Features.Add(new ShellFeatureRecord { Name = feature.Name, ShellDescriptorRecord = null });
|
||||
}
|
||||
|
||||
_shellDescriptorRecord.Parameters.Clear();
|
||||
foreach (var parameter in parameters) {
|
||||
_shellDescriptorRecord.Parameters.Add(new ShellParameterRecord {
|
||||
Component = parameter.Component,
|
||||
Name = parameter.Name,
|
||||
Value = parameter.Value,
|
||||
ShellDescriptorRecord = null
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static ShellDescriptor GetShellDescriptorFromRecord(ShellDescriptorRecord shellDescriptorRecord) {
|
||||
return new ShellDescriptor {
|
||||
SerialNumber = shellDescriptorRecord.SerialNumber,
|
||||
Features = shellDescriptorRecord.Features.Select(descriptorFeatureRecord => new ShellFeature {Name = descriptorFeatureRecord.Name}).ToList(),
|
||||
Parameters = shellDescriptorRecord.Parameters.Select(descriptorParameterRecord => new ShellParameter {
|
||||
Component = descriptorParameterRecord.Component, Name = descriptorParameterRecord.Name, Value = descriptorParameterRecord.Value
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
229
src/Orchard.Tests.Modules/Widgets/Services/WidgetsServiceTest.cs
Normal file
229
src/Orchard.Tests.Modules/Widgets/Services/WidgetsServiceTest.cs
Normal file
@@ -0,0 +1,229 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Autofac;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Settings.Metadata.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Security;
|
||||
using Orchard.Themes;
|
||||
using Orchard.Themes.Models;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Widgets.Models;
|
||||
using Orchard.Widgets.Services;
|
||||
|
||||
namespace Orchard.Tests.Modules.Widgets.Services {
|
||||
|
||||
[TestFixture]
|
||||
public class WidgetsServiceTest : DatabaseEnabledTestsBase {
|
||||
|
||||
private const string ThemeZoneName1 = "sidebar";
|
||||
private const string ThemeZoneName2 = "alternative";
|
||||
|
||||
private IWidgetsService _widgetService;
|
||||
private IContentManager _contentManager;
|
||||
|
||||
protected override IEnumerable<Type> DatabaseTypes {
|
||||
get {
|
||||
return new[] {
|
||||
typeof(LayerPartRecord),
|
||||
typeof(WidgetPartRecord),
|
||||
typeof(CommonPartRecord),
|
||||
typeof(BodyPartRecord),
|
||||
typeof(ContentPartRecord),
|
||||
typeof(ContentTypeRecord),
|
||||
typeof(ContentItemRecord),
|
||||
typeof(ContentItemVersionRecord),
|
||||
typeof(ContentTypeDefinitionRecord),
|
||||
typeof(ContentTypePartDefinitionRecord),
|
||||
typeof(ContentPartDefinitionRecord),
|
||||
typeof(ContentPartFieldDefinitionRecord),
|
||||
typeof(ContentFieldDefinitionRecord)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
|
||||
_widgetService = _container.Resolve<IWidgetsService>();
|
||||
_contentManager = _container.Resolve<IContentManager>();
|
||||
}
|
||||
|
||||
public override void Register(ContainerBuilder builder) {
|
||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
|
||||
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
|
||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
||||
builder.RegisterType<ShapeHelperFactory>().As<IShapeHelperFactory>();
|
||||
builder.RegisterType<WidgetsService>().As<IWidgetsService>();
|
||||
|
||||
Theme theme1 = new Theme { Zones = ThemeZoneName1 };
|
||||
Theme theme2 = new Theme { Zones = ThemeZoneName2 };
|
||||
Mock<IThemeService> themeServiceMock = new Mock<IThemeService>();
|
||||
themeServiceMock.Setup(x => x.GetInstalledThemes()).Returns(
|
||||
(new ITheme[] { theme1, theme2 }));
|
||||
|
||||
builder.RegisterInstance(themeServiceMock.Object).As<IThemeService>();
|
||||
builder.RegisterType<StubWidgetPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<StubLayerPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetLayersTest() {
|
||||
const string layerName1 = "Test layer 1";
|
||||
const string layerDescription1 = "Test layer 1";
|
||||
const string layerName2 = "Test layer 2";
|
||||
const string layerDescription2 = "Test layer 2";
|
||||
|
||||
IEnumerable<LayerPart> layers = _widgetService.GetLayers();
|
||||
Assert.That(layers.Count(), Is.EqualTo(0));
|
||||
|
||||
LayerPart layerPartFirst = _widgetService.CreateLayer(layerName1, layerDescription1, "");
|
||||
_contentManager.Flush();
|
||||
|
||||
layers = _widgetService.GetLayers();
|
||||
Assert.That(layers.Count(), Is.EqualTo(1));
|
||||
Assert.That(layers.First().Id, Is.EqualTo(layerPartFirst.Id));
|
||||
|
||||
_widgetService.CreateLayer(layerName2, layerDescription2, "");
|
||||
_contentManager.Flush();
|
||||
Assert.That(layers.Count(), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetLayerTest() {
|
||||
IEnumerable<LayerPart> layers = _widgetService.GetLayers();
|
||||
Assert.That(layers.Count(), Is.EqualTo(0), "No layers yet");
|
||||
|
||||
_widgetService.CreateLayer("Test layer 1", "Test layer 1", "");
|
||||
_contentManager.Flush();
|
||||
|
||||
layers = _widgetService.GetLayers();
|
||||
Assert.That(layers.Count(), Is.EqualTo(1), "One layer was created");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateLayerTest() {
|
||||
const string layerName = "Test layer 1";
|
||||
const string layerDescription = "Test layer 1";
|
||||
|
||||
IEnumerable<LayerPart> layers = _widgetService.GetLayers();
|
||||
Assert.That(layers.Count(), Is.EqualTo(0), "No layers yet");
|
||||
|
||||
_widgetService.CreateLayer(layerName, layerDescription, "");
|
||||
_contentManager.Flush();
|
||||
|
||||
layers = _widgetService.GetLayers();
|
||||
LayerPart layer = layers.First();
|
||||
Assert.That(layer.Record.Name, Is.EqualTo(layerName));
|
||||
Assert.That(layer.Record.Description, Is.EqualTo(layerDescription));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetWidgetTest() {
|
||||
const string layerName = "Test layer 1";
|
||||
const string layerDescription = "Test layer 1";
|
||||
const string widgetTitle = "Test widget 1";
|
||||
|
||||
LayerPart layerPart = _widgetService.CreateLayer(layerName, layerDescription, "");
|
||||
_contentManager.Flush();
|
||||
|
||||
WidgetPart widgetResult = _widgetService.GetWidget(0);
|
||||
Assert.That(widgetResult, Is.Null);
|
||||
|
||||
WidgetPart widgetPart = _widgetService.CreateWidget(layerPart.Id, "HtmlWidget", widgetTitle, "1", "");
|
||||
Assert.That(widgetPart, Is.Not.Null);
|
||||
|
||||
widgetResult = _widgetService.GetWidget(0);
|
||||
Assert.That(widgetResult, Is.Null, "Still yields null on an invalid identifier");
|
||||
|
||||
_contentManager.Flush();
|
||||
widgetResult = _widgetService.GetWidget(widgetPart.Id);
|
||||
Assert.That(widgetResult.Id, Is.EqualTo(widgetPart.Id), "Returns correct widget");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetWidgetsTest() {
|
||||
const string layerName = "Test layer 1";
|
||||
const string layerDescription = "Test layer 1";
|
||||
const string widgetTitle1 = "Test widget 1";
|
||||
const string widgetTitle2 = "Test widget 2";
|
||||
|
||||
LayerPart layerPart = _widgetService.CreateLayer(layerName, layerDescription, "");
|
||||
_contentManager.Flush();
|
||||
|
||||
IEnumerable<WidgetPart> widgetResults = _widgetService.GetWidgets();
|
||||
Assert.That(widgetResults.Count(), Is.EqualTo(0));
|
||||
|
||||
WidgetPart widgetPart = _widgetService.CreateWidget(layerPart.Id, "HtmlWidget", widgetTitle1, "1", "");
|
||||
Assert.That(widgetPart, Is.Not.Null);
|
||||
_contentManager.Flush();
|
||||
|
||||
widgetResults = _widgetService.GetWidgets();
|
||||
Assert.That(widgetResults.Count(), Is.EqualTo(1));
|
||||
Assert.That(widgetResults.First().Id, Is.EqualTo(widgetPart.Id));
|
||||
|
||||
_widgetService.CreateWidget(layerPart.Id, "HtmlWidget", widgetTitle2, "2", "");
|
||||
_contentManager.Flush();
|
||||
|
||||
widgetResults = _widgetService.GetWidgets();
|
||||
Assert.That(widgetResults.Count(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateWidgetTest() {
|
||||
const string layerName = "Test layer 1";
|
||||
const string layerDescription = "Test layer 1";
|
||||
const string widgetTitle = "Test widget 1";
|
||||
|
||||
LayerPart layerPart = _widgetService.CreateLayer(layerName, layerDescription, "");
|
||||
_contentManager.Flush();
|
||||
|
||||
WidgetPart widgetPart = _widgetService.CreateWidget(layerPart.Id, "HtmlWidget", widgetTitle, "1", "");
|
||||
Assert.That(widgetPart, Is.Not.Null);
|
||||
Assert.That(widgetPart.LayerPart.Id, Is.EqualTo(layerPart.Id));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetZonesTest() {
|
||||
IEnumerable<string> zones = _widgetService.GetZones();
|
||||
Assert.That(zones.Count(), Is.EqualTo(2), "One zone on the mock list");
|
||||
Assert.That(zones.FirstOrDefault(zone => zone == ThemeZoneName1), Is.Not.Null);
|
||||
Assert.That(zones.FirstOrDefault(zone => zone == ThemeZoneName2), Is.Not.Null);
|
||||
}
|
||||
|
||||
public class StubLayerPartHandler : ContentHandler {
|
||||
public StubLayerPartHandler(IRepository<LayerPartRecord> layersRepository) {
|
||||
Filters.Add(new ActivatingFilter<LayerPart>("Layer"));
|
||||
Filters.Add(new ActivatingFilter<CommonPart>("Layer"));
|
||||
Filters.Add(StorageFilter.For(layersRepository));
|
||||
}
|
||||
}
|
||||
|
||||
public class StubWidgetPartHandler : ContentHandler {
|
||||
public StubWidgetPartHandler(IRepository<WidgetPartRecord> widgetsRepository) {
|
||||
Filters.Add(new ActivatingFilter<WidgetPart>("HtmlWidget"));
|
||||
Filters.Add(new ActivatingFilter<CommonPart>("HtmlWidget"));
|
||||
Filters.Add(new ActivatingFilter<BodyPart>("HtmlWidget"));
|
||||
Filters.Add(StorageFilter.For(widgetsRepository));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -31,7 +31,7 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
|
||||
[Test]
|
||||
public void DriverHandlerShouldNotThrowException() {
|
||||
var contentHandler = _container.Resolve<IContentHandler>();
|
||||
contentHandler.BuildDisplayShape(null);
|
||||
contentHandler.BuildDisplay(null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -45,13 +45,13 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
|
||||
var contentHandler = _container.Resolve<IContentHandler>();
|
||||
|
||||
var contentItem = new ContentItem();
|
||||
var context = new BuildDisplayModelContext(contentItem, "", null, new ShapeHelperFactory(null));
|
||||
var context = new BuildDisplayContext(null, contentItem, "", new ShapeHelperFactory(null));
|
||||
|
||||
driver1.Verify(x => x.BuildDisplayShape(context), Times.Never());
|
||||
driver2.Verify(x => x.BuildDisplayShape(context), Times.Never());
|
||||
contentHandler.BuildDisplayShape(context);
|
||||
driver1.Verify(x => x.BuildDisplayShape(context));
|
||||
driver2.Verify(x => x.BuildDisplayShape(context));
|
||||
driver1.Verify(x => x.BuildDisplay(context), Times.Never());
|
||||
driver2.Verify(x => x.BuildDisplay(context), Times.Never());
|
||||
contentHandler.BuildDisplay(context);
|
||||
driver1.Verify(x => x.BuildDisplay(context));
|
||||
driver2.Verify(x => x.BuildDisplay(context));
|
||||
}
|
||||
|
||||
[Test, Ignore("no implementation for IZoneCollection")]
|
||||
@@ -66,10 +66,10 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
|
||||
var contentItem = new ContentItem();
|
||||
contentItem.Weld(new StubPart { Foo = new[] { "a", "b", "c" } });
|
||||
|
||||
var ctx = new BuildDisplayModelContext(contentItem, "", null, null);
|
||||
var ctx = new BuildDisplayContext(null, null, "", null);
|
||||
var context = shapeHelperFactory.CreateHelper().Context(ctx);
|
||||
Assert.That(context.TopMeta, Is.Null);
|
||||
contentHandler.BuildDisplayShape(ctx);
|
||||
contentHandler.BuildDisplay(ctx);
|
||||
Assert.That(context.TopMeta, Is.Not.Null);
|
||||
Assert.That(context.TopMeta.Count == 1);
|
||||
}
|
||||
@@ -79,20 +79,25 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
|
||||
get { return "Stub"; }
|
||||
}
|
||||
|
||||
protected override DriverResult Display(StubPart part, string displayType) {
|
||||
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
|
||||
if (displayType.StartsWith("Summary"))
|
||||
return ContentPartTemplate(viewModel, "StubViewModelTerse").Location("TopMeta");
|
||||
protected override DriverResult Display(StubPart part, string displayType, dynamic shapeHelper) {
|
||||
var stub = shapeHelper.Stub(ContentPart: part, Foo: string.Join(",", part.Foo));
|
||||
if (!string.IsNullOrWhiteSpace(displayType))
|
||||
stub.Metadata.Type = string.Format("{0}.{1}", stub.Metadata.Type, displayType);
|
||||
return ContentShape(stub).Location("TopMeta");
|
||||
|
||||
//var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
|
||||
//if (displayType.StartsWith("Summary"))
|
||||
// return ContentPartTemplate(viewModel, "StubViewModelTerse").Location("TopMeta");
|
||||
|
||||
return ContentPartTemplate(viewModel).Location("TopMeta");
|
||||
//return ContentPartTemplate(viewModel).Location("TopMeta");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(StubPart part) {
|
||||
protected override DriverResult Editor(StubPart part, dynamic shapeHelper) {
|
||||
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
|
||||
return ContentPartTemplate(viewModel).Location("last", "10");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(StubPart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(StubPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
|
||||
updater.TryUpdateModel(viewModel, Prefix, null, null);
|
||||
part.Foo = viewModel.Foo.Split(new[] { ',' }).Select(x => x.Trim()).ToArray();
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace Orchard.Tests.ContentManagement.Models {
|
||||
public class AlphaHandler : ContentHandler {
|
||||
public AlphaHandler() {
|
||||
OnGetDisplayShape<Alpha>((ctx, part) => ctx.Model.Zones["Main"].Add(part, "3"));
|
||||
OnGetDisplayShape<Alpha>((ctx, part) => ctx.Shape.Zones["Main"].Add(part, "3"));
|
||||
}
|
||||
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace Orchard.Tests.ContentManagement.Models {
|
||||
public class FlavoredHandler : ContentHandler {
|
||||
public FlavoredHandler() {
|
||||
OnGetDisplayShape<Flavored>((ctx, part) => ctx.Model.Zones["Main"].Add(part));
|
||||
OnGetDisplayShape<Flavored>((ctx, part) => ctx.Shape.Zones["Main"].Add(part));
|
||||
}
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
if (context.ContentType == "beta" || context.ContentType == "alpha") {
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace Orchard.Tests.ContentManagement.Models {
|
||||
public class StyledHandler : ContentHandler {
|
||||
public StyledHandler() {
|
||||
OnGetDisplayShape<Styled>((ctx, part) => ctx.Model.Zones["Main"].Add(part, "10"));
|
||||
OnGetDisplayShape<Styled>((ctx, part) => ctx.Shape.Zones["Main"].Add(part, "10"));
|
||||
}
|
||||
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
|
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Autofac;
|
||||
@@ -10,7 +8,6 @@ using NUnit.Framework;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.Themes;
|
||||
|
||||
namespace Orchard.Tests.DisplayManagement {
|
||||
@@ -20,7 +17,10 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
WorkContext _workContext;
|
||||
|
||||
protected override void Register(Autofac.ContainerBuilder builder) {
|
||||
_defaultShapeTable = new ShapeTable { Descriptors = new Dictionary<string, ShapeDescriptor>() };
|
||||
_defaultShapeTable = new ShapeTable {
|
||||
Descriptors = new Dictionary<string, ShapeDescriptor>(StringComparer.OrdinalIgnoreCase),
|
||||
Bindings = new Dictionary<string, ShapeBinding>(StringComparer.OrdinalIgnoreCase)
|
||||
};
|
||||
_workContext = new TestWorkContext {
|
||||
CurrentTheme = new Theme { ThemeName = "Hello" }
|
||||
};
|
||||
@@ -29,10 +29,22 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
builder.RegisterType<DefaultDisplayManager>().As<IDisplayManager>();
|
||||
builder.RegisterType<TestShapeTableManager>().As<IShapeTableManager>();
|
||||
builder.RegisterType<TestWorkContextAccessor>().As<IWorkContextAccessor>();
|
||||
builder.RegisterType<TestDisplayEvents>().As<IShapeDisplayEvents>()
|
||||
.As<TestDisplayEvents>()
|
||||
.InstancePerLifetimeScope();
|
||||
|
||||
builder.Register(ctx => _defaultShapeTable);
|
||||
builder.Register(ctx => _workContext);
|
||||
}
|
||||
|
||||
class TestDisplayEvents : IShapeDisplayEvents {
|
||||
public Action<ShapeDisplayingContext> Displaying = ctx => { };
|
||||
public Action<ShapeDisplayedContext> Displayed = ctx => { };
|
||||
|
||||
void IShapeDisplayEvents.Displaying(ShapeDisplayingContext context) { Displaying(context); }
|
||||
void IShapeDisplayEvents.Displayed(ShapeDisplayedContext context) { Displayed(context); }
|
||||
}
|
||||
|
||||
public class Theme : ITheme {
|
||||
public string ThemeName { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
@@ -42,6 +54,7 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
public string HomePage { get; set; }
|
||||
public string Tags { get; set; }
|
||||
public string Zones { get; set; }
|
||||
public string BaseTheme { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -85,11 +98,10 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
public IContainerProvider ContainerProvider { get; set; }
|
||||
|
||||
public override T Resolve<T>() {
|
||||
if (typeof(T) == typeof(ILifetimeScope))
|
||||
{
|
||||
return (T) ContainerProvider.RequestLifetime;
|
||||
if (typeof(T) == typeof(ILifetimeScope)) {
|
||||
return (T)ContainerProvider.RequestLifetime;
|
||||
}
|
||||
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -104,8 +116,10 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
}
|
||||
|
||||
void AddShapeDescriptor(ShapeDescriptor shapeDescriptor) {
|
||||
_defaultShapeTable.Descriptors[shapeDescriptor.ShapeType] = shapeDescriptor;
|
||||
foreach (var binding in shapeDescriptor.Bindings) {
|
||||
_defaultShapeTable.Descriptors[binding.Key] = shapeDescriptor;
|
||||
binding.Value.ShapeDescriptor = shapeDescriptor;
|
||||
_defaultShapeTable.Bindings[binding.Key] = binding.Value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +177,7 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RenderAlternateShape() {
|
||||
public void RenderAlternateShapeExplicitly() {
|
||||
var displayManager = _container.Resolve<IDisplayManager>();
|
||||
|
||||
var shape = new Shape {
|
||||
@@ -188,5 +202,146 @@ namespace Orchard.Tests.DisplayManagement {
|
||||
var result = displayManager.Execute(CreateDisplayContext(shape));
|
||||
Assert.That(result.ToString(), Is.EqualTo("Hello again!"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RenderAlternateShapeByMostRecentlyAddedMatchingAlternate() {
|
||||
var displayManager = _container.Resolve<IDisplayManager>();
|
||||
|
||||
var shape = new Shape {
|
||||
Metadata = new ShapeMetadata {
|
||||
Type = "Foo"
|
||||
}
|
||||
};
|
||||
shape.Metadata.Alternates.Add("Foo__1");
|
||||
shape.Metadata.Alternates.Add("Foo__2");
|
||||
shape.Metadata.Alternates.Add("Foo__3");
|
||||
|
||||
var descriptor = new ShapeDescriptor {
|
||||
ShapeType = "Foo",
|
||||
};
|
||||
AddBinding(descriptor, "Foo", ctx => new HtmlString("Hi there!"));
|
||||
AddBinding(descriptor, "Foo__1", ctx => new HtmlString("Hello (1)!"));
|
||||
AddBinding(descriptor, "Foo__2", ctx => new HtmlString("Hello (2)!"));
|
||||
AddShapeDescriptor(descriptor);
|
||||
|
||||
var result = displayManager.Execute(CreateDisplayContext(shape));
|
||||
Assert.That(result.ToString(), Is.EqualTo("Hello (2)!"));
|
||||
}
|
||||
|
||||
private static void AddBinding(ShapeDescriptor descriptor, string bindingName, Func<DisplayContext, IHtmlString> binding) {
|
||||
descriptor.Bindings[bindingName] = new ShapeBinding {
|
||||
BindingName = bindingName,
|
||||
Binding = binding,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void IShapeDisplayEventsIsCalled() {
|
||||
var displayManager = _container.Resolve<IDisplayManager>();
|
||||
|
||||
var shape = new Shape {
|
||||
Metadata = new ShapeMetadata {
|
||||
Type = "Foo"
|
||||
}
|
||||
};
|
||||
|
||||
var descriptor = new ShapeDescriptor {
|
||||
ShapeType = "Foo",
|
||||
};
|
||||
AddBinding(descriptor, "Foo", ctx => new HtmlString("yarg"));
|
||||
AddShapeDescriptor(descriptor);
|
||||
|
||||
var displayingEventCount = 0;
|
||||
var displayedEventCount = 0;
|
||||
_container.Resolve<TestDisplayEvents>().Displaying = ctx => { ++displayingEventCount; };
|
||||
_container.Resolve<TestDisplayEvents>().Displayed = ctx => { ++displayedEventCount; ctx.ChildContent = new HtmlString("[" + ctx.ChildContent.ToHtmlString() + "]"); };
|
||||
|
||||
var result = displayManager.Execute(CreateDisplayContext(shape));
|
||||
|
||||
Assert.That(displayingEventCount, Is.EqualTo(1));
|
||||
Assert.That(displayedEventCount, Is.EqualTo(1));
|
||||
Assert.That(result.ToString(), Is.EqualTo("[yarg]"));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ShapeDescriptorDisplayingAndDisplayedAreCalled() {
|
||||
var displayManager = _container.Resolve<IDisplayManager>();
|
||||
|
||||
var shape = new Shape {
|
||||
Metadata = new ShapeMetadata {
|
||||
Type = "Foo"
|
||||
}
|
||||
};
|
||||
|
||||
var descriptor = new ShapeDescriptor {
|
||||
ShapeType = "Foo",
|
||||
};
|
||||
AddBinding(descriptor, "Foo", ctx => new HtmlString("yarg"));
|
||||
AddShapeDescriptor(descriptor);
|
||||
|
||||
var displayingEventCount = 0;
|
||||
var displayedEventCount = 0;
|
||||
descriptor.Displaying = new Action<ShapeDisplayingContext>[] { ctx => { ++displayingEventCount; } };
|
||||
descriptor.Displayed = new Action<ShapeDisplayedContext>[] { ctx => { ++displayedEventCount; ctx.ChildContent = new HtmlString("[" + ctx.ChildContent.ToHtmlString() + "]"); } };
|
||||
|
||||
var result = displayManager.Execute(CreateDisplayContext(shape));
|
||||
|
||||
Assert.That(displayingEventCount, Is.EqualTo(1));
|
||||
Assert.That(displayedEventCount, Is.EqualTo(1));
|
||||
Assert.That(result.ToString(), Is.EqualTo("[yarg]"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DisplayingEventFiresEarlyEnoughToAddAlternateShapeBindingNames() {
|
||||
var displayManager = _container.Resolve<IDisplayManager>();
|
||||
|
||||
var shapeFoo = new Shape {
|
||||
Metadata = new ShapeMetadata {
|
||||
Type = "Foo"
|
||||
}
|
||||
};
|
||||
var descriptorFoo = new ShapeDescriptor {
|
||||
ShapeType = "Foo",
|
||||
};
|
||||
AddBinding(descriptorFoo, "Foo", ctx => new HtmlString("alpha"));
|
||||
AddShapeDescriptor(descriptorFoo);
|
||||
|
||||
var descriptorBar = new ShapeDescriptor {
|
||||
ShapeType = "Bar",
|
||||
};
|
||||
AddBinding(descriptorBar, "Bar", ctx => new HtmlString("beta"));
|
||||
AddShapeDescriptor(descriptorBar);
|
||||
|
||||
|
||||
var resultNormally = displayManager.Execute(CreateDisplayContext(shapeFoo));
|
||||
descriptorFoo.Displaying = new Action<ShapeDisplayingContext>[] { ctx => ctx.ShapeMetadata.Alternates.Add("Bar") };
|
||||
var resultWithOverride = displayManager.Execute(CreateDisplayContext(shapeFoo));
|
||||
|
||||
Assert.That(resultNormally.ToString(), Is.EqualTo("alpha"));
|
||||
Assert.That(resultWithOverride.ToString(), Is.EqualTo("beta"));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ShapeTypeAndBindingNamesAreNotCaseSensitive() {
|
||||
var displayManager = _container.Resolve<IDisplayManager>();
|
||||
|
||||
var shapeFoo = new Shape {
|
||||
Metadata = new ShapeMetadata {
|
||||
Type = "foo"
|
||||
}
|
||||
};
|
||||
var descriptorFoo = new ShapeDescriptor {
|
||||
ShapeType = "Foo",
|
||||
};
|
||||
AddBinding(descriptorFoo, "Foo", ctx => new HtmlString("alpha"));
|
||||
AddShapeDescriptor(descriptorFoo);
|
||||
|
||||
var result = displayManager.Execute(CreateDisplayContext(shapeFoo));
|
||||
|
||||
Assert.That(result.ToString(), Is.EqualTo("alpha"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using Autofac;
|
||||
using NUnit.Framework;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Tests.DisplayManagement.Descriptors {
|
||||
@@ -12,7 +13,9 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
|
||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||
|
||||
builder.RegisterType<TestShapeProvider>().As<IShapeTableProvider>()
|
||||
.WithMetadata("Feature", TestFeature());
|
||||
.WithMetadata("Feature", TestFeature())
|
||||
.As<TestShapeProvider>()
|
||||
.InstancePerLifetimeScope();
|
||||
}
|
||||
|
||||
static Feature TestFeature() {
|
||||
@@ -29,8 +32,12 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
|
||||
}
|
||||
|
||||
public class TestShapeProvider : IShapeTableProvider {
|
||||
public void Discover(ShapeTableBuilder builder) {
|
||||
|
||||
public Action<ShapeTableBuilder> Discover = x => { };
|
||||
|
||||
void IShapeTableProvider.Discover(ShapeTableBuilder builder) {
|
||||
builder.Describe("Hello");
|
||||
Discover(builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,5 +55,29 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
|
||||
Assert.That(shapeTable1.Descriptors["Hello"], Is.Not.Null);
|
||||
Assert.That(shapeTable2.Descriptors["Hello"], Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CallbackAlterationsContributeToDescriptor() {
|
||||
Action<ShapeCreatingContext> cb1 = x => { };
|
||||
Action<ShapeCreatedContext> cb2 = x => { };
|
||||
Action<ShapeDisplayingContext> cb3 = x => { };
|
||||
Action<ShapeDisplayedContext> cb4 = x => { };
|
||||
|
||||
_container.Resolve<TestShapeProvider>().Discover =
|
||||
builder => builder.Describe("Foo")
|
||||
.OnCreating(cb1)
|
||||
.OnCreated(cb2)
|
||||
.OnDisplaying(cb3)
|
||||
.OnDisplayed(cb4);
|
||||
|
||||
var manager = _container.Resolve<IShapeTableManager>();
|
||||
|
||||
var foo = manager.GetShapeTable(null).Descriptors["Foo"];
|
||||
|
||||
Assert.That(foo.Creating.Single(), Is.SameAs(cb1));
|
||||
Assert.That(foo.Created.Single(), Is.SameAs(cb2));
|
||||
Assert.That(foo.Displaying.Single(), Is.SameAs(cb3));
|
||||
Assert.That(foo.Displayed.Single(), Is.SameAs(cb4));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Common.Services;
|
||||
using Orchard.Core.Common.Settings;
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using Orchard.Core.ContentsLocation.Models;
|
||||
@@ -35,26 +33,29 @@ namespace Orchard.Core.Common.Drivers {
|
||||
get { return "Body"; }
|
||||
}
|
||||
|
||||
// \/\/ Hackalicious on many accounts - don't copy what has been done here for the wrapper \/\/
|
||||
protected override DriverResult Display(BodyPart part, string displayType) {
|
||||
protected override DriverResult Display(BodyPart part, string displayType, dynamic shapeHelper) {
|
||||
var bodyText = _htmlFilters.Aggregate(part.Text, (text, filter) => filter.ProcessContent(text));
|
||||
var model = new BodyDisplayViewModel { BodyPart = part, Html = new HtmlString(bodyText) };
|
||||
var body = shapeHelper.Parts_Common_Body(ContentPart: part, Html: new HtmlString(bodyText));
|
||||
if (!string.IsNullOrWhiteSpace(displayType))
|
||||
body.Metadata.Type = string.Format("{0}.{1}", body.Metadata.Type, displayType);
|
||||
var location = part.GetLocation(displayType);
|
||||
|
||||
return Combined(
|
||||
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPre").LongestMatch(displayType, "SummaryAdmin").Location(location) : null,
|
||||
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.Manage").LongestMatch(displayType, "SummaryAdmin").Location(location) : null,
|
||||
ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location),
|
||||
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location(location) : null);
|
||||
//return Combined(
|
||||
// Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPre").LongestMatch(displayType, "SummaryAdmin").Location(location) : null,
|
||||
// Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.Manage").LongestMatch(displayType, "SummaryAdmin").Location(location) : null,
|
||||
// ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location),
|
||||
// Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location(location) : null);
|
||||
|
||||
return ContentShape(body).Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BodyPart part) {
|
||||
protected override DriverResult Editor(BodyPart part, dynamic shapeHelper) {
|
||||
var model = BuildEditorViewModel(part);
|
||||
var location = part.GetLocation("Editor");
|
||||
return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BodyPart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(BodyPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var model = BuildEditorViewModel(part);
|
||||
updater.TryUpdateModel(model, Prefix, null, null);
|
||||
|
||||
|
@@ -35,19 +35,21 @@ namespace Orchard.Core.Common.Drivers {
|
||||
public Localizer T { get; set; }
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
protected override DriverResult Display(CommonPart part, string displayType) {
|
||||
return ContentPartTemplate(new CommonMetadataViewModel(part), "Parts/Common.Metadata")
|
||||
.LongestMatch(displayType, "Summary", "SummaryAdmin")
|
||||
.Location(part.GetLocation(displayType));
|
||||
protected override DriverResult Display(CommonPart part, string displayType, dynamic shapeHelper) {
|
||||
var metadata = shapeHelper.Parts_Common_Metadata(ContentPart: part);
|
||||
if (!string.IsNullOrWhiteSpace(displayType))
|
||||
metadata.Metadata.Type = string.Format("{0}.{1}", metadata.Metadata.Type, displayType);
|
||||
var location = part.GetLocation(displayType);
|
||||
return ContentShape(metadata).Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(CommonPart part) {
|
||||
protected override DriverResult Editor(CommonPart part, dynamic shapeHelper) {
|
||||
return Combined(
|
||||
OwnerEditor(part, null),
|
||||
ContainerEditor(part, null));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(CommonPart instance, ContentManagement.IUpdateModel updater) {
|
||||
protected override DriverResult Editor(CommonPart instance, IUpdateModel updater, dynamic shapeHelper) {
|
||||
// this event is hooked so the modified timestamp is changed when an edit-post occurs.
|
||||
instance.ModifiedUtc = _clock.UtcNow;
|
||||
instance.VersionModifiedUtc = _clock.UtcNow;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using Orchard.Core.Contents.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc.Html;
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace Orchard.Core.Common.Extensions {
|
||||
}
|
||||
|
||||
public static LocalizedString PublishedWhenForModel(this HtmlHelper<CommonMetadataViewModel> htmlHelper, Localizer T) {
|
||||
return htmlHelper.PublishedWhen(htmlHelper.ViewData.Model, T);
|
||||
return htmlHelper.PublishedWhen(htmlHelper.ViewData.Model.VersionPublishedUtc, T);
|
||||
}
|
||||
|
||||
public static LocalizedString PublishedWhen(this HtmlHelper htmlHelper, CommonMetadataViewModel metadata, Localizer T) {
|
||||
return htmlHelper.DateTimeRelative(metadata.VersionPublishedUtc, T("as a Draft"), T);
|
||||
public static LocalizedString PublishedWhen(this HtmlHelper htmlHelper, DateTime? versionPublishedUtc, Localizer T) {
|
||||
return htmlHelper.DateTimeRelative(versionPublishedUtc, T("as a Draft"), T);
|
||||
}
|
||||
}
|
||||
}
|
@@ -149,7 +149,7 @@ namespace Orchard.Core.Common.Handlers {
|
||||
}
|
||||
|
||||
|
||||
//private void GetEditor(BuildEditorModelContext context, CommonPart instance) {
|
||||
//private void GetEditor(BuildEditorContext context, CommonPart instance) {
|
||||
// var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
// if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) {
|
||||
// return;
|
||||
@@ -162,7 +162,7 @@ namespace Orchard.Core.Common.Handlers {
|
||||
//}
|
||||
|
||||
|
||||
//private void UpdateEditor(UpdateEditorModelContext context, CommonPart instance) {
|
||||
//private void UpdateEditor(UpdateEditorContext context, CommonPart instance) {
|
||||
// // this event is hooked so the modified timestamp is changed when an edit-post occurs.
|
||||
// // kind of a loose rule of thumb. may not be sufficient
|
||||
// instance.ModifiedUtc = _clock.UtcNow;
|
||||
|
@@ -1,3 +0,0 @@
|
||||
@model BodyDisplayViewModel
|
||||
@using Orchard.Core.Common.ViewModels;
|
||||
@Model.Html
|
@@ -0,0 +1 @@
|
||||
@Model.Html
|
@@ -114,7 +114,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
|
||||
|
||||
var list = Shape.List();
|
||||
list.AddRange(contentItems.Select(ci => _contentManager.BuildDisplayModel(ci, "SummaryAdmin")));
|
||||
list.AddRange(contentItems.Select(ci => _contentManager.BuildDisplay(ci, "SummaryAdmin")));
|
||||
|
||||
var viewModel = Shape.ViewModel()
|
||||
.ContentItems(list)
|
||||
@@ -216,7 +216,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Cannot create content")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var model = _contentManager.BuildEditorModel(contentItem);
|
||||
var model = _contentManager.BuildEditor(contentItem);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
_contentManager.Create(contentItem, VersionOptions.Draft);
|
||||
var model = _contentManager.UpdateEditorModel(contentItem, this);
|
||||
var model = _contentManager.UpdateEditor(contentItem, this);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
_transactionManager.Cancel();
|
||||
@@ -254,7 +254,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditOthersContent, contentItem, T("Cannot edit content")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var model = _contentManager.BuildEditorModel(contentItem);
|
||||
var model = _contentManager.BuildEditor(contentItem);
|
||||
|
||||
return View(model);
|
||||
}
|
||||
@@ -269,7 +269,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditOthersContent, contentItem, T("Couldn't edit content")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var model = _contentManager.UpdateEditorModel(contentItem, this);
|
||||
var model = _contentManager.UpdateEditor(contentItem, this);
|
||||
if (!ModelState.IsValid) {
|
||||
_transactionManager.Cancel();
|
||||
return View("Edit", model);
|
||||
|
@@ -18,7 +18,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
// /Contents/Item/Display/72
|
||||
public ActionResult Display(int id) {
|
||||
var contentItem = _contentManager.Get(id, VersionOptions.Published);
|
||||
var model = _contentManager.BuildDisplayModel(contentItem);
|
||||
var model = _contentManager.BuildDisplay(contentItem);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
versionOptions = VersionOptions.Number((int)version);
|
||||
|
||||
var contentItem = _contentManager.Get(id, versionOptions);
|
||||
var model = _contentManager.BuildDisplayModel(contentItem);
|
||||
var model = _contentManager.BuildDisplay(contentItem);
|
||||
return View("Display", model);
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,15 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Contents.ViewModels;
|
||||
using Orchard.Core.ContentsLocation.Models;
|
||||
|
||||
namespace Orchard.Core.Contents.Drivers {
|
||||
public class ContentsDriver : ContentPartDriver<ContentPart> {
|
||||
protected override DriverResult Display(ContentPart part, string displayType) {
|
||||
var location = part.GetLocation(displayType, "secondary", null);
|
||||
return ContentPartTemplate(new PublishContentViewModel(part.ContentItem), "Parts/Contents.Publish").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location);
|
||||
protected override DriverResult Display(ContentPart part, string displayType, dynamic shapeHelper) {
|
||||
var publish = shapeHelper.Parts_Contents_Publish(ContentPart: part);
|
||||
if (!string.IsNullOrWhiteSpace(displayType))
|
||||
publish.Metadata.Type = string.Format("{0}.{1}", publish.Metadata.Type, displayType);
|
||||
var location = part.GetLocation(displayType, "Secondary", "5");
|
||||
return ContentShape(publish).Location(location);
|
||||
}
|
||||
}
|
||||
}
|
@@ -67,7 +67,7 @@ namespace Orchard.Core.Localization.Controllers {
|
||||
Id = id,
|
||||
SelectedCulture = selectedCulture,
|
||||
SiteCultures = siteCultures,
|
||||
Content = _contentManager.BuildEditorModel(contentItem)
|
||||
Content = _contentManager.BuildEditor(contentItem)
|
||||
};
|
||||
Services.TransactionManager.Cancel();
|
||||
|
||||
@@ -104,13 +104,13 @@ namespace Orchard.Core.Localization.Controllers {
|
||||
}
|
||||
}
|
||||
|
||||
model.Content = _contentManager.UpdateEditorModel(contentItemTranslation, this);
|
||||
model.Content = _contentManager.UpdateEditor(contentItemTranslation, this);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
model.SiteCultures = _cultureManager.ListCultures().Where(s => s != _localizationService.GetContentCulture(contentItem) && s != _cultureManager.GetSiteCulture());
|
||||
contentItem.As<LocalizationPart>().Culture.Culture = null;
|
||||
model.Content = _contentManager.BuildEditorModel(contentItem);
|
||||
model.Content = _contentManager.BuildEditor(contentItem);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
@@ -22,15 +21,15 @@ namespace Orchard.Core.Localization.Drivers {
|
||||
_localizationService = localizationService;
|
||||
}
|
||||
|
||||
protected override DriverResult Display(LocalizationPart part, string displayType) {
|
||||
var model = new ContentLocalizationsViewModel(part) {
|
||||
Localizations = GetDisplayLocalizations(part)
|
||||
};
|
||||
|
||||
return ContentPartTemplate(model, "Parts/Localization.ContentTranslations", TemplatePrefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(part.GetLocation(displayType));
|
||||
protected override DriverResult Display(LocalizationPart part, string displayType, dynamic shapeHelper) {
|
||||
var contentTranslations = shapeHelper.Parts_Localization_ContentTranslations(ContentPart: part, Localizations: GetDisplayLocalizations(part));
|
||||
if (!string.IsNullOrWhiteSpace(displayType))
|
||||
contentTranslations.Metadata.Type = string.Format("{0}.{1}", contentTranslations.Metadata.Type, displayType);
|
||||
var location = part.GetLocation(displayType);
|
||||
return ContentShape(contentTranslations).Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(LocalizationPart part) {
|
||||
protected override DriverResult Editor(LocalizationPart part, dynamic shapeHelper) {
|
||||
var localizations = GetEditorLocalizations(part).ToList();
|
||||
var model = new EditLocalizationViewModel {
|
||||
SelectedCulture = part.Culture != null ? part.Culture.Culture : null,
|
||||
@@ -43,13 +42,13 @@ namespace Orchard.Core.Localization.Drivers {
|
||||
return ContentPartTemplate(model, "Parts/Localization.Translation", TemplatePrefix).Location(part.GetLocation("Editor"));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(LocalizationPart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(LocalizationPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var model = new EditLocalizationViewModel();
|
||||
if (updater != null && updater.TryUpdateModel(model, TemplatePrefix, null, null)) {
|
||||
_localizationService.SetContentCulture(part, model.SelectedCulture);
|
||||
}
|
||||
|
||||
return Editor(part);
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
|
||||
private IEnumerable<LocalizationPart> GetDisplayLocalizations(LocalizationPart part) {
|
||||
|
@@ -1,12 +0,0 @@
|
||||
@model Orchard.Core.Localization.ViewModels.ContentLocalizationsViewModel
|
||||
@{
|
||||
Style.Require("Localization");
|
||||
}
|
||||
@if (Model.Localizations.Count() > 0) {
|
||||
<div class="content-localization">
|
||||
<div class="content-localizations">
|
||||
<h4>@T("Translations:")</h4>
|
||||
@Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations")
|
||||
</div>
|
||||
</div>
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
@using Orchard.Core.Localization.Models;
|
||||
@{
|
||||
Style.Require("Localization");
|
||||
IEnumerable<LocalizationPart> localizations = Model.Localizations;
|
||||
}
|
||||
@if (localizations != null && localizations.Count() > 0) {
|
||||
<div class="content-localization">
|
||||
<div class="content-localizations">
|
||||
<h4>@T("Translations:")</h4>
|
||||
@Html.UnorderedList(localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations")
|
||||
</div>
|
||||
</div>
|
||||
}
|
@@ -22,7 +22,7 @@ namespace Orchard.Core.Messaging.Drivers {
|
||||
|
||||
protected override string Prefix { get { return "MessageSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(MessageSettingsPart part) {
|
||||
protected override DriverResult Editor(MessageSettingsPart part, dynamic shapeHelper) {
|
||||
|
||||
var model = new MessageSettingsPartViewModel {
|
||||
ChannelServices = _messageQueueManager.GetAvailableChannelServices(),
|
||||
@@ -32,7 +32,7 @@ namespace Orchard.Core.Messaging.Drivers {
|
||||
return ContentPartTemplate(model, "Parts/Messaging.MessageSettings");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(MessageSettingsPart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(MessageSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var model = new MessageSettingsPartViewModel {
|
||||
MessageSettings = part
|
||||
};
|
||||
|
@@ -87,7 +87,7 @@ namespace Orchard.Core.Navigation.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var menuPart = _services.ContentManager.New<MenuPart>("MenuItem");
|
||||
model.MenuItem = _services.ContentManager.UpdateEditorModel(menuPart, this);
|
||||
model.MenuItem = _services.ContentManager.UpdateEditor(menuPart, this);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
_services.TransactionManager.Cancel();
|
||||
|
@@ -15,7 +15,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
_workContextAccessor = workContextAccessor;
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(MenuItemPart itemPart, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(MenuItemPart itemPart, IUpdateModel updater, dynamic shapeHelper) {
|
||||
//todo: (heskew) need context
|
||||
var currentUser = _workContextAccessor.GetContext().CurrentUser;
|
||||
|
||||
|
@@ -24,14 +24,14 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
public virtual IUser CurrentUser { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(MenuPart part) {
|
||||
protected override DriverResult Editor(MenuPart part, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
|
||||
return null;
|
||||
|
||||
return ContentPartTemplate(part, "Parts/Navigation.EditMenuPart").Location(part.GetLocation("Editor"));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(MenuPart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(MenuPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part)) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -132,7 +132,7 @@
|
||||
<Compile Include="Reports\ViewModels\DisplayReportViewModel.cs" />
|
||||
<Compile Include="Reports\ViewModels\ReportsAdminIndexViewModel.cs" />
|
||||
<Compile Include="Routable\Controllers\ItemController.cs" />
|
||||
<Compile Include="Routable\DataMigrations\RoutableDataMigration.cs" />
|
||||
<Compile Include="Routable\Migrations.cs" />
|
||||
<Compile Include="Routable\Drivers\RoutePartDriver.cs" />
|
||||
<Compile Include="Routable\Handlers\RoutePartHandler.cs" />
|
||||
<Compile Include="Routable\IRoutablePathConstraint.cs" />
|
||||
@@ -254,12 +254,12 @@
|
||||
<Content Include="Common\Views\DefinitionTemplates\BodyTypePartSettings.cshtml" />
|
||||
<Content Include="Common\Views\DefinitionTemplates\BodyPartSettings.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Fields\Common.TextField.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.SummaryAdmin.cshtml" />
|
||||
<Content Include="Common\Views\Parts\Common.Body.SummaryAdmin.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Manage.SummaryAdmin.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPost.SummaryAdmin.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPre.SummaryAdmin.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Metadata.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Metadata.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" />
|
||||
@@ -268,8 +268,8 @@
|
||||
<Content Include="Contents\Views\Admin\List.cshtml" />
|
||||
<Content Include="Feeds\Views\Feed.cshtml" />
|
||||
<Content Include="Localization\Views\EditorTemplates\Parts\Localization.Translation.cshtml" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.cshtml" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.SummaryAdmin.cshtml" />
|
||||
<Content Include="Contents\Views\Parts\Contents.Publish.cshtml" />
|
||||
<Content Include="Contents\Views\Parts\Contents.Publish.SummaryAdmin.cshtml" />
|
||||
<Content Include="Messaging\Module.txt" />
|
||||
<Content Include="Messaging\Views\EditorTemplates\Parts\Messaging.MessageSettings.cshtml" />
|
||||
<Content Include="PublishLater\Content\Admin\images\draft.gif" />
|
||||
@@ -277,8 +277,8 @@
|
||||
<Content Include="PublishLater\Content\Admin\images\online.gif" />
|
||||
<Content Include="PublishLater\Content\Admin\images\published.gif" />
|
||||
<Content Include="PublishLater\Content\Admin\images\scheduled.gif" />
|
||||
<Content Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.cshtml" />
|
||||
<Content Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.SummaryAdmin.cshtml" />
|
||||
<Content Include="PublishLater\Views\Parts\PublishLater.Metadata.cshtml" />
|
||||
<Content Include="PublishLater\Views\Parts\PublishLater.Metadata.SummaryAdmin.cshtml" />
|
||||
<Content Include="Common\Views\EditorTemplates\Fields\Common.TextField.cshtml" />
|
||||
<Content Include="Common\Views\EditorTemplates\Parts\Common.Container.cshtml" />
|
||||
<Content Include="Common\Views\EditorTemplates\PlainTextEditor.cshtml" />
|
||||
@@ -286,8 +286,8 @@
|
||||
<Content Include="Contents\Views\Admin\CreatableTypeList.cshtml" />
|
||||
<Content Include="Localization\Styles\admin.css" />
|
||||
<Content Include="Localization\Styles\base.css" />
|
||||
<Content Include="Localization\Views\DisplayTemplates\Parts\Localization.ContentTranslations.Summary.cshtml" />
|
||||
<Content Include="Localization\Views\DisplayTemplates\Parts\Localization.ContentTranslations.cshtml" />
|
||||
<Content Include="Localization\Views\Parts\Localization.ContentTranslations.Summary.cshtml" />
|
||||
<Content Include="Localization\Views\Parts\Localization.ContentTranslations.cshtml" />
|
||||
<Content Include="PublishLater\Module.txt" />
|
||||
<Content Include="PublishLater\Styles\datetime.css" />
|
||||
<Content Include="PublishLater\Views\EditorTemplates\Parts\PublishLater.cshtml" />
|
||||
@@ -296,12 +296,11 @@
|
||||
<Content Include="Reports\Views\Admin\Index.cshtml" />
|
||||
<Content Include="Localization\Module.txt" />
|
||||
<Content Include="Localization\Views\Admin\Translate.cshtml" />
|
||||
<Content Include="Localization\Views\DisplayTemplates\Parts\Localization.ContentTranslations.SummaryAdmin.cshtml" />
|
||||
<Content Include="Localization\Views\Parts\Localization.ContentTranslations.SummaryAdmin.cshtml" />
|
||||
<Content Include="Localization\Views\CultureSelection.cshtml" />
|
||||
<Content Include="Routable\Module.txt" />
|
||||
<Content Include="Routable\Scripts\jquery.slugify.js" />
|
||||
<Content Include="Routable\Views\EditorTemplates\Parts\Routable.RoutePart.cshtml" />
|
||||
<Content Include="Routable\Views\DisplayTemplates\Parts\Routable.RoutePart.cshtml" />
|
||||
<Content Include="Settings\Module.txt" />
|
||||
<Content Include="Settings\Styles\admin.css" />
|
||||
<Content Include="Settings\Views\Admin\Index.cshtml" />
|
||||
@@ -310,6 +309,7 @@
|
||||
<Content Include="Settings\Views\DisplayTemplates\RemovableCulture.ascx" />
|
||||
<Content Include="Shapes\Module.txt" />
|
||||
<Content Include="Shapes\Scripts\base.js" />
|
||||
<Content Include="Shapes\Scripts\html5.js" />
|
||||
<Content Include="Shapes\Scripts\jquery.switchable.js" />
|
||||
<Content Include="Shapes\Styles\Images\detail-view-on.gif" />
|
||||
<Content Include="Shapes\Styles\Images\detail-view.gif" />
|
||||
@@ -346,7 +346,7 @@
|
||||
<Content Include="Common\Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.cshtml" />
|
||||
<Content Include="Common\Views\Parts\Common.Body.cshtml" />
|
||||
<Content Include="Common\Views\EditorTemplates\Parts\Common.Body.cshtml" />
|
||||
<Content Include="Common\Views\EditorTemplates\Parts\Common.Owner.cshtml" />
|
||||
<Content Include="Feeds\Module.txt" />
|
||||
@@ -362,7 +362,7 @@
|
||||
<Content Include="Navigation\Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Summary.cshtml" />
|
||||
<Content Include="Common\Views\Parts\Common.Body.Summary.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPost.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.ManageWrapperPre.cshtml" />
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Manage.cshtml" />
|
||||
@@ -391,6 +391,7 @@
|
||||
<Content Include="Shapes\Views\MenuItem.cshtml" />
|
||||
<Content Include="Shapes\Views\Web.config" />
|
||||
<Content Include="Dashboard\Views\Helper\Index.cshtml" />
|
||||
<Content Include="Routable\Views\Parts\Routable.RoutePart.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -7,7 +7,6 @@ using Orchard.Core.PublishLater.Models;
|
||||
using Orchard.Core.PublishLater.Services;
|
||||
using Orchard.Core.PublishLater.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Core.PublishLater.Drivers {
|
||||
public class PublishLaterPartDriver : ContentPartDriver<PublishLaterPart> {
|
||||
@@ -28,18 +27,19 @@ namespace Orchard.Core.PublishLater.Drivers {
|
||||
public Localizer T { get; set; }
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
protected override DriverResult Display(PublishLaterPart part, string displayType) {
|
||||
var model = new PublishLaterViewModel(part) {
|
||||
ScheduledPublishUtc = part.ScheduledPublishUtc.Value
|
||||
};
|
||||
return ContentPartTemplate(model, "Parts/PublishLater.Metadata").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(part.GetLocation(displayType));
|
||||
protected override DriverResult Display(PublishLaterPart part, string displayType, dynamic shapeHelper) {
|
||||
var metadata = shapeHelper.Parts_PublishLater_Metadata(ContentPart: part, ScheduledPublishUtc: part.ScheduledPublishUtc.Value);
|
||||
if (!string.IsNullOrWhiteSpace(displayType))
|
||||
metadata.Metadata.Type = string.Format("{0}.{1}", metadata.Metadata.Type, displayType);
|
||||
var location = part.GetLocation(displayType);
|
||||
return ContentShape(metadata).Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(PublishLaterPart part) {
|
||||
protected override DriverResult Editor(PublishLaterPart part, dynamic shapeHelper) {
|
||||
return PublishEditor(part, null);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(PublishLaterPart instance, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(PublishLaterPart instance, IUpdateModel updater, dynamic shapeHelper) {
|
||||
return PublishEditor(instance, updater);
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@ namespace Orchard.Core.Routable.Controllers {
|
||||
throw new ApplicationException("Ambiguous content");
|
||||
}
|
||||
|
||||
var model = _contentManager.BuildDisplayModel<IRoutableAspect>(hits.Single());
|
||||
var model = _contentManager.BuildDisplay(hits.Single());
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Orchard.Core.Routable.Controllers {
|
||||
}
|
||||
}
|
||||
|
||||
_contentManager.UpdateEditorModel(contentItem, this);
|
||||
_contentManager.UpdateEditor(contentItem, this);
|
||||
_transactionManager.Cancel();
|
||||
|
||||
return Json(contentItem.As<IRoutableAspect>().Slug ?? slug);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
@@ -35,7 +36,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
get { return "Routable"; }
|
||||
}
|
||||
|
||||
int? GetContainerId(IContent item) {
|
||||
static int? GetContainerId(IContent item) {
|
||||
var commonPart = item.As<ICommonPart>();
|
||||
if (commonPart != null && commonPart.Container != null) {
|
||||
return commonPart.Container.ContentItem.Id;
|
||||
@@ -43,18 +44,15 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override DriverResult Display(RoutePart part, string displayType) {
|
||||
var model = new RoutableDisplayViewModel {RoutePart = part};
|
||||
var location = part.GetLocation(displayType);
|
||||
|
||||
//todo: give this part a default location
|
||||
if (location == null || location.Zone == null)
|
||||
location = new ContentLocation {Position = "5", Zone = "Header"};
|
||||
|
||||
return ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location);
|
||||
protected override DriverResult Display(RoutePart part, string displayType, dynamic shapeHelper) {
|
||||
var routePart = shapeHelper.Parts_Routable_RoutePart(ContentPart: part, Title: part.Title);
|
||||
if (!string.IsNullOrWhiteSpace(displayType))
|
||||
routePart.Metadata.Type = string.Format("{0}.{1}", routePart.Metadata.Type, displayType);
|
||||
var location = part.GetLocation(displayType, "Header", "5");
|
||||
return ContentShape(routePart).Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(RoutePart part) {
|
||||
protected override DriverResult Editor(RoutePart part, dynamic shapeHelper) {
|
||||
var model = new RoutableEditorViewModel {
|
||||
ContentType = part.ContentItem.ContentType,
|
||||
Id = part.ContentItem.Id,
|
||||
@@ -81,7 +79,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
return ContentPartTemplate(model, TemplateName, Prefix).Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(RoutePart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(RoutePart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
||||
var model = new RoutableEditorViewModel();
|
||||
updater.TryUpdateModel(model, Prefix, null, null);
|
||||
@@ -105,7 +103,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
|
||||
}
|
||||
|
||||
return Editor(part);
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
}
|
||||
}
|
@@ -48,8 +48,8 @@ namespace Orchard.Core.Routable.Handlers {
|
||||
OnIndexing<RoutePart>((context, part) => context.DocumentIndex.Add("title", part.Record.Title).RemoveTags().Analyze());
|
||||
}
|
||||
|
||||
private static void SetModelProperties(BuildModelContext context, RoutePart routable) {
|
||||
var item = context.Model;
|
||||
private static void SetModelProperties(BuildShapeContext context, RoutePart routable) {
|
||||
var item = context.Shape;
|
||||
item.Title = routable.Title;
|
||||
item.Slug = routable.Slug;
|
||||
item.Path = routable.Path;
|
||||
|
@@ -6,8 +6,8 @@ using Orchard.Core.Contents.Extensions;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Core.Routable.DataMigrations {
|
||||
public class RoutableDataMigration : DataMigrationImpl {
|
||||
namespace Orchard.Core.Routable {
|
||||
public class Migrations : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Routable_RoutableRecord (Id INTEGER not null, Title TEXT, Slug TEXT, Path TEXT, ContentItemRecord_id INTEGER, primary key (Id));
|
@@ -37,7 +37,7 @@ namespace Orchard.Core.Routable.Services {
|
||||
if (contentItem == null || !contentItem.Is<RoutePart>())
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = _contentManager.BuildDisplayModel(contentItem);
|
||||
var model = _contentManager.BuildDisplay(contentItem);
|
||||
|
||||
return new ViewResult {
|
||||
ViewName = "Display",
|
||||
|
@@ -1,2 +0,0 @@
|
||||
@model Orchard.Core.Routable.ViewModels.RoutableDisplayViewModel
|
||||
<h1>@Model.Title</h1>
|
@@ -0,0 +1 @@
|
||||
<h1>@Model.Title</h1>
|
@@ -1,4 +1,5 @@
|
||||
using System.Globalization;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Core.Settings.Models;
|
||||
@@ -35,7 +36,7 @@ namespace Orchard.Core.Settings.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageSettings, T("Not authorized to manage settings")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var model = Services.ContentManager.BuildEditorModel(_siteService.GetSiteSettings());
|
||||
var model = Services.ContentManager.BuildEditor(_siteService.GetSiteSettings());
|
||||
|
||||
return View(model);
|
||||
}
|
||||
@@ -46,7 +47,7 @@ namespace Orchard.Core.Settings.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var site = _siteService.GetSiteSettings();
|
||||
var model = Services.ContentManager.UpdateEditorModel(site, this);
|
||||
var model = Services.ContentManager.UpdateEditor(site, this);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
@@ -74,11 +75,15 @@ namespace Orchard.Core.Settings.Controllers {
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult AddCulture(string cultureName) {
|
||||
public ActionResult AddCulture(string systemCultureName, string cultureName) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageSettings, T("Not authorized to manage settings")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
_cultureManager.AddCulture(cultureName);
|
||||
cultureName = string.IsNullOrWhiteSpace(cultureName) ? systemCultureName : cultureName;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(cultureName)) {
|
||||
_cultureManager.AddCulture(cultureName);
|
||||
}
|
||||
return RedirectToAction("Culture");
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ namespace Orchard.Core.Settings.Drivers {
|
||||
|
||||
protected override string Prefix { get { return "SiteSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(SiteSettingsPart part) {
|
||||
protected override DriverResult Editor(SiteSettingsPart part, dynamic shapeHelper) {
|
||||
var site = _siteService.GetSiteSettings().As<SiteSettingsPart>();
|
||||
|
||||
var model = new SiteSettingsPartViewModel {
|
||||
@@ -30,7 +30,7 @@ namespace Orchard.Core.Settings.Drivers {
|
||||
return ContentPartTemplate(model, "Parts/Settings.SiteSettingsPart");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(SiteSettingsPart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(SiteSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var site = _siteService.GetSiteSettings().As<SiteSettingsPart>();
|
||||
var model = new SiteSettingsPartViewModel { Site = site };
|
||||
|
||||
|
@@ -7,7 +7,8 @@
|
||||
@Html.ValidationSummary()
|
||||
<fieldset class="addCulture">
|
||||
<label for="CultureName">@T("Add a culture...")</label>
|
||||
@Html.DropDownList("CultureName", new SelectList(Model.AvailableSystemCultures.OrderBy(s => s), Model.CurrentCulture))
|
||||
@Html.DropDownList("SystemCultureName", new SelectList(Model.AvailableSystemCultures.OrderBy(s => s), Model.CurrentCulture))
|
||||
@T("Other"): @Html.TextBox("CultureName")
|
||||
<button class="primaryAction" type="submit">@T("Add")</button>
|
||||
</fieldset>
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
@@ -11,7 +10,7 @@ using System.Web.Mvc.Html;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Mvc.ViewEngines;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI;
|
||||
using Orchard.UI.Resources;
|
||||
@@ -34,35 +33,46 @@ namespace Orchard.Core.Shapes {
|
||||
// and has an automatic zone creating behavior
|
||||
builder.Describe("Layout")
|
||||
.Configure(descriptor => descriptor.Wrappers.Add("Document"))
|
||||
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(name => CreateZone(creating, name))))
|
||||
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(name => CreateZone(creating))))
|
||||
.OnCreated(created => {
|
||||
var layout = created.Shape;
|
||||
layout.Head = created.New.DocumentZone();
|
||||
layout.Body = created.New.DocumentZone();
|
||||
layout.Tail = created.New.DocumentZone();
|
||||
layout.Content = created.New.Zone();
|
||||
layout.Head = created.New.DocumentZone(ZoneName: "Head");
|
||||
layout.Body = created.New.DocumentZone(ZoneName: "Body");
|
||||
layout.Tail = created.New.DocumentZone(ZoneName: "Tail");
|
||||
|
||||
layout.Body.Add(created.New.PlaceChildContent(Source: layout));
|
||||
|
||||
layout.Content = created.New.Zone();
|
||||
layout.Content.ZoneName = "Content";
|
||||
layout.Content.Add(created.New.PlaceChildContent(Source: layout));
|
||||
});
|
||||
|
||||
// 'Zone' shapes are built on the Zone base class
|
||||
// They have class="zone zone-{name}"
|
||||
// and the template can be specialized with "Zone-{Name}" base file name
|
||||
builder.Describe("Zone")
|
||||
.OnCreating(creating => creating.BaseType = typeof (Zone));
|
||||
//.OnDisplaying(displaying => {
|
||||
// var name = displaying.Shape.ZoneName.ToLower();
|
||||
// var zone = displaying.Shape;
|
||||
// zone.Classes.Add("zone-" + name);
|
||||
// zone.Classes.Add("zone");
|
||||
// });
|
||||
.OnCreating(creating => creating.BaseType = typeof(Zone))
|
||||
.OnDisplaying(displaying => {
|
||||
var zone = displaying.Shape;
|
||||
zone.Classes.Add("zone-" + zone.ZoneName.ToLower());
|
||||
zone.Classes.Add("zone");
|
||||
zone.Metadata.Alternates.Add("Zone__" + zone.ZoneName);
|
||||
});
|
||||
|
||||
//builder.Describe("menu")
|
||||
// .OnDisplaying(displaying => {
|
||||
// var name = displaying.Shape.MenuName.ToLower();
|
||||
// var menu = displaying.Shape;
|
||||
// menu.Classes.Add("menu-" + name);
|
||||
// menu.Classes.Add("menu");
|
||||
// });
|
||||
builder.Describe("Menu")
|
||||
.OnDisplaying(displaying => {
|
||||
var menu = displaying.Shape;
|
||||
menu.Classes.Add("menu-" + menu.MenuName.ToLower());
|
||||
menu.Classes.Add("menu");
|
||||
menu.Metadata.Alternates.Add("Menu__" + menu.MenuName);
|
||||
});
|
||||
|
||||
builder.Describe("MenuItem")
|
||||
.OnDisplaying(displaying => {
|
||||
var menuItem = displaying.Shape;
|
||||
var menu = menuItem.Menu;
|
||||
menuItem.Metadata.Alternates.Add("MenuItem__" + menu.MenuName);
|
||||
});
|
||||
|
||||
// 'List' shapes start with several empty collections
|
||||
builder.Describe("List")
|
||||
@@ -73,12 +83,8 @@ namespace Orchard.Core.Shapes {
|
||||
});
|
||||
}
|
||||
|
||||
private object CreateZone(ShapeCreatingContext context, string zoneName) {
|
||||
var name = zoneName.ToLower();
|
||||
var zone = context.New.Zone();
|
||||
zone.Id = "zone-" + name;
|
||||
zone.Classes.Add("zone");
|
||||
return zone;
|
||||
static object CreateZone(ShapeCreatingContext context) {
|
||||
return context.New.Zone();
|
||||
}
|
||||
|
||||
static TagBuilder GetTagBuilder(string tagName, string id, IEnumerable<string> classes, IDictionary<string, string> attributes) {
|
||||
@@ -126,15 +132,15 @@ namespace Orchard.Core.Shapes {
|
||||
var progress = 1;
|
||||
var flatPositionComparer = new FlatPositionComparer();
|
||||
var ordering = unordered.Select(item => {
|
||||
var position = (item == null || item.GetType().GetProperty("Metadata") == null || item.Metadata.GetType().GetProperty("Position") == null)
|
||||
? null
|
||||
: item.Metadata.Position;
|
||||
return new {item, position};
|
||||
}).ToList();
|
||||
var position = (item == null || item.GetType().GetProperty("Metadata") == null || item.Metadata.GetType().GetProperty("Position") == null)
|
||||
? null
|
||||
: item.Metadata.Position;
|
||||
return new { item, position };
|
||||
}).ToList();
|
||||
|
||||
// since this isn't sticking around (hence, the "hack" in the name), throwing (in) a gnome
|
||||
while (i < ordering.Count()) {
|
||||
if (flatPositionComparer.Compare(ordering[i].position, ordering[i-1].position) > -1) {
|
||||
if (flatPositionComparer.Compare(ordering[i].position, ordering[i - 1].position) > -1) {
|
||||
if (i == progress)
|
||||
progress = ++i;
|
||||
else
|
||||
@@ -142,8 +148,8 @@ namespace Orchard.Core.Shapes {
|
||||
}
|
||||
else {
|
||||
var higherThanItShouldBe = ordering[i];
|
||||
ordering[i] = ordering[i-1];
|
||||
ordering[i-1] = higherThanItShouldBe;
|
||||
ordering[i] = ordering[i - 1];
|
||||
ordering[i - 1] = higherThanItShouldBe;
|
||||
if (i > 1)
|
||||
--i;
|
||||
}
|
||||
@@ -161,8 +167,8 @@ namespace Orchard.Core.Shapes {
|
||||
x = string.IsNullOrWhiteSpace(x) ? "5" : x.TrimStart(':'); // ':' is _sometimes_ used as a partition identifier
|
||||
y = string.IsNullOrWhiteSpace(y) ? "5" : y.TrimStart(':');
|
||||
|
||||
var xParts = x.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var yParts = y.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var xParts = x.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var yParts = y.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (var i = 0; i < xParts.Count(); i++) {
|
||||
if (yParts.Length < i - 1) // x is further defined meaning it comes after y (e.g. x == 1.2.3 and y == 1.2)
|
||||
return 1;
|
||||
@@ -251,7 +257,7 @@ namespace Orchard.Core.Shapes {
|
||||
|
||||
private static void WriteResources(HtmlHelper html, ISite site, IResourceManager rm, string resourceType, ResourceLocation? includeLocation, ResourceLocation? excludeLocation) {
|
||||
bool debugMode;
|
||||
switch(site.ResourceDebugMode) {
|
||||
switch (site.ResourceDebugMode) {
|
||||
case ResourceDebugMode.Enabled:
|
||||
debugMode = true;
|
||||
break;
|
||||
|
3
src/Orchard.Web/Core/Shapes/Scripts/html5.js
Normal file
3
src/Orchard.Web/Core/Shapes/Scripts/html5.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// html5shiv MIT @rem remysharp.com/html5-enabling-script
|
||||
// iepp v1.5.1 MIT @jon_neal iecss.com/print-protector
|
||||
/*@cc_on(function(p,e){var q=e.createElement("div");q.innerHTML="<z>i</z>";q.childNodes.length!==1&&function(){function r(a,b){if(g[a])g[a].styleSheet.cssText+=b;else{var c=s[l],d=e[j]("style");d.media=a;c.insertBefore(d,c[l]);g[a]=d;r(a,b)}}function t(a,b){for(var c=new RegExp("\\b("+m+")\\b(?!.*[;}])","gi"),d=function(k){return".iepp_"+k},h=-1;++h<a.length;){b=a[h].media||b;t(a[h].imports,b);r(b,a[h].cssText.replace(c,d))}}for(var s=e.documentElement,i=e.createDocumentFragment(),g={},m="abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".replace(/ /g, '|'),n=m.split("|"),f=[],o=-1,l="firstChild",j="createElement";++o<n.length;){e[j](n[o]);i[j](n[o])}i=i.appendChild(e[j]("div"));p.attachEvent("onbeforeprint",function(){for(var a,b=e.getElementsByTagName("*"),c,d,h=new RegExp("^"+m+"$","i"),k=-1;++k<b.length;)if((a=b[k])&&(d=a.nodeName.match(h))){c=new RegExp("^\\s*<"+d+"(.*)\\/"+d+">\\s*$","i");i.innerHTML=a.outerHTML.replace(/\r|\n/g," ").replace(c,a.currentStyle.display=="block"?"<div$1/div>":"<span$1/span>");c=i.childNodes[0];c.className+=" iepp_"+d;c=f[f.length]=[a,c];a.parentNode.replaceChild(c[1],c[0])}t(e.styleSheets,"all")});p.attachEvent("onafterprint",function(){for(var a=-1,b;++a<f.length;)f[a][1].parentNode.replaceChild(f[a][0],f[a][1]);for(b in g)s[l].removeChild(g[b]);g={};f=[]})}()})(this,document);@*/
|
@@ -2,22 +2,19 @@
|
||||
@using Orchard.UI.Resources;
|
||||
@{
|
||||
RegisterLink(new LinkEntry {Type = "image/x-icon", Rel = "shortcut icon", Href = Url.Content("~/modules/orchard.themes/Content/orchard.ico")});
|
||||
//todo: (heskew) get conditions (as in conditional comments) hooked up for script tags too
|
||||
Script.Include("html5.js").AtLocation(ResourceLocation.Head);
|
||||
}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="static @Html.ClassForPage()">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>@Html.Title(WorkContext.CurrentSite.SiteName)</title>
|
||||
@{
|
||||
//todo: (heskew) have resource modules that can be leaned on (like a jQuery module that knows about various CDNs and jQuery's version and min naming schemes)
|
||||
//todo: (heskew) this is an interim solution to inlude jQuery in every page and still allow that to be overriden in some theme by it containing a headScripts partial
|
||||
}
|
||||
@* Model.Zones.AddRenderPartial("head:before", "HeadPreload", Model); *@
|
||||
@* Html.Zone("head", ":metas :styles :scripts"); %> *@
|
||||
@Display(Model.Head)
|
||||
<meta charset="utf-8" />
|
||||
<title>@Model.Title</title>
|
||||
@Display(Model.Head)
|
||||
<script>(function(d){d.className="dyn"+d.className.substring(6,d.className.length);})(document.documentElement);</script>
|
||||
</head>
|
||||
<body>
|
||||
<body>
|
||||
@* Layout (template) is in the Body zone @ the default position (nothing, zero, zilch) *@
|
||||
@Display(Model.Body)
|
||||
@Display(Model.Tail)
|
||||
</body>
|
||||
|
@@ -28,18 +28,19 @@ namespace ArchiveLater.Drivers {
|
||||
public Localizer T { get; set; }
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
protected override DriverResult Display(ArchiveLaterPart part, string displayType) {
|
||||
var model = new ArchiveLaterViewModel(part) {
|
||||
ScheduledArchiveUtc = part.ScheduledArchiveUtc.Value
|
||||
};
|
||||
return ContentPartTemplate(model, "Parts/ArchiveLater.Metadata").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(part.GetLocation(displayType));
|
||||
protected override DriverResult Display(ArchiveLaterPart part, string displayType, dynamic shapeHelper) {
|
||||
var metadata = shapeHelper.Parts_ArchiveLater_Metadata(ContentPart: part, ScheduledArchiveUtc: part.ScheduledArchiveUtc.Value);
|
||||
if (!string.IsNullOrWhiteSpace(displayType))
|
||||
metadata.Metadata.Type = string.Format("{0}.{1}", metadata.Metadata.Type, displayType);
|
||||
var location = part.GetLocation(displayType);
|
||||
return ContentShape(metadata).Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ArchiveLaterPart part) {
|
||||
protected override DriverResult Editor(ArchiveLaterPart part, dynamic shapeHelper) {
|
||||
return ArchiveEditor(part, null);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ArchiveLaterPart instance, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(ArchiveLaterPart instance, IUpdateModel updater, dynamic shapeHelper) {
|
||||
return ArchiveEditor(instance, updater);
|
||||
}
|
||||
|
||||
|
@@ -98,8 +98,8 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\DisplayTemplates\Parts\ArchiveLater.Metadata.cshtml" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\ArchiveLater.Metadata.SummaryAdmin.cshtml" />
|
||||
<Content Include="Views\Parts\ArchiveLater.Metadata.cshtml" />
|
||||
<Content Include="Views\Parts\ArchiveLater.Metadata.SummaryAdmin.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\Parts\ArchiveLater.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
|
@@ -52,7 +52,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (blog == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = Services.ContentManager.BuildEditorModel(blog);
|
||||
var model = Services.ContentManager.BuildEditor(blog);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
_contentManager.Create(blog, VersionOptions.Draft);
|
||||
var model = _contentManager.UpdateEditorModel(blog, this);
|
||||
var model = _contentManager.UpdateEditor(blog, this);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
_transactionManager.Cancel();
|
||||
@@ -88,7 +88,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (blog == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = Services.ContentManager.BuildEditorModel(blog);
|
||||
var model = Services.ContentManager.BuildEditor(blog);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (blog == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = Services.ContentManager.UpdateEditorModel(blog, this);
|
||||
var model = Services.ContentManager.UpdateEditor(blog, this);
|
||||
if (!ModelState.IsValid)
|
||||
return View(model);
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
var list = Shape.List();
|
||||
list.AddRange(_blogService.Get()
|
||||
.Select(b => {
|
||||
var blog = Services.ContentManager.BuildDisplayModel(b, "SummaryAdmin.Blog");
|
||||
var blog = Services.ContentManager.BuildDisplay(b, "SummaryAdmin.Blog");
|
||||
blog.TotalPostCount = _blogPostService.Get(b, VersionOptions.Latest).Count();
|
||||
return blog;
|
||||
}));
|
||||
@@ -151,7 +151,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
||||
var model = Services.ContentManager.BuildDisplayModel(blogPart, "Admin.Blog");
|
||||
var model = Services.ContentManager.BuildDisplay(blogPart, "Admin.Blog");
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
protected ILogger Logger { get; set; }
|
||||
|
||||
public ActionResult List() {
|
||||
var blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplayModel(b, "Summary.Blog"));
|
||||
var blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplay(b, "Summary.Blog"));
|
||||
|
||||
var list = Shape.List();
|
||||
list.AddRange(blogs);
|
||||
@@ -53,7 +53,8 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (blog == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = _services.ContentManager.BuildDisplayModel(blog, "Blog");
|
||||
//todo: (heskew) "Blog" should be an alternative instead of a display type
|
||||
var model = _services.ContentManager.BuildDisplay(blog, "Blog");
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (blogPost.BlogPart == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = Services.ContentManager.BuildEditorModel(blogPost);
|
||||
var model = Services.ContentManager.BuildEditor(blogPost);
|
||||
|
||||
//todo: (heskew) unhack
|
||||
model.Metadata.Type += ".BlogPost";
|
||||
@@ -52,7 +52,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
Services.ContentManager.Create(blogPost, VersionOptions.Draft);
|
||||
var model = Services.ContentManager.UpdateEditorModel(blogPost, this);
|
||||
var model = Services.ContentManager.UpdateEditor(blogPost, this);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
@@ -80,7 +80,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (post == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = Services.ContentManager.BuildEditorModel(post);
|
||||
var model = Services.ContentManager.BuildEditor(post);
|
||||
|
||||
//todo: (heskew) unhack
|
||||
model.Metadata.Type += ".BlogPost";
|
||||
@@ -103,7 +103,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
// Validate form input
|
||||
var model = Services.ContentManager.UpdateEditorModel(blogPost, this);
|
||||
var model = Services.ContentManager.UpdateEditor(blogPost, this);
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
return View(model);
|
||||
|
@@ -51,7 +51,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (postPart == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = _services.ContentManager.BuildDisplayModel(postPart, "BlogPost");
|
||||
var model = _services.ContentManager.BuildDisplay(postPart, "Detail.BlogPost");
|
||||
|
||||
return View(model);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
var archive = new ArchiveData(archiveData);
|
||||
|
||||
var list = Shape.List();
|
||||
list.AddRange(_blogPostService.Get(blogPart, archive).Select(b => _services.ContentManager.BuildDisplayModel(b, "Summary.BlogPost")));
|
||||
list.AddRange(_blogPostService.Get(blogPart, archive).Select(b => _services.ContentManager.BuildDisplay(b, "Summary.BlogPost")));
|
||||
|
||||
_feedManager.Register(blogPart);
|
||||
|
||||
|
@@ -34,38 +34,50 @@ namespace Orchard.Blogs.Drivers {
|
||||
|
||||
protected override string Prefix { get { return ""; } }
|
||||
|
||||
protected override DriverResult Display(BlogPart blogPart, string displayType) {
|
||||
protected override DriverResult Display(BlogPart part, string displayType, dynamic shapeHelper) {
|
||||
var driverResults = new List<DriverResult>();
|
||||
|
||||
var metadata = shapeHelper.Parts_Blogs_Blog_Manage(ContentPart: part);
|
||||
metadata.Metadata.Type = "Parts_Blogs_Blog.Manage";
|
||||
driverResults.Add(ContentShape(metadata).Location("manage"));
|
||||
|
||||
var description = shapeHelper.Parts_Blogs_Blog_Description(ContentPart: part);
|
||||
description.Metadata.Type = "Parts_Blogs_Blog.Description";
|
||||
driverResults.Add(ContentShape(description).Location("manage", "after"));
|
||||
|
||||
IEnumerable<dynamic > blogPosts = null;
|
||||
if (displayType.StartsWith("Admin")) {
|
||||
blogPosts = _blogPostService.Get(blogPart, VersionOptions.Latest)
|
||||
.Select(bp => _contentManager.BuildDisplayModel(bp, "SummaryAdmin.BlogPost"));
|
||||
var list = shapeHelper.List();
|
||||
list.AddRange(_blogPostService.Get(part, VersionOptions.Latest)
|
||||
.Select(bp => _contentManager.BuildDisplay(bp, "SummaryAdmin.BlogPost")));
|
||||
var blogPostList = shapeHelper.Parts_Blogs_BlogPost_List(ContentPart: part, BlogPosts: list);
|
||||
blogPostList.Metadata.Type = "Parts_Blogs_BlogPost.List.Admin";
|
||||
var contentShape = ContentShape(blogPostList).Location("primary");
|
||||
driverResults.Add(contentShape);
|
||||
}
|
||||
else if (!displayType.Contains("Summary")) {
|
||||
blogPosts = _blogPostService.Get(blogPart)
|
||||
.Select(bp => _contentManager.BuildDisplayModel(bp, "Summary.BlogPost"));
|
||||
_feedManager.Register(blogPart);
|
||||
var list = shapeHelper.List();
|
||||
list.AddRange(_blogPostService.Get(part)
|
||||
.Select(bp => _contentManager.BuildDisplay(bp, "Summary.BlogPost")));
|
||||
var blogPostList = shapeHelper.Parts_Blogs_BlogPost_List(ContentPart: part, BlogPosts: list);
|
||||
blogPostList.Metadata.Type = "Parts_Blogs_BlogPost.List";
|
||||
var contentShape = ContentShape(blogPostList).Location("primary");
|
||||
driverResults.Add(contentShape);
|
||||
|
||||
_feedManager.Register(part);
|
||||
}
|
||||
|
||||
var blogPostList = Shape.List();
|
||||
blogPostList.AddRange(blogPosts);
|
||||
|
||||
return Combined(
|
||||
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Manage").Location("manage"),
|
||||
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Metadata").Location("metadata"),
|
||||
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Description").Location("manage", "after"),
|
||||
ContentPartTemplate(blogPostList, "Parts/Blogs.BlogPost.List").LongestMatch(displayType, "Admin").Location("primary"));
|
||||
return Combined(driverResults.ToArray());
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogPart blogPart) {
|
||||
protected override DriverResult Editor(BlogPart blogPart, dynamic shapeHelper) {
|
||||
var location = blogPart.GetLocation("Editor");
|
||||
return Combined(
|
||||
ContentPartTemplate(blogPart, "Parts/Blogs.Blog.Fields").Location(location));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogPart blogPart, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(BlogPart blogPart, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(blogPart, Prefix, null, null);
|
||||
return Editor(blogPart);
|
||||
return Editor(blogPart, shapeHelper);
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,11 +21,11 @@ namespace Orchard.Blogs.Drivers {
|
||||
|
||||
protected override string Prefix { get { return ""; } }
|
||||
|
||||
protected override DriverResult Display(BlogPostPart part, string displayType) {
|
||||
protected override DriverResult Display(BlogPostPart part, string displayType, dynamic shapeHelper) {
|
||||
if (displayType.StartsWith("Detail"))
|
||||
_feedManager.Register(part.BlogPart);
|
||||
|
||||
return base.Display(part, displayType);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,8 +10,8 @@ namespace Orchard.Blogs.Handlers {
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
|
||||
OnGetDisplayShape<BlogPart>((context, blog) => {
|
||||
context.Model.Description = blog.Description;
|
||||
context.Model.PostCount = blog.PostCount;
|
||||
context.Shape.Description = blog.Description;
|
||||
context.Shape.PostCount = blog.PostCount;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -61,8 +61,8 @@ namespace Orchard.Blogs.Handlers {
|
||||
blogPost => context.ContentManager.Remove(blogPost.ContentItem)));
|
||||
}
|
||||
|
||||
private static void SetModelProperties(BuildModelContext context, BlogPostPart blogPost) {
|
||||
context.Model.Blog = blogPost.BlogPart;
|
||||
private static void SetModelProperties(BuildShapeContext context, BlogPostPart blogPost) {
|
||||
context.Shape.Blog = blogPost.BlogPart;
|
||||
}
|
||||
|
||||
Localizer T { get; set; }
|
||||
|
@@ -122,17 +122,17 @@
|
||||
<Content Include="Views\BlogPost\ListByArchive.cshtml" />
|
||||
<Content Include="Views\Blog\Item.cshtml" />
|
||||
<Content Include="Views\Blog\List.cshtml" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Blogs.Blog.Manage.cshtml" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Blogs.Blog.Description.cshtml" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Blogs.Blog.Metadata.cshtml" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Blogs.BlogPost.List.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.Blog.Manage.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.Blog.Description.cshtml" />
|
||||
<Content Include="Views\Parts\Common.Metadata.Admin.Blog.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.BlogPost.List.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Blogs.Blog.Fields.cshtml" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Blogs.BlogPost.List.Admin.cshtml">
|
||||
<Content Include="Views\Parts\Blogs.BlogPost.List.Admin.cshtml">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="Views\Items\Content.Admin.Blog.cshtml" />
|
||||
<Content Include="Views\Items\Content.Blog.cshtml" />
|
||||
<Content Include="Views\Items\Content.BlogPost.cshtml" />
|
||||
<Content Include="Views\Items\Content.Detail.BlogPost.cshtml" />
|
||||
<Content Include="Views\Items\Content.Edit.Blog.cshtml">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
@@ -154,6 +154,33 @@
|
||||
<Name>Orchard.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts\Common.Metadata.Blog.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts\Localization.ContentTranslations.Summary.BlogPost.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts\Common.Body.Summary.BlogPost.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts\Tags.ShowTags.Summary.BlogPost.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts\PublishLater.Metadata.Detail.BlogPost.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts\Common.Metadata.Detail.BlogPost.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts\Localization.ContentTranslations.Detail.BlogPost.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts\Common.Body.Detail.BlogPost.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts\Tags.ShowTags.Detail.BlogPost.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -1 +0,0 @@
|
||||
[[metadata??]]
|
@@ -1,4 +0,0 @@
|
||||
@Display(Model)
|
||||
@if (Model.Items.Count < 1) {
|
||||
<p>@T("There are no posts for this blog.")</p>
|
||||
}
|
@@ -4,6 +4,6 @@
|
||||
}
|
||||
@if (AuthorizedFor(Orchard.Blogs.Permissions.ManageBlogs)) {
|
||||
<div class="item-properties actions">
|
||||
<p><a href="@Url.BlogEdit((string)Model.Slug)" class="edit">@T("Blog Properties")</a></p>
|
||||
<p><a href="@Url.BlogEdit((string)Model.ContentPart.Slug)" class="edit">@T("Blog Properties")</a></p>
|
||||
</div>
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
|
||||
</fieldset>
|
||||
<fieldset class="contentItems bulk-items">
|
||||
@Display(Model)
|
||||
@Display(Model.BlogPosts)
|
||||
</fieldset>
|
||||
}
|
||||
} else {
|
@@ -0,0 +1,7 @@
|
||||
@{
|
||||
IEnumerable<object> blogPosts = Model.BlogPosts;
|
||||
}
|
||||
@Display(blogPosts)
|
||||
@if (blogPosts == null || blogPosts.Count() < 1) {
|
||||
<p>@T("There are no posts for this blog.")</p>
|
||||
}
|
@@ -0,0 +1 @@
|
||||
@Model.Html
|
@@ -0,0 +1,9 @@
|
||||
@using Orchard.ContentManagement;
|
||||
@using Orchard.Core.Common.ViewModels;
|
||||
@*doing excerpt generation on the way out for now so we don't stick ourselves with needing to regen excerpts for existing data
|
||||
also, doing this here, inline, until we have a pluggable processing model (both in and out)
|
||||
also, ...this is ugly *@
|
||||
@{
|
||||
var body = new HtmlString(Html.Excerpt((string)Model.Html.ToString(), 200).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"));
|
||||
}
|
||||
<p>@body @Html.ItemDisplayLink(T("[more]").ToString(), (IContent)Model.ContentPart.ContentItem)</p>
|
@@ -0,0 +1 @@
|
||||
|
@@ -0,0 +1 @@
|
||||
|
@@ -0,0 +1,5 @@
|
||||
@using Orchard.Core.Common.Extensions;
|
||||
@if (Model.Creator != null) {
|
||||
<div class="metadata">
|
||||
<div class="posted">@T("Published by {0} {1}", (string)Model.ContentPart.Creator.UserName, Html.PublishedWhen((DateTime?)Model.ContentPart.VersionPublishedUtc, T))</div>
|
||||
</div>}
|
@@ -0,0 +1,13 @@
|
||||
@using Orchard.Core.Localization.Models;
|
||||
@{
|
||||
Style.Require("Localization");
|
||||
IEnumerable<LocalizationPart> localizations = Model.Localizations;
|
||||
}
|
||||
@if (localizations != null && localizations.Count() > 0) {
|
||||
<div class="content-localization">
|
||||
<div class="content-localizations">
|
||||
<h4>@T("Translations:")</h4>
|
||||
@Html.UnorderedList(localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations")
|
||||
</div>
|
||||
</div>
|
||||
}
|
@@ -0,0 +1 @@
|
||||
|
@@ -0,0 +1 @@
|
||||
|
@@ -0,0 +1,16 @@
|
||||
@{
|
||||
var tagsHtml = new List<IHtmlString>();
|
||||
foreach(var t in Model.Tags) {
|
||||
if (tagsHtml.Any()) {
|
||||
tagsHtml.Add(new HtmlString(", "));
|
||||
}
|
||||
tagsHtml.Add(Html.ActionLink((string)t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = (string)t.TagName }, new { }));
|
||||
}
|
||||
}
|
||||
|
||||
@if (tagsHtml.Any()) {
|
||||
<p class="tags">
|
||||
<span>@T("Tags:")</span>
|
||||
@foreach(var htmlString in tagsHtml) { @htmlString }
|
||||
</p>
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
@{
|
||||
var tagsHtml = new List<IHtmlString>();
|
||||
foreach(var t in Model.Tags) {
|
||||
if (tagsHtml.Any()) {
|
||||
tagsHtml.Add(new HtmlString(", "));
|
||||
}
|
||||
tagsHtml.Add(Html.ActionLink((string)t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = (string)t.TagName }, new { }));
|
||||
}
|
||||
}
|
||||
|
||||
@if (tagsHtml.Any()) {
|
||||
<p class="tags">
|
||||
<span>@T("Tags:")</span>
|
||||
@foreach(var htmlString in tagsHtml) { @htmlString }
|
||||
</p>
|
||||
}
|
@@ -13,13 +13,13 @@ namespace Orchard.Comments.Drivers {
|
||||
|
||||
protected override string Prefix { get { return "CommentSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(CommentSettingsPart part) {
|
||||
protected override DriverResult Editor(CommentSettingsPart part, dynamic shapeHelper) {
|
||||
return ContentPartTemplate(part.Record, "Parts/Comments.SiteSettings");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(CommentSettingsPart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(CommentSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(part.Record, Prefix, null, null);
|
||||
return Editor(part);
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.Comments.ViewModels;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Common.Models;
|
||||
@@ -10,27 +9,23 @@ using Orchard.Core.ContentsLocation.Models;
|
||||
namespace Orchard.Comments.Drivers {
|
||||
[UsedImplicitly]
|
||||
public class CommentsContainerPartDriver : ContentPartDriver<CommentsContainerPart> {
|
||||
protected override DriverResult Display(CommentsContainerPart part, string displayType) {
|
||||
if (displayType == "SummaryAdmin") {
|
||||
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.CountAdmin").Location(part.GetLocation("SummaryAdmin"));
|
||||
}
|
||||
else if (displayType.Contains("Summary")) {
|
||||
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.Count").Location(part.GetLocation("Summary"));
|
||||
protected override DriverResult Display(CommentsContainerPart part, string displayType, dynamic shapeHelper) {
|
||||
if (displayType.Contains("Summary")) {
|
||||
// Find all contents item with this part as the container
|
||||
var parts = part.ContentItem.ContentManager.Query()
|
||||
.Where<CommonPartRecord>(rec => rec.Container == part.ContentItem.Record).List();
|
||||
|
||||
// Count comments and create template
|
||||
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().Comments.Count : 0));
|
||||
int pendingCount = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().PendingComments.Count : 0));
|
||||
|
||||
if (displayType == "SummaryAdmin")
|
||||
return ContentShape(shapeHelper.Parts_Comments_CountAdmin(ContentPart: part, CommentCount: count, PendingCount: pendingCount)).Location(part.GetLocation("SummaryAdmin"));
|
||||
|
||||
return ContentShape(shapeHelper.Parts_Comments_Count(ContentPart: part, CommentCount: count, PendingCount: pendingCount)).Location(part.GetLocation("Summary"));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static CommentCountViewModel CreateViewModel(ContentItem contentItem) {
|
||||
// Find all contents item with this part as the container
|
||||
var parts = contentItem.ContentManager.Query()
|
||||
.Where<CommonPartRecord>(rec => rec.Container == contentItem.Record).List();
|
||||
|
||||
// Count comments and create template
|
||||
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().Comments.Count : 0));
|
||||
int pendingCount = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().PendingComments.Count : 0));
|
||||
|
||||
return new CommentCountViewModel { Item = contentItem, CommentCount = count, PendingCount = pendingCount};
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,5 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.Comments.ViewModels;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.ContentsLocation.Models;
|
||||
@@ -8,35 +7,30 @@ using Orchard.Core.ContentsLocation.Models;
|
||||
namespace Orchard.Comments.Drivers {
|
||||
[UsedImplicitly]
|
||||
public class CommentsPartDriver : ContentPartDriver<CommentsPart> {
|
||||
protected override DriverResult Display(CommentsPart part, string displayType) {
|
||||
if (part.CommentsShown == false) {
|
||||
protected override DriverResult Display(CommentsPart part, string displayType, dynamic shapeHelper) {
|
||||
if (part.CommentsShown == false)
|
||||
return null;
|
||||
}
|
||||
|
||||
// todo: (heskew) need to be more flexible with displaying parts somehow. e.g. where should the...
|
||||
// comment count go in any given skin or what if the skin builder doesn't want the count
|
||||
if (displayType.StartsWith("Detail")) {
|
||||
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Detail"));
|
||||
}
|
||||
else if (displayType == "SummaryAdmin") {
|
||||
var model = new CommentCountViewModel(part);
|
||||
return ContentPartTemplate(model, "Parts/Comments.CountAdmin").Location(part.GetLocation("SummaryAdmin"));
|
||||
}
|
||||
else if (displayType.Contains("Summary")) {
|
||||
var model = new CommentCountViewModel(part);
|
||||
return ContentPartTemplate(model, "Parts/Comments.Count").Location(part.GetLocation("Summary"));
|
||||
}
|
||||
else {
|
||||
var model = new CommentCountViewModel(part);
|
||||
return ContentPartTemplate(model, "Parts/Comments.Count").Location(part.GetLocation(displayType));
|
||||
}
|
||||
if (displayType.StartsWith("Detail"))
|
||||
return ContentShape(shapeHelper.Parts_Comments_Comments(ContentPart: part)).Location(part.GetLocation("Detail"));
|
||||
|
||||
if (displayType == "SummaryAdmin")
|
||||
return ContentShape(shapeHelper.Parts_Comments_CountAdmin(ContentPart: part, CommentCount: part.Comments.Count, PendingCount: part.PendingComments.Count))
|
||||
.Location(part.GetLocation("SummaryAdmin"));
|
||||
|
||||
var location = displayType.Contains("Summary")
|
||||
? part.GetLocation("Summary")
|
||||
: part.GetLocation(displayType);
|
||||
|
||||
return ContentShape(shapeHelper.Parts_Comments_Count(ContentPart: part, CommentCount: part.Comments.Count, PendingCount: part.PendingComments.Count))
|
||||
.Location(location);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(CommentsPart part) {
|
||||
protected override DriverResult Editor(CommentsPart part, dynamic shapeHelper) {
|
||||
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor"));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(CommentsPart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(CommentsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor"));
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\joel.net.akismet\Joel.Net.Akismet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
@@ -126,9 +127,9 @@
|
||||
<Content Include="Views\Admin\Details.cshtml" />
|
||||
<Content Include="Views\Admin\Edit.cshtml" />
|
||||
<Content Include="Views\Admin\Index.cshtml" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Comments.Comments.cshtml" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Comments.Count.cshtml" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Comments.CountAdmin.cshtml" />
|
||||
<Content Include="Views\Parts\Comments.Comments.cshtml" />
|
||||
<Content Include="Views\Parts\Comments.Count.cshtml" />
|
||||
<Content Include="Views\Parts\Comments.CountAdmin.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Comments.Comments.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Comments.SiteSettings.cshtml" />
|
||||
<Content Include="Views\ListOfComments.cshtml" />
|
||||
|
@@ -1,4 +0,0 @@
|
||||
@model Orchard.Comments.ViewModels.CommentCountViewModel
|
||||
@using Orchard.Comments.ViewModels;
|
||||
|
||||
<span class="commentcount">@T.Plural("1 Comment", "{0} Comments", Model.CommentCount)</span>
|
@@ -1,12 +1,11 @@
|
||||
@model Orchard.Comments.Models.CommentsPart
|
||||
@using Orchard.Comments.Models;
|
||||
@using Orchard.Comments.Models;
|
||||
@using Orchard.Comments;
|
||||
@using Orchard.Security;
|
||||
@using Orchard.Utility.Extensions;
|
||||
|
||||
@if (Model.Comments.Count > 0) {
|
||||
<h2 id="comments">@T.Plural("1 Comment", "{0} Comments", Model.Comments.Count)</h2>
|
||||
@Html.RenderPartial("ListOfComments", Model.Comments);
|
||||
@if (Model.ContentPart.Comments.Count > 0) {
|
||||
<h2 id="comments">@T.Plural("1 Comment", "{0} Comments", (int)Model.ContentPart.Comments.Count)</h2>
|
||||
Html.RenderPartial("ListOfComments", (IEnumerable<Orchard.Comments.Models.CommentPart>)Model.ContentPart.Comments);
|
||||
}
|
||||
|
||||
@if (Model.CommentsActive == false) {
|
||||
@@ -21,7 +20,7 @@ else if(!Request.IsAuthenticated && !AuthorizedFor(Permissions.AddComment)) {
|
||||
using (Html.BeginForm("Create", "Comment", new { area = "Orchard.Comments" }, FormMethod.Post, new { @class = "comment" })) {
|
||||
@Html.ValidationSummary()
|
||||
<h2 id="addacomment">@T("Add a Comment")</h2>
|
||||
@if (!Request.IsAuthenticated) {
|
||||
if (!Request.IsAuthenticated) {
|
||||
<fieldset class="who">
|
||||
<div>
|
||||
<label for="Name">@T("Name")</label>
|
||||
@@ -37,18 +36,17 @@ using (Html.BeginForm("Create", "Comment", new { area = "Orchard.Comments" }, Fo
|
||||
</div>
|
||||
</fieldset>
|
||||
} else {
|
||||
var currentUser = Html.Resolve<IAuthenticationService>().GetAuthenticatedUser();
|
||||
@Html.Hidden("Name", currentUser.UserName ?? "")
|
||||
@Html.Hidden("Email", currentUser.Email ?? "")
|
||||
@Html.Hidden("Name", WorkContext.CurrentUser.UserName ?? "")
|
||||
@Html.Hidden("Email", WorkContext.CurrentUser.Email ?? "")
|
||||
}
|
||||
<fieldset class="what">
|
||||
<div>
|
||||
<label for="CommentText">@if (Request.IsAuthenticated) { T("Hi, {0}!", Html.Encode(Page.User.Identity.Name))<br /> } @T("Comment")</label>
|
||||
<label for="CommentText">@if (Request.IsAuthenticated) { @T("Hi, {0}!", Html.Encode(WorkContext.CurrentUser.UserName))<br /> } @T("Comment")</label>
|
||||
<textarea id="CommentText" rows="10" cols="30" name="CommentText"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" class="button" value="@T("Submit Comment")" />
|
||||
@Html.Hidden("CommentedOn", Model.ContentItem.Id)
|
||||
@Html.Hidden("CommentedOn", (int)Model.ContentPart.ContentItem.Id)
|
||||
@Html.Hidden("ReturnUrl", Context.Request.ToUrlString())
|
||||
@Html.AntiForgeryTokenOrchard()
|
||||
</div>
|
@@ -0,0 +1,2 @@
|
||||
@using Orchard.Comments.ViewModels;
|
||||
<span class="commentcount">@T.Plural("1 Comment", "{0} Comments", (int)Model.CommentCount)</span>
|
@@ -17,13 +17,13 @@ namespace Orchard.Email.Drivers {
|
||||
|
||||
protected override string Prefix { get { return "SmtpSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(SmtpSettingsPart part) {
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, dynamic shapeHelper) {
|
||||
return ContentPartTemplate(part, "Parts/Smtp.SiteSettings");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
return Editor(part);
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
}
|
||||
}
|
@@ -39,6 +39,7 @@
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
|
@@ -39,8 +39,8 @@ namespace Orchard.Experimental.Controllers {
|
||||
.Select(x => x.GetType())
|
||||
.SelectMany(x => AllTypes(x))
|
||||
.Distinct();
|
||||
model.DisplayShape = _contentManager.BuildDisplayModel(model.Item, "Detail");
|
||||
model.EditorShape = _contentManager.BuildEditorModel(model.Item);
|
||||
model.DisplayShape = _contentManager.BuildDisplay(model.Item, "Detail");
|
||||
model.EditorShape = _contentManager.BuildEditor(model.Item);
|
||||
|
||||
return View(Shape.Model(model));
|
||||
}
|
||||
|
@@ -5,15 +5,15 @@ using Orchard.Experimental.Models;
|
||||
namespace Orchard.Experimental.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class DebugLinkHandler : ContentHandler {
|
||||
protected override void BuildDisplayShape(BuildDisplayModelContext context) {
|
||||
protected override void BuildDisplayShape(BuildDisplayContext context) {
|
||||
var experimentalSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.ExperimentalSettings>();
|
||||
if (experimentalSettings.ShowDebugLinks)
|
||||
context.Model.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999");
|
||||
context.Shape.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999");
|
||||
}
|
||||
protected override void BuildEditorShape(BuildEditorModelContext context) {
|
||||
protected override void BuildEditorShape(BuildEditorContext context) {
|
||||
var experimentalSettings = context.ContentItem.TypeDefinition.Settings.GetModel<Settings.ExperimentalSettings>();
|
||||
if (experimentalSettings.ShowDebugLinks)
|
||||
context.Model.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999");
|
||||
context.Shape.Zones["Recap"].Add(new ShowDebugLink { ContentItem = context.ContentItem }, "9999");
|
||||
}
|
||||
}
|
||||
}
|
@@ -41,7 +41,7 @@ namespace Orchard.Roles.Drivers {
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(UserRolesPart userRolesPart) {
|
||||
protected override DriverResult Editor(UserRolesPart userRolesPart, dynamic shapeHelper) {
|
||||
// don't show editor without apply roles permission
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart))
|
||||
return null;
|
||||
@@ -62,7 +62,7 @@ namespace Orchard.Roles.Drivers {
|
||||
return ContentPartTemplate(model, "Parts/Roles.UserRoles");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(UserRolesPart userRolesPart, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(UserRolesPart userRolesPart, IUpdateModel updater, dynamic shapeHelper) {
|
||||
// don't apply editor without apply roles permission
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart))
|
||||
return null;
|
||||
|
@@ -43,7 +43,7 @@ namespace Orchard.Search.Controllers {
|
||||
}
|
||||
|
||||
searchResultViewModels.Add(new SearchResultViewModel {
|
||||
Content = _contentManager.BuildDisplayModel(contentItem, "SummaryForSearch"),
|
||||
Content = _contentManager.BuildDisplay(contentItem, "SummaryForSearch"),
|
||||
SearchHit = searchHit
|
||||
});
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user