Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console error displayed for missing gif file associated with missing language flag images #3384

Merged
merged 4 commits into from
Dec 9, 2019
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System;
using System.Collections.Specialized;
using System.Globalization;
using System.IO;
using System.Web;

using DotNetNuke.Common;
Expand Down Expand Up @@ -56,6 +57,8 @@ public LanguageTokenReplace()

public class LanguagePropertyAccess : IPropertyAccess
{
private const string FlagIconPhysicalLocation = @"~\images\Flags";
private const string NonExistingFlagIconFileName = "none.gif";
private readonly PortalSettings objPortal;
public LanguageTokenReplace objParent;

Expand All @@ -74,7 +77,8 @@ public string GetProperty(string propertyName, string format, CultureInfo format
case "url":
return NewUrl(objParent.Language);
case "flagsrc":
return "/" + objParent.Language + ".gif";
var mappedGifFile = PathUtils.Instance.MapPath($@"{FlagIconPhysicalLocation}\{objParent.Language}.gif");
return File.Exists(mappedGifFile) ? $"/{objParent.Language}.gif" : $@"/{NonExistingFlagIconFileName}";
case "selected":
return (objParent.Language == CultureInfo.CurrentCulture.Name).ToString();
case "label":
Expand Down