Files
Umbraco-CMS/src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs

186 lines
8.4 KiB
C#
Raw Normal View History

using System;
2018-06-29 19:52:40 +02:00
using System.Collections.Generic;
Merge remote-tracking branch 'origin/dev-v7' into temp8 (after fixing) # Conflicts: # build/Modules/Umbraco.Build/Build-UmbracoDocs.ps1 # src/SolutionInfo.cs # src/Umbraco.Core/Configuration/UmbracoVersion.cs # src/Umbraco.Core/Constants-Applications.cs # src/Umbraco.Core/Models/Rdbms/ConsentDto.cs # src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs # src/Umbraco.Core/Persistence/Repositories/AuditRepository.cs # src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs # src/Umbraco.Core/Services/ConsentService.cs # src/Umbraco.Core/Services/IRelationService.cs # src/Umbraco.Core/Services/RelationService.cs # src/Umbraco.Tests/Plugins/PluginManagerTests.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs # src/Umbraco.Tests/Services/ConsentServiceTests.cs # src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js # src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorheader.directive.js # src/Umbraco.Web.UI.Client/src/common/directives/components/tree/umbtree.directive.js # src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js # src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js # src/Umbraco.Web.UI.Client/src/common/services/tree.service.js # src/Umbraco.Web.UI.Client/src/less/application/grid.less # src/Umbraco.Web.UI.Client/src/less/forms.less # src/Umbraco.Web.UI.Client/src/less/main.less # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/mediaPicker/mediapicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/treepicker/treepicker.controller.js # src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html # src/Umbraco.Web.UI.Client/src/views/components/html/umb-control-group.html # src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html # src/Umbraco.Web.UI.Client/src/views/content/content.copy.controller.js # src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/datatype.edit.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/edit.html # src/Umbraco.Web.UI.Client/src/views/documenttypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/edit.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.controller.js # src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/users/views/user/details.html # src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/RegisterMember.cshtml # src/Umbraco.Web.UI/config/EmbeddedMedia.Release.config # src/Umbraco.Web.UI/config/EmbeddedMedia.config # src/Umbraco.Web.UI/config/trees.Release.config # src/Umbraco.Web.UI/config/trees.config # src/Umbraco.Web.UI/config/umbracoSettings.config # src/Umbraco.Web.UI/umbraco/Views/Default.cshtml # src/Umbraco.Web.UI/umbraco/config/create/UI.xml # src/Umbraco.Web.UI/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/umbraco/config/lang/it.xml # src/Umbraco.Web.UI/umbraco/config/lang/nl.xml # src/Umbraco.Web.UI/umbraco/config/lang/ru.xml # src/Umbraco.Web/Editors/BackOfficeController.cs # src/Umbraco.Web/Editors/BackOfficeServerVariables.cs # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/Editors/MacroController.cs # src/Umbraco.Web/Editors/MemberController.cs # src/Umbraco.Web/Models/RegisterModel.cs # src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs # src/Umbraco.Web/PublishedContentExtensions.cs # src/Umbraco.Web/Trees/ContentTreeController.cs # src/Umbraco.Web/Trees/ContentTreeControllerBase.cs # src/Umbraco.Web/Trees/TreeControllerBase.cs # src/Umbraco.Web/UmbracoHelper.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.designer.cs
2018-07-11 15:58:48 +10:00
using System.Globalization;
2018-06-29 19:52:40 +02:00
using System.Linq;
using System.Text;
Merge remote-tracking branch 'origin/dev-v7' into temp8 (after fixing) # Conflicts: # build/Modules/Umbraco.Build/Build-UmbracoDocs.ps1 # src/SolutionInfo.cs # src/Umbraco.Core/Configuration/UmbracoVersion.cs # src/Umbraco.Core/Constants-Applications.cs # src/Umbraco.Core/Models/Rdbms/ConsentDto.cs # src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs # src/Umbraco.Core/Persistence/Repositories/AuditRepository.cs # src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs # src/Umbraco.Core/Services/ConsentService.cs # src/Umbraco.Core/Services/IRelationService.cs # src/Umbraco.Core/Services/RelationService.cs # src/Umbraco.Tests/Plugins/PluginManagerTests.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs # src/Umbraco.Tests/Services/ConsentServiceTests.cs # src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js # src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorheader.directive.js # src/Umbraco.Web.UI.Client/src/common/directives/components/tree/umbtree.directive.js # src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js # src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js # src/Umbraco.Web.UI.Client/src/common/services/tree.service.js # src/Umbraco.Web.UI.Client/src/less/application/grid.less # src/Umbraco.Web.UI.Client/src/less/forms.less # src/Umbraco.Web.UI.Client/src/less/main.less # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/mediaPicker/mediapicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/treepicker/treepicker.controller.js # src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html # src/Umbraco.Web.UI.Client/src/views/components/html/umb-control-group.html # src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html # src/Umbraco.Web.UI.Client/src/views/content/content.copy.controller.js # src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/datatype.edit.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/edit.html # src/Umbraco.Web.UI.Client/src/views/documenttypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/edit.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.controller.js # src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/users/views/user/details.html # src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/RegisterMember.cshtml # src/Umbraco.Web.UI/config/EmbeddedMedia.Release.config # src/Umbraco.Web.UI/config/EmbeddedMedia.config # src/Umbraco.Web.UI/config/trees.Release.config # src/Umbraco.Web.UI/config/trees.config # src/Umbraco.Web.UI/config/umbracoSettings.config # src/Umbraco.Web.UI/umbraco/Views/Default.cshtml # src/Umbraco.Web.UI/umbraco/config/create/UI.xml # src/Umbraco.Web.UI/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/umbraco/config/lang/it.xml # src/Umbraco.Web.UI/umbraco/config/lang/nl.xml # src/Umbraco.Web.UI/umbraco/config/lang/ru.xml # src/Umbraco.Web/Editors/BackOfficeController.cs # src/Umbraco.Web/Editors/BackOfficeServerVariables.cs # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/Editors/MacroController.cs # src/Umbraco.Web/Editors/MemberController.cs # src/Umbraco.Web/Models/RegisterModel.cs # src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs # src/Umbraco.Web/PublishedContentExtensions.cs # src/Umbraco.Web/Trees/ContentTreeController.cs # src/Umbraco.Web/Trees/ContentTreeControllerBase.cs # src/Umbraco.Web/Trees/TreeControllerBase.cs # src/Umbraco.Web/UmbracoHelper.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.designer.cs
2018-07-11 15:58:48 +10:00
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Core.Templates;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Extensions;
2018-06-29 19:52:40 +02:00
namespace Umbraco.Cms.Web.BackOffice.Controllers
2018-06-29 19:52:40 +02:00
{
/// <summary>
/// API controller to deal with Macro data
/// </summary>
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
public class MacroRenderingController : UmbracoAuthorizedJsonController
2018-06-29 19:52:40 +02:00
{
2019-01-21 10:55:48 +01:00
private readonly IMacroService _macroService;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IShortStringHelper _shortStringHelper;
private readonly ISiteDomainMapper _siteDomainHelper;
Merge remote-tracking branch 'origin/v8/dev' into netcore/dev # Conflicts: # build/NuSpecs/UmbracoCms.Web.nuspec # src/SolutionInfo.cs # src/Umbraco.Core/Cache/MediaCacheRefresher.cs # src/Umbraco.Core/Composing/ComponentCollection.cs # src/Umbraco.Core/Composing/Composers.cs # src/Umbraco.Core/Composing/TypeFinder.cs # src/Umbraco.Core/Composing/TypeLoader.cs # src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs # src/Umbraco.Core/Constants-SvgSanitizer.cs # src/Umbraco.Core/ContentApps/ContentAppFactoryCollection.cs # src/Umbraco.Core/Extensions/PublishedContentExtensions.cs # src/Umbraco.Core/Extensions/PublishedPropertyExtension.cs # src/Umbraco.Core/Extensions/StringExtensions.cs # src/Umbraco.Core/HealthChecks/Checks/Security/ExcessiveHeadersCheck.cs # src/Umbraco.Core/HealthChecks/HealthCheckResults.cs # src/Umbraco.Core/IO/FileSystems.cs # src/Umbraco.Core/IO/IOHelper.cs # src/Umbraco.Core/IO/MediaFileSystem.cs # src/Umbraco.Core/IO/PhysicalFileSystem.cs # src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs # src/Umbraco.Core/Logging/DisposableTimer.cs # src/Umbraco.Core/Logging/ILogger.cs # src/Umbraco.Core/Logging/LogProfiler.cs # src/Umbraco.Core/Logging/OwinLogger.cs # src/Umbraco.Core/Manifest/ManifestWatcher.cs # src/Umbraco.Core/Mapping/UmbracoMapper.cs # src/Umbraco.Core/Media/UploadAutoFillProperties.cs # src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs # src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorCollection.cs # src/Umbraco.Core/Models/Mapping/ContentPropertyBasicMapper.cs # src/Umbraco.Core/Models/Mapping/DataTypeMapDefinition.cs # src/Umbraco.Core/Models/Mapping/MacroMapDefinition.cs # src/Umbraco.Core/Models/Member.cs # src/Umbraco.Core/Packaging/PackageActionRunner.cs # src/Umbraco.Core/PropertyEditors/DataValueEditor.cs # src/Umbraco.Core/PropertyEditors/Validators/EyeDropperColorPickerConfigurationEditor.cs # src/Umbraco.Core/PropertyEditors/Validators/EyeDropperColorPickerPropertyEditor.cs # src/Umbraco.Core/Routing/DefaultUrlProvider.cs # src/Umbraco.Core/Runtime/CoreRuntime.cs # src/Umbraco.Core/Runtime/MainDom.cs # src/Umbraco.Core/RuntimeState.cs # src/Umbraco.Core/Scoping/ScopeProvider.cs # src/Umbraco.Core/Sync/DatabaseServerMessenger.cs # src/Umbraco.Core/Templates/HtmlUrlParser.cs # src/Umbraco.Core/UriExtensions.cs # src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs # src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs # src/Umbraco.Infrastructure/Examine/IndexRebuilder.cs # src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs # src/Umbraco.Infrastructure/Manifest/ManifestParser.cs # src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs # src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs # src/Umbraco.Infrastructure/Migrations/MigrationPlan.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/DropDownPropertyEditorsMigration.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/MergeDateAndDateTimePropertyEditor.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/RadioAndCheckboxPropertyEditorsMigration.cs # src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaRepository.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs # src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/RichTextEditorPastedImages.cs # src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/GridValueConverter.cs # src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs # src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/JsonValueConverter.cs # src/Umbraco.Infrastructure/PublishedCache/PublishedContentTypeCache.cs # src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs # src/Umbraco.Infrastructure/Scoping/Scope.cs # src/Umbraco.Infrastructure/Search/ExamineNotificationHandler.cs # src/Umbraco.Infrastructure/Services/Implement/ContentService.cs # src/Umbraco.Infrastructure/Services/Implement/LocalizedTextService.cs # src/Umbraco.Infrastructure/Services/Implement/LocalizedTextServiceFileSources.cs # src/Umbraco.Infrastructure/Services/Implement/MediaService.cs # src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs # src/Umbraco.Infrastructure/Sync/ServerMessengerBase.cs # src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs # src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs # src/Umbraco.PublishedCache.NuCache/ContentStore.cs # src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEventsTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Mapping/MappingTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.ModelsBuilder.Embedded/BuilderTests.cs # src/Umbraco.Tests/Composing/TypeLoaderTests.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/BackgroundTaskRunner.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/PreviewContent.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStore.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStoreFilePersister.cs # src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs # src/Umbraco.Tests/Services/PerformanceTests.cs # src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs # src/Umbraco.Tests/Testing/TestingTests/MockTests.cs # src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs # src/Umbraco.Web.BackOffice/Controllers/ContentController.cs # src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs # src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs # src/Umbraco.Web.BackOffice/HealthChecks/HealthCheckController.cs # src/Umbraco.Web.BackOffice/PropertyEditors/RteEmbedController.cs # src/Umbraco.Web.BackOffice/Services/IconService.cs # src/Umbraco.Web.BackOffice/Trees/ContentTreeControllerBase.cs # src/Umbraco.Web.Common/Extensions/FormCollectionExtensions.cs # src/Umbraco.Web.Common/Install/InstallApiController.cs # src/Umbraco.Web.Common/Macros/MacroRenderer.cs # src/Umbraco.Web.Common/ModelsBuilder/PureLiveModelFactory.cs # src/Umbraco.Web.UI.Client/package-lock.json # src/Umbraco.Web.UI.Client/src/views/memberTypes/copy.controller.js # src/Umbraco.Web.UI.Client/src/views/memberTypes/copy.html # src/Umbraco.Web.UI.NetCore/umbraco/UmbracoBackOffice/Default.cshtml # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en.xml # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/config/splashes/noNodes.aspx # src/Umbraco.Web/AspNet/AspNetHttpContextAccessor.cs # src/Umbraco.Web/Cache/DistributedCacheBinder.cs # src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs # src/Umbraco.Web/Editors/AuthenticationController.cs # src/Umbraco.Web/Editors/BackOfficeController.cs # src/Umbraco.Web/Editors/Binders/ContentModelBinderHelper.cs # src/Umbraco.Web/Editors/ContentControllerBase.cs # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/Editors/DictionaryController.cs # src/Umbraco.Web/Editors/MemberTypeController.cs # src/Umbraco.Web/Editors/PasswordChanger.cs # src/Umbraco.Web/Editors/RelationTypeController.cs # src/Umbraco.Web/Editors/TinyMceController.cs # src/Umbraco.Web/HealthCheck/Checks/Security/HttpsCheck.cs # src/Umbraco.Web/HtmlHelperRenderExtensions.cs # src/Umbraco.Web/HttpUrlHelperExtensions.cs # src/Umbraco.Web/HybridEventMessagesAccessor.cs # src/Umbraco.Web/ImageCropperTemplateExtensions.cs # src/Umbraco.Web/JavaScript/ClientDependencyConfiguration.cs # src/Umbraco.Web/Mvc/RenderMvcController.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs # src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs # src/Umbraco.Web/Routing/ContentFinderByConfigured404.cs # src/Umbraco.Web/Routing/ContentFinderByIdPath.cs # src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs # src/Umbraco.Web/Routing/ContentFinderByUrl.cs # src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs # src/Umbraco.Web/Routing/ContentFinderByUrlAndTemplate.cs # src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs # src/Umbraco.Web/Routing/PublishedRouter.cs # src/Umbraco.Web/Runtime/WebInitialComposer.cs # src/Umbraco.Web/Scheduling/KeepAlive.cs # src/Umbraco.Web/Scheduling/ScheduledPublishing.cs # src/Umbraco.Web/Scheduling/TempFileCleanup.cs # src/Umbraco.Web/Security/MembershipHelper.cs # src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs # src/Umbraco.Web/Trees/MemberTreeController.cs # src/Umbraco.Web/Trees/MemberTypeAndGroupTreeControllerBase.cs # src/Umbraco.Web/Trees/MemberTypeTreeController.cs # src/Umbraco.Web/UmbracoApplicationBase.cs # src/Umbraco.Web/UmbracoInjectedModule.cs # src/Umbraco.Web/UmbracoModule.cs # src/Umbraco.Web/WebApi/AngularJsonMediaTypeFormatter.cs # src/Umbraco.Web/WebApi/Filters/FileUploadCleanupFilterAttribute.cs # src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs
2021-04-20 19:34:18 +02:00
private readonly IUmbracoMapper _umbracoMapper;
private readonly IUmbracoComponentRenderer _componentRenderer;
2018-06-29 19:52:40 +02:00
private readonly IVariationContextAccessor _variationContextAccessor;
2020-02-10 19:59:47 +01:00
public MacroRenderingController(
Merge remote-tracking branch 'origin/v8/dev' into netcore/dev # Conflicts: # build/NuSpecs/UmbracoCms.Web.nuspec # src/SolutionInfo.cs # src/Umbraco.Core/Cache/MediaCacheRefresher.cs # src/Umbraco.Core/Composing/ComponentCollection.cs # src/Umbraco.Core/Composing/Composers.cs # src/Umbraco.Core/Composing/TypeFinder.cs # src/Umbraco.Core/Composing/TypeLoader.cs # src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs # src/Umbraco.Core/Constants-SvgSanitizer.cs # src/Umbraco.Core/ContentApps/ContentAppFactoryCollection.cs # src/Umbraco.Core/Extensions/PublishedContentExtensions.cs # src/Umbraco.Core/Extensions/PublishedPropertyExtension.cs # src/Umbraco.Core/Extensions/StringExtensions.cs # src/Umbraco.Core/HealthChecks/Checks/Security/ExcessiveHeadersCheck.cs # src/Umbraco.Core/HealthChecks/HealthCheckResults.cs # src/Umbraco.Core/IO/FileSystems.cs # src/Umbraco.Core/IO/IOHelper.cs # src/Umbraco.Core/IO/MediaFileSystem.cs # src/Umbraco.Core/IO/PhysicalFileSystem.cs # src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs # src/Umbraco.Core/Logging/DisposableTimer.cs # src/Umbraco.Core/Logging/ILogger.cs # src/Umbraco.Core/Logging/LogProfiler.cs # src/Umbraco.Core/Logging/OwinLogger.cs # src/Umbraco.Core/Manifest/ManifestWatcher.cs # src/Umbraco.Core/Mapping/UmbracoMapper.cs # src/Umbraco.Core/Media/UploadAutoFillProperties.cs # src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs # src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorCollection.cs # src/Umbraco.Core/Models/Mapping/ContentPropertyBasicMapper.cs # src/Umbraco.Core/Models/Mapping/DataTypeMapDefinition.cs # src/Umbraco.Core/Models/Mapping/MacroMapDefinition.cs # src/Umbraco.Core/Models/Member.cs # src/Umbraco.Core/Packaging/PackageActionRunner.cs # src/Umbraco.Core/PropertyEditors/DataValueEditor.cs # src/Umbraco.Core/PropertyEditors/Validators/EyeDropperColorPickerConfigurationEditor.cs # src/Umbraco.Core/PropertyEditors/Validators/EyeDropperColorPickerPropertyEditor.cs # src/Umbraco.Core/Routing/DefaultUrlProvider.cs # src/Umbraco.Core/Runtime/CoreRuntime.cs # src/Umbraco.Core/Runtime/MainDom.cs # src/Umbraco.Core/RuntimeState.cs # src/Umbraco.Core/Scoping/ScopeProvider.cs # src/Umbraco.Core/Sync/DatabaseServerMessenger.cs # src/Umbraco.Core/Templates/HtmlUrlParser.cs # src/Umbraco.Core/UriExtensions.cs # src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs # src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs # src/Umbraco.Infrastructure/Examine/IndexRebuilder.cs # src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs # src/Umbraco.Infrastructure/Manifest/ManifestParser.cs # src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs # src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs # src/Umbraco.Infrastructure/Migrations/MigrationPlan.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/DropDownPropertyEditorsMigration.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/MergeDateAndDateTimePropertyEditor.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/RadioAndCheckboxPropertyEditorsMigration.cs # src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs # src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaRepository.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs # src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/RichTextEditorPastedImages.cs # src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/GridValueConverter.cs # src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs # src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/JsonValueConverter.cs # src/Umbraco.Infrastructure/PublishedCache/PublishedContentTypeCache.cs # src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs # src/Umbraco.Infrastructure/Scoping/Scope.cs # src/Umbraco.Infrastructure/Search/ExamineNotificationHandler.cs # src/Umbraco.Infrastructure/Services/Implement/ContentService.cs # src/Umbraco.Infrastructure/Services/Implement/LocalizedTextService.cs # src/Umbraco.Infrastructure/Services/Implement/LocalizedTextServiceFileSources.cs # src/Umbraco.Infrastructure/Services/Implement/MediaService.cs # src/Umbraco.Infrastructure/Services/Implement/NotificationService.cs # src/Umbraco.Infrastructure/Sync/ServerMessengerBase.cs # src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs # src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs # src/Umbraco.PublishedCache.NuCache/ContentStore.cs # src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEventsTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Mapping/MappingTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.ModelsBuilder.Embedded/BuilderTests.cs # src/Umbraco.Tests/Composing/TypeLoaderTests.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/BackgroundTaskRunner.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/PreviewContent.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStore.cs # src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStoreFilePersister.cs # src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs # src/Umbraco.Tests/Services/PerformanceTests.cs # src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs # src/Umbraco.Tests/Testing/TestingTests/MockTests.cs # src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs # src/Umbraco.Web.BackOffice/Controllers/ContentController.cs # src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs # src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs # src/Umbraco.Web.BackOffice/HealthChecks/HealthCheckController.cs # src/Umbraco.Web.BackOffice/PropertyEditors/RteEmbedController.cs # src/Umbraco.Web.BackOffice/Services/IconService.cs # src/Umbraco.Web.BackOffice/Trees/ContentTreeControllerBase.cs # src/Umbraco.Web.Common/Extensions/FormCollectionExtensions.cs # src/Umbraco.Web.Common/Install/InstallApiController.cs # src/Umbraco.Web.Common/Macros/MacroRenderer.cs # src/Umbraco.Web.Common/ModelsBuilder/PureLiveModelFactory.cs # src/Umbraco.Web.UI.Client/package-lock.json # src/Umbraco.Web.UI.Client/src/views/memberTypes/copy.controller.js # src/Umbraco.Web.UI.Client/src/views/memberTypes/copy.html # src/Umbraco.Web.UI.NetCore/umbraco/UmbracoBackOffice/Default.cshtml # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en.xml # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/config/splashes/noNodes.aspx # src/Umbraco.Web/AspNet/AspNetHttpContextAccessor.cs # src/Umbraco.Web/Cache/DistributedCacheBinder.cs # src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs # src/Umbraco.Web/Editors/AuthenticationController.cs # src/Umbraco.Web/Editors/BackOfficeController.cs # src/Umbraco.Web/Editors/Binders/ContentModelBinderHelper.cs # src/Umbraco.Web/Editors/ContentControllerBase.cs # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/Editors/DictionaryController.cs # src/Umbraco.Web/Editors/MemberTypeController.cs # src/Umbraco.Web/Editors/PasswordChanger.cs # src/Umbraco.Web/Editors/RelationTypeController.cs # src/Umbraco.Web/Editors/TinyMceController.cs # src/Umbraco.Web/HealthCheck/Checks/Security/HttpsCheck.cs # src/Umbraco.Web/HtmlHelperRenderExtensions.cs # src/Umbraco.Web/HttpUrlHelperExtensions.cs # src/Umbraco.Web/HybridEventMessagesAccessor.cs # src/Umbraco.Web/ImageCropperTemplateExtensions.cs # src/Umbraco.Web/JavaScript/ClientDependencyConfiguration.cs # src/Umbraco.Web/Mvc/RenderMvcController.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs # src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs # src/Umbraco.Web/Routing/ContentFinderByConfigured404.cs # src/Umbraco.Web/Routing/ContentFinderByIdPath.cs # src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs # src/Umbraco.Web/Routing/ContentFinderByUrl.cs # src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs # src/Umbraco.Web/Routing/ContentFinderByUrlAndTemplate.cs # src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs # src/Umbraco.Web/Routing/PublishedRouter.cs # src/Umbraco.Web/Runtime/WebInitialComposer.cs # src/Umbraco.Web/Scheduling/KeepAlive.cs # src/Umbraco.Web/Scheduling/ScheduledPublishing.cs # src/Umbraco.Web/Scheduling/TempFileCleanup.cs # src/Umbraco.Web/Security/MembershipHelper.cs # src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs # src/Umbraco.Web/Trees/MemberTreeController.cs # src/Umbraco.Web/Trees/MemberTypeAndGroupTreeControllerBase.cs # src/Umbraco.Web/Trees/MemberTypeTreeController.cs # src/Umbraco.Web/UmbracoApplicationBase.cs # src/Umbraco.Web/UmbracoInjectedModule.cs # src/Umbraco.Web/UmbracoModule.cs # src/Umbraco.Web/WebApi/AngularJsonMediaTypeFormatter.cs # src/Umbraco.Web/WebApi/Filters/FileUploadCleanupFilterAttribute.cs # src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs
2021-04-20 19:34:18 +02:00
IUmbracoMapper umbracoMapper,
2020-02-10 19:59:47 +01:00
IUmbracoComponentRenderer componentRenderer,
IVariationContextAccessor variationContextAccessor,
IMacroService macroService,
IUmbracoContextAccessor umbracoContextAccessor,
IShortStringHelper shortStringHelper,
ISiteDomainMapper siteDomainHelper)
2018-06-29 19:52:40 +02:00
{
_umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper));
_componentRenderer = componentRenderer ?? throw new ArgumentNullException(nameof(componentRenderer));
_variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
_macroService = macroService ?? throw new ArgumentNullException(nameof(macroService));
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
_shortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper));
_siteDomainHelper = siteDomainHelper ?? throw new ArgumentNullException(nameof(siteDomainHelper));
2018-06-29 19:52:40 +02:00
}
/// <summary>
/// Gets the macro parameters to be filled in for a particular macro
/// </summary>
/// <returns></returns>
/// <remarks>
2019-01-21 10:55:48 +01:00
/// Note that ALL logged in users have access to this method because editors will need to insert macros into rte (content/media/members) and it's used for
2018-06-29 19:52:40 +02:00
/// inserting into templates/views/etc... it doesn't expose any sensitive data.
/// </remarks>
public ActionResult<IEnumerable<MacroParameter>> GetMacroParameters(int macroId)
2018-06-29 19:52:40 +02:00
{
2019-01-21 10:55:48 +01:00
var macro = _macroService.GetById(macroId);
2018-06-29 19:52:40 +02:00
if (macro == null)
{
return NotFound();
2018-06-29 19:52:40 +02:00
}
return new ActionResult<IEnumerable<MacroParameter>>(_umbracoMapper.Map<IEnumerable<MacroParameter>>(macro).OrderBy(x => x.SortOrder));
2018-06-29 19:52:40 +02:00
}
/// <summary>
/// Gets a rendered macro as HTML for rendering in the rich text editor
2018-06-29 19:52:40 +02:00
/// </summary>
/// <param name="macroAlias"></param>
/// <param name="pageId"></param>
/// <param name="macroParams">
/// To send a dictionary as a GET parameter the query should be structured like:
///
/// ?macroAlias=Test&pageId=3634&macroParams[0].key=myKey&macroParams[0].value=myVal&macroParams[1].key=anotherKey&macroParams[1].value=anotherVal
///
/// </param>
/// <returns></returns>
[HttpGet]
public async Task<IActionResult> GetMacroResultAsHtmlForEditor(string macroAlias, int pageId, [FromQuery] IDictionary<string, object> macroParams)
2018-06-29 19:52:40 +02:00
{
return await GetMacroResultAsHtml(macroAlias, pageId, macroParams);
2018-06-29 19:52:40 +02:00
}
/// <summary>
/// Gets a rendered macro as HTML for rendering in the rich text editor.
/// Using HTTP POST instead of GET allows for more parameters to be passed as it's not dependent on URL-length limitations like GET.
2018-06-29 19:52:40 +02:00
/// The method using GET is kept to maintain backwards compatibility
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> GetMacroResultAsHtmlForEditor(MacroParameterModel model)
2018-06-29 19:52:40 +02:00
{
return await GetMacroResultAsHtml(model.MacroAlias, model.PageId, model.MacroParams);
2018-06-29 19:52:40 +02:00
}
public class MacroParameterModel
{
public string MacroAlias { get; set; }
public int PageId { get; set; }
public IDictionary<string, object> MacroParams { get; set; }
}
private async Task<IActionResult> GetMacroResultAsHtml(string macroAlias, int pageId, IDictionary<string, object> macroParams)
2018-06-29 19:52:40 +02:00
{
2019-01-21 10:55:48 +01:00
var m = _macroService.GetByAlias(macroAlias);
2018-06-29 19:52:40 +02:00
if (m == null)
return NotFound();
2018-06-29 19:52:40 +02:00
var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();
var publishedContent = umbracoContext.Content.GetById(true, pageId);
2018-06-29 19:52:40 +02:00
//if it isn't supposed to be rendered in the editor then return an empty string
//currently we cannot render a macro if the page doesn't yet exist
if (pageId == -1 || publishedContent == null || m.DontRender)
2018-06-29 19:52:40 +02:00
{
//need to create a specific content result formatted as HTML since this controller has been configured
2018-06-29 19:52:40 +02:00
//with only json formatters.
return Content(string.Empty, "text/html", Encoding.UTF8);
2018-06-29 19:52:40 +02:00
}
Merge remote-tracking branch 'origin/dev-v7' into temp8 (after fixing) # Conflicts: # build/Modules/Umbraco.Build/Build-UmbracoDocs.ps1 # src/SolutionInfo.cs # src/Umbraco.Core/Configuration/UmbracoVersion.cs # src/Umbraco.Core/Constants-Applications.cs # src/Umbraco.Core/Models/Rdbms/ConsentDto.cs # src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs # src/Umbraco.Core/Persistence/Repositories/AuditRepository.cs # src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs # src/Umbraco.Core/Services/ConsentService.cs # src/Umbraco.Core/Services/IRelationService.cs # src/Umbraco.Core/Services/RelationService.cs # src/Umbraco.Tests/Plugins/PluginManagerTests.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs # src/Umbraco.Tests/Services/ConsentServiceTests.cs # src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js # src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorheader.directive.js # src/Umbraco.Web.UI.Client/src/common/directives/components/tree/umbtree.directive.js # src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js # src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js # src/Umbraco.Web.UI.Client/src/common/services/tree.service.js # src/Umbraco.Web.UI.Client/src/less/application/grid.less # src/Umbraco.Web.UI.Client/src/less/forms.less # src/Umbraco.Web.UI.Client/src/less/main.less # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/mediaPicker/mediapicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/treepicker/treepicker.controller.js # src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html # src/Umbraco.Web.UI.Client/src/views/components/html/umb-control-group.html # src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html # src/Umbraco.Web.UI.Client/src/views/content/content.copy.controller.js # src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/datatype.edit.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/edit.html # src/Umbraco.Web.UI.Client/src/views/documenttypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/edit.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.controller.js # src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/users/views/user/details.html # src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/RegisterMember.cshtml # src/Umbraco.Web.UI/config/EmbeddedMedia.Release.config # src/Umbraco.Web.UI/config/EmbeddedMedia.config # src/Umbraco.Web.UI/config/trees.Release.config # src/Umbraco.Web.UI/config/trees.config # src/Umbraco.Web.UI/config/umbracoSettings.config # src/Umbraco.Web.UI/umbraco/Views/Default.cshtml # src/Umbraco.Web.UI/umbraco/config/create/UI.xml # src/Umbraco.Web.UI/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/umbraco/config/lang/it.xml # src/Umbraco.Web.UI/umbraco/config/lang/nl.xml # src/Umbraco.Web.UI/umbraco/config/lang/ru.xml # src/Umbraco.Web/Editors/BackOfficeController.cs # src/Umbraco.Web/Editors/BackOfficeServerVariables.cs # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/Editors/MacroController.cs # src/Umbraco.Web/Editors/MemberController.cs # src/Umbraco.Web/Models/RegisterModel.cs # src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs # src/Umbraco.Web/PublishedContentExtensions.cs # src/Umbraco.Web/Trees/ContentTreeController.cs # src/Umbraco.Web/Trees/ContentTreeControllerBase.cs # src/Umbraco.Web/Trees/TreeControllerBase.cs # src/Umbraco.Web/UmbracoHelper.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.designer.cs
2018-07-11 15:58:48 +10:00
// When rendering the macro in the backoffice the default setting would be to use the Culture of the logged in user.
// Since a Macro might contain thing thats related to the culture of the "IPublishedContent" (ie Dictionary keys) we want
// to set the current culture to the culture related to the content item. This is hacky but it works.
// fixme
// in a 1:1 situation we do not handle the language being edited
// so the macro renders in the wrong language
var culture = DomainUtilities.GetCultureFromDomains(publishedContent.Id, publishedContent.Path, null, umbracoContext, _siteDomainHelper);
Merge remote-tracking branch 'origin/dev-v7' into temp8 (after fixing) # Conflicts: # build/Modules/Umbraco.Build/Build-UmbracoDocs.ps1 # src/SolutionInfo.cs # src/Umbraco.Core/Configuration/UmbracoVersion.cs # src/Umbraco.Core/Constants-Applications.cs # src/Umbraco.Core/Models/Rdbms/ConsentDto.cs # src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs # src/Umbraco.Core/Persistence/Repositories/AuditRepository.cs # src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs # src/Umbraco.Core/Services/ConsentService.cs # src/Umbraco.Core/Services/IRelationService.cs # src/Umbraco.Core/Services/RelationService.cs # src/Umbraco.Tests/Plugins/PluginManagerTests.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs # src/Umbraco.Tests/Services/ConsentServiceTests.cs # src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js # src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorheader.directive.js # src/Umbraco.Web.UI.Client/src/common/directives/components/tree/umbtree.directive.js # src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js # src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js # src/Umbraco.Web.UI.Client/src/common/services/tree.service.js # src/Umbraco.Web.UI.Client/src/less/application/grid.less # src/Umbraco.Web.UI.Client/src/less/forms.less # src/Umbraco.Web.UI.Client/src/less/main.less # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/mediaPicker/mediapicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/treepicker/treepicker.controller.js # src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html # src/Umbraco.Web.UI.Client/src/views/components/html/umb-control-group.html # src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html # src/Umbraco.Web.UI.Client/src/views/content/content.copy.controller.js # src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/datatype.edit.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/edit.html # src/Umbraco.Web.UI.Client/src/views/documenttypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/edit.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.controller.js # src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/users/views/user/details.html # src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/RegisterMember.cshtml # src/Umbraco.Web.UI/config/EmbeddedMedia.Release.config # src/Umbraco.Web.UI/config/EmbeddedMedia.config # src/Umbraco.Web.UI/config/trees.Release.config # src/Umbraco.Web.UI/config/trees.config # src/Umbraco.Web.UI/config/umbracoSettings.config # src/Umbraco.Web.UI/umbraco/Views/Default.cshtml # src/Umbraco.Web.UI/umbraco/config/create/UI.xml # src/Umbraco.Web.UI/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/umbraco/config/lang/it.xml # src/Umbraco.Web.UI/umbraco/config/lang/nl.xml # src/Umbraco.Web.UI/umbraco/config/lang/ru.xml # src/Umbraco.Web/Editors/BackOfficeController.cs # src/Umbraco.Web/Editors/BackOfficeServerVariables.cs # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/Editors/MacroController.cs # src/Umbraco.Web/Editors/MemberController.cs # src/Umbraco.Web/Models/RegisterModel.cs # src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs # src/Umbraco.Web/PublishedContentExtensions.cs # src/Umbraco.Web/Trees/ContentTreeController.cs # src/Umbraco.Web/Trees/ContentTreeControllerBase.cs # src/Umbraco.Web/Trees/TreeControllerBase.cs # src/Umbraco.Web/UmbracoHelper.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.designer.cs
2018-07-11 15:58:48 +10:00
if (culture != null)
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
// must have an active variation context!
_variationContextAccessor.VariationContext = new VariationContext(culture);
Merge remote-tracking branch 'origin/dev-v7' into temp8 (after fixing) # Conflicts: # build/Modules/Umbraco.Build/Build-UmbracoDocs.ps1 # src/SolutionInfo.cs # src/Umbraco.Core/Configuration/UmbracoVersion.cs # src/Umbraco.Core/Constants-Applications.cs # src/Umbraco.Core/Models/Rdbms/ConsentDto.cs # src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs # src/Umbraco.Core/Persistence/Repositories/AuditRepository.cs # src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs # src/Umbraco.Core/Services/ConsentService.cs # src/Umbraco.Core/Services/IRelationService.cs # src/Umbraco.Core/Services/RelationService.cs # src/Umbraco.Tests/Plugins/PluginManagerTests.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs # src/Umbraco.Tests/Services/ConsentServiceTests.cs # src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js # src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorheader.directive.js # src/Umbraco.Web.UI.Client/src/common/directives/components/tree/umbtree.directive.js # src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js # src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js # src/Umbraco.Web.UI.Client/src/common/services/tree.service.js # src/Umbraco.Web.UI.Client/src/less/application/grid.less # src/Umbraco.Web.UI.Client/src/less/forms.less # src/Umbraco.Web.UI.Client/src/less/main.less # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js # src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/mediaPicker/mediapicker.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/treepicker/treepicker.controller.js # src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html # src/Umbraco.Web.UI.Client/src/views/components/html/umb-control-group.html # src/Umbraco.Web.UI.Client/src/views/components/users/change-password.html # src/Umbraco.Web.UI.Client/src/views/content/content.copy.controller.js # src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/datatype.edit.controller.js # src/Umbraco.Web.UI.Client/src/views/datatypes/edit.html # src/Umbraco.Web.UI.Client/src/views/documenttypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/edit.controller.js # src/Umbraco.Web.UI.Client/src/views/mediatypes/views/permissions/permissions.html # src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.controller.js # src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js # src/Umbraco.Web.UI.Client/src/views/users/views/user/details.html # src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/RegisterMember.cshtml # src/Umbraco.Web.UI/config/EmbeddedMedia.Release.config # src/Umbraco.Web.UI/config/EmbeddedMedia.config # src/Umbraco.Web.UI/config/trees.Release.config # src/Umbraco.Web.UI/config/trees.config # src/Umbraco.Web.UI/config/umbracoSettings.config # src/Umbraco.Web.UI/umbraco/Views/Default.cshtml # src/Umbraco.Web.UI/umbraco/config/create/UI.xml # src/Umbraco.Web.UI/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/umbraco/config/lang/it.xml # src/Umbraco.Web.UI/umbraco/config/lang/nl.xml # src/Umbraco.Web.UI/umbraco/config/lang/ru.xml # src/Umbraco.Web/Editors/BackOfficeController.cs # src/Umbraco.Web/Editors/BackOfficeServerVariables.cs # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/Editors/MacroController.cs # src/Umbraco.Web/Editors/MemberController.cs # src/Umbraco.Web/Models/RegisterModel.cs # src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs # src/Umbraco.Web/PublishedContentExtensions.cs # src/Umbraco.Web/Trees/ContentTreeController.cs # src/Umbraco.Web/Trees/ContentTreeControllerBase.cs # src/Umbraco.Web/Trees/TreeControllerBase.cs # src/Umbraco.Web/UmbracoHelper.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs # src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.designer.cs
2018-07-11 15:58:48 +10:00
using (umbracoContext.ForcedPreview(true))
2019-10-09 00:39:28 +01:00
{
//need to create a specific content result formatted as HTML since this controller has been configured
//with only json formatters.
return Content((await _componentRenderer.RenderMacroForContent(publishedContent, m.Alias, macroParams)).ToString(), "text/html",
Encoding.UTF8);
2019-10-09 00:39:28 +01:00
}
2018-06-29 19:52:40 +02:00
}
[HttpPost]
public IActionResult CreatePartialViewMacroWithFile(CreatePartialViewMacroWithFileModel model)
2018-06-29 19:52:40 +02:00
{
if (model == null) throw new ArgumentNullException("model");
if (string.IsNullOrWhiteSpace(model.Filename)) throw new ArgumentException("Filename cannot be null or whitespace", "model.Filename");
if (string.IsNullOrWhiteSpace(model.VirtualPath)) throw new ArgumentException("VirtualPath cannot be null or whitespace", "model.VirtualPath");
var macroName = model.Filename.TrimEnd(".cshtml");
var macro = new Macro(_shortStringHelper)
2018-06-29 19:52:40 +02:00
{
Alias = macroName.ToSafeAlias(_shortStringHelper),
2018-06-29 19:52:40 +02:00
Name = macroName,
MacroSource = model.VirtualPath.EnsureStartsWith("~")
2018-06-29 19:52:40 +02:00
};
2019-01-21 10:55:48 +01:00
_macroService.Save(macro); // may throw
return Ok();
2018-06-29 19:52:40 +02:00
}
public class CreatePartialViewMacroWithFileModel
{
public string Filename { get; set; }
public string VirtualPath { get; set; }
}
}
}