Code cleanup and consistency (renaming to match patterns, moving namespaces, etc)

--HG--
branch : dev
rename : src/Orchard.Web/Core/Common/Controllers/BodyDriver.cs => src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs
rename : src/Orchard.Web/Core/Common/Controllers/RoutableDriver.cs => src/Orchard.Web/Core/Common/Drivers/RoutableDriver.cs
rename : src/Orchard.Web/Core/Common/Models/BodyAspectHandler.cs => src/Orchard.Web/Core/Common/Handlers/BodyAspectHandler.cs
rename : src/Orchard.Web/Core/Common/Models/CommonAspectHandler.cs => src/Orchard.Web/Core/Common/Handlers/CommonAspectHandler.cs
rename : src/Orchard.Web/Core/Common/Models/RoutableAspectHandler.cs => src/Orchard.Web/Core/Common/Handlers/RoutableAspectHandler.cs
rename : src/Orchard.Web/Core/Common/Records/BodyRecord.cs => src/Orchard.Web/Core/Common/Models/BodyRecord.cs
rename : src/Orchard.Web/Core/Common/Records/CommonRecord.cs => src/Orchard.Web/Core/Common/Models/CommonRecord.cs
rename : src/Orchard.Web/Core/Common/Records/CommonVersionRecord.cs => src/Orchard.Web/Core/Common/Models/CommonVersionRecord.cs
rename : src/Orchard.Web/Core/Common/Records/RoutableRecord.cs => src/Orchard.Web/Core/Common/Models/RoutableRecord.cs
rename : src/Orchard.Web/Core/Navigation/Records/MenuItemRecord.cs => src/Orchard.Web/Core/Navigation/Models/MenuItemRecord.cs
rename : src/Orchard.Web/Core/Navigation/Records/MenuPartRecord.cs => src/Orchard.Web/Core/Navigation/Models/MenuPartRecord.cs
rename : src/Orchard.Web/Core/Navigation/Services/MainMenu.cs => src/Orchard.Web/Core/Navigation/Services/MainMenuService.cs
rename : src/Orchard.Web/Core/Scheduling/Records/ScheduledTaskRecord.cs => src/Orchard.Web/Core/Scheduling/Models/ScheduledTaskRecord.cs
rename : src/Orchard.Web/Core/Settings/Controllers/SiteSettingsDriver.cs => src/Orchard.Web/Core/Settings/Drivers/SiteSettingsDriver.cs
rename : src/Orchard.Web/Core/Settings/Models/SiteSettingsHandler.cs => src/Orchard.Web/Core/Settings/Handlers/SiteSettingsHandler.cs
rename : src/Orchard.Web/Core/Settings/Records/SiteSettingsRecord.cs => src/Orchard.Web/Core/Settings/Models/SiteSettingsRecord.cs
rename : src/Orchard.Web/Core/Themes/Models/ThemeSiteSettingsHandler.cs => src/Orchard.Web/Core/Themes/Handlers/ThemeSiteSettingsHandler.cs
rename : src/Orchard.Web/Core/Themes/Records/ThemeRecord.cs => src/Orchard.Web/Core/Themes/Models/ThemeRecord.cs
rename : src/Orchard.Web/Core/Themes/Records/ThemeSiteSettingsRecord.cs => src/Orchard.Web/Core/Themes/Models/ThemeSiteSettingsRecord.cs
rename : src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogDriver.cs => src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostDriver.cs => src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogPostDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Blogs/Models/BlogArchiveHandler.cs => src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogArchiveHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Blogs/Models/BlogHandler.cs => src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Blogs/Models/BlogPostHandler.cs => src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogPostHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Controllers/CommentDriver.cs => src/Orchard.Web/Modules/Orchard.Comments/Drivers/CommentDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Controllers/HasCommentsContainerDriver.cs => src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsContainerDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Controllers/HasCommentsDriver.cs => src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/CommentHandler.cs => src/Orchard.Web/Modules/Orchard.Comments/Handlers/CommentHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/CommentSettingsHandler.cs => src/Orchard.Web/Modules/Orchard.Comments/Handlers/CommentSettingsHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/HasCommentsContainerHandler.cs => src/Orchard.Web/Modules/Orchard.Comments/Handlers/HasCommentsContainerHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Comments/Models/HasCommentsHandler.cs => src/Orchard.Web/Modules/Orchard.Comments/Handlers/HasCommentsHandler.cs
rename : src/Orchard.Web/Modules/Orchard.DevTools/Models/DebugLinkHandler.cs => src/Orchard.Web/Modules/Orchard.DevTools/Handlers/DebugLinkHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Pages/Controllers/PageDriver.cs => src/Orchard.Web/Modules/Orchard.Pages/Drivers/PageDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Pages/Models/PageHandler.cs => src/Orchard.Web/Modules/Orchard.Pages/Handlers/PageHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Pages/Services/SlugConstraint.cs => src/Orchard.Web/Modules/Orchard.Pages/Routing/SlugConstraint.cs
rename : src/Orchard.Web/Modules/Orchard.Pages/Services/SlugConstraintUpdator.cs => src/Orchard.Web/Modules/Orchard.Pages/Routing/SlugConstraintUpdator.cs
rename : src/Orchard.Web/Modules/Orchard.Roles/Controllers/UserRolesDriver.cs => src/Orchard.Web/Modules/Orchard.Roles/Drivers/UserRolesDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Roles/Models/UserRolesHandler.cs => src/Orchard.Web/Modules/Orchard.Roles/Handlers/UserRolesHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Roles/Records/PermissionRecord.cs => src/Orchard.Web/Modules/Orchard.Roles/Models/PermissionRecord.cs
rename : src/Orchard.Web/Modules/Orchard.Roles/Records/RoleRecord.cs => src/Orchard.Web/Modules/Orchard.Roles/Models/RoleRecord.cs
rename : src/Orchard.Web/Modules/Orchard.Roles/Records/RolesPermissions.cs => src/Orchard.Web/Modules/Orchard.Roles/Models/RolesPermissionsRecord.cs
rename : src/Orchard.Web/Modules/Orchard.Roles/Records/UserRolesRecord.cs => src/Orchard.Web/Modules/Orchard.Roles/Models/UserRolesRecord.cs
rename : src/Orchard.Web/Modules/Orchard.Sandbox/Controllers/SandboxPageDriver.cs => src/Orchard.Web/Modules/Orchard.Sandbox/Drivers/SandboxPageDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Sandbox/Models/SandboxContentHandler.cs => src/Orchard.Web/Modules/Orchard.Sandbox/Handlers/SandboxContentHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Tags/Controllers/HasTagsDriver.cs => src/Orchard.Web/Modules/Orchard.Tags/Drivers/HasTagsDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Tags/Models/HasTagsHandler.cs => src/Orchard.Web/Modules/Orchard.Tags/Handlers/HasTagsHandler.cs
rename : src/Orchard.Web/Modules/Orchard.Users/Controllers/UserDriver.cs => src/Orchard.Web/Modules/Orchard.Users/Drivers/UserDriver.cs
rename : src/Orchard.Web/Modules/Orchard.Users/Models/UserHandler.cs => src/Orchard.Web/Modules/Orchard.Users/Handlers/UserHandler.cs
This commit is contained in:
Erik Porter
2010-03-03 23:31:42 -08:00
parent 36fc37afd8
commit a21471ddf3
148 changed files with 705 additions and 742 deletions

View File

@@ -6,8 +6,8 @@ using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Records;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.Records;

View File

@@ -8,7 +8,6 @@ using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.Services;
using Orchard.Tests.Modules;

View File

@@ -12,7 +12,6 @@ using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Records;
using Orchard.Core.Feeds;
using Orchard.Core.Feeds.Controllers;
using Orchard.Core.Feeds.Models;

View File

@@ -5,7 +5,7 @@ using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;
using Orchard.Data;
using Orchard.Tasks;

View File

@@ -6,7 +6,7 @@ using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;
using Orchard.Data;
using Orchard.Tasks;

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Autofac.Builder;
using NUnit.Framework;
using Orchard.Roles.Records;
using Orchard.Roles.Models;
using Orchard.Roles.Services;
namespace Orchard.Tests.Modules.Roles.Services {
@@ -15,7 +15,7 @@ namespace Orchard.Tests.Modules.Roles.Services {
protected override IEnumerable<Type> DatabaseTypes {
get {
return new[] { typeof(RoleRecord), typeof(PermissionRecord), typeof(RolesPermissions) };
return new[] { typeof(RoleRecord), typeof(PermissionRecord), typeof(RolesPermissionsRecord) };
}
}

View File

@@ -18,6 +18,7 @@ using Orchard.Security;
using Orchard.Security.Permissions;
using Orchard.UI.Notify;
using Orchard.Users.Controllers;
using Orchard.Users.Handlers;
using Orchard.Users.Models;
using Orchard.Users.Services;
using Orchard.Users.ViewModels;

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
using Autofac;
using Autofac.Builder;
@@ -13,6 +10,7 @@ using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.Records;
using Orchard.Security;
using Orchard.Users.Handlers;
using Orchard.Users.Models;
using Orchard.Users.Services;

View File

@@ -1,10 +1,12 @@
using System.Text.RegularExpressions;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.ViewModels;
namespace Orchard.Core.Common.Controllers {
namespace Orchard.Core.Common.Drivers {
[UsedImplicitly]
public class BodyDriver : ContentPartDriver<BodyAspect> {
public IOrchardServices Services { get; set; }
private const string TemplateName = "Parts/Common.Body";

View File

@@ -1,9 +1,11 @@
using Orchard.ContentManagement;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.ViewModels;
namespace Orchard.Core.Common.Controllers {
namespace Orchard.Core.Common.Drivers {
[UsedImplicitly]
public class Routable : ContentPartDriver<RoutableAspect> {
private const string TemplateName = "Parts/Common.Routable";

View File

@@ -1,8 +1,10 @@
using Orchard.Core.Common.Records;
using JetBrains.Annotations;
using Orchard.Core.Common.Models;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Common.Models {
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
public class BodyAspectHandler : ContentHandler {
public BodyAspectHandler(IRepository<BodyRecord> bodyRepository) {
Filters.Add(StorageFilter.For(bodyRepository));

View File

@@ -1,4 +1,5 @@
using Orchard.Core.Common.Records;
using JetBrains.Annotations;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.ViewModels;
using Orchard.Data;
using Orchard.Localization;
@@ -8,7 +9,8 @@ using Orchard.ContentManagement.ViewModels;
using Orchard.Security;
using Orchard.Services;
namespace Orchard.Core.Common.Models {
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
public class CommonAspectHandler : ContentHandler {
private readonly IClock _clock;
private readonly IAuthenticationService _authenticationService;

View File

@@ -0,0 +1,29 @@
using System.Text;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Data;
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
public class RoutableAspectHandler : ContentHandler {
public RoutableAspectHandler(IRepository<RoutableRecord> repository) {
Filters.Add(StorageFilter.For(repository));
OnGetEditorViewModel<RoutableAspect>((context, routable) => {
var containerPathBuilder = new StringBuilder();
var container = context.ContentItem.As<ICommonAspect>().Container;
while (container != null) {
if (container.Is<RoutableAspect>())
containerPathBuilder.Insert(0, string.Format("{0}/", container.As<RoutableAspect>().Slug));
container = container.ContentItem.As<ICommonAspect>().Container;
}
routable.ContainerPath = containerPathBuilder.ToString();
});
}
}
}

View File

@@ -1,4 +1,3 @@
using Orchard.Core.Common.Records;
using Orchard.ContentManagement;
namespace Orchard.Core.Common.Models {

View File

@@ -1,7 +1,7 @@
using Orchard.ContentManagement.Records;
using Orchard.Data.Conventions;
namespace Orchard.Core.Common.Records {
namespace Orchard.Core.Common.Models {
public class BodyRecord : ContentPartVersionRecord {
[StringLengthMax]
public virtual string Text { get; set; }

View File

@@ -1,5 +1,4 @@
using System;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.Utilities;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;

View File

@@ -1,7 +1,7 @@
using System;
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Common.Records {
namespace Orchard.Core.Common.Models {
public class CommonRecord : ContentPartRecord {
public virtual int OwnerId { get; set; }
public virtual ContentItemRecord Container { get; set; }

View File

@@ -1,7 +1,7 @@
using System;
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Common.Records {
namespace Orchard.Core.Common.Models {
public class CommonVersionRecord : ContentPartVersionRecord {
public virtual DateTime? CreatedUtc { get; set; }
public virtual DateTime? PublishedUtc { get; set; }

View File

@@ -1,4 +1,3 @@
using Orchard.Core.Common.Records;
using Orchard.ContentManagement;
namespace Orchard.Core.Common.Models {

View File

@@ -1,29 +0,0 @@
using System.Text;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Records;
using Orchard.Data;
namespace Orchard.Core.Common.Models {
[UsedImplicitly]
public class RoutableAspectHandler : ContentHandler {
public RoutableAspectHandler(IRepository<RoutableRecord> repository) {
Filters.Add(StorageFilter.For(repository));
OnGetEditorViewModel<RoutableAspect>((context, routable) => {
var containerPathBuilder = new StringBuilder();
var container = context.ContentItem.As<ICommonAspect>().Container;
while (container != null) {
if (container.Is<RoutableAspect>())
containerPathBuilder.Insert(0, string.Format("{0}/", container.As<RoutableAspect>().Slug));
container = container.ContentItem.As<ICommonAspect>().Container;
}
routable.ContainerPath = containerPathBuilder.ToString();
});
}
}
}

View File

@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Common.Records {
namespace Orchard.Core.Common.Models {
public class RoutableRecord : ContentPartVersionRecord {
[StringLength(1024)]
public virtual string Title { get; set; }

View File

@@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
using Orchard.Core.Common.Models;
namespace Orchard.Core.Common.Services {
[UsedImplicitly]
public class RoutableService : IRoutableService {
public void FillSlug<TModel>(TModel model) where TModel : RoutableAspect {
if (!string.IsNullOrEmpty(model.Slug) || string.IsNullOrEmpty(model.Title))

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Mvc;
namespace Orchard.Core.Feeds.Models {
public class FeedContext {

View File

@@ -1,5 +1,4 @@
using System.Xml.Linq;
using Orchard.ContentManagement;
namespace Orchard.Core.Feeds.Models {
public class FeedItem {

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using System.Xml.Linq;

View File

@@ -3,7 +3,6 @@ using JetBrains.Annotations;
using Orchard.Mvc.Filters;
using Orchard.Mvc.ViewModels;
namespace Orchard.Core.Feeds.Services {
[UsedImplicitly]
public class FeedFilter : FilterProvider, IResultFilter {

View File

@@ -3,7 +3,6 @@ using System.Xml.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Records;
using Orchard.Core.Feeds.Models;
using Orchard.Core.Feeds.StandardBuilders;

View File

@@ -1,14 +1,13 @@
using Orchard.Core.Navigation.Drivers;
using Orchard.Core.Navigation.Records;
using JetBrains.Annotations;
using Orchard.Core.Navigation.Drivers;
using Orchard.Core.Navigation.Models;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Navigation.Models {
namespace Orchard.Core.Navigation.Handlers {
[UsedImplicitly]
public class MenuItemHandler : ContentHandler {
private readonly IOrchardServices _orchardServices;
public MenuItemHandler(IRepository<MenuItemRecord> repository, IOrchardServices orchardServices) {
_orchardServices = orchardServices;
public MenuItemHandler(IRepository<MenuItemRecord> repository) {
Filters.Add(new ActivatingFilter<MenuItem>(MenuItemDriver.ContentType.Name));
Filters.Add(StorageFilter.For(repository));
}

View File

@@ -1,10 +1,10 @@
using System;
using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Navigation.Records;
using Orchard.Core.Navigation.Models;
using Orchard.Data;
namespace Orchard.Core.Navigation.Models {
namespace Orchard.Core.Navigation.Handlers {
[UsedImplicitly]
public class MenuPartHandler : ContentHandler {
public MenuPartHandler(IRepository<MenuPartRecord> menuPartRepository) {
@@ -14,9 +14,9 @@ namespace Orchard.Core.Navigation.Models {
Filters.Add(StorageFilter.For(menuPartRepository));
OnActivated<MenuPart>((ctx, x) => {
x.OnMainMenu = false;
x.MenuText = String.Empty;
});
x.OnMainMenu = false;
x.MenuText = String.Empty;
});
}
}
}

View File

@@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.Core.Navigation.Records;
namespace Orchard.Core.Navigation.Models {
public class MenuItem : ContentPart<MenuItemRecord> {

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Navigation.Records {
namespace Orchard.Core.Navigation.Models {
public class MenuItemRecord : ContentPartRecord {
public virtual string Url { get; set; }
}

View File

@@ -1,7 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.Core.Navigation.Records;
namespace Orchard.Core.Navigation.Models {
public class MenuPart : ContentPart<MenuPartRecord> {

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Navigation.Records {
namespace Orchard.Core.Navigation.Models {
public class MenuPartRecord : ContentPartRecord {
public virtual string MenuText { get; set; }
public virtual string MenuPosition { get; set; }

View File

@@ -0,0 +1,10 @@
using System.Collections.Generic;
using Orchard.Core.Navigation.Models;
namespace Orchard.Core.Navigation.Services {
public interface IMenuService : IDependency {
IEnumerable<MenuPart> Get();
MenuPart Get(int menuPartId);
void Delete(MenuPart menuPart);
}
}

View File

@@ -1,15 +1,16 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Core.Navigation.Models;
using Orchard.Core.Navigation.Records;
using Orchard.UI.Navigation;
using MenuItem=Orchard.Core.Navigation.Models.MenuItem;
namespace Orchard.Core.Navigation.Services {
public class MainMenu : INavigationProvider, IMenuService {
[UsedImplicitly]
public class MainMenuService : INavigationProvider, IMenuService {
private readonly IContentManager _contentManager;
public MainMenu(IContentManager contentManager) {
public MainMenuService(IContentManager contentManager) {
_contentManager = contentManager;
}
@@ -28,10 +29,10 @@ namespace Orchard.Core.Navigation.Services {
}
public void GetNavigation(NavigationBuilder builder) {
IEnumerable<MenuPart> menuParts = _contentManager.Query<MenuPart, MenuPartRecord>().Where(x => x.OnMainMenu).List();
var menuParts = _contentManager.Query<MenuPart, MenuPartRecord>().Where(x => x.OnMainMenu).List();
foreach (var menuPart in menuParts) {
if (menuPart != null ) {
MenuPart part = menuPart;
var part = menuPart;
if (part.Is<MenuItem>())
builder.Add(
@@ -46,10 +47,4 @@ namespace Orchard.Core.Navigation.Services {
}
}
}
public interface IMenuService : IDependency {
IEnumerable<MenuPart> Get();
MenuPart Get(int menuPartId);
void Delete(MenuPart menuPart);
}
}

View File

@@ -61,24 +61,24 @@
<Reference Include="System.Web.Mobile" />
</ItemGroup>
<ItemGroup>
<Compile Include="Common\Controllers\BodyDriver.cs" />
<Compile Include="Common\Controllers\RoutableDriver.cs" />
<Compile Include="Common\Drivers\BodyDriver.cs" />
<Compile Include="Common\Drivers\RoutableDriver.cs" />
<Compile Include="Common\Controllers\RoutableController.cs" />
<Compile Include="Common\Models\RoutableAspectHandler.cs" />
<Compile Include="Common\Handlers\RoutableAspectHandler.cs" />
<Compile Include="Common\Permissions.cs" />
<Compile Include="Common\Records\CommonVersionRecord.cs" />
<Compile Include="Common\Models\CommonVersionRecord.cs" />
<Compile Include="Common\Routes.cs" />
<Compile Include="Common\Services\IRoutableService.cs" />
<Compile Include="Common\Services\RoutableService.cs" />
<Compile Include="Common\Utilities\LazyField.cs" />
<Compile Include="Common\Models\CommonAspectHandler.cs" />
<Compile Include="Common\Handlers\CommonAspectHandler.cs" />
<Compile Include="Common\Models\CommonAspect.cs" />
<Compile Include="Common\Models\BodyAspectHandler.cs" />
<Compile Include="Common\Handlers\BodyAspectHandler.cs" />
<Compile Include="Common\Models\BodyAspect.cs" />
<Compile Include="Common\Models\RoutableAspect.cs" />
<Compile Include="Common\Records\BodyRecord.cs" />
<Compile Include="Common\Records\CommonRecord.cs" />
<Compile Include="Common\Records\RoutableRecord.cs" />
<Compile Include="Common\Models\BodyRecord.cs" />
<Compile Include="Common\Models\CommonRecord.cs" />
<Compile Include="Common\Models\RoutableRecord.cs" />
<Compile Include="Common\ViewModels\BodyDisplayViewModel.cs" />
<Compile Include="Common\ViewModels\BodyEditorViewModel.cs" />
<Compile Include="Common\ViewModels\RoutableEditorViewModel.cs" />
@@ -115,20 +115,21 @@
<Compile Include="Navigation\Drivers\MenuPartDriver.cs" />
<Compile Include="Navigation\Handlers\MenuPartHandler.cs" />
<Compile Include="Navigation\Permissions.cs" />
<Compile Include="Navigation\Records\MenuItemRecord.cs" />
<Compile Include="Navigation\Records\MenuPartRecord.cs" />
<Compile Include="Navigation\Services\MainMenu.cs" />
<Compile Include="Navigation\Models\MenuItemRecord.cs" />
<Compile Include="Navigation\Models\MenuPartRecord.cs" />
<Compile Include="Navigation\Services\IMenuService.cs" />
<Compile Include="Navigation\Services\MainMenuService.cs" />
<Compile Include="Navigation\ViewModels\CreateMenuItemViewModel.cs" />
<Compile Include="Navigation\ViewModels\MenuItemEntry.cs" />
<Compile Include="Navigation\ViewModels\NavigationManagementViewModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scheduling\Records\ScheduledTaskRecord.cs" />
<Compile Include="Scheduling\Models\ScheduledTaskRecord.cs" />
<Compile Include="Scheduling\Services\PublishingTaskHandler.cs" />
<Compile Include="Scheduling\Services\PublishingTaskManager.cs" />
<Compile Include="Scheduling\Services\ScheduledTaskManager.cs" />
<Compile Include="Scheduling\Services\ScheduledTaskExecutor.cs" />
<Compile Include="Scheduling\Models\Task.cs" />
<Compile Include="Settings\Controllers\SiteSettingsDriver.cs" />
<Compile Include="Settings\Drivers\SiteSettingsDriver.cs" />
<Compile Include="Settings\Permissions.cs" />
<Compile Include="Themes\Preview\IPreviewTheme.cs" />
<Compile Include="Themes\Preview\PreviewThemeFilter.cs" />
@@ -136,19 +137,19 @@
<Compile Include="Themes\Services\SafeModeThemeSelector.cs" />
<Compile Include="Settings\AdminMenu.cs" />
<Compile Include="Settings\Controllers\AdminController.cs" />
<Compile Include="Settings\Models\SiteSettingsHandler.cs" />
<Compile Include="Settings\Handlers\SiteSettingsHandler.cs" />
<Compile Include="Settings\Models\SiteSettings.cs" />
<Compile Include="Settings\Records\SiteSettingsRecord.cs" />
<Compile Include="Settings\Models\SiteSettingsRecord.cs" />
<Compile Include="Settings\Services\SiteService.cs" />
<Compile Include="Settings\ViewModels\SettingsIndexViewModel.cs" />
<Compile Include="Themes\AdminMenu.cs" />
<Compile Include="Themes\Controllers\AdminController.cs" />
<Compile Include="Themes\Models\Theme.cs" />
<Compile Include="Themes\Models\ThemeSiteSettings.cs" />
<Compile Include="Themes\Models\ThemeSiteSettingsHandler.cs" />
<Compile Include="Themes\Handlers\ThemeSiteSettingsHandler.cs" />
<Compile Include="Themes\Permissions.cs" />
<Compile Include="Themes\Records\ThemeRecord.cs" />
<Compile Include="Themes\Records\ThemeSiteSettingsRecord.cs" />
<Compile Include="Themes\Models\ThemeRecord.cs" />
<Compile Include="Themes\Models\ThemeSiteSettingsRecord.cs" />
<Compile Include="Themes\Services\SiteThemeSelector.cs" />
<Compile Include="Themes\Services\ThemeService.cs" />
<Compile Include="Themes\ViewModels\PreviewViewModel.cs" />
@@ -233,9 +234,6 @@
<Content Include="Themes\Styles\special.css" />
<Content Include="Themes\Views\NotFound.ascx" />
</ItemGroup>
<ItemGroup>
<Folder Include="Scheduling\Controllers\" />
</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.

View File

@@ -1,7 +1,7 @@
using System;
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Scheduling.Records {
namespace Orchard.Core.Scheduling.Models {
public class ScheduledTaskRecord {
public virtual int Id { get; set; }
public virtual string TaskType { get; set; }

View File

@@ -1,6 +1,5 @@
using System;
using Orchard.ContentManagement;
using Orchard.Core.Scheduling.Records;
using Orchard.Tasks.Scheduling;
namespace Orchard.Core.Scheduling.Models {

View File

@@ -1,7 +1,9 @@
using Orchard.Logging;
using JetBrains.Annotations;
using Orchard.Logging;
using Orchard.Tasks.Scheduling;
namespace Orchard.Core.Scheduling.Services {
[UsedImplicitly]
public class PublishingTaskHandler : IScheduledTaskHandler {
public PublishingTaskHandler(IOrchardServices services) {
Services = services;

View File

@@ -1,9 +1,11 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Tasks.Scheduling;
namespace Orchard.Core.Scheduling.Services {
[UsedImplicitly]
public class PublishingTaskManager : IPublishingTaskManager {
private const string PublishTaskType = "Publish";
private const string UnpublishTaskType = "Unpublish";

View File

@@ -2,9 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Records;
using Orchard.Data;
using Orchard.Logging;
using Orchard.Services;

View File

@@ -1,15 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Records;
using Orchard.Data;
using Orchard.Logging;
using Orchard.Tasks.Scheduling;
using Orchard.Utility;
namespace Orchard.Core.Scheduling.Services {
[UsedImplicitly]
public class ScheduledTaskManager : IScheduledTaskManager {
private readonly IRepository<ScheduledTaskRecord> _repository;

View File

@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Settings.Models;
namespace Orchard.Core.Settings.Controllers {
namespace Orchard.Core.Settings.Drivers {
[UsedImplicitly]
public class SiteSettingsDriver : ContentItemDriver<SiteSettings> {
protected override ContentType GetContentType() {
return SiteSettings.ContentType;

View File

@@ -1,12 +1,11 @@
using System.Collections.Generic;
using Orchard.Core.Settings.Records;
using JetBrains.Annotations;
using Orchard.Core.Settings.Models;
using Orchard.Data;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Settings.Models {
namespace Orchard.Core.Settings.Handlers {
[UsedImplicitly]
public class SiteSettingsHandler : ContentHandler {
public SiteSettingsHandler(IRepository<SiteSettingsRecord> repository){
Filters.Add(new ActivatingFilter<SiteSettings>("site"));
Filters.Add(StorageFilter.For(repository));

View File

@@ -1,5 +1,4 @@
using Orchard.Core.Settings.Records;
using Orchard.ContentManagement;
using Orchard.ContentManagement;
using Orchard.Settings;
namespace Orchard.Core.Settings.Models {

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Settings.Records {
namespace Orchard.Core.Settings.Models {
public class SiteSettingsRecord : ContentPartRecord {
public virtual string SiteSalt { get; set; }
public virtual string SiteUrl { get; set; }

View File

@@ -1,7 +1,7 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using Orchard.Core.Settings.Models;
using Orchard.Core.Settings.Records;
using Orchard.Data;
using Orchard.Logging;
using Orchard.ContentManagement;
@@ -9,6 +9,7 @@ using Orchard.Settings;
using System.Web;
namespace Orchard.Core.Settings.Services {
[UsedImplicitly]
public class SiteService : ISiteService {
private readonly IRepository<SiteSettingsRecord> _siteSettingsRepository;
private readonly IContentManager _contentManager;
@@ -21,8 +22,6 @@ namespace Orchard.Core.Settings.Services {
public ILogger Logger { get; set; }
#region Implementation of ISiteService
public ISite GetSiteSettings() {
string applicationPath = HttpContext.Current.Request.ApplicationPath;
SiteSettingsRecord record = _siteSettingsRepository.Fetch(x => x.SiteUrl == applicationPath).FirstOrDefault();
@@ -39,7 +38,5 @@ namespace Orchard.Core.Settings.Services {
}
return _contentManager.Get<ISite>(record.Id);
}
#endregion
}
}

View File

@@ -0,0 +1,14 @@
using JetBrains.Annotations;
using Orchard.Core.Themes.Models;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Themes.Handlers {
[UsedImplicitly]
public class ThemeSiteSettingsHandler : ContentHandler {
public ThemeSiteSettingsHandler(IRepository<ThemeSiteSettingsRecord> repository) {
Filters.Add(new ActivatingFilter<ThemeSiteSettings>("site"));
Filters.Add(StorageFilter.For(repository));
}
}
}

View File

@@ -1,13 +1,10 @@
using Orchard.Core.Themes.Records;
using Orchard.ContentManagement;
using Orchard.ContentManagement;
using Orchard.Themes;
namespace Orchard.Core.Themes.Models {
public class Theme : ContentPart<ThemeRecord>, ITheme {
public static readonly ContentType ContentType = new ContentType { Name = "theme", DisplayName = "Themes" };
#region Implementation of ITheme
public string ThemeName { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
@@ -15,7 +12,5 @@ namespace Orchard.Core.Themes.Models {
public string Author { get; set; }
public string HomePage { get; set; }
public string Tags { get; set; }
#endregion
}
}

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Themes.Records {
namespace Orchard.Core.Themes.Models {
public class ThemeRecord : ContentPartRecord {
public virtual string ThemeName { get; set; }
public virtual string DisplayName { get; set; }

View File

@@ -1,5 +1,4 @@
using Orchard.Core.Themes.Records;
using Orchard.ContentManagement;
using Orchard.ContentManagement;
namespace Orchard.Core.Themes.Models {
public class ThemeSiteSettings : ContentPart<ThemeSiteSettingsRecord> {

View File

@@ -1,15 +0,0 @@
using Orchard.Core.Themes.Records;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Themes.Models {
public class ThemeSiteSettingsHandler : ContentHandler {
private readonly IRepository<ThemeSiteSettingsRecord> _themeSiteSettingsRepository;
public ThemeSiteSettingsHandler(IRepository<ThemeSiteSettingsRecord> repository) {
_themeSiteSettingsRepository = repository;
Filters.Add(new ActivatingFilter<ThemeSiteSettings>("site"));
Filters.Add(StorageFilter.For(_themeSiteSettingsRepository));
}
}
}

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Core.Themes.Records {
namespace Orchard.Core.Themes.Models {
public class ThemeSiteSettingsRecord : ContentPartRecord {
public virtual string CurrentThemeName { get; set; }
}

View File

@@ -1,7 +1,9 @@
using System.Web.Routing;
using JetBrains.Annotations;
using Orchard.Themes;
namespace Orchard.Core.Themes.Services {
[UsedImplicitly]
public class SafeModeThemeSelector : IThemeSelector {
public ThemeSelectorResult GetTheme(RequestContext context) {
return new ThemeSelectorResult {Priority = -100, ThemeName = "Themes"};

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using JetBrains.Annotations;
using Orchard.Core.Themes.Models;
@@ -10,6 +7,7 @@ using Orchard.Settings;
using Orchard.Themes;
namespace Orchard.Core.Themes.Services {
[UsedImplicitly]
public class SiteThemeSelector : IThemeSelector {
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }

View File

@@ -12,6 +12,7 @@ using Orchard.Themes;
using Orchard.Core.Themes.Models;
namespace Orchard.Core.Themes.Services {
[UsedImplicitly]
public class ThemeService : IThemeService {
private readonly IExtensionManager _extensionManager;
private readonly IEnumerable<IThemeSelector> _themeSelectors;
@@ -27,8 +28,6 @@ namespace Orchard.Core.Themes.Services {
public ILogger Logger { get; set; }
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
#region Implementation of IThemeService
public ITheme GetSiteTheme() {
string currentThemeName = CurrentSite.As<ThemeSiteSettings>().Record.CurrentThemeName;
@@ -109,7 +108,5 @@ namespace Orchard.Core.Themes.Services {
public void UninstallTheme(string themeName) {
_extensionManager.UninstallExtension("Theme", themeName);
}
#endregion
}
}

View File

@@ -2,6 +2,7 @@ using System;
using System.Linq;
using System.Web.Mvc;
using JetBrains.Annotations;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models;
using Orchard.Blogs.Services;

View File

@@ -1,4 +1,5 @@
using System.Web.Mvc;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models;
using Orchard.Blogs.Services;

View File

@@ -14,15 +14,15 @@ using Orchard.Localization;
using Orchard.Mvc.ViewModels;
using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers {
namespace Orchard.Blogs.Drivers {
[UsedImplicitly]
public class BlogDriver : ContentItemDriver<Blog> {
public IOrchardServices Services { get; set; }
public readonly static ContentType ContentType = new ContentType {
Name = "blog",
DisplayName = "Blog"
};
Name = "blog",
DisplayName = "Blog"
};
private readonly IContentManager _contentManager;
private readonly IBlogService _blogService;
@@ -112,10 +112,10 @@ namespace Orchard.Blogs.Controllers {
if (string.IsNullOrEmpty(blog.Slug)) {
return;
// OR
// OR
// updater.AddModelError("Routable.Slug", T("The slug is required.").ToString());
// return;
// updater.AddModelError("Routable.Slug", T("The slug is required.").ToString());
// return;
}
@@ -126,7 +126,7 @@ namespace Orchard.Blogs.Controllers {
var slugsLikeThis = _blogService.Get().Where(
b => b.Slug.StartsWith(blog.Slug, StringComparison.OrdinalIgnoreCase) &&
b.Id != blog.Id).Select(b => b.Slug);
b.Id != blog.Id).Select(b => b.Slug);
//todo: (heskew) need better messages
if (slugsLikeThis.Count() > 0) {
@@ -136,7 +136,7 @@ namespace Orchard.Blogs.Controllers {
if (originalSlug != blog.Slug)
Services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created blog so this blog now has the slug \"{1}\"",
originalSlug, blog.Slug));
originalSlug, blog.Slug));
}
}
}

View File

@@ -12,7 +12,7 @@ using Orchard.Core.Common.Services;
using Orchard.Localization;
using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers {
namespace Orchard.Blogs.Drivers {
[UsedImplicitly]
public class BlogPostDriver : ContentItemDriver<BlogPost> {
public IOrchardServices Services { get; set; }
@@ -20,9 +20,9 @@ namespace Orchard.Blogs.Controllers {
private readonly IRoutableService _routableService;
public readonly static ContentType ContentType = new ContentType {
Name = "blogpost",
DisplayName = "Blog Post"
};
Name = "blogpost",
DisplayName = "Blog Post"
};
public BlogPostDriver(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService, IRoutableService routableService) {
Services = services;
@@ -108,7 +108,7 @@ namespace Orchard.Blogs.Controllers {
var slugsLikeThis = _blogPostService.Get(post.Blog, VersionOptions.Published).Where(
p => p.Slug.StartsWith(post.Slug, StringComparison.OrdinalIgnoreCase) &&
p.Id != post.Id).Select(p => p.Slug);
p.Id != post.Id).Select(p => p.Slug);
//todo: (heskew) need better messages
if (slugsLikeThis.Count() > 0) {
@@ -123,7 +123,7 @@ namespace Orchard.Blogs.Controllers {
if (originalSlug != post.Slug)
Services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created blog post so this post now has the slug \"{1}\"",
originalSlug, post.Slug));
originalSlug, post.Slug));
}
}
}

View File

@@ -2,12 +2,13 @@ using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Models;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.Models;
using Orchard.Data;
using Orchard.Blogs.Controllers;
namespace Orchard.Blogs.Models {
namespace Orchard.Blogs.Handlers {
[UsedImplicitly]
public class BlogArchiveHandler : ContentHandler {
public BlogArchiveHandler(IRepository<BlogArchiveRecord> blogArchiveRepository, IRepository<CommonRecord> commonRepository) {

View File

@@ -1,10 +1,11 @@
using JetBrains.Annotations;
using Orchard.Blogs.Controllers;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Models;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Data;
namespace Orchard.Blogs.Models {
namespace Orchard.Blogs.Handlers {
[UsedImplicitly]
public class BlogHandler : ContentHandler {
public BlogHandler(IRepository<BlogRecord> repository) {

View File

@@ -1,16 +1,18 @@
using System;
using System.Linq;
using Orchard.Blogs.Controllers;
using JetBrains.Annotations;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Models;
using Orchard.Blogs.Services;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.Services;
using Orchard.Localization;
using Orchard.UI.Notify;
namespace Orchard.Blogs.Models {
namespace Orchard.Blogs.Handlers {
[UsedImplicitly]
public class BlogPostHandler : ContentHandler {
private readonly IBlogPostService _blogPostService;
private readonly IRoutableService _routableService;
@@ -32,12 +34,12 @@ namespace Orchard.Blogs.Models {
Action<Blog> updateBlogPostCount =
(blog => {
// Ensure we get the "right" set of published posts for the blog
blog.ContentItem.ContentManager.Flush();
// Ensure we get the "right" set of published posts for the blog
blog.ContentItem.ContentManager.Flush();
var posts = _blogPostService.Get(blog, VersionOptions.Published).ToList();
blog.PostCount = posts.Count;
});
var posts = _blogPostService.Get(blog, VersionOptions.Published).ToList();
blog.PostCount = posts.Count;
});
OnCreated<BlogPost>((context, bp) => updateBlogPostCount(bp.Blog));
OnPublished<BlogPost>((context, bp) => updateBlogPostCount(bp.Blog));
@@ -59,7 +61,7 @@ namespace Orchard.Blogs.Models {
var slugsLikeThis = _blogPostService.Get(post.Blog, VersionOptions.Published).Where(
p => p.Slug.StartsWith(post.Slug, StringComparison.OrdinalIgnoreCase) &&
p.Id != post.Id).Select(p => p.Slug);
p.Id != post.Id).Select(p => p.Slug);
//todo: (heskew) need better messages
if (slugsLikeThis.Count() > 0) {

View File

@@ -71,16 +71,16 @@
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\BlogAdminController.cs" />
<Compile Include="Controllers\BlogDriver.cs" />
<Compile Include="Drivers\BlogDriver.cs" />
<Compile Include="Controllers\BlogPostAdminController.cs" />
<Compile Include="Controllers\BlogPostController.cs" />
<Compile Include="Controllers\BlogPostDriver.cs" />
<Compile Include="Drivers\BlogPostDriver.cs" />
<Compile Include="Extensions\FeedManagerExtensions.cs" />
<Compile Include="Extensions\HtmlHelperExtensions.cs" />
<Compile Include="Extensions\UrlHelperExtensions.cs" />
<Compile Include="Filters\ArchivesFilter.cs" />
<Compile Include="Models\ArchiveData.cs" />
<Compile Include="Models\BlogArchiveHandler.cs" />
<Compile Include="Handlers\BlogArchiveHandler.cs" />
<Compile Include="Models\BlogArchiveRecord.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Routing\IsArchiveConstraint.cs" />
@@ -89,9 +89,9 @@
<Compile Include="Services\BlogService.cs" />
<Compile Include="Controllers\BlogController.cs" />
<Compile Include="Models\Blog.cs" />
<Compile Include="Models\BlogHandler.cs" />
<Compile Include="Handlers\BlogHandler.cs" />
<Compile Include="Models\BlogPost.cs" />
<Compile Include="Models\BlogPostHandler.cs" />
<Compile Include="Handlers\BlogPostHandler.cs" />
<Compile Include="Models\BlogRecord.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Routes.cs" />

View File

@@ -1,13 +1,14 @@
using System.Linq;
using System.Web.Mvc;
using JetBrains.Annotations;
using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models;
using Orchard.Blogs.ViewModels;
using Orchard.Mvc.Results;
using Orchard.Services;
using Orchard.Core.Feeds;
namespace Orchard.Blogs.Services {
[UsedImplicitly]
public class BlogHomePageProvider : IHomePageProvider {
private readonly IBlogService _blogService;
private readonly IFeedManager _feedManager;
@@ -20,15 +21,12 @@ namespace Orchard.Blogs.Services {
public IOrchardServices Services { get; private set; }
#region Implementation of IHomePageProvider
public string GetProviderName() {
return "BlogHomePageProvider";
}
public ActionResult GetHomePage(int itemId) {
Blog blog = _blogService.Get().Where(x => x.Id == itemId).FirstOrDefault();
var blog = _blogService.Get().Where(x => x.Id == itemId).FirstOrDefault();
if (blog == null)
return new NotFoundResult();
@@ -43,7 +41,5 @@ namespace Orchard.Blogs.Services {
ViewData = new ViewDataDictionary<BlogViewModel>(model)
};
}
#endregion
}
}

View File

@@ -1,14 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Orchard.Blogs.Controllers;
using JetBrains.Annotations;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Models;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.Models;
using Orchard.ContentManagement;
using Orchard.Data;
using Orchard.Tasks.Scheduling;
namespace Orchard.Blogs.Services {
[UsedImplicitly]
public class BlogPostService : IBlogPostService {
private readonly IContentManager _contentManager;
private readonly IRepository<BlogArchiveRecord> _blogArchiveRepository;

View File

@@ -1,10 +1,12 @@
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Orchard.Blogs.Models;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.Models;
using Orchard.ContentManagement;
namespace Orchard.Blogs.Services {
[UsedImplicitly]
public class BlogService : IBlogService {
private readonly IContentManager _contentManager;

View File

@@ -2,7 +2,8 @@
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Blogs.Controllers;
using JetBrains.Annotations;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Models;
using Orchard.ContentManagement;
using Orchard.Core.XmlRpc;
@@ -13,6 +14,7 @@ using Orchard.Security;
using Orchard.Blogs.Extensions;
namespace Orchard.Blogs.Services {
[UsedImplicitly]
public class XmlRpcHandler : IXmlRpcHandler {
private readonly IBlogService _blogService;
private readonly IBlogPostService _blogPostService;

View File

@@ -3,13 +3,13 @@ using Orchard.Comments.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
namespace Orchard.Comments.Controllers {
namespace Orchard.Comments.Drivers {
[UsedImplicitly]
public class CommentDriver : ContentItemDriver<Comment> {
public readonly static ContentType ContentType = new ContentType {
Name = "comment",
DisplayName = "Comment"
};
Name = "comment",
DisplayName = "Comment"
};
protected override ContentType GetContentType() {
return ContentType;

View File

@@ -4,9 +4,9 @@ using Orchard.Comments.Models;
using Orchard.Comments.ViewModels;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.Models;
namespace Orchard.Comments.Controllers {
namespace Orchard.Comments.Drivers {
[UsedImplicitly]
public class HasCommentsContainerDriver : ContentPartDriver<HasCommentsContainer> {
protected override DriverResult Display(HasCommentsContainer part, string displayType) {
@@ -20,7 +20,7 @@ namespace Orchard.Comments.Controllers {
return null;
}
private CommentCountViewModel CreateViewModel(ContentItem contentItem) {
private static CommentCountViewModel CreateViewModel(ContentItem contentItem) {
// Find all contents item with this part as the container
var parts = contentItem.ContentManager.Query()
.Where<CommonRecord>(rec => rec.Container == contentItem.Record).List();

View File

@@ -4,7 +4,7 @@ using Orchard.Comments.ViewModels;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
namespace Orchard.Comments.Controllers {
namespace Orchard.Comments.Drivers {
[UsedImplicitly]
public class HasCommentsDriver : ContentPartDriver<HasComments> {
protected override DriverResult Display(HasComments part, string displayType) {

View File

@@ -1,10 +1,11 @@
using JetBrains.Annotations;
using Orchard.Comments.Controllers;
using Orchard.Comments.Drivers;
using Orchard.Comments.Models;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Data;
namespace Orchard.Comments.Models {
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class CommentHandler : ContentHandler {
public CommentHandler(IRepository<CommentRecord> commentsRepository) {

View File

@@ -1,15 +1,14 @@
using JetBrains.Annotations;
using Orchard.Comments.Models;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Comments.Models {
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class CommentSettingsHandler : ContentHandler {
private readonly IRepository<CommentSettingsRecord> _commentSettingsRepository;
public CommentSettingsHandler(IRepository<CommentSettingsRecord> repository) {
_commentSettingsRepository = repository;
Filters.Add(new ActivatingFilter<CommentSettings>("site"));
Filters.Add(StorageFilter.For(_commentSettingsRepository));
Filters.Add(StorageFilter.For(repository));
Filters.Add(new TemplateFilterForRecord<CommentSettingsRecord>("CommentSettings", "Parts/Comments.SiteSettings"));
}
}

View File

@@ -1,7 +1,8 @@
using JetBrains.Annotations;
using Orchard.Comments.Models;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Comments.Models {
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class HasCommentsContainerHandler : ContentHandler {
public HasCommentsContainerHandler() {

View File

@@ -1,11 +1,12 @@
using System.Linq;
using JetBrains.Annotations;
using Orchard.Comments.Models;
using Orchard.Comments.Services;
using Orchard.ContentManagement;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Comments.Models {
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class HasCommentsHandler : ContentHandler {
public HasCommentsHandler(
@@ -19,23 +20,23 @@ namespace Orchard.Comments.Models {
Filters.Add(StorageFilter.For(hasCommentsRepository));
OnActivated<HasComments>((ctx, x) => {
x.CommentsActive = true;
x.CommentsShown = true;
});
x.CommentsActive = true;
x.CommentsShown = true;
});
OnLoading<HasComments>((context, comments) => {
//TODO: lazy loading?
comments.Comments = contentManager
.Query<Comment, CommentRecord>()
.Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Approved)
.List().ToList();
//TODO: lazy loading?
comments.Comments = contentManager
.Query<Comment, CommentRecord>()
.Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Approved)
.List().ToList();
//TODO: lazy loading?
comments.PendingComments = contentManager
.Query<Comment, CommentRecord>()
.Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Pending)
.List().ToList();
});
//TODO: lazy loading?
comments.PendingComments = contentManager
.Query<Comment, CommentRecord>()
.Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Pending)
.List().ToList();
});
OnRemoved<HasComments>(
(context, c) => {

View File

@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {

View File

@@ -68,26 +68,28 @@
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Controllers\CommentController.cs" />
<Compile Include="Controllers\CommentDriver.cs" />
<Compile Include="Controllers\HasCommentsContainerDriver.cs" />
<Compile Include="Controllers\HasCommentsDriver.cs" />
<Compile Include="Drivers\CommentDriver.cs" />
<Compile Include="Drivers\HasCommentsContainerDriver.cs" />
<Compile Include="Drivers\HasCommentsDriver.cs" />
<Compile Include="Extensions\HtmlHelperExtensions.cs" />
<Compile Include="Models\ClosedCommentsRecord.cs" />
<Compile Include="Models\Comment.cs" />
<Compile Include="Models\CommentHandler.cs" />
<Compile Include="Handlers\CommentHandler.cs" />
<Compile Include="Models\CommentStatus.cs" />
<Compile Include="Models\HasCommentsContainer.cs" />
<Compile Include="Models\HasCommentsContainerHandler.cs" />
<Compile Include="Handlers\HasCommentsContainerHandler.cs" />
<Compile Include="Feeds\CommentedOnContainerFeedQuery.cs" />
<Compile Include="Feeds\CommentedOnFeedQuery.cs" />
<Compile Include="Feeds\CommentFeedItemBuilder.cs" />
<Compile Include="Models\CommentRecord.cs" />
<Compile Include="Models\HasCommentsRecord.cs" />
<Compile Include="Services\CreateCommentContext.cs" />
<Compile Include="Services\ICommentService.cs" />
<Compile Include="ViewModels\CommentCountViewModel.cs" />
<Compile Include="Models\CommentSettings.cs" />
<Compile Include="Models\CommentSettingsHandler.cs" />
<Compile Include="Handlers\CommentSettingsHandler.cs" />
<Compile Include="Models\CommentSettingsRecord.cs" />
<Compile Include="Models\HasCommentsHandler.cs" />
<Compile Include="Handlers\HasCommentsHandler.cs" />
<Compile Include="Models\HasComments.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -124,10 +126,6 @@
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="Content\" />
</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.

View File

@@ -1,43 +1,17 @@
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Orchard.Comments.Drivers;
using Orchard.Comments.Models;
using Orchard.Comments.Controllers;
using Orchard.ContentManagement.Aspects;
using Orchard.Data;
using Orchard.Logging;
using Orchard.ContentManagement;
using Orchard.Security;
using Orchard.Services;
using Orchard.Settings;
namespace Orchard.Comments.Services {
public interface ICommentService : IDependency {
IEnumerable<Comment> GetComments();
IEnumerable<Comment> GetComments(CommentStatus status);
IEnumerable<Comment> GetCommentsForCommentedContent(int id);
IEnumerable<Comment> GetCommentsForCommentedContent(int id, CommentStatus status);
Comment GetComment(int id);
ContentItemMetadata GetDisplayForCommentedContent(int id);
Comment CreateComment(CreateCommentContext commentRecord, bool moderateComments);
void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status);
void ApproveComment(int commentId);
void PendComment(int commentId);
void MarkCommentAsSpam(int commentId);
void DeleteComment(int commentId);
bool CommentsClosedForCommentedContent(int id);
void CloseCommentsForCommentedContent(int id);
void EnableCommentsForCommentedContent(int id);
}
public class CreateCommentContext {
public virtual string Author { get; set; }
public virtual string SiteName { get; set; }
public virtual string Email { get; set; }
public virtual string CommentText { get; set; }
public virtual int CommentedOn { get; set; }
}
[UsedImplicitly]
public class CommentService : ICommentService {
private readonly IRepository<ClosedCommentsRecord> _closedCommentsRepository;
private readonly IClock _clock;
@@ -56,12 +30,8 @@ namespace Orchard.Comments.Services {
}
public ILogger Logger { get; set; }
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
#region Implementation of ICommentService
public IEnumerable<Comment> GetComments() {
return _contentManager
.Query<Comment, CommentRecord>()
@@ -168,7 +138,5 @@ namespace Orchard.Comments.Services {
_closedCommentsRepository.Delete(c);
}
}
#endregion
}
}

View File

@@ -12,6 +12,7 @@ using Joel.Net;
namespace Orchard.Comments.Services {
//This uses an akismet api implementation from http://akismetapi.codeplex.com/
//Since the implementation is trivial, it may make sense to implement it to reduce dependencies.
[UsedImplicitly]
public class AkismetCommentValidator : ICommentValidator {
private readonly INotifier _notifer;
public AkismetCommentValidator(INotifier notifier) {
@@ -24,9 +25,6 @@ namespace Orchard.Comments.Services {
public Localizer T { get; set; }
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
#region Implementation of ICommentValidator
public bool ValidateComment(Comment comment) {
CommentSettingsRecord commentSettingsRecord = CurrentSite.As<CommentSettings>().Record;
string akismetKey = commentSettingsRecord.AkismetKey;
@@ -58,7 +56,5 @@ namespace Orchard.Comments.Services {
return false;
}
#endregion
}
}

View File

@@ -0,0 +1,9 @@
namespace Orchard.Comments.Services {
public class CreateCommentContext {
public virtual string Author { get; set; }
public virtual string SiteName { get; set; }
public virtual string Email { get; set; }
public virtual string CommentText { get; set; }
public virtual int CommentedOn { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using System.Collections.Generic;
using Orchard.Comments.Models;
using Orchard.ContentManagement;
namespace Orchard.Comments.Services {
public interface ICommentService : IDependency {
IEnumerable<Comment> GetComments();
IEnumerable<Comment> GetComments(CommentStatus status);
IEnumerable<Comment> GetCommentsForCommentedContent(int id);
IEnumerable<Comment> GetCommentsForCommentedContent(int id, CommentStatus status);
Comment GetComment(int id);
ContentItemMetadata GetDisplayForCommentedContent(int id);
Comment CreateComment(CreateCommentContext commentRecord, bool moderateComments);
void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status);
void ApproveComment(int commentId);
void PendComment(int commentId);
void MarkCommentAsSpam(int commentId);
void DeleteComment(int commentId);
bool CommentsClosedForCommentedContent(int id);
void CloseCommentsForCommentedContent(int id);
void EnableCommentsForCommentedContent(int id);
}
}

View File

@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using Orchard.Data;
using Orchard.DevTools.ViewModels;
using Orchard.ContentManagement;
@@ -42,8 +40,6 @@ namespace Orchard.DevTools.Controllers {
return View(model);
}
static IEnumerable<Type> AllTypes(Type type) {
var scan = type;
while (scan != null && scan != typeof(Object) && scan != typeof(ContentPart)) {

View File

@@ -1,4 +1,3 @@
using System;
using System.Web.Mvc;
using Orchard.DevTools.Models;
using Orchard.Localization;

View File

@@ -1,7 +1,10 @@
using Orchard.ContentManagement.Handlers;
using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.ViewModels;
using Orchard.DevTools.Models;
namespace Orchard.DevTools.Models {
namespace Orchard.DevTools.Handlers {
[UsedImplicitly]
public class DebugLinkHandler : ContentHandler {
protected override void BuildDisplayModel(BuildDisplayModelContext context) {
context.AddDisplay(new TemplateViewModel(new ShowDebugLink { ContentItem = context.ContentItem }) { TemplateName="Parts/DevTools.ShowDebugLink", ZoneName = "recap", Position = "9999" });

View File

@@ -68,7 +68,7 @@
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\ContentController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Models\DebugLinkHandler.cs" />
<Compile Include="Handlers\DebugLinkHandler.cs" />
<Compile Include="Models\ShowDebugLink.cs" />
<Compile Include="Models\Simple.cs" />
<Compile Include="Permissions.cs" />
@@ -95,9 +95,6 @@
<Name>Orchard</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
</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.

View File

@@ -0,0 +1,38 @@
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.ViewModels;
using Orchard.Data;
using Orchard.Media.Models;
namespace Orchard.Media.Handlers {
[UsedImplicitly]
public class MediaSettingsHandler : ContentHandler {
public MediaSettingsHandler(IRepository<MediaSettingsRecord> repository) {
Filters.Add(new ActivatingFilter<MediaSettings>("site"));
Filters.Add(StorageFilter.For(repository) );
OnActivated<MediaSettings>(DefaultSettings);
}
private static void DefaultSettings(ActivatedContentContext context, MediaSettings settings) {
settings.Record.RootMediaFolder = "~/Media";
}
protected override void BuildEditorModel(BuildEditorModelContext context) {
var model = context.ContentItem.As<MediaSettings>();
if (model == null)
return;
context.AddEditor(new TemplateViewModel(model.Record, "MediaSettings") { TemplateName = "Parts/Media.SiteSettings" });
}
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
var model = context.ContentItem.As<MediaSettings>();
if (model == null)
return;
context.Updater.TryUpdateModel(model.Record, "MediaSettings", null, null);
context.AddEditor(new TemplateViewModel(model.Record, "MediaSettings") { TemplateName = "Parts/Media.SiteSettings" });
}
}
}

View File

@@ -1,44 +1,6 @@
using Orchard.Data;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.Records;
using Orchard.ContentManagement.ViewModels;
using Orchard.ContentManagement;
namespace Orchard.Media.Models {
public class MediaSettings : ContentPart<MediaSettingsRecord> {
}
public class MediaSettingsRecord : ContentPartRecord {
public virtual string RootMediaFolder { get; set; }
}
public class MediaSettingsHandler : ContentHandler {
public MediaSettingsHandler(IRepository<MediaSettingsRecord> repository) {
Filters.Add(new ActivatingFilter<MediaSettings>("site"));
Filters.Add(StorageFilter.For(repository) );
OnActivated<MediaSettings>(DefaultSettings);
}
private static void DefaultSettings(ActivatedContentContext context, MediaSettings settings) {
settings.Record.RootMediaFolder = "~/Media";
}
protected override void BuildEditorModel(BuildEditorModelContext context) {
var model = context.ContentItem.As<MediaSettings>();
if (model == null)
return;
context.AddEditor(new TemplateViewModel(model.Record, "MediaSettings") { TemplateName = "Parts/Media.SiteSettings" });
}
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
var model = context.ContentItem.As<MediaSettings>();
if (model == null)
return;
context.Updater.TryUpdateModel(model.Record, "MediaSettings", null, null);
context.AddEditor(new TemplateViewModel(model.Record, "MediaSettings") { TemplateName = "Parts/Media.SiteSettings" });
}
}
}

View File

@@ -0,0 +1,7 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Media.Models {
public class MediaSettingsRecord : ContentPartRecord {
public virtual string RootMediaFolder { get; set; }
}
}

View File

@@ -69,11 +69,14 @@
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Helpers\MediaHelpers.cs" />
<Compile Include="Models\MediaSettings.cs" />
<Compile Include="Handlers\MediaSettingsHandler.cs" />
<Compile Include="Models\MediaSettingsRecord.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Models\FolderNavigation.cs" />
<Compile Include="Models\MediaFile.cs" />
<Compile Include="Models\MediaFolder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\IMediaService.cs" />
<Compile Include="Services\MediaService.cs" />
<Compile Include="Services\XmlRpcHandler.cs" />
<Compile Include="ViewModels\MediaItemEditViewModel.cs" />
@@ -107,9 +110,6 @@
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
</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.

View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
using System.Web;
using Orchard.Media.Models;
namespace Orchard.Media.Services {
public interface IMediaService : IDependency {
IEnumerable<MediaFolder> GetMediaFolders(string path);
IEnumerable<MediaFile> GetMediaFiles(string path);
void CreateFolder(string path, string name);
void DeleteFolder(string name);
void RenameFolder(string path, string newName);
void DeleteFile(string name, string folderName);
void RenameFile(string name, string newName, string folderName);
void UploadMediaFile(string folderName, HttpPostedFileBase postedFile);
}
}

View File

@@ -1,26 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Text;
using System.Web;
using ICSharpCode.SharpZipLib.Zip;
using JetBrains.Annotations;
using Orchard.Logging;
using Orchard.Storage;
using Orchard.Media.Models;
namespace Orchard.Media.Services {
public interface IMediaService : IDependency {
IEnumerable<MediaFolder> GetMediaFolders(string path);
IEnumerable<MediaFile> GetMediaFiles(string path);
void CreateFolder(string path, string name);
void DeleteFolder(string name);
void RenameFolder(string path, string newName);
void DeleteFile(string name, string folderName);
void RenameFile(string name, string newName, string folderName);
void UploadMediaFile(string folderName, HttpPostedFileBase postedFile);
}
[UsedImplicitly]
public class MediaService : IMediaService {
private readonly IStorageProvider _storageProvider;
private readonly string _rootPath;
@@ -34,41 +24,39 @@ namespace Orchard.Media.Services {
public ILogger Logger { get; set; }
#region Implementation of IMediaService
public IEnumerable<MediaFolder> GetMediaFolders(string path) {
List<MediaFolder> mediaFolders = new List<MediaFolder>();
IEnumerable<IStorageFolder> folders = (
var mediaFolders = new List<MediaFolder>();
var folders = (
path == null ?
_storageProvider.ListFolders(_rootPath) :
_storageProvider.ListFolders(_rootPath + "\\" + path));
foreach (IStorageFolder folder in folders) {
List<string> parentHierarchy = GetParentHierarchy(folder);
string mediaPath = GetMediaPath(parentHierarchy, folder.GetName());
MediaFolder mediaFolder = new MediaFolder {
Name = folder.GetName(),
Size = folder.GetSize(),
LastUpdated = folder.GetLastUpdated(),
MediaPath = mediaPath
};
foreach (var folder in folders) {
var parentHierarchy = GetParentHierarchy(folder);
var mediaPath = GetMediaPath(parentHierarchy, folder.GetName());
var mediaFolder = new MediaFolder {
Name = folder.GetName(),
Size = folder.GetSize(),
LastUpdated = folder.GetLastUpdated(),
MediaPath = mediaPath
};
mediaFolders.Add(mediaFolder);
}
return mediaFolders;
}
public IEnumerable<MediaFile> GetMediaFiles(string path) {
List<MediaFile> mediaFiles = new List<MediaFile>();
var mediaFiles = new List<MediaFile>();
IEnumerable<IStorageFile> files = _storageProvider.ListFiles(_rootPath + "\\" + path);
foreach (IStorageFile file in files) {
MediaFile mediaFile = new MediaFile {
Name = file.GetName(),
Size = file.GetSize(),
LastUpdated = file.GetLastUpdated(),
Type = file.GetFileType(),
FolderName = path
};
var files = _storageProvider.ListFiles(_rootPath + "\\" + path);
foreach (var file in files) {
var mediaFile = new MediaFile {
Name = file.GetName(),
Size = file.GetSize(),
LastUpdated = file.GetLastUpdated(),
Type = file.GetFileType(),
FolderName = path
};
mediaFiles.Add(mediaFile);
}
return mediaFiles;
@@ -88,7 +76,7 @@ namespace Orchard.Media.Services {
}
public void RenameFolder(string path, string newName) {
string newPath = RenameFolderPath(path, newName);
var newPath = RenameFolderPath(path, newName);
_storageProvider.RenameFolder(_rootPath + "\\" + path, _rootPath + "\\" + newPath);
}
@@ -101,7 +89,7 @@ namespace Orchard.Media.Services {
}
public void UploadMediaFile(string folderName, HttpPostedFileBase postedFile) {
string targetFolder = HttpContext.Current.Server.MapPath("~/Media/" + folderName);
var targetFolder = HttpContext.Current.Server.MapPath("~/Media/" + folderName);
if (postedFile.FileName.EndsWith(".zip")) {
UnzipMediaFileArchive(targetFolder, postedFile);
// Don't save the zip file.
@@ -114,12 +102,10 @@ namespace Orchard.Media.Services {
}
}
#endregion
private static void UnzipMediaFileArchive(string targetFolder, HttpPostedFileBase postedFile) {
int postedFileLength = postedFile.ContentLength;
Stream postedFileStream = postedFile.InputStream;
byte[] postedFileData = new byte[postedFileLength];
var postedFileLength = postedFile.ContentLength;
var postedFileStream = postedFile.InputStream;
var postedFileData = new byte[postedFileLength];
postedFileStream.Read(postedFileData, 0, postedFileLength);
using (var memoryStream = new MemoryStream(postedFileData)) {
@@ -132,7 +118,7 @@ namespace Orchard.Media.Services {
// before the directories that contain them, so we create directories as soon as first
// file below their path is encountered.
while ((entry = fileInflater.GetNextEntry()) != null) {
string directoryName = Path.GetDirectoryName(entry.Name);
var directoryName = Path.GetDirectoryName(entry.Name);
if (!Directory.Exists(Path.Combine(targetFolder, directoryName))) {
Directory.CreateDirectory(Path.Combine(targetFolder, directoryName));
}
@@ -148,7 +134,7 @@ namespace Orchard.Media.Services {
}
private static List<string> GetParentHierarchy(IStorageFolder folder) {
List<string> parentHierarchy = new List<string>();
var parentHierarchy = new List<string>();
do {
IStorageFolder parentFolder = folder.GetParent();
string parentName = parentFolder.GetName();
@@ -163,7 +149,7 @@ namespace Orchard.Media.Services {
}
private static string GetMediaPath(IEnumerable<string> parentHierarchy, string folderName) {
StringBuilder mediaPath = new StringBuilder();
var mediaPath = new StringBuilder();
foreach (string parent in parentHierarchy) {
mediaPath.Append(parent);
mediaPath.Append("\\");
@@ -173,13 +159,13 @@ namespace Orchard.Media.Services {
}
private static string RenameFolderPath(string path, string newName) {
int lastIndex = path.LastIndexOf("\\");
var lastIndex = path.LastIndexOf("\\");
if (lastIndex == -1) {
return newName;
}
string parentPath = path.Substring(0, lastIndex);
return parentPath + "\\" + newName;
return path.Substring(0, lastIndex) + "\\" + newName;
}
}
}

View File

@@ -1,23 +1,20 @@
using System;
using System.IO;
using System.Web;
using JetBrains.Annotations;
using Orchard.Core.XmlRpc;
using Orchard.Core.XmlRpc.Models;
using Orchard.Security;
namespace Orchard.Media.Services {
[UsedImplicitly]
public class XmlRpcHandler : IXmlRpcHandler {
private readonly IMembershipService _membershipService;
private readonly IAuthorizationService _authorizationService;
private readonly HttpContextBase _httpContext;
public XmlRpcHandler(
IMembershipService membershipService,
IAuthorizationService authorizationService,
HttpContextBase httpContext) {
public XmlRpcHandler(IMembershipService membershipService, IAuthorizationService authorizationService) {
_membershipService = membershipService;
_authorizationService = authorizationService;
_httpContext = httpContext;
}
public void Process(XmlRpcContext context) {
@@ -26,7 +23,6 @@ namespace Orchard.Media.Services {
Query = string.Empty
};
if (context.Request.MethodName == "metaWeblog.newMediaObject") {
var result = MetaWeblogNewMediaObject(
uriBuilder,
@@ -51,7 +47,6 @@ namespace Orchard.Media.Services {
throw new ApplicationException("Access denied");
}
var name = file.Optional<string>("name");
var bits = file.Optional<byte[]>("bits");
@@ -64,6 +59,5 @@ namespace Orchard.Media.Services {
uriBuilder.Path = uriBuilder.Path.TrimEnd('/') + "/Media/" + name.TrimStart('/');
return new XRpcStruct().Set("url", uriBuilder.Uri.AbsoluteUri);
}
}
}

View File

@@ -8,6 +8,7 @@ using Orchard.Localization;
using Orchard.ContentManagement;
using Orchard.Mvc.AntiForgery;
using Orchard.Mvc.Results;
using Orchard.Pages.Drivers;
using Orchard.Pages.Models;
using Orchard.Pages.Services;
using Orchard.Pages.ViewModels;

View File

@@ -1,6 +1,7 @@
using System.Web.Mvc;
using Orchard.Localization;
using Orchard.Mvc.Results;
using Orchard.Pages.Routing;
using Orchard.Pages.Services;
using Orchard.Pages.ViewModels;
using Orchard.Security;

View File

@@ -2,6 +2,7 @@
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Routing;
using JetBrains.Annotations;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Services;
using Orchard.Localization;
@@ -11,16 +12,17 @@ using Orchard.ContentManagement.Drivers;
using Orchard.Pages.Services;
using Orchard.UI.Notify;
namespace Orchard.Pages.Controllers {
namespace Orchard.Pages.Drivers {
[UsedImplicitly]
public class PageDriver : ContentItemDriver<Page> {
public IOrchardServices Services { get; set; }
private readonly IPageService _pageService;
private readonly IRoutableService _routableService;
public readonly static ContentType ContentType = new ContentType {
Name = "page",
DisplayName = "Page"
};
Name = "page",
DisplayName = "Page"
};
public PageDriver(IOrchardServices services, IPageService pageService, IRoutableService routableService) {
Services = services;
@@ -103,7 +105,7 @@ namespace Orchard.Pages.Controllers {
var slugsLikeThis = _pageService.Get(PageStatus.Published).Where(
p => p.Slug.StartsWith(page.Slug, StringComparison.OrdinalIgnoreCase) &&
p.Id != page.Id).Select(p => p.Slug);
p.Id != page.Id).Select(p => p.Slug);
if (slugsLikeThis.Count() > 0) {
//todo: (heskew) need better messages
@@ -117,7 +119,7 @@ namespace Orchard.Pages.Controllers {
//todo: (heskew) need better messages
if (originalSlug != page.Slug)
Services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously published page so this page now has the slug \"{1}\"",
originalSlug, page.Slug));
originalSlug, page.Slug));
}
}
}

View File

@@ -1,16 +1,18 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Core.Common.Records;
using Orchard.Core.Common.Services;
using Orchard.Localization;
using Orchard.Pages.Controllers;
using Orchard.Core.Common.Models;
using Orchard.ContentManagement.Handlers;
using Orchard.Pages.Drivers;
using Orchard.Pages.Models;
using Orchard.Pages.Services;
using Orchard.UI.Notify;
namespace Orchard.Pages.Models {
namespace Orchard.Pages.Handlers {
[UsedImplicitly]
public class PageHandler : ContentHandler {
private readonly IPageService _pageService;
private readonly IRoutableService _routableService;
@@ -39,7 +41,7 @@ namespace Orchard.Pages.Models {
var slugsLikeThis = _pageService.Get(PageStatus.Published).Where(
p => p.Slug.StartsWith(page.Slug, StringComparison.OrdinalIgnoreCase) &&
p.Id != page.Id).Select(p => p.Slug);
p.Id != page.Id).Select(p => p.Slug);
//todo: (heskew) need better messages
if (slugsLikeThis.Count() > 0) {

View File

@@ -1,7 +1,6 @@
using System;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Common.Models;
using Orchard.Security;

View File

@@ -68,20 +68,21 @@
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Controllers\PageController.cs" />
<Compile Include="Controllers\PageDriver.cs" />
<Compile Include="Drivers\PageDriver.cs" />
<Compile Include="Models\Page.cs" />
<Compile Include="Models\PageHandler.cs" />
<Compile Include="Handlers\PageHandler.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Routes.cs" />
<Compile Include="Security\Authorization.cs" />
<Compile Include="Services\IPageService.cs" />
<Compile Include="Routing\ISlugConstraint.cs" />
<Compile Include="Services\PageService.cs" />
<Compile Include="Services\PageHomePageProvider.cs" />
<Compile Include="Services\SlugConstraint.cs">
<Compile Include="Routing\SlugConstraint.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Services\SlugConstraintUpdator.cs" />
<Compile Include="Routing\SlugConstraintUpdator.cs" />
<Compile Include="ViewModels\PageCreateViewModel.cs" />
<Compile Include="ViewModels\PageEditViewModel.cs" />
<Compile Include="ViewModels\PagesViewModel.cs" />

View File

@@ -2,7 +2,7 @@
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Mvc.Routes;
using Orchard.Pages.Services;
using Orchard.Pages.Routing;
namespace Orchard.Pages {
public class Routes : IRouteProvider {

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
using System.Web.Routing;
namespace Orchard.Pages.Routing {
public interface ISlugConstraint : IRouteConstraint, ISingletonDependency {
void SetCurrentlyPublishedSlugs(IEnumerable<string> slugs);
string LookupPublishedSlug(string slug);
void AddPublishedSlug(string slug);
void RemovePublishedSlug(string slug);
}
}

Some files were not shown because too many files have changed in this diff Show More