diff --git a/src/Umbraco.Core/IUmbracoContextFactory.cs b/src/Umbraco.Core/IUmbracoContextFactory.cs index 2a6dd50618..c3ed863da8 100644 --- a/src/Umbraco.Core/IUmbracoContextFactory.cs +++ b/src/Umbraco.Core/IUmbracoContextFactory.cs @@ -1,5 +1,4 @@ -using System.Web; - + namespace Umbraco.Web { /// diff --git a/src/Umbraco.Core/Install/InstallSteps/StarterKitCleanupStep.cs b/src/Umbraco.Core/Install/InstallSteps/StarterKitCleanupStep.cs index e6cceb2c5b..adca1950f3 100644 --- a/src/Umbraco.Core/Install/InstallSteps/StarterKitCleanupStep.cs +++ b/src/Umbraco.Core/Install/InstallSteps/StarterKitCleanupStep.cs @@ -1,8 +1,8 @@ using System; using System.IO; using System.Linq; +using System.Net; using System.Threading.Tasks; -using System.Web; using Umbraco.Core.IO; using Umbraco.Web.Install.Models; @@ -33,7 +33,7 @@ namespace Umbraco.Web.Install.InstallSteps private void CleanupInstallation(int packageId, string packageFile) { - var zipFile = new FileInfo(Path.Combine(_ioHelper.MapPath(Core.Constants.SystemDirectories.Packages), HttpUtility.UrlDecode(packageFile))); + var zipFile = new FileInfo(Path.Combine(_ioHelper.MapPath(Core.Constants.SystemDirectories.Packages), WebUtility.UrlDecode(packageFile))); if (zipFile.Exists) zipFile.Delete(); diff --git a/src/Umbraco.Core/Models/PublishedContent/IndexedArrayItem.cs b/src/Umbraco.Core/Models/PublishedContent/IndexedArrayItem.cs index be87dac9e8..4b0432ca50 100644 --- a/src/Umbraco.Core/Models/PublishedContent/IndexedArrayItem.cs +++ b/src/Umbraco.Core/Models/PublishedContent/IndexedArrayItem.cs @@ -1,4 +1,4 @@ -using System.Web; +using System.Net; using Umbraco.Core.Strings; namespace Umbraco.Core.Models.PublishedContent @@ -79,7 +79,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsFirst(string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsFirst() ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsFirst() ? valueIfTrue : valueIfFalse)); } /// @@ -119,7 +119,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsNotFirst(string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsNotFirst() ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsNotFirst() ? valueIfTrue : valueIfFalse)); } /// @@ -160,7 +160,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsIndex(int index, string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsIndex(index) ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsIndex(index) ? valueIfTrue : valueIfFalse)); } /// @@ -201,7 +201,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsModZero(int modulus, string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsModZero(modulus) ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsModZero(modulus) ? valueIfTrue : valueIfFalse)); } /// @@ -243,7 +243,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsNotModZero(int modulus, string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsNotModZero(modulus) ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsNotModZero(modulus) ? valueIfTrue : valueIfFalse)); } /// @@ -285,7 +285,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsNotIndex(int index, string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsNotIndex(index) ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsNotIndex(index) ? valueIfTrue : valueIfFalse)); } /// @@ -323,7 +323,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsLast(string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsLast() ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsLast() ? valueIfTrue : valueIfFalse)); } /// @@ -362,7 +362,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsNotLast(string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsNotLast() ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsNotLast() ? valueIfTrue : valueIfFalse)); } /// @@ -400,7 +400,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsEven(string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsEven() ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsEven() ? valueIfTrue : valueIfFalse)); } /// @@ -438,7 +438,7 @@ namespace Umbraco.Core.Models.PublishedContent // TODO: This method should be removed or moved to an extension method on HtmlHelper. public IHtmlEncodedString IsOdd(string valueIfTrue, string valueIfFalse) { - return new HtmlEncodedString(HttpUtility.HtmlEncode(IsOdd() ? valueIfTrue : valueIfFalse)); + return new HtmlEncodedString(WebUtility.HtmlEncode(IsOdd() ? valueIfTrue : valueIfFalse)); } } } diff --git a/src/Umbraco.Core/Packaging/PackagesRepository.cs b/src/Umbraco.Core/Packaging/PackagesRepository.cs index 2c5b964518..0764378b06 100644 --- a/src/Umbraco.Core/Packaging/PackagesRepository.cs +++ b/src/Umbraco.Core/Packaging/PackagesRepository.cs @@ -6,6 +6,7 @@ using System.IO.Compression; using System.Linq; using System.Xml.Linq; using Umbraco.Core.Configuration; +using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; @@ -28,7 +29,7 @@ namespace Umbraco.Core.Packaging private readonly ILocalizationService _languageService; private readonly IEntityXmlSerializer _serializer; private readonly ILogger _logger; - private readonly IIOHelper _ioHelper; + private readonly IHostingEnvironment _hostingEnvironment; private readonly string _packageRepositoryFileName; private readonly string _mediaFolderPath; private readonly string _packagesFolderPath; @@ -45,7 +46,7 @@ namespace Umbraco.Core.Packaging /// /// /// - /// + /// /// /// /// @@ -57,7 +58,7 @@ namespace Umbraco.Core.Packaging public PackagesRepository(IContentService contentService, IContentTypeService contentTypeService, IDataTypeService dataTypeService, IFileService fileService, IMacroService macroService, ILocalizationService languageService, - IIOHelper ioHelper, + IHostingEnvironment hostingEnvironment, IEntityXmlSerializer serializer, ILogger logger, IUmbracoVersion umbracoVersion, IGlobalSettings globalSettings, @@ -73,7 +74,7 @@ namespace Umbraco.Core.Packaging _languageService = languageService; _serializer = serializer; _logger = logger; - _ioHelper = ioHelper; + _hostingEnvironment = hostingEnvironment; _packageRepositoryFileName = packageRepositoryFileName; _tempFolderPath = tempFolderPath ?? Constants.SystemDirectories.TempData.EnsureEndsWith('/') + "PackageFiles"; @@ -162,7 +163,7 @@ namespace Umbraco.Core.Packaging ValidatePackage(definition); //Create a folder for building this package - var temporaryPath = _ioHelper.MapPath(_tempFolderPath.EnsureEndsWith('/') + Guid.NewGuid()); + var temporaryPath = _hostingEnvironment.MapPathContentRoot(_tempFolderPath.EnsureEndsWith('/') + Guid.NewGuid()); if (Directory.Exists(temporaryPath) == false) Directory.CreateDirectory(temporaryPath); @@ -183,15 +184,19 @@ namespace Umbraco.Core.Packaging PackageLanguages(definition, root); PackageDataTypes(definition, root); + // TODO: This needs to be split into content vs web files, for now we are going to + // assume all files are web (www) files. But this is a larger discussion/change since + // we will actually need to modify how packages and files are organized. + //Files foreach (var fileName in definition.Files) - AppendFileToPackage(fileName, temporaryPath, filesXml, _ioHelper); + AppendFileToPackage(fileName, temporaryPath, filesXml, true); //Load view on install... if (!string.IsNullOrEmpty(definition.PackageView)) { var control = new XElement("view", definition.PackageView); - AppendFileToPackage(definition.PackageView, temporaryPath, filesXml, _ioHelper); + AppendFileToPackage(definition.PackageView, temporaryPath, filesXml, true); root.Add(control); } @@ -221,11 +226,11 @@ namespace Umbraco.Core.Packaging // check if there's a packages directory below media - if (Directory.Exists(_ioHelper.MapPath(_mediaFolderPath)) == false) - Directory.CreateDirectory(_ioHelper.MapPath(_mediaFolderPath)); + if (Directory.Exists(_hostingEnvironment.MapPathWebRoot(_mediaFolderPath)) == false) + Directory.CreateDirectory(_hostingEnvironment.MapPathWebRoot(_mediaFolderPath)); var packPath = _mediaFolderPath.EnsureEndsWith('/') + (definition.Name + "_" + definition.Version).Replace(' ', '_') + ".zip"; - ZipPackage(temporaryPath, _ioHelper.MapPath(packPath)); + ZipPackage(temporaryPath, _hostingEnvironment.MapPathWebRoot(packPath)); //we need to update the package path and save it definition.PackagePath = packPath; @@ -301,7 +306,7 @@ namespace Umbraco.Core.Packaging macros.Add(macroXml); //if the macro has a file copy it to the xml if (!string.IsNullOrEmpty(macro.MacroSource)) - AppendFileToPackage(macro.MacroSource, temporaryPath, filesXml,_ioHelper); + AppendFileToPackage(macro.MacroSource, temporaryPath, filesXml, false); } root.Add(macros); } @@ -451,12 +456,13 @@ namespace Umbraco.Core.Packaging /// The path. /// The package directory. /// The files xml node - private static void AppendFileToPackage(string path, string packageDirectory, XContainer filesXml, IIOHelper ioHelper) + /// true if it's a web file, false if it's a content file + private void AppendFileToPackage(string path, string packageDirectory, XContainer filesXml, bool isWebFile) { if (!path.StartsWith("~/") && !path.StartsWith("/")) path = "~/" + path; - var serverPath = ioHelper.MapPath(path); + var serverPath = isWebFile ? _hostingEnvironment.MapPathWebRoot(path) : _hostingEnvironment.MapPathContentRoot(path); if (File.Exists(serverPath)) AppendFileXml(new FileInfo(serverPath), path, packageDirectory, filesXml); @@ -615,11 +621,11 @@ namespace Umbraco.Core.Packaging private XDocument EnsureStorage(out string packagesFile) { - var packagesFolder = _ioHelper.MapPath(_packagesFolderPath); + var packagesFolder = _hostingEnvironment.MapPathContentRoot(_packagesFolderPath); //ensure it exists Directory.CreateDirectory(packagesFolder); - packagesFile = _ioHelper.MapPath(CreatedPackagesFile); + packagesFile = _hostingEnvironment.MapPathContentRoot(CreatedPackagesFile); if (!File.Exists(packagesFile)) { var xml = new XDocument(new XElement("packages")); diff --git a/src/Umbraco.Core/PublishedElementExtensions.cs b/src/Umbraco.Core/PublishedElementExtensions.cs index 4b529147e3..a5eaef2df9 100644 --- a/src/Umbraco.Core/PublishedElementExtensions.cs +++ b/src/Umbraco.Core/PublishedElementExtensions.cs @@ -1,6 +1,8 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using Umbraco.Core.Models.PublishedContent; +using Umbraco.Web.Routing; namespace Umbraco.Core { @@ -175,5 +177,30 @@ namespace Umbraco.Core } #endregion + + #region MediaUrl + + /// + /// Gets the url for a media. + /// + /// The content item. + /// The published url provider. + /// The culture (use current culture by default). + /// The url mode (use site configuration by default). + /// The alias of the property (use 'umbracoFile' by default). + /// The url for the media. + /// + /// The value of this property is contextual. It depends on the 'current' request uri, + /// if any. In addition, when the content type is multi-lingual, this is the url for the + /// specified culture. Otherwise, it is the invariant url. + /// + public static string MediaUrl(this IPublishedContent content, IPublishedUrlProvider publishedUrlProvider, string culture = null, UrlMode mode = UrlMode.Default, string propertyAlias = Constants.Conventions.Media.File) + { + if (publishedUrlProvider == null) throw new ArgumentNullException(nameof(publishedUrlProvider)); + + return publishedUrlProvider.GetMediaUrl(content, mode, culture, propertyAlias); + } + + #endregion } } diff --git a/src/Umbraco.Core/Routing/ContentFinderByRedirectUrl.cs b/src/Umbraco.Core/Routing/ContentFinderByRedirectUrl.cs index 5b3e0a5d99..4e67779c1c 100644 --- a/src/Umbraco.Core/Routing/ContentFinderByRedirectUrl.cs +++ b/src/Umbraco.Core/Routing/ContentFinderByRedirectUrl.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Web; using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Services; diff --git a/src/Umbraco.Core/Routing/RoutableAttemptEventArgs.cs b/src/Umbraco.Core/Routing/RoutableAttemptEventArgs.cs index 54ea98b3a4..9f80d8ed3f 100644 --- a/src/Umbraco.Core/Routing/RoutableAttemptEventArgs.cs +++ b/src/Umbraco.Core/Routing/RoutableAttemptEventArgs.cs @@ -1,6 +1,4 @@ -using System.Web; - -namespace Umbraco.Web.Routing +namespace Umbraco.Web.Routing { /// /// Event args containing information about why the request was not routable, or if it is routable diff --git a/src/Umbraco.Core/Routing/UmbracoRequestEventArgs.cs b/src/Umbraco.Core/Routing/UmbracoRequestEventArgs.cs index 4430d9689f..d93a27ddf4 100644 --- a/src/Umbraco.Core/Routing/UmbracoRequestEventArgs.cs +++ b/src/Umbraco.Core/Routing/UmbracoRequestEventArgs.cs @@ -1,5 +1,4 @@ using System; -using System.Web; namespace Umbraco.Web.Routing { diff --git a/src/Umbraco.Core/Routing/UriUtility.cs b/src/Umbraco.Core/Routing/UriUtility.cs index ad785c111f..1ff6ba7436 100644 --- a/src/Umbraco.Core/Routing/UriUtility.cs +++ b/src/Umbraco.Core/Routing/UriUtility.cs @@ -1,6 +1,5 @@ using System; using System.Text; -using System.Web; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; diff --git a/src/Umbraco.Core/Templates/UmbracoComponentRenderer.cs b/src/Umbraco.Core/Templates/UmbracoComponentRenderer.cs index 91004a2f29..4618eb2822 100644 --- a/src/Umbraco.Core/Templates/UmbracoComponentRenderer.cs +++ b/src/Umbraco.Core/Templates/UmbracoComponentRenderer.cs @@ -1,9 +1,9 @@ using System; using System.Linq; using System.IO; -using System.Web; using Umbraco.Web.Templates; using System.Collections.Generic; +using System.Net; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Strings; using Umbraco.Web; @@ -120,7 +120,7 @@ namespace Umbraco.Core.Templates //NOTE: the value could have HTML encoded values, so we need to deal with that var macroProps = parameters?.ToDictionary( x => x.Key.ToLowerInvariant(), - i => (i.Value is string) ? HttpUtility.HtmlDecode(i.Value.ToString()) : i.Value); + i => (i.Value is string) ? WebUtility.HtmlDecode(i.Value.ToString()) : i.Value); var html = _macroRenderer.Render(alias, content, macroProps).Text; diff --git a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Services.cs b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Services.cs index 0b44c52375..dd8476959a 100644 --- a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Services.cs +++ b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Services.cs @@ -89,7 +89,7 @@ namespace Umbraco.Core.Composing.CompositionExtensions factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), - factory.GetInstance(), + factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs b/src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs index 861e849fe2..d067060014 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs +++ b/src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Web; +using System.Net; namespace Umbraco.Web.Media.EmbedProviders { @@ -14,7 +14,7 @@ namespace Umbraco.Web.Media.EmbedProviders }; public override Dictionary RequestParams => new Dictionary(); - + public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0) { var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight); @@ -25,7 +25,7 @@ namespace Umbraco.Web.Media.EmbedProviders var imageHeight = GetXmlProperty(xmlDocument, "/oembed/height"); var imageTitle = GetXmlProperty(xmlDocument, "/oembed/title"); - return string.Format("\"{3}\"", imageUrl, imageWidth, imageHeight, HttpUtility.HtmlEncode(imageTitle)); - } + return string.Format("\"{3}\"", imageUrl, imageWidth, imageHeight, WebUtility.HtmlEncode(imageTitle)); + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs b/src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs index 64b18f52d3..cc3e34931e 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs +++ b/src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs @@ -1,5 +1,4 @@ -using System.Text; -using System.Web; +using System.Net; using Newtonsoft.Json; namespace Umbraco.Web.Media.EmbedProviders @@ -52,7 +51,7 @@ namespace Umbraco.Web.Media.EmbedProviders { if (Type == "photo") { - return "\"""; + return "\"""; } return string.IsNullOrEmpty(Html) == false ? Html : string.Empty; diff --git a/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs b/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs index 3f931d6358..0d0ec703ba 100644 --- a/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs +++ b/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs @@ -7,7 +7,6 @@ using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; using Umbraco.Core.Configuration; -using System.Web; using Umbraco.Core.Hosting; using Umbraco.Core.Logging; using Umbraco.Core.Persistence; diff --git a/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs similarity index 86% rename from src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs index 788b5dce10..77d7aead5e 100644 --- a/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs @@ -1,29 +1,14 @@ -using System; -using System.Globalization; -using Moq; +using System.Globalization; using Newtonsoft.Json; using NUnit.Framework; using Newtonsoft.Json.Linq; using Umbraco.Core; -using Umbraco.Core.Composing; -using Umbraco.Core.Configuration.UmbracoSettings; -using Umbraco.Core.IO; -using Umbraco.Core.Logging; using Umbraco.Core.Models; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.ValueConverters; -using Umbraco.Core.Services; -using Umbraco.Core.Strings; -using Umbraco.Tests.Components; -using Umbraco.Tests.TestHelpers; using Umbraco.Web.Models; -using Umbraco.Web; -using Umbraco.Web.PropertyEditors; using System.Text; -using Current = Umbraco.Web.Composing.Current; -using Umbraco.Core.Cache; using Umbraco.Core.Media; +using Umbraco.Extensions; namespace Umbraco.Tests.PropertyEditors { @@ -67,48 +52,48 @@ namespace Umbraco.Tests.PropertyEditors Assert.AreEqual(cropperValue, obj); } - [TestCase(CropperJson1, CropperJson1, true)] - [TestCase(CropperJson1, CropperJson2, false)] - public void CanConvertImageCropperPropertyEditor(string val1, string val2, bool expected) - { - try - { - var container = TestHelper.GetRegister(); - var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache); - - composition.WithCollectionBuilder(); - - Current.Factory = composition.CreateFactory(); - - var logger = Mock.Of(); - var scheme = Mock.Of(); - var shortStringHelper = Mock.Of(); - - var mediaFileSystem = new MediaFileSystem(Mock.Of(), scheme, logger, shortStringHelper); - - var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new ImageCropperPropertyEditor(Mock.Of(), mediaFileSystem, Mock.Of(), Mock.Of(), Mock.Of(), TestHelper.IOHelper, TestHelper.ShortStringHelper, Mock.Of())) { Id = 1 }); - - var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), dataTypeService); - - var converter = new ImageCropperValueConverter(); - var result = converter.ConvertSourceToIntermediate(null, factory.CreatePropertyType("test", 1), val1, false); // does not use type for conversion - - var resultShouldMatch = val2.DeserializeImageCropperValue(); - if (expected) - { - Assert.AreEqual(resultShouldMatch, result); - } - else - { - Assert.AreNotEqual(resultShouldMatch, result); - } - } - finally - { - Current.Reset(); - } - } + // [TestCase(CropperJson1, CropperJson1, true)] + // [TestCase(CropperJson1, CropperJson2, false)] + // public void CanConvertImageCropperPropertyEditor(string val1, string val2, bool expected) + // { + // try + // { + // var container = TestHelper.GetRegister(); + // var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache); + // + // composition.WithCollectionBuilder(); + // + // Current.Factory = composition.CreateFactory(); + // + // var logger = Mock.Of(); + // var scheme = Mock.Of(); + // var shortStringHelper = Mock.Of(); + // + // var mediaFileSystem = new MediaFileSystem(Mock.Of(), scheme, logger, shortStringHelper); + // + // var dataTypeService = new TestObjects.TestDataTypeService( + // new DataType(new ImageCropperPropertyEditor(Mock.Of(), mediaFileSystem, Mock.Of(), Mock.Of(), Mock.Of(), TestHelper.IOHelper, TestHelper.ShortStringHelper, Mock.Of())) { Id = 1 }); + // + // var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), dataTypeService); + // + // var converter = new ImageCropperValueConverter(); + // var result = converter.ConvertSourceToIntermediate(null, factory.CreatePropertyType("test", 1), val1, false); // does not use type for conversion + // + // var resultShouldMatch = val2.DeserializeImageCropperValue(); + // if (expected) + // { + // Assert.AreEqual(resultShouldMatch, result); + // } + // else + // { + // Assert.AreNotEqual(resultShouldMatch, result); + // } + // } + // finally + // { + // Current.Reset(); + // } + // } [Test] public void GetCropUrl_CropAliasTest() diff --git a/src/Umbraco.Tests/Packaging/CreatedPackagesRepositoryTests.cs b/src/Umbraco.Tests/Packaging/CreatedPackagesRepositoryTests.cs index 013e2e5c5f..6533dd6113 100644 --- a/src/Umbraco.Tests/Packaging/CreatedPackagesRepositoryTests.cs +++ b/src/Umbraco.Tests/Packaging/CreatedPackagesRepositoryTests.cs @@ -41,7 +41,7 @@ namespace Umbraco.Tests.Packaging public ICreatedPackagesRepository PackageBuilder => new PackagesRepository( ServiceContext.ContentService, ServiceContext.ContentTypeService, ServiceContext.DataTypeService, ServiceContext.FileService, ServiceContext.MacroService, ServiceContext.LocalizationService, - IOHelper, + HostingEnvironment, Factory.GetInstance(), Logger, UmbracoVersion, Factory.GetInstance(), diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects.cs b/src/Umbraco.Tests/TestHelpers/TestObjects.cs index efd5feb2e0..a26c3c5316 100644 --- a/src/Umbraco.Tests/TestHelpers/TestObjects.cs +++ b/src/Umbraco.Tests/TestHelpers/TestObjects.cs @@ -179,9 +179,9 @@ namespace Umbraco.Tests.TestHelpers var compiledPackageXmlParser = new CompiledPackageXmlParser(new ConflictingPackageData(macroService.Value, fileService.Value), globalSettings); return new PackagingService( auditService.Value, - new PackagesRepository(contentService.Value, contentTypeService.Value, dataTypeService.Value, fileService.Value, macroService.Value, localizationService.Value, ioHelper, + new PackagesRepository(contentService.Value, contentTypeService.Value, dataTypeService.Value, fileService.Value, macroService.Value, localizationService.Value, hostingEnvironment, new EntityXmlSerializer(contentService.Value, mediaService.Value, dataTypeService.Value, userService.Value, localizationService.Value, contentTypeService.Value, urlSegmentProviders, TestHelper.ShortStringHelper, propertyEditorCollection), logger, umbracoVersion, globalSettings, "createdPackages.config"), - new PackagesRepository(contentService.Value, contentTypeService.Value, dataTypeService.Value, fileService.Value, macroService.Value, localizationService.Value, ioHelper, + new PackagesRepository(contentService.Value, contentTypeService.Value, dataTypeService.Value, fileService.Value, macroService.Value, localizationService.Value, hostingEnvironment, new EntityXmlSerializer(contentService.Value, mediaService.Value, dataTypeService.Value, userService.Value, localizationService.Value, contentTypeService.Value, urlSegmentProviders, TestHelper.ShortStringHelper, propertyEditorCollection), logger, umbracoVersion, globalSettings, "installedPackages.config"), new PackageInstallation( new PackageDataInstallation(logger, fileService.Value, macroService.Value, localizationService.Value, dataTypeService.Value, entityService.Value, contentTypeService.Value, contentService.Value, propertyEditorCollection, scopeProvider, shortStringHelper, GetGlobalSettings(), localizedTextService.Value), diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 9b55d7add8..806bf2cdd1 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -302,7 +302,6 @@ - diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeNotificationsController.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeNotificationsController.cs index c5ca1d0815..6bb6e87a5e 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeNotificationsController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeNotificationsController.cs @@ -9,7 +9,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// currently in the request. /// [PrefixlessBodyModelValidator] - [AppendCurrentEventMessagesAttribute] + [AppendCurrentEventMessages] public abstract class BackOfficeNotificationsController : UmbracoAuthorizedJsonController { } diff --git a/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs b/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs index 439ae2e79c..621f3a0e78 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs @@ -31,7 +31,7 @@ namespace Umbraco.Web.BackOffice.Controllers // ref: https://www.exceptionnotfound.net/the-asp-net-web-api-exception-handling-pipeline-a-guided-tour/ [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] //[PrefixlessBodyModelValidator] - [UmbracoApplicationAuthorizeAttribute(Constants.Applications.Settings)] + [UmbracoApplicationAuthorize(Constants.Applications.Settings)] public class CodeFileController : BackOfficeNotificationsController { private readonly IIOHelper _ioHelper; diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs index 1335ee049d..231b8d9a5e 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs @@ -48,7 +48,7 @@ namespace Umbraco.Web.Editors /// This controller is decorated with the UmbracoApplicationAuthorizeAttribute which means that any user requesting /// access to ALL of the methods on this controller will need access to the content application. /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoApplicationAuthorize(Constants.Applications.Content)] public class ContentController : ContentControllerBase { diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs index 936ce02ee5..444667b591 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs @@ -50,7 +50,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// An API controller used for dealing with content types /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoTreeAuthorize(Constants.Trees.DocumentTypes)] public class ContentTypeController : ContentTypeControllerBase { diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeControllerBase.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeControllerBase.cs index 5357ee3ac3..969400e213 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeControllerBase.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeControllerBase.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Am abstract API controller providing functionality used for dealing with content and media types /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] //[PrefixlessBodyModelValidator] //TODO reintroduce public abstract class ContentTypeControllerBase : UmbracoAuthorizedJsonController where TContentType : class, IContentTypeComposition diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index 617a715922..69b566d0cd 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -33,7 +33,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Controller to back the User.Resource service, used for fetching user data when already authenticated. user.service is currently used for handling authentication /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] public class CurrentUserController : UmbracoAuthorizedJsonController { private readonly IMediaFileSystem _mediaFileSystem; diff --git a/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs index bbbea978ba..194029db4b 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs @@ -29,7 +29,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// Content Types, Member Types or Media Types ... and of course to Data Types /// [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] - [UmbracoTreeAuthorizeAttribute(Constants.Trees.DataTypes, Constants.Trees.DocumentTypes, Constants.Trees.MediaTypes, Constants.Trees.MemberTypes)] + [UmbracoTreeAuthorize(Constants.Trees.DataTypes, Constants.Trees.DocumentTypes, Constants.Trees.MediaTypes, Constants.Trees.MemberTypes)] public class DataTypeController : BackOfficeNotificationsController { private readonly PropertyEditorCollection _propertyEditors; @@ -425,7 +425,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Permission is granted to this method if the user has access to any of these sections: Content, media, settings, developer, members /// - [UmbracoTreeAuthorizeAttribute(Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members, + [UmbracoTreeAuthorize(Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members, Constants.Applications.Settings, Constants.Applications.Packages)] public IDictionary> GetGroupedDataTypes() { @@ -457,7 +457,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Permission is granted to this method if the user has access to any of these sections: Content, media, settings, developer, members /// - [UmbracoTreeAuthorizeAttribute(Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members, + [UmbracoTreeAuthorize(Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members, Constants.Applications.Settings, Constants.Applications.Packages)] public IDictionary> GetGroupedPropertyEditors() @@ -490,7 +490,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Permission is granted to this method if the user has access to any of these sections: Content, media, settings, developer, members /// - [UmbracoTreeAuthorizeAttribute(Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members, + [UmbracoTreeAuthorize(Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members, Constants.Applications.Settings, Constants.Applications.Packages)] public IEnumerable GetAllPropertyEditors() diff --git a/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs b/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs index 05c8b3a213..433cf6f345 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs @@ -44,7 +44,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Some objects such as macros are not based on CMSNode /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] public class EntityController : UmbracoAuthorizedJsonController { private readonly ITreeService _treeService; diff --git a/src/Umbraco.Web.BackOffice/Controllers/HelpController.cs b/src/Umbraco.Web.BackOffice/Controllers/HelpController.cs index fe055b5270..24ec184519 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/HelpController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/HelpController.cs @@ -3,11 +3,14 @@ using System.Collections.Generic; using System.Net.Http; using System.Runtime.Serialization; using System.Threading.Tasks; +using Umbraco.Core; using Umbraco.Core.Logging; +using Umbraco.Web.Common.Attributes; using Umbraco.Web.Editors; namespace Umbraco.Web.BackOffice.Controllers { + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] public class HelpController : UmbracoAuthorizedJsonController { private readonly ILogger _logger; diff --git a/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs b/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs index f2cbe571db..14667c1fe5 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs @@ -78,7 +78,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Deletes a language with a given ID /// - [UmbracoTreeAuthorizeAttribute(Constants.Trees.Languages)] + [UmbracoTreeAuthorize(Constants.Trees.Languages)] [HttpDelete] [HttpPost] public IActionResult DeleteLanguage(int id) @@ -107,7 +107,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// Creates or saves a language /// - [UmbracoTreeAuthorizeAttribute(Constants.Trees.Languages)] + [UmbracoTreeAuthorize(Constants.Trees.Languages)] [HttpPost] public Language SaveLanguage(Language language) { diff --git a/src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs b/src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs index 15194221bd..af87b8494b 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs @@ -29,7 +29,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// enable this for webapi controllers, however since this controller is used to render macro content and macros can access /// Session, we don't want it to throw null reference exceptions. /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] public class MacroRenderingController : UmbracoAuthorizedJsonController { private readonly IMacroService _macroService; diff --git a/src/Umbraco.Web.BackOffice/Controllers/MacrosController.cs b/src/Umbraco.Web.BackOffice/Controllers/MacrosController.cs index 720b01acd9..cf951a57c3 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MacrosController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MacrosController.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// The API controller used for editing dictionary items /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoTreeAuthorize(Constants.Trees.Macros)] public class MacrosController : BackOfficeNotificationsController { diff --git a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs index c641e78c0d..6bb68248b1 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs @@ -47,7 +47,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// This controller is decorated with the UmbracoApplicationAuthorizeAttribute which means that any user requesting /// access to ALL of the methods on this controller will need access to the media application. /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoApplicationAuthorize(Constants.Applications.Media)] public class MediaController : ContentControllerBase { diff --git a/src/Umbraco.Web.BackOffice/Controllers/MediaTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/MediaTypeController.cs index bed8ae3183..d030d03cf9 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MediaTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MediaTypeController.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// An API controller used for dealing with content types /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoTreeAuthorize(Constants.Trees.MediaTypes)] public class MediaTypeController : ContentTypeControllerBase { diff --git a/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs b/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs index 0680041c42..9627c96e24 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs @@ -40,7 +40,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// This controller is decorated with the UmbracoApplicationAuthorizeAttribute which means that any user requesting /// access to ALL of the methods on this controller will need access to the member application. /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoApplicationAuthorize(Constants.Applications.Members)] [OutgoingNoHyphenGuidFormat] public class MemberController : ContentControllerBase diff --git a/src/Umbraco.Web.BackOffice/Controllers/MemberGroupController.cs b/src/Umbraco.Web.BackOffice/Controllers/MemberGroupController.cs index 7ca81333d3..153990937d 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MemberGroupController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MemberGroupController.cs @@ -17,7 +17,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// An API controller used for dealing with member groups /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoTreeAuthorize(Constants.Trees.MemberGroups)] public class MemberGroupController : UmbracoAuthorizedJsonController { diff --git a/src/Umbraco.Web.BackOffice/Controllers/MemberTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/MemberTypeController.cs index c3f0a87dde..240a2e0f5b 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MemberTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MemberTypeController.cs @@ -28,7 +28,7 @@ namespace Umbraco.Web.Editors /// /// An API controller used for dealing with member types /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoTreeAuthorize(new string[] { Constants.Trees.MemberTypes, Constants.Trees.Members})] public class MemberTypeController : ContentTypeControllerBase { diff --git a/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs b/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs index e5e39f944f..d8df34748d 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using System.Net; using System.Text; -using System.Web; using Microsoft.AspNetCore.Mvc; using Microsoft.Net.Http.Headers; using Semver; @@ -113,16 +112,15 @@ namespace Umbraco.Web.BackOffice.Controllers var cd = new System.Net.Mime.ContentDisposition { - FileName = HttpUtility.UrlEncode(fileName, encoding), + FileName = WebUtility.UrlEncode(fileName), Inline = false // false = prompt the user for downloading; true = browser to try to show the file inline }; Response.Headers.Add("Content-Disposition", cd.ToString()); // Set custom header so umbRequestHelper.downloadFile can save the correct filename - Response.Headers.Add("x-filename", HttpUtility.UrlEncode(fileName, encoding)); + Response.Headers.Add("x-filename", WebUtility.UrlEncode(fileName)); return new FileStreamResult(System.IO.File.OpenRead(fullPath), new MediaTypeHeaderValue("application/octet-stream") { Charset = encoding.WebName, - }); } diff --git a/src/Umbraco.Web.BackOffice/Controllers/RelationTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/RelationTypeController.cs index 31c77ce0a4..ef7fe94e77 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/RelationTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/RelationTypeController.cs @@ -23,7 +23,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// The API controller for editing relation types. /// [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] - [UmbracoTreeAuthorizeAttribute(Constants.Trees.RelationTypes)] + [UmbracoTreeAuthorize(Constants.Trees.RelationTypes)] public class RelationTypeController : BackOfficeNotificationsController { private readonly ILogger _logger; diff --git a/src/Umbraco.Web.BackOffice/Controllers/TemplateController.cs b/src/Umbraco.Web.BackOffice/Controllers/TemplateController.cs index 0c1798fa8d..b99ebce7a7 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/TemplateController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/TemplateController.cs @@ -17,7 +17,7 @@ using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.BackOffice.Controllers { [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] - [UmbracoTreeAuthorizeAttribute(Constants.Trees.Templates)] + [UmbracoTreeAuthorize(Constants.Trees.Templates)] public class TemplateController : BackOfficeNotificationsController { private readonly IFileService _fileService; diff --git a/src/Umbraco.Web.BackOffice/Controllers/TemplateQueryController.cs b/src/Umbraco.Web.BackOffice/Controllers/TemplateQueryController.cs index 10686f0db5..e0808682d5 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/TemplateQueryController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/TemplateQueryController.cs @@ -15,7 +15,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// The API controller used for building content queries within the template /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [JsonCamelCaseFormatter] public class TemplateQueryController : UmbracoAuthorizedJsonController { diff --git a/src/Umbraco.Web.BackOffice/Controllers/UserGroupsController.cs b/src/Umbraco.Web.BackOffice/Controllers/UserGroupsController.cs index deb9f7fad1..44b675771b 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/UserGroupsController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/UserGroupsController.cs @@ -18,7 +18,7 @@ using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.BackOffice.Controllers { - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoApplicationAuthorize(Constants.Applications.Users)] [PrefixlessBodyModelValidator] public class UserGroupsController : UmbracoAuthorizedJsonController diff --git a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs index 2ef261ff1f..fff609322c 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs @@ -43,7 +43,7 @@ using Umbraco.Web.Security; namespace Umbraco.Web.BackOffice.Controllers { - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [UmbracoApplicationAuthorize(Constants.Applications.Users)] [PrefixlessBodyModelValidator] [IsCurrentUserModelFilter] diff --git a/src/Umbraco.Web.BackOffice/HealthCheck/HealthCheckController.cs b/src/Umbraco.Web.BackOffice/HealthCheck/HealthCheckController.cs index 92d8f1f910..6b8eada506 100644 --- a/src/Umbraco.Web.BackOffice/HealthCheck/HealthCheckController.cs +++ b/src/Umbraco.Web.BackOffice/HealthCheck/HealthCheckController.cs @@ -7,13 +7,15 @@ using Umbraco.Core.Logging; using Umbraco.Core.Configuration.HealthChecks; using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.HealthCheck; +using Umbraco.Web.Common.Attributes; namespace Umbraco.Web.BackOffice.Controllers { /// /// The API controller used to display the health check info and execute any actions /// - [UmbracoApplicationAuthorizeAttribute(Constants.Applications.Settings)] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] + [UmbracoApplicationAuthorize(Constants.Applications.Settings)] public class HealthCheckController : UmbracoAuthorizedJsonController { private readonly HealthCheckCollection _checks; diff --git a/src/Umbraco.Web.BackOffice/Profiling/WebProfilingController.cs b/src/Umbraco.Web.BackOffice/Profiling/WebProfilingController.cs index b5824f73a4..101e00d752 100644 --- a/src/Umbraco.Web.BackOffice/Profiling/WebProfilingController.cs +++ b/src/Umbraco.Web.BackOffice/Profiling/WebProfilingController.cs @@ -2,15 +2,17 @@ using Umbraco.Core.Hosting; using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.BackOffice.Controllers; - +using Umbraco.Web.Common.Attributes; +using Umbraco.Web.Common.Controllers; namespace Umbraco.Web.BackOffice.Profiling { /// /// The API controller used to display the state of the web profiler /// - [UmbracoApplicationAuthorizeAttribute(Constants.Applications.Settings)] - public class WebProfilingController : UmbracoAuthorizedJsonController + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] + [UmbracoApplicationAuthorize(Constants.Applications.Settings)] + public class WebProfilingController : UmbracoAuthorizedJsonController { private readonly IHostingEnvironment _hosting; diff --git a/src/Umbraco.Web.BackOffice/Trees/FileSystemTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/FileSystemTreeController.cs index c9bde4818f..74d2ee90f8 100644 --- a/src/Umbraco.Web.BackOffice/Trees/FileSystemTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/FileSystemTreeController.cs @@ -1,7 +1,7 @@ using System; using System.IO; using System.Linq; -using System.Web; +using System.Net; using Microsoft.AspNetCore.Http; using Umbraco.Core; using Umbraco.Core.IO; @@ -48,7 +48,7 @@ namespace Umbraco.Web.BackOffice.Trees protected override TreeNodeCollection GetTreeNodes(string id, FormCollection queryStrings) { var path = string.IsNullOrEmpty(id) == false && id != Constants.System.RootString - ? HttpUtility.UrlDecode(id).TrimStart("/") + ? WebUtility.UrlDecode(id).TrimStart("/") : ""; var directories = FileSystem.GetDirectories(path); @@ -59,7 +59,7 @@ namespace Umbraco.Web.BackOffice.Trees var hasChildren = FileSystem.GetFiles(directory).Any() || FileSystem.GetDirectories(directory).Any(); var name = Path.GetFileName(directory); - var node = CreateTreeNode(HttpUtility.UrlEncode(directory), path, queryStrings, name, "icon-folder", hasChildren); + var node = CreateTreeNode(WebUtility.UrlEncode(directory), path, queryStrings, name, "icon-folder", hasChildren); OnRenderFolderNode(ref node); if (node != null) nodes.Add(node); @@ -83,7 +83,7 @@ namespace Umbraco.Web.BackOffice.Trees if (withoutExt.IsNullOrWhiteSpace()) continue; var name = Path.GetFileName(file); - var node = CreateTreeNode(HttpUtility.UrlEncode(file), path, queryStrings, name, FileIcon, false); + var node = CreateTreeNode(WebUtility.UrlEncode(file), path, queryStrings, name, FileIcon, false); OnRenderFileNode(ref node); if (node != null) nodes.Add(node); @@ -159,7 +159,7 @@ namespace Umbraco.Web.BackOffice.Trees var menu = MenuItemCollectionFactory.Create(); var path = string.IsNullOrEmpty(id) == false && id != Constants.System.RootString - ? HttpUtility.UrlDecode(id).TrimStart("/") + ? WebUtility.UrlDecode(id).TrimStart("/") : ""; var isFile = FileSystem.FileExists(path); diff --git a/src/Umbraco.Web.BackOffice/Trees/UrlHelperExtensions.cs b/src/Umbraco.Web.BackOffice/Trees/UrlHelperExtensions.cs index bf4d09a497..878a23b38f 100644 --- a/src/Umbraco.Web.BackOffice/Trees/UrlHelperExtensions.cs +++ b/src/Umbraco.Web.BackOffice/Trees/UrlHelperExtensions.cs @@ -1,7 +1,7 @@ using System; using System.Linq; +using System.Net; using System.Text; -using System.Web; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Umbraco.Core; @@ -32,7 +32,7 @@ namespace Umbraco.Extensions for (var p = 0; p < pathPaths.Length; p++) { - var path = HttpUtility.UrlEncode(string.Join("/", pathPaths.Take(p + 1))); + var path = WebUtility.UrlEncode(string.Join("/", pathPaths.Take(p + 1))); if (string.IsNullOrEmpty(path) == false) { sb.Append(","); diff --git a/src/Umbraco.Web/ImageCropperTemplateCoreExtensions.cs b/src/Umbraco.Web.Common/Extensions/ImageCropperTemplateCoreExtensions.cs similarity index 88% rename from src/Umbraco.Web/ImageCropperTemplateCoreExtensions.cs rename to src/Umbraco.Web.Common/Extensions/ImageCropperTemplateCoreExtensions.cs index 0b7e065c59..45c6c15000 100644 --- a/src/Umbraco.Web/ImageCropperTemplateCoreExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/ImageCropperTemplateCoreExtensions.cs @@ -7,8 +7,9 @@ using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors.ValueConverters; using Umbraco.Web.Models; using Umbraco.Core.Media; +using Umbraco.Web.Routing; -namespace Umbraco.Web +namespace Umbraco.Extensions { public static class ImageCropperTemplateCoreExtensions { @@ -21,12 +22,20 @@ namespace Umbraco.Web /// /// The crop alias e.g. thumbnail /// + /// The image url generator. + /// The published value fallback. + /// The published url provider. /// /// The ImageProcessor.Web Url. /// - public static string GetCropUrl(this IPublishedContent mediaItem, string cropAlias, IImageUrlGenerator imageUrlGenerator) + public static string GetCropUrl( + this IPublishedContent mediaItem, + string cropAlias, + IImageUrlGenerator imageUrlGenerator, + IPublishedValueFallback publishedValueFallback, + IPublishedUrlProvider publishedUrlProvider) { - return mediaItem.GetCropUrl(imageUrlGenerator, cropAlias: cropAlias, useCropDimensions: true); + return mediaItem.GetCropUrl(imageUrlGenerator, publishedValueFallback, publishedUrlProvider, cropAlias: cropAlias, useCropDimensions: true); } /// @@ -41,12 +50,21 @@ namespace Umbraco.Web /// /// The crop alias e.g. thumbnail /// + /// The image url generator. + /// The published value fallback. + /// The published url provider. /// /// The ImageProcessor.Web Url. /// - public static string GetCropUrl(this IPublishedContent mediaItem, string propertyAlias, string cropAlias, IImageUrlGenerator imageUrlGenerator) + public static string GetCropUrl( + this IPublishedContent mediaItem, + string propertyAlias, + string cropAlias, + IImageUrlGenerator imageUrlGenerator, + IPublishedValueFallback publishedValueFallback, + IPublishedUrlProvider publishedUrlProvider) { - return mediaItem.GetCropUrl(imageUrlGenerator, propertyAlias: propertyAlias, cropAlias: cropAlias, useCropDimensions: true); + return mediaItem.GetCropUrl( imageUrlGenerator, publishedValueFallback, publishedUrlProvider, propertyAlias: propertyAlias, cropAlias: cropAlias, useCropDimensions: true); } /// @@ -55,6 +73,9 @@ namespace Umbraco.Web /// /// The IPublishedContent item. /// + /// The image url generator. + /// The published value fallback. + /// The published url provider. /// /// The width of the output image. /// @@ -99,12 +120,15 @@ namespace Umbraco.Web /// /// If the image should be upscaled to requested dimensions /// + /// /// The . /// public static string GetCropUrl( this IPublishedContent mediaItem, IImageUrlGenerator imageUrlGenerator, + IPublishedValueFallback publishedValueFallback, + IPublishedUrlProvider publishedUrlProvider, int? width = null, int? height = null, string propertyAlias = Constants.Conventions.Media.File, @@ -126,10 +150,10 @@ namespace Umbraco.Web if (mediaItem.HasProperty(propertyAlias) == false || mediaItem.HasValue(propertyAlias) == false) return string.Empty; - var mediaItemUrl = mediaItem.MediaUrl(propertyAlias: propertyAlias); + var mediaItemUrl = mediaItem.MediaUrl(publishedUrlProvider, propertyAlias: propertyAlias); //get the default obj from the value converter - var cropperValue = mediaItem.Value(propertyAlias); + var cropperValue = mediaItem.Value(publishedValueFallback, propertyAlias); //is it strongly typed? var stronglyTyped = cropperValue as ImageCropperValue; diff --git a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs b/src/Umbraco.Web.Common/Extensions/ImageCropperTemplateExtensions.cs similarity index 95% rename from src/Umbraco.Web/ImageCropperTemplateExtensions.cs rename to src/Umbraco.Web.Common/Extensions/ImageCropperTemplateExtensions.cs index 3c10aba227..ddcd8e7abe 100644 --- a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/ImageCropperTemplateExtensions.cs @@ -1,11 +1,11 @@ using System; using System.Globalization; using Newtonsoft.Json; +using Umbraco.Composing; using Umbraco.Core; -using Umbraco.Web.Composing; using Umbraco.Core.PropertyEditors.ValueConverters; -namespace Umbraco.Web +namespace Umbraco.Extensions { /// /// Provides extension methods for getting ImageProcessor Url from the core Image Cropper property editor diff --git a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs index 7a1d907520..959c4c27a2 100644 --- a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs +++ b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs @@ -17,6 +17,7 @@ using Umbraco.Web.Common.Profiler; using Umbraco.Web.Common.Install; using Umbraco.Extensions; using System.Linq; +using Umbraco.Core.Configuration; using Umbraco.Web.Common.Controllers; using Umbraco.Web.Common.Middleware; using Umbraco.Web.Common.ModelBinding; @@ -95,6 +96,7 @@ namespace Umbraco.Web.Common.Runtime composition.RegisterUnique(); composition.RegisterUnique(); + composition.RegisterUnique(factory => new LegacyPasswordSecurity(factory.GetInstance())); } diff --git a/src/Umbraco.Web.Common/Umbraco.Web.Common.csproj b/src/Umbraco.Web.Common/Umbraco.Web.Common.csproj index 447681c4ff..979764af7e 100644 --- a/src/Umbraco.Web.Common/Umbraco.Web.Common.csproj +++ b/src/Umbraco.Web.Common/Umbraco.Web.Common.csproj @@ -25,8 +25,8 @@ - - + + diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Gallery.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/Gallery.cshtml similarity index 50% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Gallery.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/Gallery.cshtml index 8388c7a90d..8e5ab9fd7d 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Gallery.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/Gallery.cshtml @@ -2,8 +2,14 @@ @using Umbraco.Web @using Umbraco.Core @using Umbraco.Core.Media -@using Umbraco.Web.Composing -@inherits Umbraco.Web.Macros.PartialViewMacroPage +@using Umbraco.Extensions +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedContentQuery PublishedContentQuery +@inject IVariationContextAccessor VariationContextAccessor +@inject IPublishedUrlProvider PublishedUrlProvider +@inject IImageUrlGenerator ImageUrlGenerator @* Macro to display a gallery of images from the Media section. @@ -26,28 +32,27 @@
@foreach (var mediaId in mediaIds.Split(',')) { - var media = Current.PublishedContentQuery.Media(mediaId); + var media = PublishedContentQuery.Media(mediaId); @* a single image *@ if (media.IsDocumentType("Image")) { - @Render(media) +
+ + @media.Name + +
} @* a folder with images under it *@ - foreach (var image in media.Children(Current.VariationContextAccessor)) + foreach (var image in media.Children(VariationContextAccessor)) { - @Render(image) +
+ + @image.Name + +
} }
} - -@helper Render(IPublishedContent item) -{ -
- - @item.Name - -
-} diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml similarity index 77% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml index 070f67ff23..2b2e04064b 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml @@ -1,7 +1,7 @@ @using Umbraco.Core -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedUrlProvider PublishedUrlProvider @* This snippet makes a list of links to the of parents of the current page using an unordered HTML list. @@ -18,7 +18,7 @@ @* For each page in the ancestors collection which have been ordered by Level (so we start with the highest top node first) *@ @foreach (var item in selection.OrderBy(x => x.Level)) { -
  • @item.Name »
  • +
  • @item.Name »
  • } @* Display the current page as the last item in the list *@ diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml similarity index 57% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml index ec41d45c0c..0cc090fd9e 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml @@ -1,7 +1,11 @@ +@using Umbraco.Core +@using Umbraco.Core.Models.PublishedContent @using Umbraco.Web -@using Umbraco.Web.Composing -@inherits Umbraco.Web.Macros.PartialViewMacroPage - +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedContentQuery PublishedContentQuery +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider @* Macro to list all child pages under a specific page in the content tree. @@ -19,15 +23,15 @@ @if (startNodeId != null) { @* Get the starting page *@ - var startNode = Current.PublishedContentQuery.Content(startNodeId); - var selection = startNode.Children.Where(x => x.IsVisible()).ToArray(); + var startNode = PublishedContentQuery.Content(startNodeId); + var selection = startNode.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); if (selection.Length > 0) { } diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml similarity index 56% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml index e6606d6204..1b3c04beb1 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml @@ -1,6 +1,9 @@ -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - +@using Umbraco.Core +@using Umbraco.Core.Models.PublishedContent +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider @* This snippet makes a list of links to the of children of the current page using an unordered HTML list. @@ -9,7 +12,7 @@ - It then generates links so the visitor can go to each page *@ -@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).ToArray(); } +@{ var selection = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); } @if (selection.Length > 0) { @@ -17,7 +20,7 @@ @foreach (var item in selection) {
  • - @item.Name + @item.Name
  • } diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml similarity index 57% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml index 2c2cc4422b..896fdda614 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml @@ -1,6 +1,9 @@ -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - +@using Umbraco.Core +@using Umbraco.Core.Models.PublishedContent +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider @* This snippet makes a list of links to the of children of the current page using an unordered HTML list. @@ -10,14 +13,14 @@ - It then generates links so the visitor can go to each page *@ -@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderByDescending(x => x.CreateDate).ToArray(); } +@{ var selection = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).OrderByDescending(x => x.CreateDate).ToArray(); } @if (selection.Length > 0) { } diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml similarity index 57% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml index d0398e7272..b80ff6ead7 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml @@ -1,6 +1,9 @@ -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - +@using Umbraco.Core +@using Umbraco.Core.Models.PublishedContent +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider @* This snippet makes a list of links to the of children of the current page using an unordered HTML list. @@ -10,14 +13,14 @@ - It then generates links so the visitor can go to each page *@ -@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.Name).ToArray(); } +@{ var selection = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).OrderBy(x => x.Name).ToArray(); } @if (selection.Length > 0) { } diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml similarity index 63% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml index 1bffae04c4..e2c7ae19df 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml @@ -1,6 +1,9 @@ -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - +@using Umbraco.Core +@using Umbraco.Core.Models.PublishedContent +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider @* Macro to list all child pages with a specific property, sorted by the value of that property. @@ -17,14 +20,14 @@ @if (propertyAlias != null) { - var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.Value(propertyAlias.ToString())).ToArray(); + var selection = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).OrderBy(x => x.Value(PublishedValueFallback, propertyAlias.ToString())).ToArray(); if (selection.Length > 0) { } diff --git a/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesWithDoctype.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesWithDoctype.cshtml new file mode 100644 index 0000000000..6aa3771fd3 --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListChildPagesWithDoctype.cshtml @@ -0,0 +1,25 @@ +@using Umbraco.Core +@using Umbraco.Core.Models.PublishedContent +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IVariationContextAccessor VariationContextAccessor +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider +@* + This snippet shows how simple it is to fetch only children of a certain Document Type. + + Be sure to change "IPublishedContent" below to match your needs, such as "TextPage" or "NewsItem". + (You can find the alias of your Document Type by editing it in the Settings section) +*@ + +@{ var selection = Model.Content.Children(VariationContextAccessor).Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); } + +@if (selection.Length > 0) +{ +
      + @foreach (var item in selection) + { +
    • @item.Name
    • + } +
    +} diff --git a/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml new file mode 100644 index 0000000000..a891839cec --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml @@ -0,0 +1,72 @@ +@using Umbraco.Core +@using Umbraco.Core.Models.PublishedContent +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider +@* + This snippet creates links for every single page (no matter how deep) below + the page currently being viewed by the website visitor, displayed as nested unordered HTML lists. +*@ + +@{ var selection = Model.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); } + +@* Ensure that the Current Page has children *@ +@if (selection.Length > 0) +{ + @* Get the first page in the children, where the property umbracoNaviHide is not True *@ + var naviLevel = selection[0].Level; + + @* Add in level for a CSS hook *@ +
      + @* Loop through the selection *@ + @foreach (var item in selection) + { +
    • + @item.Name + + @* if this child page has any children, where the property umbracoNaviHide is not True *@ + @{ + var children = item.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); + if (children.Length > 0) + { + @* Call a local method to display the children *@ + ChildPages(children); + } + } +
    • + } +
    +} + +@{ + void ChildPages(IPublishedContent[] selection) + { + //Ensure that we have a collection of pages + if (selection.Length > 0) + { + // Get the first page in pages and get the level + var naviLevel = selection[0].Level; + + // Add in level for a CSS hook +
      + @foreach (var item in selection) + { +
    • + @item.Name + + @* if the page has any children, where the property umbracoNaviHide is not True *@ + @{ + var children = item.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); + if (children.Length > 0) + { + @* Recurse and call the ChildPages method to display the children *@ + ChildPages(children); + } + } +
    • + } +
    + } + } +} diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml similarity index 71% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml index 386bc824df..93bde0a1c4 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml @@ -1,7 +1,9 @@ +@using Umbraco.Core @using Umbraco.Web -@using Umbraco.Web.Composing -@inherits Umbraco.Web.Macros.PartialViewMacroPage - +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedContentQuery PublishedContentQuery +@inject IPublishedUrlProvider PublishedUrlProvider @* Macro to display a series of images from a media folder. @@ -19,7 +21,7 @@ @if (mediaId != null) { @* Get the media item associated with the id passed in *@ - var media = Current.PublishedContentQuery.Media(mediaId); + var media = PublishedContentQuery.Media(mediaId); var selection = media.Children.ToArray(); if (selection.Length > 0) @@ -28,7 +30,7 @@ @foreach (var item in selection) {
  • - @item.Name + @item.Name
  • } diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/MultinodeTree-picker.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/MultinodeTree-picker.cshtml similarity index 63% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/MultinodeTree-picker.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/MultinodeTree-picker.cshtml index d845e699e0..c8f0d9c52f 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/MultinodeTree-picker.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/MultinodeTree-picker.cshtml @@ -1,7 +1,9 @@ +@using Umbraco.Core @using Umbraco.Core.Models.PublishedContent -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider @* This snippet lists the items from a Multinode tree picker, using the picker's default settings. Content Values stored as XML. @@ -10,7 +12,7 @@ multinode treepicker (so: replace "PropertyWithPicker" with the alias of your property). *@ -@{ var selection = Model.Content.Value>("PropertyWithPicker").ToArray(); } +@{ var selection = Model.Content.Value>(PublishedValueFallback, "PropertyWithPicker").ToArray(); } @if (selection.Length > 0) { @@ -18,7 +20,7 @@ @foreach (var item in selection) {
  • - @item.Name + @item.Name
  • } diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/Navigation.cshtml similarity index 61% rename from src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml rename to src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/Navigation.cshtml index 15427f4b3c..5476a3af61 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/Navigation.cshtml @@ -1,14 +1,16 @@ @using Umbraco.Core -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - +@using Umbraco.Core.Models.PublishedContent +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider @* This snippet displays a list of links of the pages immediately under the top-most page in the content tree. This is the home page for a standard website. It also highlights the current active page/section in the navigation with the CSS class "current". *@ -@{ var selection = Model.Content.Root().Children.Where(x => x.IsVisible()).ToArray(); } +@{ var selection = Model.Content.Root().Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); } @if (selection.Length > 0) { @@ -16,7 +18,7 @@ @foreach (var item in selection) {
  • - @item.Name + @item.Name
  • } diff --git a/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml new file mode 100644 index 0000000000..e6ad50d200 --- /dev/null +++ b/src/Umbraco.Web.UI.NetCore/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml @@ -0,0 +1,47 @@ +@using Umbraco.Core +@using Umbraco.Core.Models.PublishedContent +@using Umbraco.Web.Routing +@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage +@inject IPublishedValueFallback PublishedValueFallback +@inject IPublishedUrlProvider PublishedUrlProvider +@* + This snippet makes a list of links of all visible pages of the site, as nested unordered HTML lists. + + How it works: + - It uses a local method called Traverse() to select and display the markup and links. +*@ + +@{ var selection = Model.Content.Root(); } + +
    + @* Render the sitemap by passing the root node to the traverse method, below *@ + @{ Traverse(selection); } +
    + +@* Helper method to traverse through all descendants *@ +@{ + void Traverse(IPublishedContent node) + { + //Update the level to reflect how deep you want the sitemap to go + const int maxLevelForSitemap = 4; + + @* Select visible children *@ + var selection = node.Children.Where(x => x.IsVisible(PublishedValueFallback) && x.Level <= maxLevelForSitemap).ToArray(); + + @* If any items are returned, render a list *@ + if (selection.Length > 0) + { +
      + @foreach (var item in selection) + { +
    • + @item.Name + + @* Run the traverse method again for any child pages *@ + @{ Traverse(item); } +
    • + } +
    + } + } +} diff --git a/src/Umbraco.Web.UI.NetCore/appsettings.json b/src/Umbraco.Web.UI.NetCore/appsettings.json index 8a1ccba072..6bec080f56 100644 --- a/src/Umbraco.Web.UI.NetCore/appsettings.json +++ b/src/Umbraco.Web.UI.NetCore/appsettings.json @@ -1,123 +1,123 @@ { - "ConnectionStrings": { - "umbracoDbDSN": "" - }, - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*", - "Umbraco": { - "CMS": { - "Hosting": { - "Debug": true - }, - "RuntimeMinification": { - "dataFolder": "App_Data/TEMP/Smidge", - "version": "637212411755687059" - }, - "Imaging": { - "Resize": { - "MaxWidth": 5000, - "MaxHeight": 5000 - }, - "Cache": { - "Folder": "../App_Data/Cache", - "MaxBrowserCacheDays": 7, - "MaxCacheDays": 365, - "CachedNameLength": 8 + "ConnectionStrings": { + "umbracoDbDSN": "" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" } - }, - "HealthChecks": { - "DisabledChecks": [ - { - "id": "1B5D221B-CE99-4193-97CB-5F3261EC73DF", - "disabledBy": 1, - "disabledOn": "2020-03-15 19:19:10" - } - ], - "NotificationSettings": { - "Enabled": true, - "FirstRunTime": "", - "PeriodInHours": 24, - "NotificationMethods": { - "Email": { - "Enabled": true, - "Verbosity": "Summary", - "Settings": { - "RecipientEmail": "" - } + }, + "AllowedHosts": "*", + "Umbraco": { + "CMS": { + "Hosting": { + "Debug": true + }, + "RuntimeMinification": { + "dataFolder": "App_Data/TEMP/Smidge", + "version": "637212411755687059" + }, + "Imaging": { + "Resize": { + "MaxWidth": 5000, + "MaxHeight": 5000 + }, + "Cache": { + "Folder": "../App_Data/Cache", + "MaxBrowserCacheDays": 7, + "MaxCacheDays": 365, + "CachedNameLength": 8 + } + }, + "HealthChecks": { + "DisabledChecks": [ + { + "id": "1B5D221B-CE99-4193-97CB-5F3261EC73DF", + "disabledBy": 1, + "disabledOn": "2020-03-15 19:19:10" + } + ], + "NotificationSettings": { + "Enabled": true, + "FirstRunTime": "", + "PeriodInHours": 24, + "NotificationMethods": { + "Email": { + "Enabled": true, + "Verbosity": "Summary", + "Settings": { + "RecipientEmail": "" + } + } + }, + "DisabledChecks": [ + { + "id": "1B5D221B-CE99-4193-97CB-5F3261EC73DF", + "disabledBy": 1, + "disabledOn": "2020-03-15 19:19:10" + } + ] + } + }, + "Tours": { + "EnableTours": true + }, + "Core": { + "Debug": {} + }, + "Content": { + "Errors": { + "Error404": { + "default": "1047", + "en-US": "$site/error [@name = 'error']", + "en-UK": "8560867F-B88F-4C74-A9A4-679D8E5B3BFC" + } + }, + "LoginBackgroundImage": "assets/img/login.jpg" + }, + "RequestHandler": { + "AddTrailingSlash": true, + "CharCollection": [ + { + "Char": " ", + "Replacement": "-" + }, + { + "Char": "\"", + "Replacement": "" + }, + { + "Char": "'", + "Replacement": "" + }, + { + "Char": "%", + "Replacement": "" + }, + { + "Char": ".", + "Replacement": "" + }, + { + "Char": ";", + "Replacement": "" + }, + { + "Char": "/", + "Replacement": "" + }, + { + "Char": "\\", + "Replacement": "" + }, + { + "Char": ":", + "Replacement": "" + } + ] } - }, - "DisabledChecks": [ - { - "id": "1B5D221B-CE99-4193-97CB-5F3261EC73DF", - "disabledBy": 1, - "disabledOn": "2020-03-15 19:19:10" - } - ] } - }, - "Tours": { - "EnableTours": true - }, - "Core": { - "Debug": {} - }, - "Content": { - "Errors": { - "Error404": { - "default": "1047", - "en-US": "$site/error [@name = 'error']", - "en-UK": "8560867F-B88F-4C74-A9A4-679D8E5B3BFC" - } - }, - "LoginBackgroundImage": "assets/img/login.jpg" - }, - "RequestHandler": { - "AddTrailingSlash": true, - "CharCollection": [ - { - "Char": " ", - "Replacement": "-" - }, - { - "Char": "\"", - "Replacement": "" - }, - { - "Char": "'", - "Replacement": "" - }, - { - "Char": "%", - "Replacement": "" - }, - { - "Char": ".", - "Replacement": "" - }, - { - "Char": ";", - "Replacement": "" - }, - { - "Char": "/", - "Replacement": "" - }, - { - "Char": "\\", - "Replacement": "" - }, - { - "Char": ":", - "Replacement": "" - } - ] - } } - } } diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 88ba56b9a4..8e0d7177cf 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -190,46 +190,6 @@ true PreserveNewest - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - true PreserveNewest @@ -238,22 +198,10 @@ true PreserveNewest - - true - PreserveNewest - - - true - PreserveNewest - true PreserveNewest - - true - PreserveNewest - @@ -409,4 +357,4 @@ - + \ No newline at end of file diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesWithDoctype.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesWithDoctype.cshtml deleted file mode 100644 index c90e419903..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesWithDoctype.cshtml +++ /dev/null @@ -1,22 +0,0 @@ -@using Umbraco.Core.Models.PublishedContent -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - -@* - This snippet shows how simple it is to fetch only children of a certain Document Type. - - Be sure to change "IPublishedContent" below to match your needs, such as "TextPage" or "NewsItem". - (You can find the alias of your Document Type by editing it in the Settings section) -*@ - -@{ var selection = Model.Content.Children().Where(x => x.IsVisible()).ToArray(); } - -@if (selection.Length > 0) -{ -
      - @foreach (var item in selection) - { -
    • @item.Name
    • - } -
    -} diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml deleted file mode 100644 index 7ae917b41d..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml +++ /dev/null @@ -1,68 +0,0 @@ -@using Umbraco.Core.Models.PublishedContent -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - -@* - This snippet creates links for every single page (no matter how deep) below - the page currently being viewed by the website visitor, displayed as nested unordered HTML lists. -*@ - -@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).ToArray(); } - -@* Ensure that the Current Page has children *@ -@if (selection.Length > 0) -{ - @* Get the first page in the children, where the property umbracoNaviHide is not True *@ - var naviLevel = selection[0].Level; - - @* Add in level for a CSS hook *@ -
      - @* Loop through the selection *@ - @foreach (var item in selection) - { -
    • - @item.Name - - @* if this child page has any children, where the property umbracoNaviHide is not True *@ - @{ - var children = item.Children.Where(x => x.IsVisible()).ToArray(); - if (children.Length > 0) - { - @* Call our helper to display the children *@ - @ChildPages(children) - } - } -
    • - } -
    -} - -@helper ChildPages(IPublishedContent[] selection) -{ - @* Ensure that we have a collection of pages *@ - if (selection.Length > 0) - { - @* Get the first page in pages and get the level *@ - var naviLevel = selection[0].Level; - - @* Add in level for a CSS hook *@ -
      - @foreach (var item in selection) - { -
    • - @item.Name - - @* if the page has any children, where the property umbracoNaviHide is not True *@ - @{ - var children = item.Children.Where(x => x.IsVisible()).ToArray(); - if (children.Length > 0) - { - @* Recurse and call our helper to display the children *@ - @ChildPages(children) - } - } -
    • - } -
    - } -} diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml deleted file mode 100644 index a4127a9636..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml +++ /dev/null @@ -1,44 +0,0 @@ -@using Umbraco.Core -@using Umbraco.Core.Models.PublishedContent -@using Umbraco.Web -@inherits Umbraco.Web.Macros.PartialViewMacroPage - -@* - This snippet makes a list of links of all visible pages of the site, as nested unordered HTML lists. - - How it works: - - It uses a custom Razor helper called Traverse() to select and display the markup and links. -*@ - -@{ var selection = Model.Content.Root(); } - -
    - @* Render the sitemap by passing the root node to the traverse helper, below *@ - @Traverse(selection) -
    - -@* Helper method to traverse through all descendants *@ -@helper Traverse(IPublishedContent node) -{ - @* Update the level to reflect how deep you want the sitemap to go *@ - const int maxLevelForSitemap = 4; - - @* Select visible children *@ - var selection = node.Children.Where(x => x.IsVisible() && x.Level <= maxLevelForSitemap).ToArray(); - - @* If any items are returned, render a list *@ - if (selection.Length > 0) - { -
      - @foreach (var item in selection) - { -
    • - @item.Name - - @* Run the traverse helper again for any child pages *@ - @Traverse(item) -
    • - } -
    - } -} diff --git a/src/Umbraco.Web.Website/ActionResults/RedirectToUmbracoPageResult.cs b/src/Umbraco.Web.Website/ActionResults/RedirectToUmbracoPageResult.cs index d271e63e2f..4b400b35dd 100644 --- a/src/Umbraco.Web.Website/ActionResults/RedirectToUmbracoPageResult.cs +++ b/src/Umbraco.Web.Website/ActionResults/RedirectToUmbracoPageResult.cs @@ -1,8 +1,7 @@ using System; using System.Collections.Specialized; -using System.Linq; using System.Threading.Tasks; -using System.Web; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.Extensions.DependencyInjection; @@ -20,7 +19,7 @@ namespace Umbraco.Web.Website.ActionResults { private IPublishedContent _publishedContent; private readonly int _pageId; - private readonly NameValueCollection _queryStringValues; + private readonly QueryString _queryString; private readonly IPublishedUrlProvider _publishedUrlProvider; private readonly IUmbracoContextAccessor _umbracoContextAccessor; private string _url; @@ -79,24 +78,10 @@ namespace Umbraco.Web.Website.ActionResults /// /// /// - public RedirectToUmbracoPageResult(int pageId, NameValueCollection queryStringValues, IPublishedUrlProvider publishedUrlProvider, IUmbracoContextAccessor umbracoContextAccessor) + public RedirectToUmbracoPageResult(int pageId, QueryString queryString, IPublishedUrlProvider publishedUrlProvider, IUmbracoContextAccessor umbracoContextAccessor) { _pageId = pageId; - _queryStringValues = queryStringValues; - _publishedUrlProvider = publishedUrlProvider; - _umbracoContextAccessor = umbracoContextAccessor; - } - - /// - /// Creates a new RedirectToUmbracoResult - /// - /// - /// - /// - public RedirectToUmbracoPageResult(int pageId, string queryString, IPublishedUrlProvider publishedUrlProvider, IUmbracoContextAccessor umbracoContextAccessor) - { - _pageId = pageId; - _queryStringValues = ParseQueryString(queryString); + _queryString = queryString; _publishedUrlProvider = publishedUrlProvider; _umbracoContextAccessor = umbracoContextAccessor; } @@ -115,22 +100,6 @@ namespace Umbraco.Web.Website.ActionResults _umbracoContextAccessor = umbracoContextAccessor; } - /// - /// Creates a new RedirectToUmbracoResult - /// - /// - /// - /// - /// - public RedirectToUmbracoPageResult(IPublishedContent publishedContent, NameValueCollection queryStringValues, IPublishedUrlProvider publishedUrlProvider, IUmbracoContextAccessor umbracoContextAccessor) - { - _publishedContent = publishedContent; - _pageId = publishedContent.Id; - _queryStringValues = queryStringValues; - _publishedUrlProvider = publishedUrlProvider; - _umbracoContextAccessor = umbracoContextAccessor; - } - /// /// Creates a new RedirectToUmbracoResult /// @@ -138,11 +107,11 @@ namespace Umbraco.Web.Website.ActionResults /// /// /// - public RedirectToUmbracoPageResult(IPublishedContent publishedContent, string queryString, IPublishedUrlProvider publishedUrlProvider, IUmbracoContextAccessor umbracoContextAccessor) + public RedirectToUmbracoPageResult(IPublishedContent publishedContent, QueryString queryString, IPublishedUrlProvider publishedUrlProvider, IUmbracoContextAccessor umbracoContextAccessor) { _publishedContent = publishedContent; _pageId = publishedContent.Id; - _queryStringValues = ParseQueryString(queryString); + _queryString = queryString; _publishedUrlProvider = publishedUrlProvider; _umbracoContextAccessor = umbracoContextAccessor; } @@ -155,10 +124,9 @@ namespace Umbraco.Web.Website.ActionResults var ioHelper = httpContext.RequestServices.GetRequiredService(); var destinationUrl = ioHelper.ResolveUrl(Url); - if (!(_queryStringValues is null) && _queryStringValues.Count > 0) + if (_queryString.HasValue) { - destinationUrl += "?" + string.Join("&", - _queryStringValues.AllKeys.Select(x => x + "=" + HttpUtility.UrlEncode(_queryStringValues[x]))); + destinationUrl += _queryString.ToUriComponent(); } var tempDataDictionaryFactory = context.HttpContext.RequestServices.GetRequiredService(); @@ -170,9 +138,5 @@ namespace Umbraco.Web.Website.ActionResults return Task.CompletedTask; } - private NameValueCollection ParseQueryString(string queryString) - { - return !string.IsNullOrEmpty(queryString) ? HttpUtility.ParseQueryString(queryString) : null; - } } } diff --git a/src/Umbraco.Web.Website/Controllers/SurfaceController.cs b/src/Umbraco.Web.Website/Controllers/SurfaceController.cs index 161fe1750f..be6ee8ddce 100644 --- a/src/Umbraco.Web.Website/Controllers/SurfaceController.cs +++ b/src/Umbraco.Web.Website/Controllers/SurfaceController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Specialized; +using Microsoft.AspNetCore.Http; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Logging; @@ -54,24 +55,13 @@ namespace Umbraco.Web.Website.Controllers return new RedirectToUmbracoPageResult(pageId, _publishedUrlProvider, UmbracoContextAccessor); } - /// - /// Redirects to the Umbraco page with the given id and passes provided querystring - /// - /// - /// - /// - protected RedirectToUmbracoPageResult RedirectToUmbracoPage(int pageId, NameValueCollection queryStringValues) - { - return new RedirectToUmbracoPageResult(pageId, queryStringValues, _publishedUrlProvider, UmbracoContextAccessor); - } - /// /// Redirects to the Umbraco page with the given id and passes provided querystring /// /// /// /// - protected RedirectToUmbracoPageResult RedirectToUmbracoPage(int pageId, string queryString) + protected RedirectToUmbracoPageResult RedirectToUmbracoPage(int pageId, QueryString queryString) { return new RedirectToUmbracoPageResult(pageId, queryString, _publishedUrlProvider, UmbracoContextAccessor); } @@ -86,24 +76,13 @@ namespace Umbraco.Web.Website.Controllers return new RedirectToUmbracoPageResult(publishedContent, _publishedUrlProvider, UmbracoContextAccessor); } - /// - /// Redirects to the Umbraco page with the given published content and passes provided querystring - /// - /// - /// - /// - protected RedirectToUmbracoPageResult RedirectToUmbracoPage(IPublishedContent publishedContent, NameValueCollection queryStringValues) - { - return new RedirectToUmbracoPageResult(publishedContent, queryStringValues, _publishedUrlProvider, UmbracoContextAccessor); - } - /// /// Redirects to the Umbraco page with the given published content and passes provided querystring /// /// /// /// - protected RedirectToUmbracoPageResult RedirectToUmbracoPage(IPublishedContent publishedContent, string queryString) + protected RedirectToUmbracoPageResult RedirectToUmbracoPage(IPublishedContent publishedContent, QueryString queryString) { return new RedirectToUmbracoPageResult(publishedContent, queryString, _publishedUrlProvider, UmbracoContextAccessor); } @@ -117,22 +96,12 @@ namespace Umbraco.Web.Website.Controllers return new RedirectToUmbracoPageResult(CurrentPage, _publishedUrlProvider, UmbracoContextAccessor); } - /// - /// Redirects to the currently rendered Umbraco page and passes provided querystring - /// - /// - /// - protected RedirectToUmbracoPageResult RedirectToCurrentUmbracoPage(NameValueCollection queryStringValues) - { - return new RedirectToUmbracoPageResult(CurrentPage, queryStringValues, _publishedUrlProvider, UmbracoContextAccessor); - } - /// /// Redirects to the currently rendered Umbraco page and passes provided querystring /// /// /// - protected RedirectToUmbracoPageResult RedirectToCurrentUmbracoPage(string queryString) + protected RedirectToUmbracoPageResult RedirectToCurrentUmbracoPage(QueryString queryString) { return new RedirectToUmbracoPageResult(CurrentPage, queryString, _publishedUrlProvider, UmbracoContextAccessor); } diff --git a/src/Umbraco.Web.Website/Umbraco.Web.Website.csproj b/src/Umbraco.Web.Website/Umbraco.Web.Website.csproj index 70355f51e8..24a3260a00 100644 --- a/src/Umbraco.Web.Website/Umbraco.Web.Website.csproj +++ b/src/Umbraco.Web.Website/Umbraco.Web.Website.csproj @@ -22,8 +22,4 @@ - - - - diff --git a/src/Umbraco.Web/Editors/AuthenticationController.cs b/src/Umbraco.Web/Editors/AuthenticationController.cs index 93c9592bc6..fc5d4504bd 100644 --- a/src/Umbraco.Web/Editors/AuthenticationController.cs +++ b/src/Umbraco.Web/Editors/AuthenticationController.cs @@ -29,13 +29,14 @@ using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Hosting; using Umbraco.Extensions; using Umbraco.Web.Routing; +using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Editors { /// /// The API controller used for editing content /// - [PluginController("UmbracoApi")] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] [ValidationFilter] [AngularJsonOnlyConfiguration] [IsBackOffice] diff --git a/src/Umbraco.Web/PublishedElementExtensions.cs b/src/Umbraco.Web/PublishedElementExtensions.cs index 9d13af2fb6..637d22902c 100644 --- a/src/Umbraco.Web/PublishedElementExtensions.cs +++ b/src/Umbraco.Web/PublishedElementExtensions.cs @@ -97,31 +97,6 @@ namespace Umbraco.Web #endregion - #region MediaUrl - /// - /// Gets the url for a media. - /// - /// The content item. - /// The culture (use current culture by default). - /// The url mode (use site configuration by default). - /// The alias of the property (use 'umbracoFile' by default). - /// The url for the media. - /// - /// The value of this property is contextual. It depends on the 'current' request uri, - /// if any. In addition, when the content type is multi-lingual, this is the url for the - /// specified culture. Otherwise, it is the invariant url. - /// - public static string MediaUrl(this IPublishedContent content, string culture = null, UrlMode mode = UrlMode.Default, string propertyAlias = Constants.Conventions.Media.File) - { - var publishedUrlProvider = Current.PublishedUrlProvider; - - if (publishedUrlProvider== null) - throw new InvalidOperationException("Cannot resolve a Url when Current.PublishedUrlProvider is null."); - - return publishedUrlProvider.GetMediaUrl(content, mode, culture, propertyAlias); - } - - #endregion } } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index afa9f9f147..08a6de41d7 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -162,7 +162,6 @@ - @@ -284,7 +283,6 @@ - diff --git a/src/Umbraco.Web/UrlHelperRenderExtensions.cs b/src/Umbraco.Web/UrlHelperRenderExtensions.cs index 156a3dfba1..3a836f5d8b 100644 --- a/src/Umbraco.Web/UrlHelperRenderExtensions.cs +++ b/src/Umbraco.Web/UrlHelperRenderExtensions.cs @@ -21,252 +21,252 @@ namespace Umbraco.Web private static readonly IHtmlString EmptyHtmlString = new HtmlString(string.Empty); - #region GetCropUrl - - /// - /// Gets the ImageProcessor Url of a media item by the crop alias (using default media item property alias of "umbracoFile") - /// - /// - /// - /// The IPublishedContent item. - /// - /// - /// The crop alias e.g. thumbnail - /// - /// - /// Whether to HTML encode this URL - default is true - w3c standards require HTML attributes to be HTML encoded but this can be - /// set to false if using the result of this method for CSS. - /// - /// - public static IHtmlString GetCropUrl(this UrlHelper urlHelper, IPublishedContent mediaItem, IImageUrlGenerator imageUrlGenerator, string cropAlias, bool htmlEncode = true) - { - if (mediaItem == null) return EmptyHtmlString; - - var url = mediaItem.GetCropUrl(imageUrlGenerator, cropAlias: cropAlias, useCropDimensions: true); - return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); - } - - /// - /// Gets the ImageProcessor Url by the crop alias using the specified property containing the image cropper Json data on the IPublishedContent item. - /// - /// - /// - /// The IPublishedContent item. - /// - /// - /// The property alias of the property containing the Json data e.g. umbracoFile - /// - /// - /// The crop alias e.g. thumbnail - /// - /// - /// Whether to HTML encode this URL - default is true - w3c standards require HTML attributes to be HTML encoded but this can be - /// set to false if using the result of this method for CSS. - /// - /// - /// The ImageProcessor.Web Url. - /// - public static IHtmlString GetCropUrl(this UrlHelper urlHelper, IPublishedContent mediaItem, string propertyAlias, string cropAlias, IImageUrlGenerator imageUrlGenerator, bool htmlEncode = true) - { - if (mediaItem == null) return EmptyHtmlString; - - var url = mediaItem.GetCropUrl(imageUrlGenerator, propertyAlias: propertyAlias, cropAlias: cropAlias, useCropDimensions: true); - return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); - } - - /// - /// Gets the ImageProcessor Url from the image path. - /// - /// - /// The IPublishedContent item. - /// - /// - /// The width of the output image. - /// - /// - /// The height of the output image. - /// - /// - /// Property alias of the property containing the Json data. - /// - /// - /// The crop alias. - /// - /// - /// Quality percentage of the output image. - /// - /// - /// The image crop mode. - /// - /// - /// The image crop anchor. - /// - /// - /// Use focal point to generate an output image using the focal point instead of the predefined crop if there is one - /// - /// - /// Use crop dimensions to have the output image sized according to the predefined crop sizes, this will override the width and height parameters - /// - /// - /// Add a serialized date of the last edit of the item to ensure client cache refresh when updated - /// - /// - /// These are any query string parameters (formatted as query strings) that ImageProcessor supports. For example: - /// - /// - /// - /// - /// - /// Use a dimension as a ratio - /// - /// - /// If the image should be upscaled to requested dimensions - /// - /// - /// - /// Whether to HTML encode this URL - default is true - w3c standards require HTML attributes to be HTML encoded but this can be - /// set to false if using the result of this method for CSS. - /// - /// - /// The . - /// - public static IHtmlString GetCropUrl(this UrlHelper urlHelper, - IPublishedContent mediaItem, - IImageUrlGenerator imageUrlGenerator, - int? width = null, - int? height = null, - string propertyAlias = Umbraco.Core.Constants.Conventions.Media.File, - string cropAlias = null, - int? quality = null, - ImageCropMode? imageCropMode = null, - ImageCropAnchor? imageCropAnchor = null, - bool preferFocalPoint = false, - bool useCropDimensions = false, - bool cacheBuster = true, - string furtherOptions = null, - ImageCropRatioMode? ratioMode = null, - bool upScale = true, - bool htmlEncode = true) - { - if (mediaItem == null) return EmptyHtmlString; - - var url = mediaItem.GetCropUrl(imageUrlGenerator, width, height, propertyAlias, cropAlias, quality, imageCropMode, - imageCropAnchor, preferFocalPoint, useCropDimensions, cacheBuster, furtherOptions, ratioMode, - upScale); - return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); - } - - /// - /// Gets the ImageProcessor Url from the image path. - /// - /// - /// The image url. - /// - /// - /// The width of the output image. - /// - /// - /// The height of the output image. - /// - /// - /// The Json data from the Umbraco Core Image Cropper property editor - /// - /// - /// The crop alias. - /// - /// - /// Quality percentage of the output image. - /// - /// - /// The image crop mode. - /// - /// - /// The image crop anchor. - /// - /// - /// Use focal point to generate an output image using the focal point instead of the predefined crop if there is one - /// - /// - /// Use crop dimensions to have the output image sized according to the predefined crop sizes, this will override the width and height parameters - /// - /// - /// Add a serialized date of the last edit of the item to ensure client cache refresh when updated - /// - /// - /// These are any query string parameters (formatted as query strings) that ImageProcessor supports. For example: - /// - /// - /// - /// - /// - /// Use a dimension as a ratio - /// - /// - /// If the image should be upscaled to requested dimensions - /// - /// - /// - /// Whether to HTML encode this URL - default is true - w3c standards require HTML attributes to be HTML encoded but this can be - /// set to false if using the result of this method for CSS. - /// - /// - /// The . - /// - public static IHtmlString GetCropUrl(this UrlHelper urlHelper, - string imageUrl, - IImageUrlGenerator imageUrlGenerator, - int? width = null, - int? height = null, - string imageCropperValue = null, - string cropAlias = null, - int? quality = null, - ImageCropMode? imageCropMode = null, - ImageCropAnchor? imageCropAnchor = null, - bool preferFocalPoint = false, - bool useCropDimensions = false, - string cacheBusterValue = null, - string furtherOptions = null, - ImageCropRatioMode? ratioMode = null, - bool upScale = true, - bool htmlEncode = true) - { - var url = imageUrl.GetCropUrl(imageUrlGenerator, width, height, imageCropperValue, cropAlias, quality, imageCropMode, - imageCropAnchor, preferFocalPoint, useCropDimensions, cacheBusterValue, furtherOptions, ratioMode, - upScale); - return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); - } - - public static IHtmlString GetCropUrl(this UrlHelper urlHelper, - ImageCropperValue imageCropperValue, - IImageUrlGenerator imageUrlGenerator, - int? width = null, - int? height = null, - string cropAlias = null, - int? quality = null, - ImageCropMode? imageCropMode = null, - ImageCropAnchor? imageCropAnchor = null, - bool preferFocalPoint = false, - bool useCropDimensions = false, - string cacheBusterValue = null, - string furtherOptions = null, - ImageCropRatioMode? ratioMode = null, - bool upScale = true, - bool htmlEncode = true) - { - if (imageCropperValue == null) return EmptyHtmlString; - - var imageUrl = imageCropperValue.Src; - var url = imageUrl.GetCropUrl(imageUrlGenerator, imageCropperValue, width, height, cropAlias, quality, imageCropMode, - imageCropAnchor, preferFocalPoint, useCropDimensions, cacheBusterValue, furtherOptions, ratioMode, - upScale); - return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); - } - - #endregion + // #region GetCropUrl + // + // /// + // /// Gets the ImageProcessor Url of a media item by the crop alias (using default media item property alias of "umbracoFile") + // /// + // /// + // /// + // /// The IPublishedContent item. + // /// + // /// + // /// The crop alias e.g. thumbnail + // /// + // /// + // /// Whether to HTML encode this URL - default is true - w3c standards require HTML attributes to be HTML encoded but this can be + // /// set to false if using the result of this method for CSS. + // /// + // /// + // public static IHtmlString GetCropUrl(this UrlHelper urlHelper, IPublishedContent mediaItem, IImageUrlGenerator imageUrlGenerator, string cropAlias, bool htmlEncode = true) + // { + // if (mediaItem == null) return EmptyHtmlString; + // + // var url = mediaItem.GetCropUrl(imageUrlGenerator, cropAlias: cropAlias, useCropDimensions: true); + // return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); + // } + // + // /// + // /// Gets the ImageProcessor Url by the crop alias using the specified property containing the image cropper Json data on the IPublishedContent item. + // /// + // /// + // /// + // /// The IPublishedContent item. + // /// + // /// + // /// The property alias of the property containing the Json data e.g. umbracoFile + // /// + // /// + // /// The crop alias e.g. thumbnail + // /// + // /// + // /// Whether to HTML encode this URL - default is true - w3c standards require HTML attributes to be HTML encoded but this can be + // /// set to false if using the result of this method for CSS. + // /// + // /// + // /// The ImageProcessor.Web Url. + // /// + // public static IHtmlString GetCropUrl(this UrlHelper urlHelper, IPublishedContent mediaItem, string propertyAlias, string cropAlias, IImageUrlGenerator imageUrlGenerator, bool htmlEncode = true) + // { + // if (mediaItem == null) return EmptyHtmlString; + // + // var url = mediaItem.GetCropUrl(imageUrlGenerator, propertyAlias: propertyAlias, cropAlias: cropAlias, useCropDimensions: true); + // return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); + // } + // + // /// + // /// Gets the ImageProcessor Url from the image path. + // /// + // /// + // /// The IPublishedContent item. + // /// + // /// + // /// The width of the output image. + // /// + // /// + // /// The height of the output image. + // /// + // /// + // /// Property alias of the property containing the Json data. + // /// + // /// + // /// The crop alias. + // /// + // /// + // /// Quality percentage of the output image. + // /// + // /// + // /// The image crop mode. + // /// + // /// + // /// The image crop anchor. + // /// + // /// + // /// Use focal point to generate an output image using the focal point instead of the predefined crop if there is one + // /// + // /// + // /// Use crop dimensions to have the output image sized according to the predefined crop sizes, this will override the width and height parameters + // /// + // /// + // /// Add a serialized date of the last edit of the item to ensure client cache refresh when updated + // /// + // /// + // /// These are any query string parameters (formatted as query strings) that ImageProcessor supports. For example: + // /// + // /// + // /// + // /// + // /// + // /// Use a dimension as a ratio + // /// + // /// + // /// If the image should be upscaled to requested dimensions + // /// + // /// + // /// + // /// Whether to HTML encode this URL - default is true - w3c standards require HTML attributes to be HTML encoded but this can be + // /// set to false if using the result of this method for CSS. + // /// + // /// + // /// The . + // /// + // public static IHtmlString GetCropUrl(this UrlHelper urlHelper, + // IPublishedContent mediaItem, + // IImageUrlGenerator imageUrlGenerator, + // int? width = null, + // int? height = null, + // string propertyAlias = Umbraco.Core.Constants.Conventions.Media.File, + // string cropAlias = null, + // int? quality = null, + // ImageCropMode? imageCropMode = null, + // ImageCropAnchor? imageCropAnchor = null, + // bool preferFocalPoint = false, + // bool useCropDimensions = false, + // bool cacheBuster = true, + // string furtherOptions = null, + // ImageCropRatioMode? ratioMode = null, + // bool upScale = true, + // bool htmlEncode = true) + // { + // if (mediaItem == null) return EmptyHtmlString; + // + // var url = mediaItem.GetCropUrl(imageUrlGenerator, width, height, propertyAlias, cropAlias, quality, imageCropMode, + // imageCropAnchor, preferFocalPoint, useCropDimensions, cacheBuster, furtherOptions, ratioMode, + // upScale); + // return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); + // } + // + // /// + // /// Gets the ImageProcessor Url from the image path. + // /// + // /// + // /// The image url. + // /// + // /// + // /// The width of the output image. + // /// + // /// + // /// The height of the output image. + // /// + // /// + // /// The Json data from the Umbraco Core Image Cropper property editor + // /// + // /// + // /// The crop alias. + // /// + // /// + // /// Quality percentage of the output image. + // /// + // /// + // /// The image crop mode. + // /// + // /// + // /// The image crop anchor. + // /// + // /// + // /// Use focal point to generate an output image using the focal point instead of the predefined crop if there is one + // /// + // /// + // /// Use crop dimensions to have the output image sized according to the predefined crop sizes, this will override the width and height parameters + // /// + // /// + // /// Add a serialized date of the last edit of the item to ensure client cache refresh when updated + // /// + // /// + // /// These are any query string parameters (formatted as query strings) that ImageProcessor supports. For example: + // /// + // /// + // /// + // /// + // /// + // /// Use a dimension as a ratio + // /// + // /// + // /// If the image should be upscaled to requested dimensions + // /// + // /// + // /// + // /// Whether to HTML encode this URL - default is true - w3c standards require HTML attributes to be HTML encoded but this can be + // /// set to false if using the result of this method for CSS. + // /// + // /// + // /// The . + // /// + // public static IHtmlString GetCropUrl(this UrlHelper urlHelper, + // string imageUrl, + // IImageUrlGenerator imageUrlGenerator, + // int? width = null, + // int? height = null, + // string imageCropperValue = null, + // string cropAlias = null, + // int? quality = null, + // ImageCropMode? imageCropMode = null, + // ImageCropAnchor? imageCropAnchor = null, + // bool preferFocalPoint = false, + // bool useCropDimensions = false, + // string cacheBusterValue = null, + // string furtherOptions = null, + // ImageCropRatioMode? ratioMode = null, + // bool upScale = true, + // bool htmlEncode = true) + // { + // var url = imageUrl.GetCropUrl(imageUrlGenerator, width, height, imageCropperValue, cropAlias, quality, imageCropMode, + // imageCropAnchor, preferFocalPoint, useCropDimensions, cacheBusterValue, furtherOptions, ratioMode, + // upScale); + // return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); + // } + // + // public static IHtmlString GetCropUrl(this UrlHelper urlHelper, + // ImageCropperValue imageCropperValue, + // IImageUrlGenerator imageUrlGenerator, + // int? width = null, + // int? height = null, + // string cropAlias = null, + // int? quality = null, + // ImageCropMode? imageCropMode = null, + // ImageCropAnchor? imageCropAnchor = null, + // bool preferFocalPoint = false, + // bool useCropDimensions = false, + // string cacheBusterValue = null, + // string furtherOptions = null, + // ImageCropRatioMode? ratioMode = null, + // bool upScale = true, + // bool htmlEncode = true) + // { + // if (imageCropperValue == null) return EmptyHtmlString; + // + // var imageUrl = imageCropperValue.Src; + // var url = imageUrl.GetCropUrl(imageUrlGenerator, imageCropperValue, width, height, cropAlias, quality, imageCropMode, + // imageCropAnchor, preferFocalPoint, useCropDimensions, cacheBusterValue, furtherOptions, ratioMode, + // upScale); + // return htmlEncode ? new HtmlString(HttpUtility.HtmlEncode(url)) : new HtmlString(url); + // } + // + // #endregion /// /// Generates a URL based on the current Umbraco URL with a custom query string that will route to the specified SurfaceController