mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
- Blogs: Create needed the tag aspect, also removing forms from individual aspect editors.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043112
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Orchard.Core.Settings.Models;
|
using System.Linq;
|
||||||
|
using Orchard.Core.Settings.Models;
|
||||||
using Orchard.Core.Settings.Records;
|
using Orchard.Core.Settings.Records;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
@@ -23,7 +24,7 @@ namespace Orchard.Core.Settings.Services {
|
|||||||
|
|
||||||
public ISite GetSiteSettings() {
|
public ISite GetSiteSettings() {
|
||||||
string applicationName = HttpContext.Current.Request.ApplicationPath;
|
string applicationName = HttpContext.Current.Request.ApplicationPath;
|
||||||
SiteSettingsRecord record = _siteSettingsRepository.Get(x => x.SiteUrl == applicationName);
|
SiteSettingsRecord record = _siteSettingsRepository.Fetch(x => x.SiteUrl == applicationName).FirstOrDefault();
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
ISite site = _contentManager.Create<SiteSettings>("site", item => {
|
ISite site = _contentManager.Create<SiteSettings>("site", item => {
|
||||||
item.Record.SiteUrl = applicationName;
|
item.Record.SiteUrl = applicationName;
|
||||||
|
@@ -70,7 +70,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
if (blog == null)
|
if (blog == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
return View(new CreateBlogPostViewModel { Blog = blog });
|
return View(new CreateBlogPostViewModel { Blog = blog, ItemView = _contentManager.GetEditors(_contentManager.New("blogpost"), null) });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@@ -84,10 +84,13 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
if (blog == null)
|
if (blog == null)
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (ModelState.IsValid == false) {
|
||||||
|
model.ItemView = _contentManager.UpdateEditors(_contentManager.New("blogpost"), null, this);
|
||||||
return View(model);
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
BlogPost blogPost = _blogPostService.Create(model.ToCreateBlogPostParams(blog));
|
BlogPost blogPost = _blogPostService.Create(model.ToCreateBlogPostParams(blog));
|
||||||
|
model.ItemView = _contentManager.UpdateEditors(blogPost, null, this);
|
||||||
|
|
||||||
//TEMP: (erikpo) ensure information has committed for this record
|
//TEMP: (erikpo) ensure information has committed for this record
|
||||||
var session = _sessionLocator.For(typeof(BlogPostRecord));
|
var session = _sessionLocator.For(typeof(BlogPostRecord));
|
||||||
@@ -136,8 +139,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
model.ItemView = _contentManager.UpdateEditors(model.Post.ContentItem, null, this);
|
model.ItemView = _contentManager.UpdateEditors(model.Post.ContentItem, null, this);
|
||||||
|
|
||||||
IValueProvider values = input.ToValueProvider();
|
IValueProvider values = input.ToValueProvider();
|
||||||
if (!TryUpdateModel(model, values))
|
TryUpdateModel(model, values);
|
||||||
return View(model);
|
|
||||||
|
|
||||||
_notifier.Information(T("Blog post information updated"));
|
_notifier.Information(T("Blog post information updated"));
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Web.Routing;
|
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Models;
|
using Orchard.Models;
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using Orchard.Blogs.Models;
|
using Orchard.Blogs.Models;
|
||||||
|
using Orchard.Models.ViewModels;
|
||||||
using Orchard.Mvc.ViewModels;
|
using Orchard.Mvc.ViewModels;
|
||||||
|
|
||||||
namespace Orchard.Blogs.ViewModels {
|
namespace Orchard.Blogs.ViewModels {
|
||||||
@@ -18,5 +19,7 @@ namespace Orchard.Blogs.ViewModels {
|
|||||||
public string Slug { get; set; }
|
public string Slug { get; set; }
|
||||||
|
|
||||||
public DateTime? Published { get; set; }
|
public DateTime? Published { get; set; }
|
||||||
|
|
||||||
|
public ItemEditorViewModel ItemView { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -9,5 +9,13 @@
|
|||||||
<%using (Html.BeginForm()) { %>
|
<%using (Html.BeginForm()) { %>
|
||||||
<%= Html.ValidationSummary() %>
|
<%= Html.ValidationSummary() %>
|
||||||
<%= Html.EditorForModel() %>
|
<%= Html.EditorForModel() %>
|
||||||
|
<%foreach (var editor in Model.ItemView.Editors) { %>
|
||||||
|
<%-- TODO: why is Body in editors? --%>
|
||||||
|
<%-- TODO: because any content type using the body editor doesn't need
|
||||||
|
to re-implement the rich editor, media extensions, format filter chain selection, etc --%>
|
||||||
|
<% if (!String.Equals(editor.Prefix, "Body")) { %>
|
||||||
|
<%=Html.EditorFor(m=>editor.Model, editor.TemplateName, editor.Prefix) %>
|
||||||
|
<% } %>
|
||||||
|
<%} %>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% Html.Include("AdminFoot"); %>
|
<% Html.Include("AdminFoot"); %>
|
@@ -9,7 +9,6 @@
|
|||||||
<%=Html.ValidationSummary() %>
|
<%=Html.ValidationSummary() %>
|
||||||
<%=Html.EditorForModel() %>
|
<%=Html.EditorForModel() %>
|
||||||
<fieldset><input class="button" type="submit" value="Save" /></fieldset>
|
<fieldset><input class="button" type="submit" value="Save" /></fieldset>
|
||||||
<% } %>
|
|
||||||
<%foreach (var editor in Model.ItemView.Editors) { %>
|
<%foreach (var editor in Model.ItemView.Editors) { %>
|
||||||
<%-- TODO: why is Body in editors? --%>
|
<%-- TODO: why is Body in editors? --%>
|
||||||
<%-- TODO: because any content type using the body editor doesn't need
|
<%-- TODO: because any content type using the body editor doesn't need
|
||||||
@@ -18,4 +17,5 @@
|
|||||||
<%=Html.EditorFor(m=>editor.Model, editor.TemplateName, editor.Prefix) %>
|
<%=Html.EditorFor(m=>editor.Model, editor.TemplateName, editor.Prefix) %>
|
||||||
<% } %>
|
<% } %>
|
||||||
<%} %>
|
<%} %>
|
||||||
|
<% } %>
|
||||||
<% Html.Include("AdminFoot"); %>
|
<% Html.Include("AdminFoot"); %>
|
@@ -1,5 +1,6 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HasComments>" %>
|
||||||
<%@ Import Namespace="Orchard.Comments.Models"%>
|
<%@ Import Namespace="Orchard.Comments.Models"%>
|
||||||
|
<% if (Model.ContentItem.Id != 0) { %>
|
||||||
<h3><%= Model.Comments.Count() %> Comments</h3>
|
<h3><%= Model.Comments.Count() %> Comments</h3>
|
||||||
<ol>
|
<ol>
|
||||||
<% foreach (var comment in Model.Comments) {%>
|
<% foreach (var comment in Model.Comments) {%>
|
||||||
@@ -21,3 +22,4 @@
|
|||||||
<% } else { %>
|
<% } else { %>
|
||||||
<%= Html.ActionLink("Close Comments for this content", "Close", new { Area="Orchard.Comments", Controller="Admin", returnUrl = Context.Request.Url, commentedItemId = Model.ContentItem.Id })%>
|
<%= Html.ActionLink("Close Comments for this content", "Close", new { Area="Orchard.Comments", Controller="Admin", returnUrl = Context.Request.Url, commentedItemId = Model.ContentItem.Id })%>
|
||||||
<% } %> | <%=Html.ActionLink("Go to comments management for this post", "Details", new {Area="Orchard.Comments", Controller="Admin", id = Model.ContentItem.Id, returnUrl = Context.Request.Url}) %>
|
<% } %> | <%=Html.ActionLink("Go to comments management for this post", "Details", new {Area="Orchard.Comments", Controller="Admin", id = Model.ContentItem.Id, returnUrl = Context.Request.Url}) %>
|
||||||
|
<% } %>
|
@@ -1,9 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Models;
|
using Orchard.Models;
|
||||||
using Orchard.Models.Driver;
|
using Orchard.Models.Driver;
|
||||||
using Orchard.Models.ViewModels;
|
using Orchard.Models.ViewModels;
|
||||||
|
using Orchard.Tags.Services;
|
||||||
|
|
||||||
namespace Orchard.Tags.Models {
|
namespace Orchard.Tags.Models {
|
||||||
public class HasTags : ContentPart {
|
public class HasTags : ContentPart {
|
||||||
@@ -19,10 +21,12 @@ namespace Orchard.Tags.Models {
|
|||||||
public class HasTagsProvider : ContentProvider {
|
public class HasTagsProvider : ContentProvider {
|
||||||
private readonly IRepository<Tag> _tagsRepository;
|
private readonly IRepository<Tag> _tagsRepository;
|
||||||
private readonly IRepository<TagsContentItems> _tagsContentItemsRepository;
|
private readonly IRepository<TagsContentItems> _tagsContentItemsRepository;
|
||||||
|
private readonly ITagService _tagService;
|
||||||
|
|
||||||
public HasTagsProvider(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository) {
|
public HasTagsProvider(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository, ITagService tagService) {
|
||||||
_tagsRepository = tagsRepository;
|
_tagsRepository = tagsRepository;
|
||||||
_tagsContentItemsRepository = tagsContentItemsRepository;
|
_tagsContentItemsRepository = tagsContentItemsRepository;
|
||||||
|
_tagService = tagService;
|
||||||
Filters.Add(new ActivatingFilter<HasTags>("sandboxpage"));
|
Filters.Add(new ActivatingFilter<HasTags>("sandboxpage"));
|
||||||
Filters.Add(new ActivatingFilter<HasTags>("blogpost"));
|
Filters.Add(new ActivatingFilter<HasTags>("blogpost"));
|
||||||
|
|
||||||
@@ -43,6 +47,12 @@ namespace Orchard.Tags.Models {
|
|||||||
if (context.ContentItem.Has<HasTags>() == false) {
|
if (context.ContentItem.Has<HasTags>() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TagsViewModel viewModel = new TagsViewModel();
|
||||||
|
context.Updater.TryUpdateModel(viewModel, String.Empty, null, null);
|
||||||
|
List<string> tagNames = 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>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,5 +69,23 @@ namespace Orchard.Tags.Models {
|
|||||||
tags.CurrentTags.Add(tag);
|
tags.CurrentTags.Add(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<string> ParseCommaSeparatedTagNames(string tags) {
|
||||||
|
if (String.IsNullOrEmpty(tags)) {
|
||||||
|
return new List<string>();
|
||||||
|
}
|
||||||
|
IEnumerable<string> tagNames = tags.Split(',');
|
||||||
|
List<string> sanitizedTagNames = new List<string>();
|
||||||
|
foreach (var tagName in tagNames) {
|
||||||
|
if (!String.IsNullOrEmpty(tagName)) {
|
||||||
|
sanitizedTagNames.Add(tagName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sanitizedTagNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TagsViewModel {
|
||||||
|
public string Tags { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,12 +2,8 @@
|
|||||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||||
<%@ Import Namespace="Orchard.Tags.Models"%>
|
<%@ Import Namespace="Orchard.Tags.Models"%>
|
||||||
<h3>Tags</h3>
|
<h3>Tags</h3>
|
||||||
<% Html.BeginForm("Update", "Home", new { area = "Orchard.Tags" }); %>
|
|
||||||
<%= Html.ValidationSummary() %>
|
|
||||||
<div class="yui-g">
|
<div class="yui-g">
|
||||||
<h2 class="separator">Edit Tags</h2>
|
<h2 class="separator">Edit Tags</h2>
|
||||||
<%= Html.Hidden("TaggedContentId", Model.ContentItem.Id) %>
|
|
||||||
<%= Html.Hidden("ReturnUrl", Context.Request.Url) %>
|
|
||||||
<%
|
<%
|
||||||
string tags = "";
|
string tags = "";
|
||||||
foreach (var tag in Model.CurrentTags) {
|
foreach (var tag in Model.CurrentTags) {
|
||||||
@@ -16,9 +12,7 @@
|
|||||||
} %>
|
} %>
|
||||||
<ol>
|
<ol>
|
||||||
<li>
|
<li>
|
||||||
<input id="tags" class="inputText inputTextLarge" name="tags" type="text" value="<%=tags %>" />
|
<input id="Tags" class="inputText inputTextLarge" name="Tags" type="text" value="<%=tags %>" />
|
||||||
<input type="submit" class="button" name="submit.Add" value="Add" />
|
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<% Html.EndForm(); %>
|
|
Reference in New Issue
Block a user