mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-24 05:23:33 +08:00
- Fixing more tags related regressions.
- Fixing a bug where tags weren't being applied to new posts. --HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4046035
This commit is contained in:
@@ -62,6 +62,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Services.ContentManager.Create(model.BlogPost.Item.ContentItem, VersionOptions.Draft);
|
Services.ContentManager.Create(model.BlogPost.Item.ContentItem, VersionOptions.Draft);
|
||||||
|
Services.ContentManager.UpdateEditorModel(blogPost, this);
|
||||||
|
|
||||||
// Execute publish command
|
// Execute publish command
|
||||||
switch (Request.Form["Command"]) {
|
switch (Request.Form["Command"]) {
|
||||||
|
@@ -45,7 +45,9 @@ namespace Orchard.Tags.Controllers {
|
|||||||
updater.TryUpdateModel(model, Prefix, null, null);
|
updater.TryUpdateModel(model, Prefix, null, null);
|
||||||
|
|
||||||
var tagNames = TagHelpers.ParseCommaSeparatedTagNames(model.Tags);
|
var tagNames = TagHelpers.ParseCommaSeparatedTagNames(model.Tags);
|
||||||
|
if (part.ContentItem.Id != 0) {
|
||||||
_tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames);
|
_tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames);
|
||||||
|
}
|
||||||
|
|
||||||
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location("primary", "9");
|
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location("primary", "9");
|
||||||
}
|
}
|
||||||
|
@@ -3,8 +3,10 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
|
using Orchard.Security;
|
||||||
using Orchard.Settings;
|
using Orchard.Settings;
|
||||||
using Orchard.Tags.Helpers;
|
using Orchard.Tags.Helpers;
|
||||||
using Orchard.Tags.Services;
|
using Orchard.Tags.Services;
|
||||||
@@ -15,16 +17,20 @@ namespace Orchard.Tags.Controllers {
|
|||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
public class HomeController : Controller {
|
public class HomeController : Controller {
|
||||||
private readonly ITagService _tagService;
|
private readonly ITagService _tagService;
|
||||||
|
private readonly IContentManager _contentManager;
|
||||||
|
private readonly INotifier _notifier;
|
||||||
|
private readonly IAuthorizer _authorizer;
|
||||||
|
|
||||||
public HomeController(ITagService tagService) {
|
public HomeController(ITagService tagService, IAuthorizer authorizer, INotifier notifier, IContentManager contentManager) {
|
||||||
_tagService = tagService;
|
_tagService = tagService;
|
||||||
|
_authorizer = authorizer;
|
||||||
|
_notifier = notifier;
|
||||||
|
_contentManager = contentManager;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IOrchardServices Services { get; set; }
|
|
||||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||||
|
|
||||||
|
|
||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
@@ -35,7 +41,7 @@ namespace Orchard.Tags.Controllers {
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
Services.Notifier.Error(T("Listing tags failed: " + exception.Message));
|
_notifier.Error(T("Listing tags failed: " + exception.Message));
|
||||||
return Index();
|
return Index();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,7 +49,7 @@ namespace Orchard.Tags.Controllers {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Edit(FormCollection input, int taggedContentId, string returnUrl, string newTagName) {
|
public ActionResult Edit(FormCollection input, int taggedContentId, string returnUrl, string newTagName) {
|
||||||
try {
|
try {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
|
if (!_authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
if (!String.IsNullOrEmpty(newTagName)) {
|
if (!String.IsNullOrEmpty(newTagName)) {
|
||||||
foreach (var tagName in TagHelpers.ParseCommaSeparatedTagNames(newTagName)) {
|
foreach (var tagName in TagHelpers.ParseCommaSeparatedTagNames(newTagName)) {
|
||||||
@@ -59,7 +65,7 @@ namespace Orchard.Tags.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
Services.Notifier.Error(T("Editing tags failed: " + exception.Message));
|
_notifier.Error(T("Editing tags failed: " + exception.Message));
|
||||||
if (!String.IsNullOrEmpty(returnUrl)) {
|
if (!String.IsNullOrEmpty(returnUrl)) {
|
||||||
return Redirect(returnUrl);
|
return Redirect(returnUrl);
|
||||||
}
|
}
|
||||||
@@ -70,7 +76,7 @@ namespace Orchard.Tags.Controllers {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Update(string tags, int taggedContentId, string returnUrl) {
|
public ActionResult Update(string tags, int taggedContentId, string returnUrl) {
|
||||||
try {
|
try {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
|
if (!_authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
List<string> tagNames = TagHelpers.ParseCommaSeparatedTagNames(tags);
|
List<string> tagNames = TagHelpers.ParseCommaSeparatedTagNames(tags);
|
||||||
_tagService.UpdateTagsForContentItem(taggedContentId, tagNames);
|
_tagService.UpdateTagsForContentItem(taggedContentId, tagNames);
|
||||||
@@ -80,7 +86,7 @@ namespace Orchard.Tags.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
Services.Notifier.Error(T("Updating tags failed: " + exception.Message));
|
_notifier.Error(T("Updating tags failed: " + exception.Message));
|
||||||
if (!String.IsNullOrEmpty(returnUrl)) {
|
if (!String.IsNullOrEmpty(returnUrl)) {
|
||||||
return Redirect(returnUrl);
|
return Redirect(returnUrl);
|
||||||
}
|
}
|
||||||
@@ -93,7 +99,7 @@ namespace Orchard.Tags.Controllers {
|
|||||||
var tag = _tagService.GetTagByName(tagName);
|
var tag = _tagService.GetTagByName(tagName);
|
||||||
var items =
|
var items =
|
||||||
_tagService.GetTaggedContentItems(tag.Id).Select(
|
_tagService.GetTaggedContentItems(tag.Id).Select(
|
||||||
ic => Services.ContentManager.BuildDisplayModel(ic, "SummaryForSearch"));
|
ic => _contentManager.BuildDisplayModel(ic, "SummaryForSearch"));
|
||||||
|
|
||||||
var viewModel = new TagsSearchViewModel {
|
var viewModel = new TagsSearchViewModel {
|
||||||
TagName = tag.TagName,
|
TagName = tag.TagName,
|
||||||
@@ -103,7 +109,7 @@ namespace Orchard.Tags.Controllers {
|
|||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
Services.Notifier.Error(T("Retrieving tagged items failed: " + exception.Message));
|
_notifier.Error(T("Retrieving tagged items failed: " + exception.Message));
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user