Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions DNN Platform/Library/Entities/Urls/FriendlyUrlController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information
namespace DotNetNuke.Entities.Urls
{
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Globalization;
using System.Linq;
Expand All @@ -13,6 +14,7 @@ namespace DotNetNuke.Entities.Urls
using System.Web;
using System.Web.UI.WebControls;


using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Data;
Expand All @@ -30,9 +32,12 @@ public class FriendlyUrlController
private const string DisableMobileRedirectQueryStringName = "nomo";

// google uses the same name nomo=1 means do not redirect to mobile
private const string MobileViewSiteCookieName = "dnn_IsMobile";
private const string DisableMobileViewCookieName = "dnn_NoMobile";
// set the web.config AppSettings for the mobile view cookie name
private static readonly string MobileViewSiteCookieName = ConfigurationManager.AppSettings[name: "MobileViewSiteCookieName"] ?? "dnn_IsMobile";
private static readonly string DisableMobileViewCookieName = ConfigurationManager.AppSettings[name: "DisableMobileViewSiteCookieName"] ?? "dnn_NoMobile";


// <summary>Gets the Friendly URL Settings for the given portal.</summary>
public static FriendlyUrlSettings GetCurrentSettings(int portalId)
{
return new FriendlyUrlSettings(portalId);
Expand Down Expand Up @@ -917,6 +922,7 @@ public static string ValidateUrl(string cleanUrl, int validateUrlForTabId, Porta
internal static bool CanUseMobileDevice(HttpRequest request, HttpResponse response)
{
var canUseMobileDevice = true;
var cn = new FriendlyUrlController();
int val;
if (int.TryParse(request.QueryString[DisableMobileRedirectQueryStringName], out val))
{
Expand All @@ -926,6 +932,7 @@ internal static bool CanUseMobileDevice(HttpRequest request, HttpResponse respon
// no, can't do it
canUseMobileDevice = false;
var cookie = new HttpCookie(DisableMobileViewCookieName)

{
Path = !string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/",
};
Expand All @@ -935,10 +942,12 @@ internal static bool CanUseMobileDevice(HttpRequest request, HttpResponse respon
{
// check for disable mobile view cookie name
var cookie = request.Cookies[DisableMobileViewCookieName];

if (cookie != null)
{
// if exists, expire cookie to allow redirect
cookie = new HttpCookie(DisableMobileViewCookieName)

{
Expires = DateTime.Now.AddMinutes(-1),
Path = !string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/",
Expand All @@ -959,6 +968,7 @@ internal static bool CanUseMobileDevice(HttpRequest request, HttpResponse respon
{
// look for disable mobile view cookie
var cookie = request.Cookies[DisableMobileViewCookieName];

if (cookie != null)
{
canUseMobileDevice = false;
Expand Down Expand Up @@ -1010,7 +1020,8 @@ private static void CheckCharsForReplace(FriendlyUrlOptions options, ref string
return;
}

if (ch != " ") // if not replacing spaces, which are implied
// if not replacing spaces, which are implied
if (ch != " ")
{
replacedUnwantedChars = true;
}
Expand All @@ -1037,7 +1048,8 @@ private static bool ValidateUrl(string url, int validateUrlForTabId, PortalSetti
isUnique = tabId == -1 || tabId == validateUrlForTabId;
}

if (isUnique) // check whether have a tab which use the url.
// check whether have a tab which use the url.
if (isUnique)
{
var friendlyUrlSettings = GetCurrentSettings(settings.PortalId);
var tabs = TabController.Instance.GetTabsByPortal(settings.PortalId).AsList();
Expand Down
9 changes: 9 additions & 0 deletions DNN Platform/Website/Install/Config/09.07.02.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<configuration>
<nodes configfile="Web.config">
<!-- Add mobile view cookie names setting-->
<node path="/configuration/appSettings" action="update" key="key" collision="ignore">
<add key="MobileViewSiteCookieName" value="dnn_IsMobile" />
<add key="DisableMobileViewSiteCookieName" value="dnn_NoMobile" />
</node>
</nodes>
</configuration>
2 changes: 2 additions & 0 deletions DNN Platform/Website/development.config
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
<add key="loginUrl" value="~/Login.aspx" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
<add key="ImprovementProgram.Endpoint" value="https://dev.dnnapi.com/beacon" />
<add key="MobileViewSiteCookieName" value="dnn_IsMobile" />
<add key="DisableMobileViewSiteCookieName" value="dnn_NoMobile" />
</appSettings>

<system.web.webPages.razor>
Expand Down
2 changes: 2 additions & 0 deletions DNN Platform/Website/release.config
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
<add key="loginUrl" value="~/Login.aspx" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
<add key="ImprovementProgram.Endpoint" value="https://dnnapi.com/beacon" />
<add key="MobileViewSiteCookieName" value="dnn_IsMobile" />
<add key="DisableMobileViewSiteCookieName" value="dnn_NoMobile" />
</appSettings>

<system.web.webPages.razor>
Expand Down