Skip to content

Commit 37a5cbc

Browse files
committed
Topics: added IsPublished, ShortTitle (link text) and Intro (teaser) properties.
1 parent 08663b0 commit 37a5cbc

File tree

19 files changed

+229
-86
lines changed

19 files changed

+229
-86
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* #1144 Enable multi server search index
77
* Made Topic ACL enabled
88
* Implemented paging & filtering for Topic grid
9+
* Topics: added **IsPublished**, **Short Title** (link text) and **Intro** (teaser) properties.
910
* New security option: Use invisible reCAPTCHA
1011
* **BeezUp**:
1112
* #1459 Add option to only submit one category name per product

src/Libraries/SmartStore.Core/Extensions/EnumerableExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ join entity in source on id equals entity.Id
286286
return sorted;
287287
}
288288

289+
public static string StrJoin(this IEnumerable<string> source, string separator)
290+
{
291+
return string.Join(separator, source);
292+
}
293+
289294
#endregion
290295

291296
#region Multimap

src/Libraries/SmartStore.Data/Migrations/MigrationsConfiguration.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,18 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
327327
"Unsichtbaren reCAPTCHA verwenden",
328328
"Does not require the user to click on a checkbox, instead it is invoked directly when the user submits a form. By default only the most suspicious traffic will be prompted to solve a captcha.",
329329
"Der Benutzer muss nicht auf ein Kontrollkästchen klicken, sondern die Validierung erfolgt direkt beim Absenden eines Formulars. Nur bei 'verdächtigem' Traffic wird der Benutzer aufgefordert, ein Captcha zu lösen.");
330+
331+
builder.AddOrUpdate("Admin.ContentManagement.Topics.Fields.ShortTitle",
332+
"Short title",
333+
"Kurztitel",
334+
"Optional. Used as link text. If empty, 'Title' sets the link text.",
335+
"Optional. Wird u.A. als Linktext verwendet. Wenn leer, stellt 'Titel' den Linktext.");
336+
337+
builder.AddOrUpdate("Admin.ContentManagement.Topics.Fields.Intro",
338+
"Intro",
339+
"Intro",
340+
"Optional. Short introduction / teaser.",
341+
"Optional. Einleitung / Teaser.");
330342
}
331343
}
332344
}

src/Libraries/SmartStore.Data/Setup/SeedData/InvariantSeedData.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3891,7 +3891,7 @@ public IList<Topic> Topics()
38913891
SystemName = "ContactUs",
38923892
IncludeInSitemap = false,
38933893
IsPasswordProtected = false,
3894-
Title = "",
3894+
Title = "Contact us",
38953895
Body = "<p>Put your contact information here. You can edit this in the admin site.</p>"
38963896
},
38973897
new Topic
@@ -3923,6 +3923,7 @@ public IList<Topic> Topics()
39233923
SystemName = "PrivacyInfo",
39243924
IncludeInSitemap = false,
39253925
IsPasswordProtected = false,
3926+
ShortTitle = "Privacy",
39263927
Title = "Privacy policy",
39273928
Body = "<p><strong></strong></p>"
39283929
},

src/Libraries/SmartStore.Services/Topics/TopicService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected virtual IQueryable<Topic> BuildTopicsQuery(string systemName, int stor
7878
var entityName = nameof(Topic);
7979
var joinApplied = false;
8080

81-
var query = _topicRepository.Table;
81+
var query = _topicRepository.Table.Where(x => showHidden || x.IsPublished);
8282

8383
if (systemName.HasValue())
8484
{

src/Presentation/SmartStore.Web.Framework/Extensions/UrlHelperExtensions.cs

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using SmartStore.Services.Seo;
99
using SmartStore.Services.Security;
1010
using System.Web.Routing;
11+
using System;
12+
using SmartStore.Services.Localization;
1113

1214
namespace SmartStore.Web.Framework
1315
{
@@ -54,21 +56,33 @@ public static string Picture(this UrlHelper urlHelper, Picture picture, int targ
5456

5557
public static string TopicUrl(this UrlHelper urlHelper, string systemName, bool popup = false)
5658
{
57-
var seName = TopicSeName(urlHelper, systemName);
59+
var linkData = GetTopicLinkData(systemName);
5860

59-
if (seName.Length == 0)
61+
if (linkData == null)
6062
{
6163
return string.Empty;
6264
}
6365

64-
var routeValues = new RouteValueDictionary { ["SeName"] = seName };
66+
var routeValues = new RouteValueDictionary { ["SeName"] = linkData.SeName };
6567
if (popup)
6668
routeValues["popup"] = true;
6769

6870
return urlHelper.RouteUrl("Topic", routeValues);
6971
}
7072

7173
public static string TopicSeName(this UrlHelper urlHelper, string systemName)
74+
{
75+
var data = GetTopicLinkData(systemName);
76+
return data?.SeName.EmptyNull();
77+
}
78+
79+
public static string TopicLinkText(this UrlHelper urlHelper, string systemName)
80+
{
81+
var data = GetTopicLinkData(systemName);
82+
return data?.LinkText.EmptyNull();
83+
}
84+
85+
private static TopicLinkData GetTopicLinkData(string systemName)
7286
{
7387
var container = EngineContext.Current.ContainerManager;
7488

@@ -77,15 +91,33 @@ public static string TopicSeName(this UrlHelper urlHelper, string systemName)
7791
var cache = container.Resolve<ICacheManager>();
7892

7993
var cacheKey = string.Format(FrameworkCacheConsumer.TOPIC_SENAME_BY_SYSTEMNAME, systemName.ToLower(), workContext.WorkingLanguage.Id, storeId, workContext.CurrentCustomer.GetRolesIdent());
80-
var seName = cache.Get(cacheKey, () =>
94+
var data = cache.Get(cacheKey, () =>
8195
{
8296
var topicService = container.Resolve<ITopicService>();
8397
var topic = topicService.GetTopicBySystemName(systemName, storeId, true);
84-
85-
return topic?.GetSeName() ?? string.Empty;
98+
99+
if (topic == null || !topic.IsPublished)
100+
return null;
101+
102+
var seName = topic.GetSeName();
103+
if (seName.IsEmpty())
104+
return null;
105+
106+
return new TopicLinkData
107+
{
108+
SeName = seName,
109+
LinkText = topic.GetLocalized(x => x.ShortTitle).Value.NullEmpty() ?? topic.GetLocalized(x => x.Title).Value.NullEmpty() ?? seName
110+
};
86111
});
87112

88-
return seName;
113+
return data;
89114
}
90115
}
116+
117+
[Serializable]
118+
public class TopicLinkData
119+
{
120+
public string SeName { get; set; }
121+
public string LinkText { get; set; }
122+
}
91123
}

src/Presentation/SmartStore.Web/Administration/Controllers/TopicController.cs

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,15 @@ public void UpdateLocales(Topic topic, TopicModel model)
5353
{
5454
foreach (var localized in model.Locales)
5555
{
56-
_localizedEntityService.SaveLocalizedValue(topic,
57-
x => x.Title,
58-
localized.Title,
59-
localized.LanguageId);
60-
61-
_localizedEntityService.SaveLocalizedValue(topic,
62-
x => x.Body,
63-
localized.Body,
64-
localized.LanguageId);
65-
66-
_localizedEntityService.SaveLocalizedValue(topic,
67-
x => x.MetaKeywords,
68-
localized.MetaKeywords,
69-
localized.LanguageId);
70-
71-
_localizedEntityService.SaveLocalizedValue(topic,
72-
x => x.MetaDescription,
73-
localized.MetaDescription,
74-
localized.LanguageId);
75-
76-
_localizedEntityService.SaveLocalizedValue(topic,
77-
x => x.MetaTitle,
78-
localized.MetaTitle,
79-
localized.LanguageId);
80-
81-
var seName = topic.ValidateSeName(localized.SeName, localized.Title, false);
56+
_localizedEntityService.SaveLocalizedValue(topic, x => x.ShortTitle, localized.ShortTitle, localized.LanguageId);
57+
_localizedEntityService.SaveLocalizedValue(topic, x => x.Title, localized.Title, localized.LanguageId);
58+
_localizedEntityService.SaveLocalizedValue(topic, x => x.Intro, localized.Intro, localized.LanguageId);
59+
_localizedEntityService.SaveLocalizedValue(topic, x => x.Body, localized.Body, localized.LanguageId);
60+
_localizedEntityService.SaveLocalizedValue(topic, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId);
61+
_localizedEntityService.SaveLocalizedValue(topic, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId);
62+
_localizedEntityService.SaveLocalizedValue(topic, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId);
63+
64+
var seName = topic.ValidateSeName(localized.SeName, localized.Title.NullEmpty() ?? localized.ShortTitle, false);
8265
_urlRecordService.SaveSlug(topic, seName, localized.LanguageId);
8366

8467
}
@@ -189,7 +172,7 @@ public ActionResult List(GridCommand command, TopicListModel model)
189172
q2 = q2.Where(x => x.SystemName.Contains(model.SystemName));
190173

191174
if (model.Title.HasValue())
192-
q2 = q2.Where(x => x.Title.Contains(model.Title));
175+
q2 = q2.Where(x => x.Title.Contains(model.Title) || x.ShortTitle.Contains(model.Title));
193176

194177
if (model.RenderAsWidget.HasValue)
195178
q2 = q2.Where(x => x.RenderAsWidget == model.RenderAsWidget.Value);
@@ -297,8 +280,10 @@ public ActionResult Edit(int id)
297280

298281
AddLocales(_languageService, model.Locales, (locale, languageId) =>
299282
{
300-
locale.Title = topic.GetLocalized(x => x.Title, languageId, false, false);
301-
locale.Body = topic.GetLocalized(x => x.Body, languageId, false, false);
283+
locale.ShortTitle = topic.GetLocalized(x => x.ShortTitle, languageId, false, false);
284+
locale.Title = topic.GetLocalized(x => x.Title, languageId, false, false);
285+
locale.Intro = topic.GetLocalized(x => x.Intro, languageId, false, false);
286+
locale.Body = topic.GetLocalized(x => x.Body, languageId, false, false);
302287
locale.MetaKeywords = topic.GetLocalized(x => x.MetaKeywords, languageId, false, false);
303288
locale.MetaDescription = topic.GetLocalized(x => x.MetaDescription, languageId, false, false);
304289
locale.MetaTitle = topic.GetLocalized(x => x.MetaTitle, languageId, false, false);

src/Presentation/SmartStore.Web/Administration/Models/Topics/TopicModel.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,19 @@ public TopicModel()
5656
[AllowHtml]
5757
public string Url { get; set; }
5858

59-
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Title")]
59+
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.ShortTitle")]
60+
[AllowHtml]
61+
public string ShortTitle { get; set; }
62+
63+
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Title")]
6064
[AllowHtml]
6165
public string Title { get; set; }
6266

63-
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Body")]
67+
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Intro")]
68+
[AllowHtml]
69+
public string Intro { get; set; }
70+
71+
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Body")]
6472
[AllowHtml]
6573
public string Body { get; set; }
6674

@@ -103,7 +111,10 @@ public TopicModel()
103111

104112
public bool IsSystemTopic { get; set; }
105113

106-
public IList<SelectListItem> AvailableTitleTags { get; private set; }
114+
[SmartResourceDisplayName("Common.Published")]
115+
public bool IsPublished { get; set; }
116+
117+
public IList<SelectListItem> AvailableTitleTags { get; private set; }
107118

108119
public IList<TopicLocalizedModel> Locales { get; set; }
109120
}
@@ -112,11 +123,19 @@ public class TopicLocalizedModel : ILocalizedModelLocal
112123
{
113124
public int LanguageId { get; set; }
114125

115-
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Title")]
126+
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.ShortTitle")]
127+
[AllowHtml]
128+
public string ShortTitle { get; set; }
129+
130+
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Title")]
116131
[AllowHtml]
117132
public string Title { get; set; }
118133

119-
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Body")]
134+
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Intro")]
135+
[AllowHtml]
136+
public string Intro { get; set; }
137+
138+
[SmartResourceDisplayName("Admin.ContentManagement.Topics.Fields.Body")]
120139
[AllowHtml]
121140
public string Body { get; set; }
122141

0 commit comments

Comments
 (0)