--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-11-15 18:03:48 -08:00
6 changed files with 8 additions and 5 deletions

View File

@@ -9,7 +9,6 @@ using Orchard.Core.Routable.Services;
using Orchard.Core.Routable.ViewModels; using Orchard.Core.Routable.ViewModels;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Services; using Orchard.Services;
using Orchard.UI.Notify;
namespace Orchard.Core.Routable.Drivers { namespace Orchard.Core.Routable.Drivers {
public class RoutePartDriver : ContentPartDriver<RoutePart> { public class RoutePartDriver : ContentPartDriver<RoutePart> {
@@ -82,7 +81,7 @@ namespace Orchard.Core.Routable.Drivers {
if ( slug.StartsWith(".") || slug.EndsWith(".") ) if ( slug.StartsWith(".") || slug.EndsWith(".") )
updater.AddModelError("Routable.Slug", T("The \".\" can't be used around routes.")); updater.AddModelError("Routable.Slug", T("The \".\" can't be used around routes."));
else else
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\". No spaces are allowed (please use dashes or underscores instead).")); updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\". No spaces are allowed (please use dashes or underscores instead)."));
} }
if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null) if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null)

View File

@@ -10,7 +10,7 @@ namespace Orchard.Core.Routable {
table => table table => table
.ContentPartVersionRecord() .ContentPartVersionRecord()
.Column<string>("Title", column => column.WithLength(1024)) .Column<string>("Title", column => column.WithLength(1024))
.Column<string>("Slug") .Column<string>("Slug", column => column.WithLength(1024))
.Column<string>("Path", column => column.WithLength(2048)) .Column<string>("Path", column => column.WithLength(2048))
); );

View File

@@ -3,6 +3,7 @@ using Orchard.ContentManagement.Aspects;
namespace Orchard.Core.Routable.Models { namespace Orchard.Core.Routable.Models {
public class RoutePart : ContentPart<RoutePartRecord>, IRoutableAspect { public class RoutePart : ContentPart<RoutePartRecord>, IRoutableAspect {
public string Title { public string Title {
get { return Record.Title; } get { return Record.Title; }
set { Record.Title = value; } set { Record.Title = value; }

View File

@@ -6,6 +6,7 @@ namespace Orchard.Core.Routable.Models {
[StringLength(1024)] [StringLength(1024)]
public virtual string Title { get; set; } public virtual string Title { get; set; }
[StringLength(1024)]
public virtual string Slug { get; set; } public virtual string Slug { get; set; }
[StringLength(2048)] [StringLength(2048)]

View File

@@ -32,7 +32,7 @@ namespace Orchard.Core.Routable.Services {
return; return;
var slug = model.Title; var slug = model.Title;
var dissallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s]+"); var dissallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""\<\>]+");
slug = dissallowed.Replace(slug, "-"); slug = dissallowed.Replace(slug, "-");
slug = slug.Trim('-'); slug = slug.Trim('-');
@@ -79,7 +79,7 @@ namespace Orchard.Core.Routable.Services {
} }
public bool IsSlugValid(string slug) { public bool IsSlugValid(string slug) {
return String.IsNullOrWhiteSpace(slug) || Regex.IsMatch(slug, @"^[^:?#\[\]@!$&'()*+,;=\s]+$") && !(slug.StartsWith(".") || slug.EndsWith(".")); return String.IsNullOrWhiteSpace(slug) || Regex.IsMatch(slug, @"^[^:?#\[\]@!$&'()*+,;=\s\""\<\>]+$") && !(slug.StartsWith(".") || slug.EndsWith("."));
} }
public bool ProcessSlug(IRoutableAspect part) { public bool ProcessSlug(IRoutableAspect part) {

View File

@@ -8,7 +8,9 @@ namespace Orchard.Core.Routable.ViewModels {
public string ContentType { get; set; } public string ContentType { get; set; }
[Required] [Required]
[StringLength(1024)]
public string Title { get; set; } public string Title { get; set; }
[StringLength(1024)]
public string Slug { get; set; } public string Slug { get; set; }
public int? ContainerId { get; set; } public int? ContainerId { get; set; }
public bool PromoteToHomePage { get; set; } public bool PromoteToHomePage { get; set; }