Missing UmbracoSettings change in umbraco.core

IOHelper in umbraco.core
Both related to mvc views in template tree
This commit is contained in:
PerPloug
2012-09-27 06:30:59 -02:00
parent c409cfa421
commit b8b951f094
2 changed files with 82 additions and 0 deletions

View File

@@ -1140,6 +1140,71 @@ namespace Umbraco.Core.Configuration
}
}
/// <summary>
/// Enables MVC, and at the same time disable webform masterpage templates.
/// This ensure views are automaticly created instead of masterpages.
/// Views are display in the tree instead of masterpages and a MVC template editor
/// is used instead of the masterpages editor
/// </summary>
/// <value><c>true</c> if umbraco defaults to using MVC views for templating, otherwise <c>false</c>.</value>
private static bool? _enableMvc;
public static bool EnableMvcSupport
{
get
{
if (_enableMvc == null)
{
try
{
bool enableMvc = false;
string value = GetKey("/settings/templates/enableMvcSupport");
if (value != null)
if (bool.TryParse(value, out enableMvc))
_enableMvc = enableMvc;
}
catch (Exception ex)
{
Trace.WriteLine("Could not load /settings/templates/enableMvcSupport from umbracosettings.config:\r\n {0}",
ex.Message);
_enableMvc = false;
}
}
return _enableMvc == true;
}
}
private static string[] _mvcViewExtensions;
public static string[] MvcViewExtensions
{
get
{
string[] defaultValue = "cshtml".Split(',');
if (_mvcViewExtensions == null)
{
try
{
string value = GetKey("/settings/templates/mvcViewExtensions");
if (!string.IsNullOrEmpty(value))
_mvcViewExtensions = value.Split(',');
else
_mvcViewExtensions = defaultValue;
}
catch (Exception ex)
{
Trace.WriteLine("Could not load /settings/templates/mvcViewExtensions from umbracosettings.config:\r\n {0}",
ex.Message);
_mvcViewExtensions = defaultValue;
}
}
return _mvcViewExtensions;
}
}
/// <summary>
/// Configuration regarding webservices
/// </summary>

View File

@@ -165,6 +165,23 @@ namespace Umbraco.Core.IO
return true;
}
public static bool ValidateEditPath(string filePath, string[] validDirs)
{
foreach (var dir in validDirs)
{
var validDir = dir;
if (!filePath.StartsWith(MapPath(SystemDirectories.Root)))
filePath = MapPath(filePath);
if (!validDir.StartsWith(MapPath(SystemDirectories.Root)))
validDir = MapPath(validDir);
if (filePath.StartsWith(validDir))
return true;
}
throw new FileSecurityException(String.Format("The filepath '{0}' is not within an allowed directory for this type of files", filePath.Replace(MapPath(SystemDirectories.Root), "")));
}
public static bool ValidateFileExtension(string filePath, List<string> validFileExtensions)
{
if (!filePath.StartsWith(MapPath(SystemDirectories.Root)))