mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-28 17:32:44 +08:00
Midway through template refactoring. CURRENTLY BROKEN.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4044393
This commit is contained in:
@@ -75,10 +75,6 @@ namespace Orchard.Tests.Environment {
|
||||
}
|
||||
|
||||
public class StubCompositionStrategy : ICompositionStrategy {
|
||||
public IEnumerable<Assembly> GetAssemblies() {
|
||||
return Enumerable.Empty<Assembly>();
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetModuleTypes() {
|
||||
return Enumerable.Empty<Type>();
|
||||
}
|
||||
|
||||
@@ -141,12 +141,15 @@
|
||||
<Content Include="Themes\Styles\site.css" />
|
||||
<Content Include="Themes\Views\Admin\Install.aspx" />
|
||||
<Content Include="Themes\Views\document.aspx" />
|
||||
<Content Include="Themes\Views\Shared\EditorTemplates\ThemeSiteSettingsRecord.ascx" />
|
||||
<Content Include="Themes\Views\Shared\layout.ascx" />
|
||||
<Content Include="Themes\Views\Shared\user.ascx" />
|
||||
<Content Include="Themes\Views\Shared\menu.ascx" />
|
||||
<Content Include="Themes\Views\EditorTemplates\Parts\Themes.SiteSettings.ascx" />
|
||||
<Content Include="Themes\Views\layout.ascx" />
|
||||
<Content Include="Themes\Views\user.ascx" />
|
||||
<Content Include="Themes\Views\menu.ascx" />
|
||||
<Content Include="Themes\Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Themes\Views\Shared\" />
|
||||
</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.
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Orchard.Core.Themes.Controllers {
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public IUser CurrentUser { get; set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
try {
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Orchard.Core.Themes.Models {
|
||||
_themeSiteSettingsRepository = repository;
|
||||
Filters.Add(new ActivatingFilter<ThemeSiteSettings>("site"));
|
||||
Filters.Add(new StorageFilter<ThemeSiteSettingsRecord>(_themeSiteSettingsRepository) { AutomaticallyCreateMissingRecord = true });
|
||||
Filters.Add(new TemplateFilterForRecord<ThemeSiteSettingsRecord>("ThemeSiteSettings"));
|
||||
Filters.Add(new TemplateFilterForRecord<ThemeSiteSettingsRecord>("ThemeSiteSettings", "Parts/Themes.SiteSettings"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Core.Themes.Models;
|
||||
using Orchard.Models;
|
||||
using Orchard.Settings;
|
||||
@@ -11,7 +12,7 @@ using Orchard.Themes;
|
||||
namespace Orchard.Core.Themes.Services {
|
||||
public class SiteThemeSelector : IThemeSelector {
|
||||
|
||||
public ISite CurrentSite { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public ThemeSelectorResult GetTheme(RequestContext context) {
|
||||
string currentThemeName = CurrentSite.As<ThemeSiteSettings>().Record.CurrentThemeName;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Models;
|
||||
@@ -24,7 +25,7 @@ namespace Orchard.Core.Themes.Services {
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public ISite CurrentSite { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
#region Implementation of IThemeService
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ThemeSiteSettingsRecord>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Themes.Records"%>
|
||||
<h3>Themes</h3>
|
||||
<ol>
|
||||
<li>
|
||||
<%= Html.LabelFor(x=>x.CurrentThemeName) %>
|
||||
<%= Html.EditorFor(x=>x.CurrentThemeName) %>
|
||||
<%= Html.ValidationMessage("CurrentThemeName", "*")%>
|
||||
</li>
|
||||
</ol>
|
||||
21
src/Orchard.Web/Core/Themes/Views/layout.ascx
Normal file
21
src/Orchard.Web/Core/Themes/Views/layout.ascx
Normal file
@@ -0,0 +1,21 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BaseViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %><%
|
||||
Html.RegisterStyle("site.css"); %>
|
||||
<div class="page">
|
||||
<div id="header">
|
||||
<div id="title"><h1>My MVC Application</h1></div><%
|
||||
Html.Zone("header");
|
||||
Html.Zone("menu"); %>
|
||||
<%-- todo:(nheskew) this will need to all go in the header zone (user widget) --%>
|
||||
<% Html.Include("user"); %>
|
||||
<%-- todo:(nheskew) this will need to be a generated menu --%>
|
||||
<% Html.Include("menu"); %>
|
||||
</div>
|
||||
<div id="main"><%
|
||||
Html.ZoneBody("content");
|
||||
%> <div id="footer"><%
|
||||
Html.Zone("footer");
|
||||
%></div>
|
||||
</div>
|
||||
</div>
|
||||
9
src/Orchard.Web/Core/Themes/Views/menu.ascx
Normal file
9
src/Orchard.Web/Core/Themes/Views/menu.ascx
Normal file
@@ -0,0 +1,9 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
|
||||
<div id="menucontainer">
|
||||
<ul id="menu">
|
||||
<li><%= Html.ActionLink("Home", "Index", "Home", new {Area = ""}, new {})%></li>
|
||||
<li><%= Html.ActionLink("About", "About", "Home", new {Area = ""}, new {})%></li>
|
||||
<li><%= Html.ActionLink("Blogs", "List", "Blog", new {Area = "Orchard.Blogs"}, new {})%></li>
|
||||
<li><%= Html.ActionLink("Admin", "List", new {Area = "Orchard.Blogs", Controller = "BlogAdmin"})%></li>
|
||||
</ul>
|
||||
</div>
|
||||
8
src/Orchard.Web/Core/Themes/Views/user.ascx
Normal file
8
src/Orchard.Web/Core/Themes/Views/user.ascx
Normal file
@@ -0,0 +1,8 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
|
||||
<div id="logindisplay"><%
|
||||
if (Request.IsAuthenticated) {
|
||||
%>Welcome <strong><%=Html.Encode(Page.User.Identity.Name) %></strong>! [<%=Html.ActionLink("Log Off", "LogOff", "Account", new { area = "" }, new { }) %>]<%
|
||||
} else {
|
||||
%>[<%=Html.ActionLink("Log On", "LogOn", "Account", new{area=""}, new{}) %>]<%
|
||||
}
|
||||
%></div>
|
||||
@@ -19,11 +19,11 @@ namespace Orchard.Blogs.Models {
|
||||
Filters.Add(new ContentItemTemplates<Blog>("Items/Blogs.Blog", "Detail Summary"));
|
||||
|
||||
OnGetEditorViewModel<Blog>((context, blog) =>
|
||||
context.AddEditor(new TemplateViewModel(blog) { TemplateName = "Blog/Fields", ZoneName = "primary", Position = "1" })
|
||||
context.AddEditor(new TemplateViewModel(blog) { TemplateName = "Parts/Blogs.Blog.Fields", ZoneName = "primary", Position = "1" })
|
||||
);
|
||||
|
||||
OnUpdateEditorViewModel<Blog>((context, blog) => {
|
||||
context.AddEditor(new TemplateViewModel(blog) { TemplateName = "Blog/Fields", ZoneName = "primary", Position = "1" });
|
||||
context.AddEditor(new TemplateViewModel(blog) { TemplateName = "Parts/Blogs.Blog.Fields", ZoneName = "primary", Position = "1" });
|
||||
context.Updater.TryUpdateModel(blog, "", null, null);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,14 +60,14 @@ namespace Orchard.Blogs.Models {
|
||||
case "Detail":
|
||||
context.AddDisplay(
|
||||
new TemplateViewModel(posts.Select(bp => contentManager.BuildDisplayModel(bp, "Summary"))) {
|
||||
TemplateName = "BlogPost/List",
|
||||
TemplateName = "Parts/Blogs.BlogPost.List",
|
||||
ZoneName = "body"
|
||||
});
|
||||
break;
|
||||
case "DetailAdmin":
|
||||
context.AddDisplay(
|
||||
new TemplateViewModel(posts.Select(bp => contentManager.BuildDisplayModel(bp, "SummaryAdmin"))) {
|
||||
TemplateName = "BlogPost/ListAdmin",
|
||||
TemplateName = "Parts/Blogs.BlogPost.List",
|
||||
ZoneName = "body"
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -31,6 +31,14 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac, Version=1.4.4.561, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\autofac\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Integration.Web, Version=1.4.4.561, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\autofac\Autofac.Integration.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\fluentnhibernate\NHibernate.dll</HintPath>
|
||||
@@ -100,27 +108,26 @@
|
||||
<Content Include="Package.txt" />
|
||||
<Content Include="Views\BlogPost\Create.ascx" />
|
||||
<Content Include="Views\BlogPost\Edit.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\Admin\Blog\Detail.ascx" />
|
||||
<Content Include="Views\BlogAdmin\DisplayTemplates\Items\Blogs.Blog.Detail.ascx" />
|
||||
<Content Include="Views\BlogAdmin\Item.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\Admin\Blog\Summary.ascx" />
|
||||
<Content Include="Views\BlogAdmin\DisplayTemplates\Items\Blogs.Blog.Summary.ascx" />
|
||||
<Content Include="Views\Blog\List.ascx" />
|
||||
<Content Include="Views\BlogAdmin\List.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\BlogPost\Detail.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\BlogPost\Summary.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\Blog\Detail.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\BlogPost\List.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\Blog\Summary.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\BlogPost\FieldsSecondary.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Items\Blogs.BlogPost.Detail.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Items\Blogs.BlogPost.Summary.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Items\Blogs.Blog.Detail.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Blogs.BlogPost.List.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Items\Blogs.Blog.Summary.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Blogs.BlogPost.Publish.ascx" />
|
||||
<Content Include="Views\BlogPost\Item.ascx" />
|
||||
<Content Include="Views\Blog\Create.ascx" />
|
||||
<Content Include="Views\Blog\Edit.ascx" />
|
||||
<Content Include="Views\Blog\Item.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\Admin\BlogPost\Summary.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\Admin\BlogPost\List.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\Blog\Fields.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\Blog\Detail.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\BlogPost\Detail.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\BlogPost\FieldsPrimary.ascx" />
|
||||
<Content Include="Views\BlogAdmin\DisplayTemplates\Items\Blogs.BlogPost.Summary.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Blogs.Blog.Fields.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Items\Blogs.Blog.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Items\Blogs.BlogPost.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Blogs.BlogPost.Fields.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Autofac.Integration.Web;
|
||||
using Orchard.Blogs.Routing;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.Mvc.Routes;
|
||||
|
||||
namespace Orchard.Blogs {
|
||||
public class Routes : IRouteProvider
|
||||
{
|
||||
private readonly IBlogService _blogService;
|
||||
private readonly IContainerProvider _containerProvider;
|
||||
|
||||
public Routes(IBlogService blogService) {
|
||||
_blogService = blogService;
|
||||
public Routes(IContainerProvider containerProvider) {
|
||||
_containerProvider = containerProvider;
|
||||
}
|
||||
|
||||
public void GetRoutes(ICollection<RouteDescriptor> routes) {
|
||||
@@ -58,7 +58,7 @@ namespace Orchard.Blogs {
|
||||
{"action", "Edit"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", new IsBlogConstraint(_blogService)}
|
||||
{"blogSlug", new IsBlogConstraint(_containerProvider)}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
@@ -74,7 +74,7 @@ namespace Orchard.Blogs {
|
||||
{"action", "Delete"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", new IsBlogConstraint(_blogService)}
|
||||
{"blogSlug", new IsBlogConstraint(_containerProvider)}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
@@ -90,7 +90,7 @@ namespace Orchard.Blogs {
|
||||
{"action", "Item"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", new IsBlogConstraint(_blogService)}
|
||||
{"blogSlug", new IsBlogConstraint(_containerProvider)}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
@@ -106,7 +106,7 @@ namespace Orchard.Blogs {
|
||||
{"action", "Create"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", new IsBlogConstraint(_blogService)}
|
||||
{"blogSlug", new IsBlogConstraint(_containerProvider)}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
@@ -122,7 +122,7 @@ namespace Orchard.Blogs {
|
||||
{"action", "Edit"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", new IsBlogConstraint(_blogService)}
|
||||
{"blogSlug", new IsBlogConstraint(_containerProvider)}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
@@ -138,7 +138,7 @@ namespace Orchard.Blogs {
|
||||
{"action", "Delete"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", new IsBlogConstraint(_blogService)}
|
||||
{"blogSlug", new IsBlogConstraint(_containerProvider)}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
@@ -198,7 +198,7 @@ namespace Orchard.Blogs {
|
||||
{"action", "Item"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", new IsBlogConstraint(_blogService)}
|
||||
{"blogSlug", new IsBlogConstraint(_containerProvider)}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
@@ -214,7 +214,7 @@ namespace Orchard.Blogs {
|
||||
{"action", "Item"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", new IsBlogConstraint(_blogService)}
|
||||
{"blogSlug", new IsBlogConstraint(_containerProvider)}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using Autofac.Integration.Web;
|
||||
using Orchard.Blogs.Services;
|
||||
|
||||
namespace Orchard.Blogs.Routing {
|
||||
public class IsBlogConstraint : IRouteConstraint {
|
||||
private readonly IBlogService _blogService;
|
||||
private readonly IContainerProvider _containerProvider;
|
||||
|
||||
public IsBlogConstraint(IBlogService blogService) {
|
||||
_blogService = blogService;
|
||||
public IsBlogConstraint(IContainerProvider containerProvider) {
|
||||
_containerProvider = containerProvider;
|
||||
}
|
||||
|
||||
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) {
|
||||
return _blogService.Get(values[parameterName].ToString()) != null;
|
||||
return _containerProvider.RequestContainer.Resolve<IBlogService>().Get(values[parameterName].ToString()) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<% Html.Title(Model.Item.Name); %>
|
||||
<%-- todo: (heskew) get what actions we can out of the h2 :| --%>
|
||||
<h2 class="withActions">
|
||||
<a href="<%=Url.BlogForAdmin(Model.Item.Slug) %>"><%=Html.Encode(Model.Item.Name) %></a>
|
||||
<a href="<%=Url.BlogEdit(Model.Item.Slug) %>" class="ibutton edit" title="Edit Blog">Edit Blog</a>
|
||||
<span class="actions"><span class="destruct"><a href="<%=Url.BlogDelete(Model.Item.Slug) %>" class="ibutton remove" title="Remove Blog">Remove Blog</a></span></span></h2>
|
||||
<p><%=Model.Item.Description%></p>
|
||||
<div class="actions"><a href="<%=Url.BlogPostCreate(Model.Item.Slug) %>" class="add button">New Post</a></div>
|
||||
<%--TODO: (erikpo) Need to figure out which zones should be displayed in this template--%>
|
||||
<%=Html.DisplayZonesAny() %>
|
||||
|
||||
<%--<%
|
||||
if (Model.Posts.Count() > 0) { %>
|
||||
<%=Html.UnorderedList(Model.Posts, (p, i) => Html.DisplayFor(blog => p, "BlogPostPreviewForAdmin").ToHtmlString(), "contentItems")%>
|
||||
<div class="actions"><a href="<%=Url.BlogPostCreate(Model.Blog.Slug) %>" class="add button">New Post</a></div><%
|
||||
} else { %>
|
||||
<div class="info message">This blog is sad with no posts, but don't fret. You can add a new post right <a href="<%=Url.BlogPostCreate(Model.Blog.Slug) %>">here</a>!</div><%
|
||||
} %>--%>
|
||||
@@ -0,0 +1,21 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<h3><a href="<%=Url.BlogForAdmin(Model.Item.Slug) %>"><%=Html.Encode(Model.Item.Name) %></a></h3>
|
||||
<div class="meta">
|
||||
<% var postCount = Model.Item.PostCount; %><a href="<%=Url.BlogForAdmin(Model.Item.Slug) %>"><%=string.Format("{0} post{1}", postCount, postCount == 1 ? "" : "s") %></a>
|
||||
| <a href="#">?? comments</a>
|
||||
</div>
|
||||
<%--<p>[list of authors] [modify blog access]</p>--%>
|
||||
<p><%=Model.Item.Description %></p>
|
||||
<p class="actions">
|
||||
<%-- todo: (heskew) make into a ul --%>
|
||||
<span class="construct">
|
||||
<a href="<%=Url.BlogForAdmin(Model.Item.Slug) %>" class="ibutton blog" title="Manage Blog">Manage Blog</a>
|
||||
<a href="<%=Url.BlogEdit(Model.Item.Slug) %>" class="ibutton edit" title="Edit Blog">Edit Blog</a>
|
||||
<a href="<%=Url.Blog(Model.Item.Slug) %>" class="ibutton view" title="View Blog">View Blog</a>
|
||||
<a href="<%=Url.BlogPostCreate(Model.Item.Slug) %>" class="ibutton add page" title="New Post">New Post</a>
|
||||
</span>
|
||||
<span class="destruct"><a href="<%=Url.BlogDelete(Model.Item.Slug) %>" class="ibutton remove" title="Delete Blog">Remove Blog</a></span>
|
||||
</p>
|
||||
@@ -0,0 +1,23 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Models"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<h3><a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Slug) %>"><%=Html.Encode(Model.Item.Title)%></a></h3>
|
||||
<div class="meta">
|
||||
<%=Html.PublishedState(Model.Item) %>
|
||||
| <a href="#">?? comments</a>
|
||||
</div>
|
||||
<div class="content"><%=Model.Item.As<BodyAspect>().Text ?? "<p><em>there's no content for this blog post</em></p>"%></div>
|
||||
<p class="actions">
|
||||
<%-- todo: (heskew) make into a ul --%>
|
||||
<span class="construct">
|
||||
<a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton edit" title="Edit Post">Edit Post</a>
|
||||
<a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton view" title="View Post">View Post</a><%
|
||||
if (Model.Item.Published == null) { // todo: (heskew) be smart about this and maybe have other contextual actions - including view/preview for view up there ^^ %>
|
||||
<a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton publish" title="Publish Post Now">Publish Post Now</a>
|
||||
<% } %>
|
||||
</span>
|
||||
<span class="destruct"><a href="#" class="ibutton remove" title="Remove Post">Remove Post</a></span>
|
||||
</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<% Html.Title(Model.Item.Name); %>
|
||||
<div class="manage"><a href="<%=Url.BlogEdit(Model.Item.Slug) %>" class="ibutton edit">edit</a></div>
|
||||
<h1><%=Html.Encode(Model.Item.Name) %></h1>
|
||||
<div><%=Html.Encode(Model.Item.Description) %></div>
|
||||
<%--TODO: (erikpo) Need to figure out which zones should be displayed in this template--%>
|
||||
<%=Html.DisplayZonesAny() %>
|
||||
@@ -0,0 +1,10 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<h3><%=Html.Link(Html.Encode(Model.Item.Name), Url.Blog(Model.Item.Slug)) %></h3>
|
||||
<div class="blog metadata"><a href="<%=Url.Blog(Model.Item.Slug) %>"><%=Model.Item.PostCount %> post<%=Model.Item.PostCount == 1 ? "" : "s" %></a></div>
|
||||
<p><%=Model.Item.Description %></p>
|
||||
<%--TODO: (erikpo) Need to figure out which zones should be displayed in this template--%>
|
||||
<%--<%=Html.DisplayZonesAny() %>--%>
|
||||
@@ -0,0 +1,15 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<% Html.Title(Model.Item.Title); %>
|
||||
<div class="manage"><a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton edit">edit</a></div>
|
||||
<h1><%=Html.Encode(Model.Item.Title)%></h1>
|
||||
<div class="metadata">
|
||||
<% if (Model.Item.Creator != null)
|
||||
{
|
||||
%><div class="posted">Posted by <%=Html.Encode(Model.Item.Creator.UserName)%> <%=Html.PublishedWhen(Model.Item)%></div><%
|
||||
} %>
|
||||
</div>
|
||||
<%=Html.DisplayZonesAny() %>
|
||||
@@ -0,0 +1,12 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Models"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<h3><a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>"><%=Html.Encode(Model.Item.Title) %></a></h3>
|
||||
<div class="meta">
|
||||
<%=Html.PublishedState(Model.Item) %>
|
||||
| <a href="#">?? comments</a>
|
||||
</div>
|
||||
<div class="content"><%=Model.Item.As<BodyAspect>().Text ?? "<p><em>there's no content for this blog post</em></p>" %></div>
|
||||
@@ -0,0 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<ItemDisplayModel<BlogPost>>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%=Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
||||
@@ -0,0 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<% Html.Title(Model.Item.Name); %>
|
||||
<%=Html.EditorZone("primary") %>
|
||||
<%=Html.EditorZonesAny() %>
|
||||
@@ -0,0 +1,17 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<% Html.Title(Model.Item.Title); %>
|
||||
<div class="sections">
|
||||
<div class="primary">
|
||||
<%=Html.EditorZone("primary") %>
|
||||
<%=Html.EditorZonesExcept("secondary") %>
|
||||
</div>
|
||||
<div class="secondary">
|
||||
<%=Html.EditorZone("secondary")%>
|
||||
<fieldset>
|
||||
<input class="button" type="submit" name="submit.Save" value="Save"/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Blog>" %>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models" %>
|
||||
<fieldset>
|
||||
<label for="Name">Blog Name</label>
|
||||
<%=Html.EditorFor(m => m.Name) %>
|
||||
</fieldset>
|
||||
<fieldset class="permalink">
|
||||
<label class="sub" for="Slug">Permalink: <span><%=Request.Url.ToRootString() %>/</span></label>
|
||||
<span><%=Html.TextBoxFor(m => m.Slug, new { @class = "text" })%></span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label for="Description">Description</label>
|
||||
<%=Html.TextAreaFor(m => m.Description, 5, 60, null) %>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,12 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BlogPost>" %>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||
<fieldset>
|
||||
<label for="Title">Title</label>
|
||||
<span><%=Html.TextBoxFor(m => m.Title, new { @class = "large text" })%></span>
|
||||
</fieldset>
|
||||
<fieldset class="permalink">
|
||||
<label class="sub" for="Slug">Permalink<br /><span><%=Request.Url.ToRootString() %>/<%=Model.Blog.Slug %>/</span></label>
|
||||
<span><%=Html.TextBoxFor(m => m.Slug, new { @class = "text" })%></span>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,15 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BlogPost>" %>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
|
||||
<fieldset>
|
||||
<legend>Publish Settings</legend>
|
||||
<label for="Command_SaveDraft"><%=Html.RadioButton("Command", "SaveDraft", true, new { id = "Command_SaveDraft" }) %> Save Draft</label><br />
|
||||
</fieldset>
|
||||
<%--<fieldset>
|
||||
<label for="Command_PublishNow"><%=Html.RadioButton("Command", "PublishNow", new { id = "Command_PublishNow" }) %> Publish Now</label>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label for="Command_PublishLater"><%=Html.RadioButton("Command", "PublishLater", new { id = "Command_PublishLater" }) %> Publish Later</label>
|
||||
<%=Html.EditorFor(m => m.Published) %>
|
||||
</fieldset>--%>
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.CmsPages.Models;
|
||||
using Orchard.CmsPages.Services;
|
||||
using Orchard.CmsPages.Services.Templates;
|
||||
@@ -40,9 +41,6 @@ namespace Orchard.CmsPages.Controllers {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
// That's what it takes to get the CurrentUser for a module.
|
||||
// See Orchard.Security.SecurityModule.
|
||||
public IUser CurrentUser { get; set; }
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
@@ -28,8 +29,8 @@ namespace Orchard.Comments.Controllers {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IUser CurrentUser { get; set; }
|
||||
public ISite CurrentSite { get; set; }
|
||||
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Orchard.Comments.Models {
|
||||
_commentSettingsRepository = repository;
|
||||
Filters.Add(new ActivatingFilter<CommentSettings>("site"));
|
||||
Filters.Add(new StorageFilter<CommentSettingsRecord>(_commentSettingsRepository) { AutomaticallyCreateMissingRecord = true });
|
||||
Filters.Add(new TemplateFilterForRecord<CommentSettingsRecord>("CommentSettings"));
|
||||
Filters.Add(new TemplateFilterForRecord<CommentSettingsRecord>("CommentSettings", "Parts/Comments.SiteSettings"));
|
||||
OnActivated<CommentSettings>(DefaultSettings);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,15 @@ namespace Orchard.Comments.Models {
|
||||
if (context.ContentItem.Has<HasComments>() == false) {
|
||||
return;
|
||||
}
|
||||
context.AddDisplay(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { Position = "999" });
|
||||
context.AddDisplay(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { TemplateName = "Parts/Comments.Count", ZoneName="body", Position = "above" });
|
||||
context.AddDisplay(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { TemplateName = "Parts/Comments.HasComments", Position = "999" });
|
||||
}
|
||||
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context) {
|
||||
if (context.ContentItem.Has<HasComments>() == false) {
|
||||
return;
|
||||
}
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasComments>()));
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { TemplateName = "Parts/Comments.HasComments" });
|
||||
}
|
||||
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
@@ -50,7 +51,7 @@ namespace Orchard.Comments.Models {
|
||||
}
|
||||
}
|
||||
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasComments>()));
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { TemplateName = "Parts/Comments.HasComments" });
|
||||
}
|
||||
|
||||
protected override void Loading(LoadContentContext context) {
|
||||
|
||||
@@ -89,9 +89,10 @@
|
||||
<Content Include="Views\Admin\Edit.aspx" />
|
||||
<Content Include="Views\Admin\Index.aspx" />
|
||||
<Content Include="Views\Admin\Create.aspx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\HasComments.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\CommentSettingsRecord.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\HasComments.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Comments.HasComments.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Comments.Count.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Comments.SiteSettings.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Comments.HasComments.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Logging;
|
||||
@@ -49,7 +50,8 @@ namespace Orchard.Comments.Services {
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public ISite CurrentSite { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
|
||||
#region Implementation of ICommentService
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
@@ -21,7 +22,8 @@ namespace Orchard.Comments.Services {
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
public ISite CurrentSite { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
|
||||
#region Implementation of ICommentValidator
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Comments.Models"%>
|
||||
<span class="commentcount"><a href="#comments"><%=Model.Comments.Count() %> Comment<%=Model.Comments.Count() == 1 ? "" : "s" %></a></span>
|
||||
@@ -0,0 +1,38 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Comments.Models"%>
|
||||
<h3 id="comments"><a name="comments"><%=Model.Comments.Count() %> Comment<%=Model.Comments.Count() == 1 ? "" : "s" %></a></h3><%
|
||||
foreach (var comment in Model.Comments) { %>
|
||||
<div>
|
||||
<div class="comment">
|
||||
<%--TODO: (erikpo) Need to clean the name and url so nothing dangerous goes out--%>
|
||||
<span class="who"><%=Html.LinkOrDefault(comment.UserName, comment.SiteName, new { rel = "nofollow" })%></span>
|
||||
<span>said <%=Html.Link(Html.DateTimeRelative(comment.CommentDate), "#")%></span>
|
||||
</div>
|
||||
<div class="text">
|
||||
<p><%=Html.Encode(comment.CommentText) %></p>
|
||||
</div>
|
||||
</div><%
|
||||
}
|
||||
if (Model.Closed) { %>
|
||||
<p>Comments have been disabled for this content.</p><%
|
||||
} else { %>
|
||||
<% using(Html.BeginForm("Create", "Admin", new { area = "Orchard.Comments" }, FormMethod.Post, new { @class = "comments" })) { %>
|
||||
<%=Html.ValidationSummary() %>
|
||||
<fieldset class="who">
|
||||
<%= Html.Hidden("CommentedOn", Model.ContentItem.Id) %>
|
||||
<%= Html.Hidden("ReturnUrl", Context.Request.Url) %>
|
||||
<label for="Name">Name</label>
|
||||
<input id="Name" class="text" name="Name" type="text" /><br />
|
||||
<label for="Email">Email</label>
|
||||
<input id="Email" class="text" name="Email" type="text" /><br />
|
||||
<label for="SiteName">Url</label>
|
||||
<input id="SiteName" class="text" name="SiteName" type="text" /><br />
|
||||
</fieldset>
|
||||
<fieldset class="what">
|
||||
<label for="CommentText">Leave a comment</label>
|
||||
<textarea id="CommentText" rows="10" cols="30" name="CommentText"></textarea><br />
|
||||
<input type="submit" class="button" value="Submit Comment" />
|
||||
</fieldset><%
|
||||
}
|
||||
} %>
|
||||
@@ -0,0 +1,20 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
||||
<%@ Import Namespace="Orchard.Comments.Models"%>
|
||||
<fieldset>
|
||||
<legend>Comments<% if (Model.ContentItem.Id != 0) { %>: <% var commentCount = Model.Comments.Count(); %>
|
||||
<%=Html.ActionLink(
|
||||
string.Format("{0} comment{1}", commentCount, commentCount == 1 ? "" : "s"),
|
||||
"Details",
|
||||
new { Area = "Orchard.Comments", Controller = "Admin", id = Model.ContentItem.Id, returnUrl = Context.Request.Url }
|
||||
) %>
|
||||
- <a href="#">0 pending</a><% } %></legend>
|
||||
<label for="Closed">
|
||||
<% if (Model.Closed) {%>
|
||||
<input id="Closed" name="Closed" type="checkbox" checked="checked" />
|
||||
<% } else { %>
|
||||
<input id="Closed" name="Closed" type="checkbox" />
|
||||
<% } %>
|
||||
Comments are disabled
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Orchard.Comments.Models.CommentSettingsRecord>" %>
|
||||
<h3>Comments</h3>
|
||||
<ol>
|
||||
<li>
|
||||
<%= Html.LabelFor(x=>x.RequireLoginToAddComment) %>
|
||||
<%= Html.EditorFor(x=>x.RequireLoginToAddComment) %>
|
||||
<%= Html.ValidationMessage("RequireLoginToAddComment", "*")%>
|
||||
</li>
|
||||
<li>
|
||||
<%= Html.LabelFor(x=>x.EnableCommentsOnPages) %>
|
||||
<%= Html.EditorFor(x=>x.EnableCommentsOnPages) %>
|
||||
<%= Html.ValidationMessage("EnableCommentsOnPages", "*")%>
|
||||
</li>
|
||||
<li>
|
||||
<%= Html.LabelFor(x=>x.EnableCommentsOnPosts) %>
|
||||
<%= Html.EditorFor(x=>x.EnableCommentsOnPosts) %>
|
||||
<%= Html.ValidationMessage("EnableCommentsOnPosts", "*")%>
|
||||
</li>
|
||||
<li>
|
||||
<%= Html.LabelFor(x=>x.EnableSpamProtection) %>
|
||||
<%= Html.EditorFor(x=>x.EnableSpamProtection) %>
|
||||
<%= Html.ValidationMessage("EnableSpamProtection", "*")%>
|
||||
</li>
|
||||
<li>
|
||||
<%= Html.LabelFor(x=>x.AkismetKey) %>
|
||||
<%= Html.EditorFor(x=>x.AkismetKey) %>
|
||||
<%= Html.ValidationMessage("AkismetKey", "*")%>
|
||||
</li>
|
||||
<li>
|
||||
<%= Html.LabelFor(x=>x.AkismetUrl) %>
|
||||
<%= Html.EditorFor(x=>x.AkismetUrl) %>
|
||||
<%= Html.ValidationMessage("AkismetUrl", "*")%>
|
||||
</li>
|
||||
</ol>
|
||||
@@ -88,8 +88,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Views\Shared\DisplayTemplates\" />
|
||||
<Folder Include="Views\Shared\EditorTemplates\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
||||
@@ -22,9 +22,6 @@ namespace Orchard.Media.Controllers {
|
||||
_notifier = notifier;
|
||||
}
|
||||
|
||||
// That's what it takes to get the CurrentUser for a module.
|
||||
// See Orchard.Security.SecurityModule.
|
||||
public IUser CurrentUser { get; set; }
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Orchard.Media.Models {
|
||||
if (model == null)
|
||||
return;
|
||||
|
||||
context.AddEditor(new TemplateViewModel(model.Record, "MediaSettings"));
|
||||
context.AddEditor(new TemplateViewModel(model.Record, "MediaSettings") { TemplateName = "Parts/Media.SiteSettings" });
|
||||
}
|
||||
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
@@ -37,7 +37,7 @@ namespace Orchard.Media.Models {
|
||||
return;
|
||||
|
||||
context.Updater.TryUpdateModel(model.Record, "MediaSettings", null, null);
|
||||
context.AddEditor(new TemplateViewModel(model.Record, "MediaSettings"));
|
||||
context.AddEditor(new TemplateViewModel(model.Record, "MediaSettings") { TemplateName = "Parts/Media.SiteSettings" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
<Content Include="Views\Admin\EditMedia.aspx" />
|
||||
<Content Include="Views\Admin\EditProperties.aspx" />
|
||||
<Content Include="Views\Admin\Index.aspx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\MediaSettingsRecord.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Media.SiteSettings.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Content\Site.css" />
|
||||
<Content Include="Views\Web.config" />
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MediaSettingsRecord>" %>
|
||||
<%@ Import Namespace="Orchard.Media.Models"%>
|
||||
<h3>Media</h3>
|
||||
<ol>
|
||||
<li>
|
||||
<%= Html.LabelFor(x=>x.RootMediaFolder) %>
|
||||
<%= Html.EditorFor(x=>x.RootMediaFolder) %>
|
||||
<%= Html.ValidationMessage("RootMediaFolder", "*")%>
|
||||
</li>
|
||||
</ol>
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Models;
|
||||
using Orchard.Roles.Models.NoRecord;
|
||||
@@ -18,7 +19,7 @@ namespace Orchard.Roles.Services {
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public ISite CurrentSite { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
#region Implementation of IAuthorizationService
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
@@ -22,8 +23,8 @@ namespace Orchard.Sandbox.Controllers {
|
||||
_notifier = notifier;
|
||||
}
|
||||
|
||||
public ISite CurrentSite { get; set; }
|
||||
public IUser CurrentUser { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Orchard.Sandbox.Models {
|
||||
// add settings to site, and simple record-template gui
|
||||
Filters.Add(new ActivatingFilter<ContentPart<SandboxSettingsRecord>>("site"));
|
||||
Filters.Add(new StorageFilter<SandboxSettingsRecord>(settingsRepository) { AutomaticallyCreateMissingRecord = true });
|
||||
Filters.Add(new TemplateFilterForRecord<SandboxSettingsRecord>("SandboxSettings"));
|
||||
Filters.Add(new TemplateFilterForRecord<SandboxSettingsRecord>("SandboxSettings", "Parts/Sandbox.SiteSettings"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@
|
||||
<Content Include="Views\DisplayTemplates\Parts\Sandbox.Page.Title.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Items\Sandbox.Page.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Items\Sandbox.Page.Summary.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\SandboxPage.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\SandboxSettingsRecord.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Items\Sandbox.Page.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Sandbox.SiteSettings.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
@@ -101,8 +101,6 @@
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Content\" />
|
||||
<Folder Include="Scripts\" />
|
||||
<Folder Include="Views\EditorTemplates\" />
|
||||
<Folder Include="Views\Shared\DisplayTemplates\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Models;
|
||||
@@ -27,8 +28,9 @@ namespace Orchard.Tags.Controllers {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IUser CurrentUser { get; set; }
|
||||
public ISite CurrentSite { get; set; }
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Models;
|
||||
@@ -31,8 +32,9 @@ namespace Orchard.Tags.Controllers {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IUser CurrentUser { get; set; }
|
||||
public ISite CurrentSite { get; set; }
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Orchard.Tags.Models {
|
||||
public TagSettingsHandler(IRepository<TagSettingsRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<TagSettings>("site"));
|
||||
Filters.Add(new StorageFilter<TagSettingsRecord>(repository) { AutomaticallyCreateMissingRecord = true });
|
||||
Filters.Add(new TemplateFilterForRecord<TagSettingsRecord>("TagSettings"));
|
||||
Filters.Add(new TemplateFilterForRecord<TagSettingsRecord>("TagSettings", "Parts/Tags.SiteSettings"));
|
||||
OnActivated<TagSettings>(DefaultSettings);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ namespace Orchard.Tags.Models {
|
||||
Filters.Add(new ActivatingFilter<HasTags>("blogpost"));
|
||||
|
||||
OnGetDisplayViewModel<HasTags>((context, hasTags) => {
|
||||
context.AddDisplay(new TemplateViewModel(hasTags) { Position = "6", TemplateName = "HasTagsList" });
|
||||
context.AddDisplay(new TemplateViewModel(hasTags) { Position = "6" });
|
||||
context.AddDisplay(new TemplateViewModel(hasTags) { TemplateName = "Parts/Tags.HasTags", Position = "6" });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,7 +40,7 @@ namespace Orchard.Tags.Models {
|
||||
if (context.ContentItem.Has<HasTags>() == false) {
|
||||
return;
|
||||
}
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasTags>()) { Position = "0" });
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasTags>()) { TemplateName = "Parts/Tags.HasTags", Position = "0" });
|
||||
}
|
||||
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
@@ -54,7 +53,7 @@ namespace Orchard.Tags.Models {
|
||||
List<string> tagNames = TagHelpers.ParseCommaSeparatedTagNames(viewModel.Tags);
|
||||
_tagService.UpdateTagsForContentItem(context.ContentItem.Id, tagNames);
|
||||
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasTags>()));
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasTags>()) { TemplateName = "Parts/Tags.HasTags" });
|
||||
}
|
||||
|
||||
protected override void Loading(LoadContentContext context) {
|
||||
|
||||
@@ -87,10 +87,9 @@
|
||||
<Content Include="Views\Admin\Search.aspx" />
|
||||
<Content Include="Views\Home\Index.aspx" />
|
||||
<Content Include="Views\Home\Search.aspx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\HasTags.ascx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\HasTagsList.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\HasTags.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\TagSettingsRecord.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\Tags.HasTags.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Tags.HasTags.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Tags.SiteSettings.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
@@ -41,7 +42,7 @@ namespace Orchard.Tags.Services {
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public ISite CurrentSite { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
#region ITagService Members
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasTags>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<%@ Import Namespace="Orchard.Tags.Models" %>
|
||||
<p class="tags">
|
||||
<% if (Model.CurrentTags.Count > 0) { %><span>Tags:</span> <% } %>
|
||||
<%=string.Join(", ", Model.CurrentTags.Select(t => Html.ActionLink(t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = t.TagName }, new { }).ToHtmlString()).ToArray())%>
|
||||
<%--<%=Html.UnorderedList(Model.CurrentTags, (t, i) => Html.ActionLink(t.TagName, "Search", "Home", new { area = "Orchard.Tags", tagName = t.TagName }, new { }).ToHtmlString(), "tags")%>--%>
|
||||
</p>
|
||||
@@ -0,0 +1,8 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasTags>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Tags.Models"%>
|
||||
<formset>
|
||||
<label for="Tags">Tags</label>
|
||||
<input class="large text" id="Tags" name="Tags" type="text" value="<%=string.Join(", ", Model.CurrentTags.Select((t, i) => t.TagName).ToArray()) %>" />
|
||||
</formset>
|
||||
<%--<% Html.BeginForm("Update", "Home", new { area = "Orchard.Tags" }); %>--%>
|
||||
@@ -0,0 +1,10 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TagSettingsRecord>" %>
|
||||
<%@ Import Namespace="Orchard.Tags.Models"%>
|
||||
<h3>Tags</h3>
|
||||
<ol>
|
||||
<li>
|
||||
<%= Html.LabelFor(x=>x.EnableTagsOnPages) %>
|
||||
<%= Html.EditorFor(x=>x.EnableTagsOnPages) %>
|
||||
<%= Html.ValidationMessage("EnableTagsOnPages", "*")%>
|
||||
</li>
|
||||
</ol>
|
||||
@@ -125,7 +125,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Shared\EditorTemplates\TinyMceTextEditor.ascx" />
|
||||
<Content Include="Views\EditorTemplates\TinyMceTextEditor.ascx" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -15,11 +15,13 @@ using Orchard.Models.Records;
|
||||
namespace Orchard.Data {
|
||||
public class HackSessionLocator : ISessionLocator, IDisposable {
|
||||
private readonly ICompositionStrategy _compositionStrategy;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private static ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
|
||||
public HackSessionLocator(ICompositionStrategy compositionStrategy) {
|
||||
public HackSessionLocator(ICompositionStrategy compositionStrategy, ITransactionManager transactionManager) {
|
||||
_compositionStrategy = compositionStrategy;
|
||||
_transactionManager = transactionManager;
|
||||
}
|
||||
|
||||
private ISessionFactory BindSessionFactory() {
|
||||
@@ -73,14 +75,16 @@ namespace Orchard.Data {
|
||||
}
|
||||
|
||||
public ISession For(Type entityType) {
|
||||
return _session ?? Interlocked.CompareExchange(ref _session, BindSessionFactory().OpenSession(), null) ?? _session;
|
||||
var sessionFactory = BindSessionFactory();
|
||||
_transactionManager.Demand();
|
||||
return _session ?? Interlocked.CompareExchange(ref _session, sessionFactory.OpenSession(), null) ?? _session;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
if (_session != null) {
|
||||
//_session.Flush();
|
||||
_session.Close();
|
||||
}
|
||||
//if (_session != null) {
|
||||
// //_session.Flush();
|
||||
// _session.Close();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,29 +8,35 @@ using Orchard.Mvc.Filters;
|
||||
|
||||
namespace Orchard.Data {
|
||||
public interface ITransactionManager : IDependency {
|
||||
void Demand();
|
||||
void Cancel();
|
||||
}
|
||||
|
||||
public class TransactionManager : ITransactionManager, IDisposable {
|
||||
private readonly TransactionScope _scope;
|
||||
private TransactionScope _scope;
|
||||
private bool _cancelled;
|
||||
|
||||
public TransactionManager() {
|
||||
_scope = new TransactionScope(TransactionScopeOption.Required);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
if (!_cancelled)
|
||||
_scope.Complete();
|
||||
_scope.Dispose();
|
||||
void ITransactionManager.Demand() {
|
||||
if (_scope == null) {
|
||||
_scope = new TransactionScope(TransactionScopeOption.Required);
|
||||
}
|
||||
}
|
||||
|
||||
void ITransactionManager.Cancel() {
|
||||
_cancelled = true;
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
if (_scope != null) {
|
||||
if (!_cancelled)
|
||||
_scope.Complete();
|
||||
_scope.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TransactionFilter : FilterProvider, IExceptionFilter{
|
||||
public class TransactionFilter : FilterProvider, IExceptionFilter {
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
|
||||
public TransactionFilter(ITransactionManager transactionManager) {
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace Orchard.Environment {
|
||||
//TEMP: This will be replaced by packaging system
|
||||
|
||||
public interface ICompositionStrategy {
|
||||
IEnumerable<Assembly> GetAssemblies();
|
||||
IEnumerable<Type> GetModuleTypes();
|
||||
IEnumerable<Type> GetDependencyTypes();
|
||||
IEnumerable<Type> GetRecordTypes();
|
||||
@@ -24,13 +23,6 @@ namespace Orchard.Environment {
|
||||
_extensionManager = extensionManager;
|
||||
}
|
||||
|
||||
public IEnumerable<Assembly> GetAssemblies() {
|
||||
return _extensionManager.ActiveExtensions()
|
||||
.Select(entry => entry.Assembly)
|
||||
.Concat(new[] { typeof(IOrchardHost).Assembly });
|
||||
//return BuildManager.GetReferencedAssemblies().OfType<Assembly>();
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetModuleTypes() {
|
||||
var types = _extensionManager.ActiveExtensions().SelectMany(x => x.ExportedTypes);
|
||||
types = types.Concat(typeof(IOrchardHost).Assembly.GetExportedTypes());
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Autofac;
|
||||
using Autofac.Builder;
|
||||
using Autofac.Integration.Web;
|
||||
using System.Collections.Generic;
|
||||
using AutofacContrib.DynamicProxy2;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.ViewEngines;
|
||||
|
||||
@@ -62,7 +65,7 @@ namespace Orchard.Environment {
|
||||
|
||||
// add components by the IDependency interfaces they expose
|
||||
foreach (var serviceType in _compositionStrategy.GetDependencyTypes()) {
|
||||
foreach (var interfaceType in serviceType.GetInterfaces())
|
||||
foreach (var interfaceType in serviceType.GetInterfaces()) {
|
||||
if (typeof(IDependency).IsAssignableFrom(interfaceType)) {
|
||||
var registrar = addingModulesAndServices.Register(serviceType).As(interfaceType);
|
||||
if (typeof(ISingletonDependency).IsAssignableFrom(interfaceType)) {
|
||||
@@ -75,6 +78,7 @@ namespace Orchard.Environment {
|
||||
registrar.ContainerScoped();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var shellContainer = _container.CreateInnerContainer();
|
||||
@@ -82,17 +86,21 @@ namespace Orchard.Environment {
|
||||
addingModulesAndServices.Build(shellContainer);
|
||||
|
||||
// instantiate and register modules on container being built
|
||||
var modules = shellContainer.Resolve<IEnumerable<IModule>>();
|
||||
var addingModules = new ContainerBuilder();
|
||||
foreach (var module in shellContainer.Resolve<IEnumerable<IModule>>()) {
|
||||
foreach (var module in modules) {
|
||||
addingModules.RegisterModule(module);
|
||||
}
|
||||
addingModules.RegisterModule(new ExtensibleInterceptionModule(modules.OfType<IComponentInterceptorProvider>()));
|
||||
addingModules.Build(shellContainer);
|
||||
|
||||
foreach (var reg in shellContainer.ComponentRegistrations) {
|
||||
reg.Preparing += (s, e) => {
|
||||
Debug.WriteLine(e.Component.Descriptor.BestKnownImplementationType.FullName);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//foreach (var reg in shellContainer.ComponentRegistrations) {
|
||||
// reg.Preparing += (s, e) => {
|
||||
// Debug.WriteLine(e.Component.Descriptor.BestKnownImplementationType.FullName);
|
||||
// };
|
||||
//}
|
||||
|
||||
return shellContainer;
|
||||
}
|
||||
@@ -110,4 +118,25 @@ namespace Orchard.Environment {
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class ExtensibleInterceptionModule : InterceptionModule {
|
||||
public ExtensibleInterceptionModule(IEnumerable<IComponentInterceptorProvider> providers)
|
||||
: base(new CombinedProvider(providers.Concat(new[] { new FlexibleInterceptorProvider() })), new FlexibleInterceptorAttacher()) {
|
||||
}
|
||||
|
||||
class CombinedProvider : IComponentInterceptorProvider {
|
||||
private readonly IEnumerable<IComponentInterceptorProvider> _providers;
|
||||
|
||||
public CombinedProvider(IEnumerable<IComponentInterceptorProvider> providers) {
|
||||
_providers = providers;
|
||||
}
|
||||
|
||||
public IEnumerable<Service> GetInterceptorServices(IComponentDescriptor descriptor) {
|
||||
return _providers
|
||||
.SelectMany(x => x.GetInterceptorServices(descriptor))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Autofac;
|
||||
using Autofac.Builder;
|
||||
using Autofac.Integration.Web;
|
||||
using Autofac.Modules;
|
||||
using AutofacContrib.DynamicProxy2;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Loaders;
|
||||
|
||||
|
||||
@@ -4,18 +4,20 @@ using Orchard.Models.ViewModels;
|
||||
namespace Orchard.Models.Driver {
|
||||
public class TemplateFilterForRecord<TRecord> : TemplateFilterBase<ContentPart<TRecord>> where TRecord : ContentPartRecord, new() {
|
||||
private readonly string _prefix;
|
||||
private readonly string _templateName;
|
||||
|
||||
public TemplateFilterForRecord(string prefix) {
|
||||
public TemplateFilterForRecord(string prefix, string templateName) {
|
||||
_prefix = prefix;
|
||||
_templateName = templateName;
|
||||
}
|
||||
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context, ContentPart<TRecord> part) {
|
||||
context.AddEditor(new TemplateViewModel(part.Record, _prefix));
|
||||
context.AddEditor(new TemplateViewModel(part.Record, _prefix) { TemplateName = _templateName });
|
||||
}
|
||||
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context, ContentPart<TRecord> part) {
|
||||
context.Updater.TryUpdateModel(part.Record, _prefix, null, null);
|
||||
context.AddEditor(new TemplateViewModel(part.Record, _prefix));
|
||||
context.AddEditor(new TemplateViewModel(part.Record, _prefix) { TemplateName = _templateName });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac\Autofac.Integration.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AutofacContrib.DynamicProxy2, Version=1.4.4.565, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac-contrib\AutofacContrib.DynamicProxy2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Castle.Core, Version=1.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\Castle Windsor 2.0\bin\Castle.Core.dll</HintPath>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Orchard.Localization;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security.Permissions;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
@@ -19,7 +20,7 @@ namespace Orchard.Security {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IUser CurrentUser { get; set; }
|
||||
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public bool Authorize(Permission permission, LocalizedString message) {
|
||||
|
||||
@@ -1,24 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Module=Autofac.Builder.Module;
|
||||
using Autofac;
|
||||
using AutofacContrib.DynamicProxy2;
|
||||
using Castle.Core.Interceptor;
|
||||
using Module = Autofac.Builder.Module;
|
||||
|
||||
namespace Orchard.Security {
|
||||
public class SecurityModule : Module {
|
||||
protected override void AttachToComponentRegistration(Autofac.IContainer container, Autofac.IComponentRegistration registration) {
|
||||
|
||||
var userProperty = FindUserProperty(registration.Descriptor.BestKnownImplementationType);
|
||||
|
||||
if (userProperty != null) {
|
||||
registration.Activated += (sender, e) => {
|
||||
var authenticationService = e.Context.Resolve<IAuthenticationService>();
|
||||
var currentUser = authenticationService.GetAuthenticatedUser();
|
||||
userProperty.SetValue(e.Instance, currentUser, null);
|
||||
};
|
||||
public class SecurityModule : Module, IComponentInterceptorProvider {
|
||||
public IEnumerable<Service> GetInterceptorServices(IComponentDescriptor descriptor) {
|
||||
var property = FindProperty(descriptor.BestKnownImplementationType);
|
||||
if (property != null) {
|
||||
if (property.GetGetMethod(true).IsVirtual == false) {
|
||||
throw new ApplicationException(string.Format("CurrentUser property must be virtual on class {0}", descriptor.BestKnownImplementationType.FullName));
|
||||
}
|
||||
yield return new TypedService(typeof(ISecurityModuleInterceptor));
|
||||
}
|
||||
}
|
||||
|
||||
private static PropertyInfo FindUserProperty(Type type) {
|
||||
return type.GetProperty("CurrentUser", typeof (IUser));
|
||||
private static PropertyInfo FindProperty(Type type) {
|
||||
return type.GetProperty("CurrentUser",
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
|
||||
null,
|
||||
typeof(IUser),
|
||||
new Type[0],
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
public interface ISecurityModuleInterceptor : IInterceptor, IDependency {
|
||||
|
||||
}
|
||||
|
||||
public class SecurityModuleInterceptor : ISecurityModuleInterceptor {
|
||||
private readonly IAuthenticationService _authenticationService;
|
||||
|
||||
public SecurityModuleInterceptor(IAuthenticationService authenticationService) {
|
||||
_authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
public void Intercept(IInvocation invocation) {
|
||||
if (invocation.Method.ReturnType == typeof(IUser) && invocation.Method.Name == "get_CurrentUser") {
|
||||
invocation.ReturnValue = _authenticationService.GetAuthenticatedUser();
|
||||
}
|
||||
else {
|
||||
invocation.Proceed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Autofac;
|
||||
using AutofacContrib.DynamicProxy2;
|
||||
using Castle.Core.Interceptor;
|
||||
using Orchard.Security;
|
||||
using Module = Autofac.Builder.Module;
|
||||
|
||||
namespace Orchard.Settings {
|
||||
public class SettingsModule : Module {
|
||||
protected override void AttachToComponentRegistration(Autofac.IContainer container, Autofac.IComponentRegistration registration) {
|
||||
|
||||
var siteProperty = FindSiteProperty(registration.Descriptor.BestKnownImplementationType);
|
||||
|
||||
if (siteProperty != null) {
|
||||
registration.Activated += (sender, e) => {
|
||||
var siteService = e.Context.Resolve<ISiteService>();
|
||||
var currentSite = siteService.GetSiteSettings();
|
||||
siteProperty.SetValue(e.Instance, currentSite, null);
|
||||
};
|
||||
public class SettingsModule : Module, IComponentInterceptorProvider {
|
||||
public IEnumerable<Service> GetInterceptorServices(IComponentDescriptor descriptor) {
|
||||
var property = FindProperty(descriptor.BestKnownImplementationType);
|
||||
if (property != null) {
|
||||
if (property.GetGetMethod(true).IsVirtual == false) {
|
||||
throw new ApplicationException(string.Format("CurrentSite property must be virtual on class {0}", descriptor.BestKnownImplementationType.FullName));
|
||||
}
|
||||
yield return new TypedService(typeof(ISettingsModuleInterceptor));
|
||||
}
|
||||
}
|
||||
|
||||
private static PropertyInfo FindSiteProperty(Type type) {
|
||||
return type.GetProperty("CurrentSite", typeof(ISite));
|
||||
private static PropertyInfo FindProperty(Type type) {
|
||||
return type.GetProperty("CurrentSite",
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
|
||||
null,
|
||||
typeof(ISite),
|
||||
new Type[0],
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
public interface ISettingsModuleInterceptor : IInterceptor, IDependency {
|
||||
|
||||
}
|
||||
|
||||
public class SettingsModuleInterceptor : ISettingsModuleInterceptor {
|
||||
private readonly ISiteService _siteService;
|
||||
|
||||
public SettingsModuleInterceptor(ISiteService siteService) {
|
||||
_siteService = siteService;
|
||||
}
|
||||
|
||||
public void Intercept(IInvocation invocation) {
|
||||
if (invocation.Method.ReturnType == typeof(ISite) && invocation.Method.Name == "get_CurrentSite") {
|
||||
invocation.ReturnValue = _siteService.GetSiteSettings();
|
||||
}
|
||||
else {
|
||||
invocation.Proceed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Orchard.UI.Navigation {
|
||||
_authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
public IUser CurrentUser { get; set; }
|
||||
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
|
||||
|
||||
public IEnumerable<MenuItem> BuildMenu(string menuName) {
|
||||
return Reduce(Merge(AllSources(menuName))).ToArray();
|
||||
|
||||
Reference in New Issue
Block a user