Fix pages slug to not be case sensitive when used in url

There was one line of code left to be resurrected from the old cms pages module

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045978
This commit is contained in:
rpaquay
2010-01-26 05:03:55 +00:00
parent ac483d511e
commit 1b780e242e

View File

@@ -2,20 +2,18 @@
using System.Web.Mvc; using System.Web.Mvc;
using Orchard.Localization; using Orchard.Localization;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.Mvc.Results;
using Orchard.Pages.Services; using Orchard.Pages.Services;
using Orchard.Pages.ViewModels; using Orchard.Pages.ViewModels;
using Orchard.Security; using Orchard.Security;
namespace Orchard.Pages.Controllers { namespace Orchard.Pages.Controllers {
[ValidateInput(false)] [ValidateInput(false)]
public class PageController : Controller, IUpdateModel { public class PageController : Controller {
private readonly IPageService _pageService; private readonly IPageService _pageService;
private readonly ISlugConstraint _slugConstraint; private readonly ISlugConstraint _slugConstraint;
public PageController( public PageController(IOrchardServices services, IPageService pageService, ISlugConstraint slugConstraint) {
IOrchardServices services,
IPageService pageService,
ISlugConstraint slugConstraint) {
Services = services; Services = services;
_pageService = pageService; _pageService = pageService;
_slugConstraint = slugConstraint; _slugConstraint = slugConstraint;
@@ -29,25 +27,18 @@ namespace Orchard.Pages.Controllers {
if (!Services.Authorizer.Authorize(StandardPermissions.AccessFrontEnd, T("Couldn't view page"))) if (!Services.Authorizer.Authorize(StandardPermissions.AccessFrontEnd, T("Couldn't view page")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
if (slug == null) { var correctedSlug = _slugConstraint.LookupPublishedSlug(slug);
throw new ArgumentNullException("slug"); if (correctedSlug == null)
} return new NotFoundResult();
//var correctedSlug = _slugConstraint.LookupPublishedSlug(pageSlug); var page = _pageService.Get(correctedSlug);
if (page == null)
var page = _pageService.Get(slug); return new NotFoundResult();
var model = new PageViewModel { var model = new PageViewModel {
Page = Services.ContentManager.BuildDisplayModel(page, "Detail") Page = Services.ContentManager.BuildDisplayModel(page, "Detail")
}; };
return View(model); return View(model);
} }
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
}
void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) {
ModelState.AddModelError(key, errorMessage.ToString());
}
} }
} }