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:
103
src/Orchard.5.0.ReSharper
Normal file
103
src/Orchard.5.0.ReSharper
Normal file
@@ -0,0 +1,103 @@
|
||||
<Configuration>
|
||||
<CodeStyleSettings>
|
||||
<ExternalPath IsNull="False">
|
||||
</ExternalPath>
|
||||
<Sharing>SOLUTION</Sharing>
|
||||
<CSharp>
|
||||
<FormatSettings>
|
||||
<ANONYMOUS_METHOD_DECLARATION_BRACES>END_OF_LINE</ANONYMOUS_METHOD_DECLARATION_BRACES>
|
||||
<CASE_BLOCK_BRACES>END_OF_LINE</CASE_BLOCK_BRACES>
|
||||
<FORCE_FIXED_BRACES_STYLE>ALWAYS_ADD</FORCE_FIXED_BRACES_STYLE>
|
||||
<FORCE_FOR_BRACES_STYLE>ALWAYS_ADD</FORCE_FOR_BRACES_STYLE>
|
||||
<FORCE_FOREACH_BRACES_STYLE>ALWAYS_ADD</FORCE_FOREACH_BRACES_STYLE>
|
||||
<FORCE_IFELSE_BRACES_STYLE>ALWAYS_ADD</FORCE_IFELSE_BRACES_STYLE>
|
||||
<FORCE_USING_BRACES_STYLE>ALWAYS_ADD</FORCE_USING_BRACES_STYLE>
|
||||
<FORCE_WHILE_BRACES_STYLE>ALWAYS_ADD</FORCE_WHILE_BRACES_STYLE>
|
||||
<INITIALIZER_BRACES>END_OF_LINE</INITIALIZER_BRACES>
|
||||
<INVOCABLE_DECLARATION_BRACES>END_OF_LINE</INVOCABLE_DECLARATION_BRACES>
|
||||
<MODIFIERS_ORDER IsNull="False">
|
||||
<Item>public</Item>
|
||||
<Item>protected</Item>
|
||||
<Item>internal</Item>
|
||||
<Item>private</Item>
|
||||
<Item>new</Item>
|
||||
<Item>abstract</Item>
|
||||
<Item>virtual</Item>
|
||||
<Item>override</Item>
|
||||
<Item>sealed</Item>
|
||||
<Item>static</Item>
|
||||
<Item>readonly</Item>
|
||||
<Item>extern</Item>
|
||||
<Item>unsafe</Item>
|
||||
<Item>volatile</Item>
|
||||
</MODIFIERS_ORDER>
|
||||
<OTHER_BRACES>END_OF_LINE</OTHER_BRACES>
|
||||
<TYPE_DECLARATION_BRACES>END_OF_LINE</TYPE_DECLARATION_BRACES>
|
||||
</FormatSettings>
|
||||
<UsingsSettings />
|
||||
<Naming2>
|
||||
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
|
||||
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
|
||||
<ExceptionName IsNull="False">
|
||||
</ExceptionName>
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
|
||||
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
|
||||
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
|
||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
|
||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
|
||||
</Naming2>
|
||||
</CSharp>
|
||||
<VB>
|
||||
<FormatSettings />
|
||||
<ImportsSettings />
|
||||
<Naming2>
|
||||
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
|
||||
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
|
||||
</Naming2>
|
||||
</VB>
|
||||
<Web>
|
||||
<Naming2 />
|
||||
</Web>
|
||||
<Xaml>
|
||||
<Naming2 />
|
||||
</Xaml>
|
||||
<XML>
|
||||
<FormatSettings />
|
||||
</XML>
|
||||
<GenerateMemberBody />
|
||||
<Naming2>
|
||||
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
|
||||
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
|
||||
<ExceptionName IsNull="False">
|
||||
</ExceptionName>
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
|
||||
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
|
||||
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
|
||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PublicFields" />
|
||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
|
||||
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
|
||||
<PredefinedRule Inspect="False" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
|
||||
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
|
||||
<Abbreviation Text="SQ" />
|
||||
</Naming2>
|
||||
</CodeStyleSettings>
|
||||
</Configuration>
|
@@ -0,0 +1,64 @@
|
||||
using Autofac;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.ContentManagement.MetaData.Records;
|
||||
using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
|
||||
namespace Orchard.Tests.ContentManagement{
|
||||
[TestFixture]
|
||||
class ContentTypeMetaDataTests
|
||||
{
|
||||
private IContainer _container;
|
||||
private ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void InitFixture()
|
||||
{
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
databaseFileName,
|
||||
typeof(ContentTypeRecord),
|
||||
typeof(ContentItemRecord),
|
||||
typeof(ContentTypePartRecord),
|
||||
typeof(ContentTypePartNameRecord),
|
||||
typeof(ContentItemVersionRecord));
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TermFixture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
var builder = new ContainerBuilder();
|
||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterType<ContentTypeService>().As<IContentTypeService>();
|
||||
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
|
||||
_session = _sessionFactory.OpenSession();
|
||||
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
|
||||
|
||||
_container = builder.Build();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MapandUnMapContentTypeToContentPart()
|
||||
{
|
||||
var contentTypeService = _container.Resolve<IContentTypeService>();
|
||||
contentTypeService.MapContentTypeToContentPart("foo", "bar");
|
||||
Assert.IsTrue(contentTypeService.ValidateContentTypeToContentPartMapping("foo","bar"),"Content Type not successfully mapped");
|
||||
contentTypeService.UnMapContentTypeToContentPart("foo", "bar");
|
||||
Assert.IsFalse(contentTypeService.ValidateContentTypeToContentPartMapping("foo", "bar"), "Content Type mapping not successfully deleted");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -133,6 +133,7 @@
|
||||
<Compile Include="ContentManagement\ContentQueryTests.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ContentManagement\ContentTypeMetaDataTests.cs" />
|
||||
<Compile Include="ContentManagement\DefaultContentManagerTests.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
@@ -14,9 +14,6 @@ namespace Orchard.Comments.Handlers {
|
||||
IRepository<HasCommentsRecord> hasCommentsRepository,
|
||||
ICommentService commentService) {
|
||||
|
||||
Filters.Add(new ActivatingFilter<HasComments>("sandboxpage"));
|
||||
Filters.Add(new ActivatingFilter<HasComments>("blogpost"));
|
||||
Filters.Add(new ActivatingFilter<HasComments>("page"));
|
||||
Filters.Add(StorageFilter.For(hasCommentsRepository));
|
||||
|
||||
OnActivated<HasComments>((ctx, x) => {
|
||||
|
19
src/Orchard.Web/Modules/Orchard.MetaData/AdminMenu.cs
Normal file
19
src/Orchard.Web/Modules/Orchard.MetaData/AdminMenu.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
namespace Orchard.MetaData {
|
||||
public class AdminMenu : INavigationProvider {
|
||||
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder)
|
||||
{
|
||||
builder.Add("Content Types", "5",
|
||||
menu => menu
|
||||
.Add("Content Types", "1.0", item => item.Action("ContentTypeList", "MetaData", new { area = "Orchard.MetaData" }).Permission(Permissions.ManageMetaData))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.Localization;
|
||||
using Orchard.MetaData.ViewModels;
|
||||
using Orchard.UI.Admin;
|
||||
|
||||
namespace Orchard.MetaData.Controllers
|
||||
{
|
||||
[Admin]
|
||||
public class MetaDataController : Controller
|
||||
{
|
||||
private readonly IContentTypeService _contentTypeService;
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public MetaDataController(IOrchardServices services, IContentTypeService contentTypeService)
|
||||
{
|
||||
_contentTypeService = contentTypeService;
|
||||
Services = services;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
private Localizer T { get; set; }
|
||||
//
|
||||
// GET: /ContentTypeList/
|
||||
|
||||
public ActionResult ContentTypeList(string id) {
|
||||
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMetaData, T("Not allowed to manage MetaData")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentTypes = _contentTypeService.GetContentTypes();
|
||||
var contentTypePartNames = _contentTypeService.GetContentTypePartNames();
|
||||
|
||||
var model = new ContentTypesIndexViewModel();
|
||||
|
||||
foreach(var contentType in contentTypes) {
|
||||
var contentTypeEntry = new ContentTypeEntry {Name = contentType.Name,DisplayName = contentType.Name};
|
||||
|
||||
if (contentType.Name==id) {
|
||||
foreach(var contentTypePartNameRecord in contentTypePartNames) {
|
||||
var contentTypePartEntry = new ContentTypePartEntry { Name = contentTypePartNameRecord.PartName };
|
||||
foreach(var contentTypePartEntryTest in contentType.ContentParts) {
|
||||
if (contentTypePartEntryTest.PartName.PartName==contentTypePartEntry.Name) {
|
||||
contentTypePartEntry.Selected = true;
|
||||
}
|
||||
}
|
||||
model.ContentTypeParts.Add(contentTypePartEntry);
|
||||
}
|
||||
model.SelectedContentType = contentTypeEntry;
|
||||
}
|
||||
model.ContentTypes.Add(contentTypeEntry);
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// POST: /ContentTypeList/Save
|
||||
[HttpPost]
|
||||
public ActionResult Save(string id, FormCollection collection)
|
||||
{
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMetaData, T("Not allowed to manage MetaData")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentTypeRecord = _contentTypeService.GetContentTypeRecord(id);
|
||||
//using a while loop because we are removing items from the collection
|
||||
while (contentTypeRecord.ContentParts.Count>0) {
|
||||
_contentTypeService.UnMapContentTypeToContentPart(contentTypeRecord.Name, contentTypeRecord.ContentParts[0].PartName.PartName);
|
||||
}
|
||||
foreach(var formKey in collection.AllKeys) {
|
||||
if (formKey.Contains("part_")) {
|
||||
var partName = formKey.Replace("part_", "");
|
||||
_contentTypeService.MapContentTypeToContentPart(contentTypeRecord.Name,partName);
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToAction("ContentTypeList", new { id });
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
7
src/Orchard.Web/Modules/Orchard.MetaData/Module.txt
Normal file
7
src/Orchard.Web/Modules/Orchard.MetaData/Module.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
name: MetaData
|
||||
antiforgery: enabled
|
||||
features:
|
||||
Orchard.MetaData:
|
||||
Description: Module for managing Orchard MetaData
|
||||
Dependencies: Common, XmlRpc
|
||||
Category: MetaData
|
124
src/Orchard.Web/Modules/Orchard.MetaData/Orchard.MetaData.csproj
Normal file
124
src/Orchard.Web/Modules/Orchard.MetaData/Orchard.MetaData.csproj
Normal file
@@ -0,0 +1,124 @@
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{23E04990-2A8D-41B8-9908-6DDB71EA3B23}</ProjectGuid>
|
||||
<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Orchard.MetaData</RootNamespace>
|
||||
<AssemblyName>Orchard.MetaData</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<MvcBuildViews>false</MvcBuildViews>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Web.Abstractions" />
|
||||
<Reference Include="System.Web.Routing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
<Reference Include="System.Web.Mobile" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\MetaDataController.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ViewModels\ContentTypesViewModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Site.css" />
|
||||
<Content Include="Module.txt" />
|
||||
<Content Include="Views\MetaData\Old_ContentTypeList.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\MetaData\ContentTypeList.ascx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
|
||||
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
|
||||
<Name>Orchard.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Styles\ContentTypes.css" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="Scripts\" />
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target> -->
|
||||
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
|
||||
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
|
||||
</Target>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>33002</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
33
src/Orchard.Web/Modules/Orchard.MetaData/Permissions.cs
Normal file
33
src/Orchard.Web/Modules/Orchard.MetaData/Permissions.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.MetaData {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageMetaData = new Permission { Description = "Manage MetaData", Name = "ManageMetaData" };//q: Should edit_MetaData be ManageMetaData?
|
||||
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "MetaData";
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
ManageMetaData,
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
|
||||
return new[] {
|
||||
new PermissionStereotype {
|
||||
Name = "Administrator",
|
||||
Permissions = new[] {ManageMetaData}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,34 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Orchard.MetaData")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("Orchard.MetaData")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("9b958fbe-1d0d-4975-9a1b-7e3ff5bed510")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@@ -0,0 +1,35 @@
|
||||
|
||||
.ContentTypeList
|
||||
{
|
||||
width: 100px;
|
||||
float:left;
|
||||
}
|
||||
.ContentTypePartList
|
||||
{
|
||||
width: 200px;
|
||||
float: left;
|
||||
margin-left: 20px;
|
||||
}
|
||||
.ContentTypePartListRow
|
||||
{
|
||||
height:5px;
|
||||
padding:0px;
|
||||
}
|
||||
.ContentTypePartListRowItem
|
||||
{
|
||||
background:#EAEAEA;
|
||||
|
||||
padding:0px;
|
||||
vertical-align:top;
|
||||
margin:1px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.SelectedContentPart {
|
||||
background:#D1F2A5;
|
||||
border-color:#BCD994;
|
||||
}
|
||||
.UnSelectedContentPart {
|
||||
background:#EAEAEA;
|
||||
border-color:#CCC;
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.MetaData.ViewModels
|
||||
{
|
||||
public class ContentTypesIndexViewModel : BaseViewModel {
|
||||
public IList<ContentTypeEntry> ContentTypes { get; set; }
|
||||
public IList<ContentTypePartEntry> ContentTypeParts { get; set; }
|
||||
public ContentTypesIndexViewModel() {
|
||||
ContentTypes=new List<ContentTypeEntry>();
|
||||
ContentTypeParts = new List<ContentTypePartEntry>();
|
||||
}
|
||||
public ContentTypeEntry SelectedContentType { get; set; }
|
||||
}
|
||||
|
||||
public class ContentTypeEntry {
|
||||
public string Name { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public IList<ContentTypePartEntry> ContentTypeParts { get; set; }
|
||||
public ContentTypeEntry(){
|
||||
ContentTypeParts = new List<ContentTypePartEntry>();
|
||||
}
|
||||
}
|
||||
|
||||
public class ContentTypePartEntry {
|
||||
public string Name { get; set; }
|
||||
public bool Selected { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentTypesIndexViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.MetaData.ViewModels"%>
|
||||
<% Html.RegisterStyle("ContentTypes.css"); %>
|
||||
|
||||
<div class="ContentTypeList">
|
||||
<table>
|
||||
<tr>
|
||||
|
||||
<th>
|
||||
Content Types
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<% foreach (var item in Model.ContentTypes) { %>
|
||||
|
||||
<%
|
||||
var contentTypeClass = "";
|
||||
if (Model.SelectedContentType!=null && Model.SelectedContentType.Name == item.Name)
|
||||
{
|
||||
contentTypeClass = "SelectedContentPart";
|
||||
}else{
|
||||
contentTypeClass = "UnSelectedContentPart";
|
||||
}
|
||||
%>
|
||||
<tr class="<%=contentTypeClass %>">
|
||||
<td>
|
||||
<%= Html.ActionLink(item.Name, "ContentTypeList", new {id=item.Name})%>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% } %>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<%if (Model.SelectedContentType!=null) {%>
|
||||
|
||||
<div class="ContentTypePartList">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
|
||||
</th>
|
||||
<th>
|
||||
Included Content Part
|
||||
</th>
|
||||
</tr>
|
||||
<%
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("Save",new {id=Model.SelectedContentType.Name}))) { %>
|
||||
|
||||
<% foreach (var item in Model.ContentTypeParts) { %>
|
||||
|
||||
<tr class="ContentTypePartListRow">
|
||||
<td class="ContentTypePartListRowItem">
|
||||
<%if (item.Selected)
|
||||
{%>
|
||||
<input name="<%="part_" + item.Name%>" type="checkbox" checked="checked" /><%}
|
||||
else {%>
|
||||
<input name="<%="part_" + item.Name%>" type="checkbox" /><%}%>
|
||||
</td>
|
||||
<td class="ContentTypePartListRowItem">
|
||||
<%= Html.Encode(item.Name)%>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% } %>
|
||||
|
||||
</table>
|
||||
<p>
|
||||
<input type="submit" value="<%=_Encoded("Save") %>" />
|
||||
</p>
|
||||
<% } %>
|
||||
</div>
|
||||
<%} %>
|
||||
|
||||
|
||||
|
||||
|
34
src/Orchard.Web/Modules/Orchard.MetaData/Views/Web.config
Normal file
34
src/Orchard.Web/Modules/Orchard.MetaData/Views/Web.config
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
Enabling request validation in view pages would cause validation to occur
|
||||
after the input has already been processed by the controller. By default
|
||||
MVC performs request validation before a controller processes the input.
|
||||
To change this behavior apply the ValidateInputAttribute to a
|
||||
controller or action.
|
||||
-->
|
||||
<pages
|
||||
validateRequest="false"
|
||||
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
|
||||
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
|
||||
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<controls>
|
||||
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
|
||||
</controls>
|
||||
</pages>
|
||||
</system.web>
|
||||
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
158
src/Orchard.Web/Modules/Orchard.MetaData/Web.config
Normal file
158
src/Orchard.Web/Modules/Orchard.MetaData/Web.config
Normal file
@@ -0,0 +1,158 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Note: As an alternative to hand editing this file you can use the
|
||||
web admin tool to configure settings for your application. Use
|
||||
the Website->Asp.Net Configuration option in Visual Studio.
|
||||
A full list of settings and comments can be found in
|
||||
machine.config.comments usually located in
|
||||
\Windows\Microsoft.Net\Framework\v2.x\Config
|
||||
-->
|
||||
<configuration>
|
||||
|
||||
<configSections>
|
||||
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
|
||||
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
</sectionGroup>
|
||||
</sectionGroup>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<appSettings/>
|
||||
|
||||
<connectionStrings>
|
||||
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
|
||||
</connectionStrings>
|
||||
|
||||
<system.web>
|
||||
|
||||
<!--
|
||||
Set compilation debug="true" to insert debugging
|
||||
symbols into the compiled page. Because this
|
||||
affects performance, set this value to true only
|
||||
during development.
|
||||
-->
|
||||
<compilation debug="true">
|
||||
<assemblies>
|
||||
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
|
||||
</assemblies>
|
||||
</compilation>
|
||||
|
||||
<!--
|
||||
The <customErrors> section enables configuration
|
||||
of what to do if/when an unhandled error occurs
|
||||
during the execution of a request. Specifically,
|
||||
it enables developers to configure html error pages
|
||||
to be displayed in place of a error stack trace.
|
||||
|
||||
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
|
||||
<error statusCode="403" redirect="NoAccess.htm" />
|
||||
<error statusCode="404" redirect="FileNotFound.htm" />
|
||||
</customErrors>
|
||||
-->
|
||||
|
||||
<pages>
|
||||
<controls>
|
||||
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
</controls>
|
||||
|
||||
<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" />
|
||||
<add namespace="Orchard.Mvc" />
|
||||
</namespaces>
|
||||
</pages>
|
||||
|
||||
<httpHandlers>
|
||||
<remove verb="*" path="*.asmx"/>
|
||||
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
|
||||
<add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
</httpHandlers>
|
||||
|
||||
<httpModules>
|
||||
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
</httpModules>
|
||||
|
||||
</system.web>
|
||||
|
||||
<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
|
||||
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<providerOption name="CompilerVersion" value="v3.5"/>
|
||||
<providerOption name="WarnAsError" value="false"/>
|
||||
</compiler>
|
||||
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4"
|
||||
type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<providerOption name="CompilerVersion" value="v3.5"/>
|
||||
<providerOption name="OptionInfer" value="true"/>
|
||||
<providerOption name="WarnAsError" value="false"/>
|
||||
</compiler>
|
||||
</compilers>
|
||||
</system.codedom>
|
||||
|
||||
<system.web.extensions/>
|
||||
|
||||
<!--
|
||||
The system.webServer section is required for running ASP.NET AJAX under Internet
|
||||
Information Services 7.0. It is not necessary for previous version of IIS.
|
||||
-->
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
|
||||
<modules runAllManagedModulesForAllRequests="true">
|
||||
<remove name="ScriptModule" />
|
||||
<remove name="UrlRoutingModule" />
|
||||
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
</modules>
|
||||
|
||||
<handlers>
|
||||
<remove name="WebServiceHandlerFactory-Integrated"/>
|
||||
<remove name="ScriptHandlerFactory" />
|
||||
<remove name="ScriptHandlerFactoryAppServices" />
|
||||
<remove name="ScriptResource" />
|
||||
<remove name="MvcHttpHandler" />
|
||||
<remove name="UrlRoutingHandler" />
|
||||
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
|
||||
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
|
||||
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
|
||||
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
</configuration>
|
@@ -14,6 +14,7 @@ using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Themes;
|
||||
@@ -159,6 +160,24 @@ namespace Orchard.Setup.Services {
|
||||
var authenticationService = environment.Resolve<IAuthenticationService>();
|
||||
authenticationService.SignIn(user, true);
|
||||
}
|
||||
|
||||
//Add ContentType mappings
|
||||
var contentTypeService = environment.Resolve<IContentTypeService>();
|
||||
|
||||
//Add ContentTypePartNames to MetaData
|
||||
contentTypeService.AddContentTypePartNameToMetaData("HasComments");
|
||||
contentTypeService.AddContentTypePartNameToMetaData("HasTags");
|
||||
|
||||
//Add mappings from ContentTypes to ContentParts to MetaData
|
||||
contentTypeService.MapContentTypeToContentPart("blogpost","HasComments");
|
||||
contentTypeService.MapContentTypeToContentPart("page", "HasComments");
|
||||
contentTypeService.MapContentTypeToContentPart("sandboxpage", "HasComments");
|
||||
contentTypeService.MapContentTypeToContentPart("blogpost", "HasTags");
|
||||
contentTypeService.MapContentTypeToContentPart("page", "HasTags");
|
||||
contentTypeService.MapContentTypeToContentPart("sandboxpage", "HasTags");
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch {
|
||||
environment.Resolve<ITransactionManager>().Cancel();
|
||||
|
@@ -10,10 +10,7 @@ namespace Orchard.Tags.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class HasTagsHandler : ContentHandler {
|
||||
public HasTagsHandler(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository) {
|
||||
Filters.Add(new ActivatingFilter<HasTags>("sandboxpage"));
|
||||
Filters.Add(new ActivatingFilter<HasTags>("blogpost"));
|
||||
Filters.Add(new ActivatingFilter<HasTags>("page"));
|
||||
|
||||
|
||||
OnLoading<HasTags>((context, tags) => {
|
||||
|
||||
// provide names of all tags on demand
|
||||
|
@@ -63,6 +63,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Modules", "Orchard.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Profile", "Orchard.Profile\Orchard.Profile.csproj", "{94E694A2-D140-468D-A277-C5FCE1D13E9B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.MetaData", "Orchard.Web\Modules\Orchard.MetaData\Orchard.MetaData.csproj", "{23E04990-2A8D-41B8-9908-6DDB71EA3B23}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -177,6 +179,10 @@ Global
|
||||
{94E694A2-D140-468D-A277-C5FCE1D13E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{94E694A2-D140-468D-A277-C5FCE1D13E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{94E694A2-D140-468D-A277-C5FCE1D13E9B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{23E04990-2A8D-41B8-9908-6DDB71EA3B23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{23E04990-2A8D-41B8-9908-6DDB71EA3B23}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{23E04990-2A8D-41B8-9908-6DDB71EA3B23}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{23E04990-2A8D-41B8-9908-6DDB71EA3B23}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -202,6 +208,7 @@ Global
|
||||
{72457126-E118-4171-A08F-9A709EE4B7FC} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{CDE24A24-01D3-403C-84B9-37722E18DFB7} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{17F86780-9A1F-4AA1-86F1-875EEC2730C7} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{23E04990-2A8D-41B8-9908-6DDB71EA3B23} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{5E5E7A21-C7B2-44D8-8593-2F9541AE041D} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||
{4AB4B5B6-277E-4FF6-B69B-7AE9E16D2A56} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||
{33B1BC8D-E292-4972-A363-22056B207156} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
namespace Orchard.ContentManagement.Drivers {
|
||||
public abstract class AutomaticContentPartDriver<TPart> : ContentPartDriver<TPart> where TPart : class, IContent {
|
||||
public abstract class AutomaticContentPartDriver<TPart> : ContentPartDriver<TPart> where TPart : ContentPart, new() {
|
||||
protected override string Prefix {
|
||||
get {
|
||||
return (typeof (TPart).Name);
|
||||
|
@@ -5,7 +5,7 @@ using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement.Drivers {
|
||||
public abstract class ContentItemDriver<TContent> : ContentPartDriver<TContent>, IContentItemDriver where TContent : class, IContent {
|
||||
public abstract class ContentItemDriver<TContent> : ContentPartDriver<TContent>, IContentItemDriver where TContent : ContentPart, new() {
|
||||
private readonly ContentType _contentType;
|
||||
protected virtual bool UseDefaultTemplate { get { return false; } }
|
||||
|
||||
|
@@ -1,13 +1,18 @@
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
|
||||
namespace Orchard.ContentManagement.Drivers {
|
||||
|
||||
public interface IContentPartDriver : IEvents {
|
||||
DriverResult BuildDisplayModel(BuildDisplayModelContext context);
|
||||
DriverResult BuildEditorModel(BuildEditorModelContext context);
|
||||
DriverResult UpdateEditorModel(UpdateEditorModelContext context);
|
||||
|
||||
IEnumerable<ContentPartInfo> GetPartInfo();
|
||||
}
|
||||
|
||||
public abstract class ContentPartDriver<TContent> : IContentPartDriver where TContent : class, IContent {
|
||||
public abstract class ContentPartDriver<TContent> : IContentPartDriver where TContent : ContentPart, new() {
|
||||
protected virtual string Prefix { get { return ""; } }
|
||||
protected virtual string Zone { get { return "body"; } }
|
||||
|
||||
@@ -46,5 +51,16 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
public CombinedResult Combined(params DriverResult[] results) {
|
||||
return new CombinedResult(results);
|
||||
}
|
||||
|
||||
public IEnumerable<ContentPartInfo> GetPartInfo()
|
||||
{
|
||||
var contentPartInfo = new List<ContentPartInfo>() {
|
||||
new ContentPartInfo()
|
||||
{PartName = typeof(TContent).Name,Factory = () => new TContent()}
|
||||
};
|
||||
|
||||
return contentPartInfo;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -15,5 +15,11 @@
|
||||
_item.Weld(part);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContentItemBuilder Weld(ContentPart contentPart) {
|
||||
_item.Weld(contentPart);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
42
src/Orchard/ContentManagement/MetaData/ContentPartHandler.cs
Normal file
42
src/Orchard/ContentManagement/MetaData/ContentPartHandler.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData.Records;
|
||||
using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ContentPartHandler : ContentHandler
|
||||
{
|
||||
private readonly IEnumerable<ContentPartInfo> _contentPartInfos;
|
||||
private readonly IContentTypeService _contentTypeService;
|
||||
|
||||
public ContentPartHandler(IEnumerable<IContentPartDriver> contentPartDrivers, IOrchardServices orchardServices, IContentTypeService contentTypeService) {
|
||||
_contentTypeService = contentTypeService;
|
||||
_contentPartInfos = contentPartDrivers.SelectMany<IContentPartDriver, ContentPartInfo>(cpp => cpp.GetPartInfo());
|
||||
}
|
||||
|
||||
protected override void Activating(ActivatingContentContext context) {
|
||||
var contentTypeRecord = _contentTypeService.GetContentTypeRecord(context.ContentType) ?? new ContentTypeRecord();
|
||||
|
||||
if (contentTypeRecord.ContentParts != null){
|
||||
foreach (var contentTypePartRecord in contentTypeRecord.ContentParts){
|
||||
//var record = contentTypePartRecord;
|
||||
|
||||
var contentPart = _contentPartInfos.Single(x => x.PartName == contentTypePartRecord.PartName.PartName).Factory();
|
||||
context.Builder.Weld(contentPart);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
10
src/Orchard/ContentManagement/MetaData/ContentPartInfo.cs
Normal file
10
src/Orchard/ContentManagement/MetaData/ContentPartInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData
|
||||
{
|
||||
public class ContentPartInfo
|
||||
{
|
||||
public string PartName { get; set; }
|
||||
public Func<ContentPart> Factory { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
namespace Orchard.ContentManagement.MetaData.Records {
|
||||
public class ContentTypePartNameRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual string PartName { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
namespace Orchard.ContentManagement.MetaData.Records {
|
||||
public class ContentTypePartRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual ContentTypePartNameRecord PartName { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement.MetaData.Records;
|
||||
using Orchard.Data;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData.Services
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ContentTypeService : IContentTypeService
|
||||
{
|
||||
private readonly IRepository<ContentTypeRecord> _contentTypeRepository;
|
||||
private readonly IRepository<ContentTypePartNameRecord> _contentTypePartNameRepository;
|
||||
private readonly IRepository<ContentTypePartRecord> _contentTypePartRepository;
|
||||
|
||||
public ContentTypeService(IRepository<ContentTypePartRecord> contentTypePartRepository, IRepository<ContentTypeRecord> contentTypeRepository, IRepository<ContentTypePartNameRecord> contentTypePartNameRepository)
|
||||
{
|
||||
_contentTypeRepository = contentTypeRepository;
|
||||
_contentTypePartNameRepository = contentTypePartNameRepository;
|
||||
_contentTypePartRepository = contentTypePartRepository;
|
||||
}
|
||||
|
||||
public ContentTypePartNameRecord GetContentPartNameRecord(string name) {
|
||||
return _contentTypePartNameRepository.Fetch(x => x.PartName == name).Single();
|
||||
}
|
||||
|
||||
public void MapContentTypeToContentPart(string contentType, string contentPart) {
|
||||
var contentTypeRecord = GetContentTypeRecord(contentType) ?? new ContentTypeRecord();
|
||||
contentTypeRecord.Name = contentType;
|
||||
var contentTypePartNameRecord =
|
||||
_contentTypePartNameRepository.Fetch(x => x.PartName == contentPart).SingleOrDefault();
|
||||
if (contentTypePartNameRecord==null) {
|
||||
contentTypePartNameRecord=new ContentTypePartNameRecord(){PartName = contentPart};
|
||||
_contentTypePartNameRepository.Update(contentTypePartNameRecord);
|
||||
contentTypePartNameRecord =
|
||||
_contentTypePartNameRepository.Fetch(x => x.PartName == contentPart).SingleOrDefault();
|
||||
}
|
||||
var contentTypePartRecord = new ContentTypePartRecord() {
|
||||
PartName = contentTypePartNameRecord
|
||||
};
|
||||
if (contentTypeRecord.ContentParts==null) {
|
||||
contentTypeRecord.ContentParts = new List<ContentTypePartRecord> { contentTypePartRecord };
|
||||
}
|
||||
else {
|
||||
contentTypeRecord.ContentParts.Add(contentTypePartRecord);
|
||||
}
|
||||
|
||||
_contentTypeRepository.Update(contentTypeRecord);
|
||||
}
|
||||
|
||||
public void UnMapContentTypeToContentPart(string contentType, string contentPart) {
|
||||
var contentTypeRecord = GetContentTypeRecord(contentType) ?? new ContentTypeRecord();
|
||||
var contentTypePartNameRecord = _contentTypePartNameRepository.Fetch(x => x.PartName == contentPart).Single();
|
||||
|
||||
var contentTypePartRecord = contentTypeRecord.ContentParts.SingleOrDefault(x => x.PartName == contentTypePartNameRecord);
|
||||
if (contentTypePartRecord != null)
|
||||
{
|
||||
_contentTypePartRepository.Delete(contentTypePartRecord);
|
||||
contentTypeRecord.ContentParts.Remove(contentTypePartRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ValidateContentTypeToContentPartMapping(string contentType, string contentPart) {
|
||||
var contentTypeRecord = GetContentTypeRecord(contentType) ?? new ContentTypeRecord();
|
||||
if (contentTypeRecord.ContentParts.Count==0)
|
||||
return false;
|
||||
var contentTypePart = contentTypeRecord.ContentParts.Single(x => x.PartName.PartName == contentPart);
|
||||
return contentTypePart != null;
|
||||
}
|
||||
|
||||
|
||||
public void AddContentTypePartNameToMetaData(string contentTypePartName) {
|
||||
var contentTypePartNameRecord = new ContentTypePartNameRecord() {
|
||||
PartName = contentTypePartName
|
||||
};
|
||||
|
||||
_contentTypePartNameRepository.Update(contentTypePartNameRecord);
|
||||
}
|
||||
|
||||
public ContentTypeRecord GetContentTypeRecord(string contentTypeName) {
|
||||
return _contentTypeRepository.Fetch(x => x.Name == contentTypeName).SingleOrDefault();
|
||||
}
|
||||
|
||||
public IEnumerable<ContentTypeRecord> GetContentTypes() {
|
||||
return _contentTypeRepository.Table.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<ContentTypePartNameRecord> GetContentTypePartNames() {
|
||||
return _contentTypePartNameRepository.Table.ToList();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.MetaData.Records;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData.Services
|
||||
{
|
||||
public interface IContentTypeService : IDependency {
|
||||
void MapContentTypeToContentPart(string contentType, string contentPart);
|
||||
void UnMapContentTypeToContentPart(string contentType, string contentPart);
|
||||
void AddContentTypePartNameToMetaData(string contentTypePartName);
|
||||
ContentTypeRecord GetContentTypeRecord(string contentTypeName);
|
||||
bool ValidateContentTypeToContentPartMapping(string contentType, string contentPart);
|
||||
IEnumerable<ContentTypeRecord> GetContentTypes();
|
||||
IEnumerable<ContentTypePartNameRecord> GetContentTypePartNames();
|
||||
ContentTypePartNameRecord GetContentPartNameRecord(string name);
|
||||
}
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
using Orchard.Data.Conventions;
|
||||
|
||||
namespace Orchard.ContentManagement.Records {
|
||||
public abstract class ContentPartRecord {
|
||||
public virtual int Id { get; set; }
|
||||
[CascadeAllDeleteOrphan]
|
||||
public virtual ContentItemRecord ContentItemRecord { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,12 @@
|
||||
namespace Orchard.ContentManagement.Records {
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.MetaData.Records;
|
||||
using Orchard.Data.Conventions;
|
||||
|
||||
namespace Orchard.ContentManagement.Records {
|
||||
public class ContentTypeRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
[CascadeAllDeleteOrphan]
|
||||
public virtual IList<ContentTypePartRecord> ContentParts { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -152,6 +152,7 @@
|
||||
<Compile Include="Caching\Weak.cs" />
|
||||
<Compile Include="ContentManagement\DefaultContentManagerSession.cs" />
|
||||
<Compile Include="ContentManagement\IContentManagerSession.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Records\ContentTypePartNameRecord.cs" />
|
||||
<Compile Include="ContentManagement\Utilities\LazyField.cs" />
|
||||
<Compile Include="FileSystems\WebSite\WebSiteFolder.cs" />
|
||||
<Compile Include="FileSystems\AppData\IAppDataFolder.cs" />
|
||||
@@ -182,6 +183,11 @@
|
||||
<Compile Include="ContentManagement\Handlers\PublishContentContext.cs" />
|
||||
<Compile Include="ContentManagement\Handlers\RemoveContentContext.cs" />
|
||||
<Compile Include="ContentManagement\Handlers\VersionContentContext.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\ContentPartHandler.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\ContentPartInfo.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Services\ContentTypeService.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Services\IContentTypeService.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Records\ContentTypePartRecord.cs" />
|
||||
<Compile Include="Data\Conventions\RecordTableNameConvention.cs" />
|
||||
<Compile Include="Data\Builders\AbstractBuilder.cs" />
|
||||
<Compile Include="Data\Builders\SessionFactoryBuilder.cs" />
|
||||
@@ -459,6 +465,9 @@
|
||||
<None Include="app.config" />
|
||||
<None Include="ContentManagement\Diagram.cd" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="ContentManagement\MetaData\Models\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
Reference in New Issue
Block a user