Skip to content

Commit ba958c9

Browse files
committed
#2030 Added a setting ('commonsettings.bbcodeeditoropenlinksinnewwindow') indicating whether BBCode Editor should generate URL with "target=_blank" (new window).
1 parent cf11d04 commit ba958c9

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

src/Libraries/Nop.Core/Domain/Common/CommonSettings.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ public CommonSettings()
1111
IgnoreLogWordlist = new List<string>();
1212
}
1313

14+
15+
/// <summary>
16+
/// Gets or sets a value indicating whether the contacts form should have "Subject"
17+
/// </summary>
1418
public bool SubjectFieldOnContactUsForm { get; set; }
19+
/// <summary>
20+
/// Gets or sets a value indicating whether the contacts form should use system email
21+
/// </summary>
1522
public bool UseSystemEmailForContactUsForm { get; set; }
1623

24+
/// <summary>
25+
/// Gets or sets a value indicating whether stored procedures are enabled (should be used if possible)
26+
/// </summary>
1727
public bool UseStoredProceduresIfSupported { get; set; }
1828

1929
/// <summary>
@@ -76,5 +86,10 @@ public CommonSettings()
7686
/// Gets or sets ignore words (phrases) to be ignored when logging errors/messages
7787
/// </summary>
7888
public List<string> IgnoreLogWordlist { get; set; }
89+
90+
/// <summary>
91+
/// Gets or sets a value indicating whether links generated by BBCode Editor should be opened in a new window
92+
/// </summary>
93+
public bool BbcodeEditorOpenLinksInNewWindow { get; set; }
7994
}
8095
}

src/Libraries/Nop.Core/Html/BBCodeHelper.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Text.RegularExpressions;
3+
using Nop.Core.Domain.Common;
34
using Nop.Core.Html.CodeFormatter;
5+
using Nop.Core.Infrastructure;
46

57
namespace Nop.Core.Html
68
{
@@ -62,13 +64,14 @@ public static string FormatText(string text, bool replaceBold, bool replaceItali
6264

6365
if (replaceUrl)
6466
{
67+
var newWindow = EngineContext.Current.Resolve<CommonSettings>().BbcodeEditorOpenLinksInNewWindow;
6568
// format the url tags: [url=http://www.nopCommerce.com]my site[/url]
6669
// becomes: <a href="http://www.nopCommerce.com">my site</a>
67-
text = regexUrl1.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$2</a>");
70+
text = regexUrl1.Replace(text, string.Format("<a href=\"$1\" rel=\"nofollow\"{0}>$2</a>", newWindow ? " target=_blank" : ""));
6871

6972
// format the url tags: [url]http://www.nopCommerce.com[/url]
7073
// becomes: <a href="http://www.nopCommerce.com">http://www.nopCommerce.com</a>
71-
text = regexUrl2.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$1</a>");
74+
text = regexUrl2.Replace(text, string.Format("<a href=\"$1\" rel=\"nofollow\"{0}>$1</a>", newWindow ? " target=_blank" : ""));
7275
}
7376

7477
if (replaceQuote)

src/Libraries/Nop.Services/Installation/CodeFirstInstallationService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5766,7 +5766,8 @@ protected virtual void InstallSettings()
57665766
Log404Errors = true,
57675767
BreadcrumbDelimiter = "/",
57685768
RenderXuaCompatible = false,
5769-
XuaCompatibleValue = "IE=edge"
5769+
XuaCompatibleValue = "IE=edge",
5770+
BbcodeEditorOpenLinksInNewWindow = false
57705771
});
57715772

57725773
settingService.SaveSetting(new SeoSettings

upgradescripts/3.80-the next version/upgrade.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,4 +3710,12 @@ BEGIN
37103710
INSERT [Setting] ([Name], [Value], [StoreId])
37113711
VALUES (N'shippingsettings.considerassociatedproductsdimensions', N'True', 0)
37123712
END
3713+
GO
3714+
3715+
--new setting
3716+
IF NOT EXISTS (SELECT 1 FROM [Setting] WHERE [name] = N'commonsettings.bbcodeeditoropenlinksinnewwindow')
3717+
BEGIN
3718+
INSERT [Setting] ([Name], [Value], [StoreId])
3719+
VALUES (N'commonsettings.bbcodeeditoropenlinksinnewwindow', N'false', 0)
3720+
END
37133721
GO

0 commit comments

Comments
 (0)