diff --git a/src/Umbraco.Core/IO/SystemDirectories.cs b/src/Umbraco.Core/IO/SystemDirectories.cs index 100dbc265e..2f33d82bdc 100644 --- a/src/Umbraco.Core/IO/SystemDirectories.cs +++ b/src/Umbraco.Core/IO/SystemDirectories.cs @@ -1,5 +1,4 @@ -using System; -using System.Web; +using System.Web; namespace Umbraco.Core.IO { @@ -36,9 +35,6 @@ namespace Umbraco.Core.IO public static string Umbraco => IOHelper.ReturnPath("umbracoPath", "~/umbraco"); - [Obsolete("Usercontrols are obsolete and code should be removed")] - public static string UserControls => "~/usercontrols"; - public static string Packages => Data + "/packages"; public static string Preview => Data + "/preview"; diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorMacroColumns.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorMacroColumns.cs index 623a842525..bd08b53877 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorMacroColumns.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorMacroColumns.cs @@ -26,7 +26,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 //populate the new macroSource column with legacy data Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroXSLT, macroType = {(int)MacroTypes.Unknown} WHERE macroXSLT IS NOT NULL").Do(); Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroScriptAssembly, macroType = {(int)MacroTypes.Unknown} WHERE macroScriptAssembly IS NOT NULL").Do(); - Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroScriptType, macroType = {(int)MacroTypes.UserControl} WHERE macroScriptType IS NOT NULL").Do(); + Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroScriptType, macroType = {(int)MacroTypes.Unknown} WHERE macroScriptType IS NOT NULL").Do(); Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroPython, macroType = {(int)MacroTypes.PartialView} WHERE macroPython IS NOT NULL").Do(); //now apply constraints (NOT NULL) to new table diff --git a/src/Umbraco.Core/Models/MacroTypes.cs b/src/Umbraco.Core/Models/MacroTypes.cs index 1f8ae696c5..5f8440845d 100644 --- a/src/Umbraco.Core/Models/MacroTypes.cs +++ b/src/Umbraco.Core/Models/MacroTypes.cs @@ -10,8 +10,6 @@ namespace Umbraco.Core.Models [DataContract(IsReference = true)] public enum MacroTypes { - [EnumMember] - UserControl = 3, [EnumMember] Unknown = 4, [EnumMember] diff --git a/src/Umbraco.Tests/IO/IoHelperTests.cs b/src/Umbraco.Tests/IO/IoHelperTests.cs index 3f510dd57e..34b18ffc5e 100644 --- a/src/Umbraco.Tests/IO/IoHelperTests.cs +++ b/src/Umbraco.Tests/IO/IoHelperTests.cs @@ -7,7 +7,6 @@ namespace Umbraco.Tests.IO [TestFixture] public class IoHelperTests { - [TestCase("~/Scripts", "/Scripts", null)] [TestCase("/Scripts", "/Scripts", null)] [TestCase("../Scripts", "/Scripts", typeof(ArgumentException))] @@ -42,8 +41,7 @@ namespace Umbraco.Tests.IO Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Preview, true), IOHelper.MapPath(SystemDirectories.Preview, false)); Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Root, true), IOHelper.MapPath(SystemDirectories.Root, false)); Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Scripts, true), IOHelper.MapPath(SystemDirectories.Scripts, false)); - Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Umbraco, true), IOHelper.MapPath(SystemDirectories.Umbraco, false)); - Assert.AreEqual(IOHelper.MapPath(SystemDirectories.UserControls, true), IOHelper.MapPath(SystemDirectories.UserControls, false)); + Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Umbraco, true), IOHelper.MapPath(SystemDirectories.Umbraco, false)); } [Test] diff --git a/src/Umbraco.Tests/Macros/MacroTests.cs b/src/Umbraco.Tests/Macros/MacroTests.cs index 0d60181c79..9cc1d14954 100644 --- a/src/Umbraco.Tests/Macros/MacroTests.cs +++ b/src/Umbraco.Tests/Macros/MacroTests.cs @@ -1,12 +1,7 @@ -using System; -using System.Web.UI; -using System.Web.UI.WebControls; -using NUnit.Framework; +using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration; -using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Models; using Umbraco.Tests.TestHelpers; using Umbraco.Web.Macros; @@ -32,47 +27,7 @@ namespace Umbraco.Tests.Macros Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); } - [TestCase("123", "IntProp", typeof(int))] - [TestCase("Hello", "StringProp", typeof(string))] - [TestCase("123456789.01", "DoubleProp", typeof(double))] - [TestCase("1234567", "FloatProp", typeof(float))] - [TestCase("1", "BoolProp", typeof(bool))] - [TestCase("true", "BoolProp", typeof(bool))] - [TestCase("0", "BoolProp", typeof(bool))] - [TestCase("false", "BoolProp", typeof(bool))] - [TestCase("2001-05-10", "DateProp", typeof(DateTime))] - [TestCase("123px", "UnitProp", typeof(Unit))] - [TestCase("456pt", "UnitProp", typeof(Unit))] - [TestCase("CEC063D3-D73E-4B7D-93ED-7F69CA9BF2D0", "GuidProp", typeof(Guid))] - [TestCase("CEC063D3D73E4B7D93ED7F69CA9BF2D0", "GuidProp", typeof(Guid))] - [TestCase("", "NullDateProp", typeof(DateTime?))] - [TestCase("2001-05-10", "NullDateProp", typeof(DateTime?))] - [TestCase("", "NullUnitProp", typeof(Unit?))] - [TestCase("456pt", "NullUnitProp", typeof(Unit?))] - public void SetUserControlProperty(string val, string macroPropName, Type convertTo) - { - var ctrl = new UserControlTest(); - var macroModel = new MacroModel - { - Name = "test", - Alias = "test", - MacroSource = "~/usercontrols/menu.ascx" - }; - macroModel.Properties.Add(new MacroPropertyModel(macroPropName, val)); - - UserControlMacroEngine.UpdateControlProperties(ctrl, macroModel); - - var ctrlType = ctrl.GetType(); - var prop = ctrlType.GetProperty(macroPropName); - var converted = val.TryConvertTo(convertTo); - - Assert.IsTrue(converted.Success); - Assert.NotNull(prop); - Assert.AreEqual(converted.Result, prop.GetValue(ctrl)); - } - [TestCase("PartialView", true)] - [TestCase("UserControl", true)] [TestCase("Unknown", false)] public void Macro_Is_File_Based(string macroTypeString, bool expectedNonNull) { @@ -102,19 +57,5 @@ namespace Umbraco.Tests.Macros { //var asdf = macro.GetCacheIdentifier() } - - private class UserControlTest : UserControl - { - public int IntProp { get; set; } - public string StringProp { get; set; } - public double DoubleProp { get; set; } - public float FloatProp { get; set; } - public bool BoolProp { get; set; } - public DateTime DateProp { get; set; } - public Unit UnitProp { get; set; } - public Guid GuidProp { get; set; } - public DateTime? NullDateProp { get; set; } - public Unit? NullUnitProp { get; set; } - } } } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/macro.service.js b/src/Umbraco.Web.UI.Client/src/common/services/macro.service.js index 77ed6e821e..6c8c0a6ff2 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/macro.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/macro.service.js @@ -40,7 +40,7 @@ function macroService() { /** * @ngdoc function - * @name umbraco.services.macroService#generateWebFormsSyntax + * @name umbraco.services.macroService#generateMacroSyntax * @methodOf umbraco.services.macroService * @function * @@ -82,35 +82,6 @@ function macroService() { return macroString; }, - - /** - * @ngdoc function - * @name umbraco.services.macroService#generateWebFormsSyntax - * @methodOf umbraco.services.macroService - * @function - * - * @description - * generates the syntax for inserting a macro into a webforms templates - * - * @param {object} args an object containing the macro alias and it's parameter values - */ - generateWebFormsSyntax: function(args) { - - var macroString = '"; - - return macroString; - }, /** * @ngdoc function @@ -180,10 +151,7 @@ function macroService() { }); //get the syntax based on the rendering engine - if (renderingEngine && renderingEngine === "WebForms") { - syntax = this.generateWebFormsSyntax({ macroAlias: macroAlias, macroParamsDictionary: paramDictionary }); - } - else if (renderingEngine && renderingEngine === "Mvc") { + if (renderingEngine && renderingEngine === "Mvc") { syntax = this.generateMvcSyntax({ macroAlias: macroAlias, macroParamsDictionary: paramDictionary }); } else { diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/macro-service.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/macro-service.spec.js index 44334e140a..3f92236169 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/macro-service.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/macro-service.spec.js @@ -108,34 +108,6 @@ describe('macro service tests', function () { toBe(""); }); - - it('can generate syntax for webforms', function () { - - var syntax = macroService.generateWebFormsSyntax({ - macroAlias: "myMacro", - macroParamsDictionary: { - param1: "value1", - param2: "value2", - param3: "value3" - } - }); - - expect(syntax). - toBe(""); - - }); - - it('can generate syntax for webforms with no params', function () { - - var syntax = macroService.generateWebFormsSyntax({ - macroAlias: "myMacro", - macroParamsDictionary: {} - }); - - expect(syntax). - toBe(""); - - }); it('can generate syntax for MVC', function () { @@ -167,4 +139,4 @@ describe('macro service tests', function () { }); }); -}); \ No newline at end of file +}); diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml index e89ef44923..ad78274c91 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml @@ -544,7 +544,6 @@ Please fill both alias and name on the new property type! There is a problem with read/write access to a specific file or folder Error loading Partial View script (file: %0%) - Error loading userControl '%0%' Please enter a title Please choose a type You're about to make the picture larger than the original size. Are you sure that you want to proceed? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml index bb8d9b12eb..36c738c42c 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -548,7 +548,6 @@ Please fill both alias and name on the new property type! There is a problem with read/write access to a specific file or folder Error loading Partial View script (file: %0%) - Error loading userControl '%0%' Please enter a title Please choose a type You're about to make the picture larger than the original size. Are you sure that you want to proceed? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/es.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/es.xml index 9aeab1dba4..fb7350d603 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/es.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/es.xml @@ -451,7 +451,6 @@ Debes rellenar el alias y el nombre en el tipo de propiedad Hay un problema de lectura y escritura al acceder a un archivo o carpeta Error cargando Vista Parcial (archivo: %0%) - Error cargando userControl '%0%' Por favor, elige un tipo diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml index b6fd93df03..45af92a440 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml @@ -464,7 +464,6 @@ Veuillez remplir l'alias et le nom de la nouvelle propriété! Il y a un problème de droits en lecture/écriture sur un fichier ou dossier spécifique Erreur de chargement du script d'une Partial View (fichier : %0%) - Erreur de chargement du userControl '%0%' Veuillez entrer un titre Veuillez choisir un type Vous allez définir une taille d'image supérieure à sa taille d'origine. Êtes-vous certain(e) de vouloir continuer? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/ja.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/ja.xml index 730e4e06b7..bf6a9eea75 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/ja.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/ja.xml @@ -344,7 +344,6 @@ 新しいプロパティ型のエイリアスと名前の両方を設定してください! 特定のファイルまたはフォルタの読み込み/書き込みアクセスに問題があります Partial View スクリプトの読み込みエラー (ファイル: %0%) - userControl の読み込みエラー '%0%' タイトルを入力してください 型を選択してください 元画像より大きくしようとしていますが、本当によろしいのですか? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml index 5904958b93..60f8e36449 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml @@ -376,7 +376,6 @@ Zowel de alias als de naam van het nieuwe eigenschappentype moeten worden ingevuld! Er is een probleem met de lees/schrijfrechten op een bestand of map Error bij het laden van Partial View script (file: %0%) - Error bij het laden van userControl '%0%' Vul een titel in Selecteer een type U wilt een afbeelding groter maken dan de originele afmetingen. Weet je zeker dat je wilt doorgaan? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/pl.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/pl.xml index 893bf356dd..159bb8e7c2 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/pl.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/pl.xml @@ -446,7 +446,6 @@ Proszę uzupełnij zarówno alias, jak i nazwę dla nowego typu właściwości Wystąpił problem podczas zapisu/odczytu wymaganego pliku lub folderu Wystąpił błąd podczas ładowania skryptu Częściowego Widoku (plik: %0%) - Wystąpił błąd podczas ładowania userControl '%0%' Proszę podać tytuł Proszę wybrać typ Chcesz utworzyć obraz większy niż rozmiar oryginalny. Czy na pewno chcesz kontynuować? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml index 4854a2c3aa..c484e33423 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml @@ -483,7 +483,6 @@ Использование данного типа файлов на сайте запрещено администратором Ошибка доступа к указанному файлу или папке Ошибка загрузки кода в частичном представлении (файл: %0%) - Ошибка загрузки пользовательского элемента управления '%0%' Укажите заголовок Выберите тип Вы пытаетесь увеличить изображение по сравнению с его исходным размером. Уверены, что хотите сделать это? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/tr.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/tr.xml index 7f0f874237..6c4a0773a4 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/tr.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/tr.xml @@ -286,7 +286,6 @@ Yeni özellik tipine takma adını ve hem de doldurunuz! Belirli bir dosya veya klasör için okuma / yazma erişimi olan bir sorun var Error loading Partial View script (Dosya: %0%) - Error loading userControl '%0%' Lütfen bir başlık girin Lütfen bir tür seçin Orijinal boyutundan daha resmi büyütmek üzereyiz. Devam etmek istediğinizden emin misiniz? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/zh.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/zh.xml index 374d8802eb..7e3c275b06 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/zh.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/zh.xml @@ -364,7 +364,6 @@ 请为新的属性类型填写名称和别名! 权限有问题,访问指定文件或文件夹失败! 加载Partial视图脚本时出错(文件: %0%) - 加载 userControl 时出错 '%0%' 请输入标题 请选择类型 图片尺寸大于原始尺寸不会提高图片质量,您确定要把图片尺寸变大吗? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml index 98279d58f3..f7461ad9d7 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml @@ -357,7 +357,6 @@ 請為新的屬性類型填寫名稱和別名! 許可權有問題,訪問指定文檔或資料夾失敗! 讀取片段視圖腳本錯誤(檔案:%0%) - 讀取使用者控制項 %0% 錯誤 請輸入標題 請選擇類型 圖片尺寸大於原始尺寸不會提高圖片品質,您確定要把圖片尺寸變大嗎? diff --git a/src/Umbraco.Web/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs index 273d19bae0..ee6f254235 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs @@ -68,7 +68,6 @@ namespace Umbraco.Web.HealthCheck.Checks.Permissions { SystemDirectories.Media, PermissionCheckRequirement.Optional }, { SystemDirectories.Scripts, PermissionCheckRequirement.Optional }, { SystemDirectories.Umbraco, PermissionCheckRequirement.Optional }, - { SystemDirectories.UserControls, PermissionCheckRequirement.Optional }, { SystemDirectories.MvcViews, PermissionCheckRequirement.Optional } }; diff --git a/src/Umbraco.Web/Install/FilePermissionHelper.cs b/src/Umbraco.Web/Install/FilePermissionHelper.cs index 6c166e734b..e802b19c8d 100644 --- a/src/Umbraco.Web/Install/FilePermissionHelper.cs +++ b/src/Umbraco.Web/Install/FilePermissionHelper.cs @@ -11,8 +11,8 @@ namespace Umbraco.Web.Install internal class FilePermissionHelper { // ensure that these directories exist and Umbraco can write to them - private static readonly string[] PermissionDirs = { SystemDirectories.Css, SystemDirectories.Config, SystemDirectories.Data, SystemDirectories.Media, SystemDirectories.UserControls, SystemDirectories.Preview }; - private static readonly string[] PackagesPermissionsDirs = { SystemDirectories.Bin, SystemDirectories.Umbraco, SystemDirectories.UserControls, SystemDirectories.Packages }; + private static readonly string[] PermissionDirs = { SystemDirectories.Css, SystemDirectories.Config, SystemDirectories.Data, SystemDirectories.Media, SystemDirectories.Preview }; + private static readonly string[] PackagesPermissionsDirs = { SystemDirectories.Bin, SystemDirectories.Umbraco, SystemDirectories.Packages }; // ensure Umbraco can write to these files (the directories must exist) private static readonly string[] PermissionFiles = { }; diff --git a/src/Umbraco.Web/Macros/MacroRenderer.cs b/src/Umbraco.Web/Macros/MacroRenderer.cs index 17c5859e91..c975c4a60b 100755 --- a/src/Umbraco.Web/Macros/MacroRenderer.cs +++ b/src/Umbraco.Web/Macros/MacroRenderer.cs @@ -11,7 +11,6 @@ using System.Text; using System.Text.RegularExpressions; using System.Web; using System.Web.Caching; -using System.Web.Hosting; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; @@ -171,8 +170,7 @@ namespace Umbraco.Web.Macros switch (model.MacroType) { case MacroTypes.PartialView: - case MacroTypes.UserControl: - filename = model.MacroSource; //user controls & partial views are saved with their full virtual path + filename = model.MacroSource; // partial views are saved with their full virtual path break; default: // not file-based, or not supported @@ -363,14 +361,6 @@ namespace Umbraco.Web.Macros () => ExecutePartialView(model), () => textService.Localize("errors/macroErrorLoadingPartialView", new[] { model.MacroSource })); - case MacroTypes.UserControl: - return ExecuteMacroWithErrorWrapper(model, - $"Loading UserControl: MacroSource=\"{model.MacroSource}\".", - "Loaded UserControl.", - () => ExecuteUserControl(model), - () => textService.Localize("errors/macroErrorLoadingUsercontrol", new[] { model.MacroSource })); - - //case MacroTypes.Script: default: return ExecuteMacroWithErrorWrapper(model, $"Execute macro with unsupported type \"{model.MacroType}\".", @@ -411,17 +401,6 @@ namespace Umbraco.Web.Macros return engine.Execute(macro, content); } - public static MacroContent ExecuteUserControl(MacroModel macro) - { - // add tilde for v4 defined macros - if (string.IsNullOrEmpty(macro.MacroSource) == false - && macro.MacroSource.StartsWith("~") == false) - macro.MacroSource = "~/" + macro.MacroSource; - - var engine = new UserControlMacroEngine(); - return engine.Execute(macro); - } - #endregion #region Execution helpers diff --git a/src/Umbraco.Web/Macros/MacroTagParser.cs b/src/Umbraco.Web/Macros/MacroTagParser.cs index 8e3f116614..7dea3674b0 100644 --- a/src/Umbraco.Web/Macros/MacroTagParser.cs +++ b/src/Umbraco.Web/Macros/MacroTagParser.cs @@ -162,8 +162,6 @@ namespace Umbraco.Web.Macros while (!stop) { var tagIndex = fieldResult.ToString().ToLower().IndexOf(" -1) { var tempElementContent = ""; diff --git a/src/Umbraco.Web/Macros/UserControlMacroEngine.cs b/src/Umbraco.Web/Macros/UserControlMacroEngine.cs deleted file mode 100644 index f92074a91b..0000000000 --- a/src/Umbraco.Web/Macros/UserControlMacroEngine.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.IO; -using System.Web; -using System.Web.UI; -using Umbraco.Core; -using Umbraco.Core.IO; -using Umbraco.Core.Logging; -using Umbraco.Web.Composing; - -namespace Umbraco.Web.Macros -{ - class UserControlMacroEngine - { - public MacroContent Execute(MacroModel model) - { - var filename = model.MacroSource; - - // ensure the file exists - var path = IOHelper.FindFile(filename); - if (File.Exists(IOHelper.MapPath(path)) == false) - throw new Exception($"Failed to load control, file {filename} does not exist."); - - // load the control - var control = (UserControl)new UserControl().LoadControl(path); - control.ID = string.IsNullOrEmpty(model.MacroControlIdentifier) - ? GetControlUniqueId(filename) - : model.MacroControlIdentifier; - - // initialize the control - // note: we are not setting the 'CurrentNode' property on the control anymore, - // as that was an INode which is gone in v8. Use UmbracoContext to access the - // current content. - Current.Logger.Info("Loaded control '{UserControlFile}' with ID '{UserControlId}'", filename, control.ID); - UpdateControlProperties(control, model); - - return new MacroContent { Control = control }; - } - - private static string GetControlUniqueId(string filename) - { - const string key = "MacroControlUniqueId"; - - var x = 0; - - if (HttpContext.Current != null) - { - if (HttpContext.Current.Items.Contains(key)) - x = (int)HttpContext.Current.Items[key]; - x += 1; - HttpContext.Current.Items[key] = x; - } - - return $"{Path.GetFileNameWithoutExtension(filename)}_{x}"; - } - - // set the control properties according to the model properties ie parameters - internal static void UpdateControlProperties(Control control, MacroModel model) - { - var type = control.GetType(); - - foreach (var modelProperty in model.Properties) - { - var controlProperty = type.GetProperty(modelProperty.Key); - if (controlProperty == null) - { - Current.Logger.Warn("Control property '{UserControlProperty}' doesn't exist or isn't accessible, skip.", modelProperty.Key); - continue; - } - - var tryConvert = modelProperty.Value.TryConvertTo(controlProperty.PropertyType); - if (tryConvert.Success) - { - try - { - controlProperty.SetValue(control, tryConvert.Result, null); - Current.Logger.Debug("Set property '{UserControlProperty}' value '{UserControlPropertyValue}'", modelProperty.Key, modelProperty.Value); - } - catch (Exception e) - { - Current.Logger.Warn(e, "Failed to set property '{UserControlProperty}' value '{UserControlPropertyValue}'", modelProperty.Key, modelProperty.Value); - } - } - else - { - Current.Logger.Warn("Failed to set property '{UserControlProperty}' value '{UserControlPropertyValue}'", modelProperty.Key, modelProperty.Value); - } - } - } - } -} diff --git a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs index 4cd7e3b0e0..215eb39573 100644 --- a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs @@ -386,11 +386,8 @@ namespace Umbraco.Web.Mvc var handler = GetHandlerOnMissingTemplate(request); - // if it's not null it can be either the PublishedContentNotFoundHandler (no document was - // found to handle 404, or document with no template was found) or the WebForms handler - // (a document was found and its template is WebForms) - - // if it's null it means that a document was found and its template is Mvc + // if it's not null it's the PublishedContentNotFoundHandler (no document was found to handle 404, or document with no template was found) + // if it's null it means that a document was found // if we have a handler, return now if (handler != null) diff --git a/src/Umbraco.Web/Mvc/UmbracoPageResult.cs b/src/Umbraco.Web/Mvc/UmbracoPageResult.cs index d506090ecd..75804b47bb 100644 --- a/src/Umbraco.Web/Mvc/UmbracoPageResult.cs +++ b/src/Umbraco.Web/Mvc/UmbracoPageResult.cs @@ -1,11 +1,9 @@ using System; using System.IO; -using System.Web; using System.Web.Mvc; using System.Web.Routing; using Umbraco.Core; using Umbraco.Core.Logging; -using Umbraco.Web.Composing; namespace Umbraco.Web.Mvc { @@ -80,27 +78,6 @@ namespace Umbraco.Web.Mvc } } - /// - /// When POSTing to MVC but rendering in WebForms we need to do some trickery, we'll create a dummy viewcontext with all of the - /// current model state, tempdata, viewdata so that if we're rendering partial view macros within the webforms view, they will - /// get all of this merged into them. - /// - /// - private static void EnsureViewContextForWebForms(ControllerContext context) - { - var tempDataDictionary = new TempDataDictionary(); - tempDataDictionary.Save(context, new SessionStateTempDataProvider()); - var viewCtx = new ViewContext(context, new DummyView(), new ViewDataDictionary(), tempDataDictionary, new StringWriter()); - - viewCtx.ViewData.ModelState.Merge(new ModelStateDictionary(context.Controller.ViewData.ModelState)); - - foreach (var d in context.Controller.ViewData) - viewCtx.ViewData[d.Key] = d.Value; - - //now we need to add it to the special route tokens so it's picked up later - context.HttpContext.Request.RequestContext.RouteData.DataTokens[Constants.DataTokenCurrentViewContext] = viewCtx; - } - /// /// Ensure ModelState, ViewData and TempData is copied across /// diff --git a/src/Umbraco.Web/Templates/TemplateRenderer.cs b/src/Umbraco.Web/Templates/TemplateRenderer.cs index 214612ef2d..9279eea124 100644 --- a/src/Umbraco.Web/Templates/TemplateRenderer.cs +++ b/src/Umbraco.Web/Templates/TemplateRenderer.cs @@ -2,7 +2,6 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Web.Compilation; using System.Web.Mvc; using System.Web.Routing; using Umbraco.Core; @@ -10,7 +9,6 @@ using Umbraco.Web.Models; using Umbraco.Web.Mvc; using Umbraco.Web.Routing; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration; using Umbraco.Core.Services; using Umbraco.Web.Macros; using Current = Umbraco.Web.Composing.Current; @@ -21,7 +19,7 @@ namespace Umbraco.Web.Templates /// This is used purely for the RenderTemplate functionality in Umbraco /// /// - /// This allows you to render either an MVC or Webforms template based purely off of a node id and an optional alttemplate id as string output. + /// This allows you to render an MVC template based purely off of a node id and an optional alttemplate id as string output. /// internal class TemplateRenderer { diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 849d82940f..6b7f568566 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -341,7 +341,6 @@ -