mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Orchard.Blogs.Extensions;
|
using Orchard.Blogs.Extensions;
|
||||||
using Orchard.Blogs.Models;
|
using Orchard.Blogs.Models;
|
||||||
using Orchard.Blogs.Services;
|
using Orchard.Blogs.Services;
|
||||||
@@ -10,6 +12,7 @@ using Orchard.Data;
|
|||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Mvc.Results;
|
using Orchard.Mvc.Results;
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
|
using Orchard.Settings;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
|
|
||||||
namespace Orchard.Blogs.Controllers {
|
namespace Orchard.Blogs.Controllers {
|
||||||
@@ -33,6 +36,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Localizer T { get; set; }
|
private Localizer T { get; set; }
|
||||||
|
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||||
|
|
||||||
public ActionResult Create() {
|
public ActionResult Create() {
|
||||||
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
||||||
@@ -100,12 +104,17 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
var model = new BlogEditViewModel {
|
var model = new BlogEditViewModel {
|
||||||
Blog = _services.ContentManager.UpdateEditorModel(blog, this)
|
Blog = _services.ContentManager.UpdateEditorModel(blog, this),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return View(model);
|
return View(model);
|
||||||
|
|
||||||
|
string setAsHomePage = input["PromoteToHomePage"];
|
||||||
|
if (!String.IsNullOrEmpty(setAsHomePage) && !setAsHomePage.Equals("false")) {
|
||||||
|
CurrentSite.HomePage = "BlogHomePageProvider;" + model.Blog.Item.Id;
|
||||||
|
}
|
||||||
|
|
||||||
_notifier.Information(T("Blog information updated"));
|
_notifier.Information(T("Blog information updated"));
|
||||||
|
|
||||||
return Redirect(Url.BlogsForAdmin());
|
return Redirect(Url.BlogsForAdmin());
|
||||||
|
@@ -85,6 +85,7 @@
|
|||||||
<Compile Include="Permissions.cs" />
|
<Compile Include="Permissions.cs" />
|
||||||
<Compile Include="Routing\IsArchiveConstraint.cs" />
|
<Compile Include="Routing\IsArchiveConstraint.cs" />
|
||||||
<Compile Include="Routing\IsBlogConstraint.cs" />
|
<Compile Include="Routing\IsBlogConstraint.cs" />
|
||||||
|
<Compile Include="Services\BlogHomePageProvider.cs" />
|
||||||
<Compile Include="Services\BlogService.cs" />
|
<Compile Include="Services\BlogService.cs" />
|
||||||
<Compile Include="Controllers\BlogController.cs" />
|
<Compile Include="Controllers\BlogController.cs" />
|
||||||
<Compile Include="Models\Blog.cs" />
|
<Compile Include="Models\Blog.cs" />
|
||||||
|
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
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 {
|
||||||
|
public class BlogHomePageProvider : IHomePageProvider {
|
||||||
|
private readonly IBlogService _blogService;
|
||||||
|
private readonly IFeedManager _feedManager;
|
||||||
|
|
||||||
|
public BlogHomePageProvider(IOrchardServices services, IBlogService blogService, IFeedManager feedManager) {
|
||||||
|
Services = services;
|
||||||
|
_feedManager = feedManager;
|
||||||
|
_blogService = blogService;
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
if (blog == null)
|
||||||
|
return new NotFoundResult();
|
||||||
|
|
||||||
|
var model = new BlogViewModel {
|
||||||
|
Blog = Services.ContentManager.BuildDisplayModel(blog, "Detail")
|
||||||
|
};
|
||||||
|
|
||||||
|
_feedManager.Register(blog);
|
||||||
|
|
||||||
|
return new ViewResult {
|
||||||
|
ViewName = "~/Modules/Orchard.Blogs/Views/Blog/Item.ascx",
|
||||||
|
ViewData = new ViewDataDictionary<BlogViewModel>(model)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@@ -4,5 +4,6 @@ using Orchard.Mvc.ViewModels;
|
|||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
public class BlogEditViewModel : AdminViewModel {
|
public class BlogEditViewModel : AdminViewModel {
|
||||||
public ContentItemViewModel<Blog> Blog { get; set; }
|
public ContentItemViewModel<Blog> Blog { get; set; }
|
||||||
|
public bool PromoteToHomePage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,5 +4,7 @@
|
|||||||
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
||||||
<%=Html.ValidationSummary() %>
|
<%=Html.ValidationSummary() %>
|
||||||
<%=Html.EditorForItem(m => m.Blog) %>
|
<%=Html.EditorForItem(m => m.Blog) %>
|
||||||
|
<%=Html.EditorFor(m => m.PromoteToHomePage) %>
|
||||||
|
<label for="PromoteToHomePage" class="forcheckbox"><%=_Encoded("Set as home page") %></label>
|
||||||
<fieldset><input class="button" type="submit" value="<%=_Encoded("Save") %>" /></fieldset><%
|
<fieldset><input class="button" type="submit" value="<%=_Encoded("Save") %>" /></fieldset><%
|
||||||
} %>
|
} %>
|
Reference in New Issue
Block a user