Skip to content

Commit

Permalink
Merge pull request #3389 from 2sic/develop
Browse files Browse the repository at this point in the history
v17.08
  • Loading branch information
iJungleboy authored May 16, 2024
2 parents 2692fe5 + 5f47959 commit e96aec6
Show file tree
Hide file tree
Showing 334 changed files with 3,827 additions and 3,488 deletions.
Binary file modified Dependencies/Imageflow/Dnn/ToSic.Imageflow.Dnn.dll
Binary file not shown.
Binary file modified Dependencies/Imageflow/Dnn/ToSic.Imageflow.Dnn.pdb
Binary file not shown.
600 changes: 452 additions & 148 deletions Src/Data/App_Data/system/bundles/system-cms.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions Src/Dnn.Tests/ToSic.Dnn.Tests/ToSic.Dnn.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter">
<Version>2.2.7</Version>
<Version>2.2.9</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>2.2.7</Version>
<Version>2.2.9</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -89,7 +89,9 @@
<Name>ToSic.Sxc.Dnn</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
11 changes: 11 additions & 0 deletions Src/Dnn.Tests/ToSic.Dnn.Tests/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
12 changes: 8 additions & 4 deletions Src/Dnn/ToSic.Sxc.Dnn.Core/Dnn/Adam/DnnAdamFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,21 @@ public File<int, int> GetFile(int fileId)
return DnnToAdam(file);
}

public void Rename(IFile file, string newName) => Log.Do($"{nameof(file)}:{file.Id}, {nameof(newName)}: {newName}", () =>
public void Rename(IFile file, string newName)
{
var l = Log.Fn($"{nameof(file)}:{file.Id}, {nameof(newName)}: {newName}");
var dnnFile = _dnnFiles.GetFile(file.AsDnn().SysId);
_dnnFiles.RenameFile(dnnFile, newName);
});
l.Done();
}

public void Delete(IFile file) => Log.Do(() =>
public void Delete(IFile file)
{
var l = Log.Fn($"file: {file.Id}");
var dnnFile = _dnnFiles.GetFile(file.AsDnn().SysId);
_dnnFiles.DeleteFile(dnnFile);
});
l.Done();
}

public File<int, int> Add(IFolder parent, Stream body, string fileName, bool ensureUniqueName)
{
Expand Down
40 changes: 10 additions & 30 deletions Src/Dnn/ToSic.Sxc.Dnn.Core/Dnn/Cms/DnnModuleUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,13 @@

namespace ToSic.Sxc.Dnn.Cms;

internal class DnnModuleUpdater : ServiceBase, IPlatformModuleUpdater
internal class DnnModuleUpdater(
GenWorkPlus<WorkViews> workViews,
IZoneMapper zoneMapper,
IAppStates appStates,
ISite site)
: ServiceBase("Dnn.MapA2I", connect: [workViews, appStates, site, zoneMapper]), IPlatformModuleUpdater
{
#region Constructor and DI

/// <summary>
/// Empty constructor for DI
/// </summary>
// ReSharper disable once UnusedMember.Global
public DnnModuleUpdater(GenWorkPlus<WorkViews> workViews, IZoneMapper zoneMapper, IAppStates appStates, ISite site) : base("Dnn.MapA2I")
{
ConnectServices(
_workViews = workViews,
_appStates = appStates,
_site = site,
_zoneMapper = zoneMapper
);
}

private readonly GenWorkPlus<WorkViews> _workViews;
private readonly IAppStates _appStates;
private readonly ISite _site;
private readonly IZoneMapper _zoneMapper;


#endregion


public void SetAppId(IModule instance, int? appId)
{
Log.A($"SetAppIdForInstance({instance.Id}, -, appid: {appId})");
Expand All @@ -50,13 +30,13 @@ public void SetAppId(IModule instance, int? appId)

// ToDo: Should throw exception if a real BlockConfiguration exists
// note: this is the correct zone, even if the module is shared from another portal, because the Site is prepared correctly
var zoneId = _site.ZoneId;
var zoneId = site.ZoneId;

if (appId == Eav.Constants.AppIdEmpty || !appId.HasValue)
UpdateInstanceSettingForAllLanguages(instance.Id, ModuleSettingNames.AppName, null, Log);
else
{
var appName = _appStates.AppIdentifier(zoneId, appId.Value);
var appName = appStates.AppIdentifier(zoneId, appId.Value);
UpdateInstanceSettingForAllLanguages(instance.Id, ModuleSettingNames.AppName, appName, Log);
}

Expand All @@ -65,7 +45,7 @@ public void SetAppId(IModule instance, int? appId)
{
var appIdentity = new AppIdentity(zoneId, appId.Value);

var templateGuid = _workViews.New(appIdentity).GetAll()
var templateGuid = workViews.New(appIdentity).GetAll()
.OrderByDescending(v => v.Metadata.HasType(Decorators.IsDefaultDecorator)) // first sort by IsDefaultDecorator DESC
.ThenBy(v => v.Name) // than by Name ASC
.FirstOrDefault(t => !t.IsHidden)?.Guid;
Expand Down Expand Up @@ -111,7 +91,7 @@ public void UpdateTitle(IBlock block, IEntity titleItem)
{
Log.A("update title");

var languages = _zoneMapper.CulturesWithState(block.Context.Site);
var languages = zoneMapper.CulturesWithState(block.Context.Site);

// Find Module for default language
var moduleController = new ModuleController();
Expand Down
24 changes: 6 additions & 18 deletions Src/Dnn/ToSic.Sxc.Dnn.Core/Dnn/Cms/DnnPagePublishing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,12 @@

namespace ToSic.Sxc.Dnn.Cms;

internal partial class DnnPagePublishing : ServiceBase, IPagePublishing
internal partial class DnnPagePublishing(
LazySvc<IModuleAndBlockBuilder> moduleAndBlockBuilder,
GenWorkDb<WorkEntityPublish> entPublish)
: ServiceBase("Dnn.Publsh", connect: [moduleAndBlockBuilder, entPublish]), IPagePublishing
{

#region DI Constructors and More

public DnnPagePublishing(LazySvc<IModuleAndBlockBuilder> moduleAndBlockBuilder, GenWorkDb<WorkEntityPublish> entPublish) : base("Dnn.Publsh")
{
ConnectServices(
_moduleAndBlockBuilder = moduleAndBlockBuilder,
_entPublish = entPublish
);
}

private readonly GenWorkDb<WorkEntityPublish> _entPublish;
private readonly LazySvc<IModuleAndBlockBuilder> _moduleAndBlockBuilder;

#endregion

public void DoInsidePublishing(IContextOfSite context, Action<VersioningActionInfo> action)
{
var possibleContextOfBlock = context as IContextOfBlock;
Expand Down Expand Up @@ -92,7 +80,7 @@ public void Publish(int instanceId, int version)
// publish all entities of this content block
var dnnModule = ModuleController.Instance.GetModule(instanceId, Null.NullInteger, true);
// must find tenant through module, as the Portal-Settings.Current is null in search mode
var cb = _moduleAndBlockBuilder.Value.BuildBlock(dnnModule, null);
var cb = moduleAndBlockBuilder.Value.BuildBlock(dnnModule, null);

l.A($"found dnn mod {cb.Context.Module.Id}, tenant {cb.Context.Site.Id}, cb exists: {cb.ContentGroupExists}");
if (cb.ContentGroupExists)
Expand Down Expand Up @@ -126,7 +114,7 @@ public void Publish(int instanceId, int version)
l.A(Log.Try(() => $"will publish id⋮{ids.Count} ids:[{ string.Join(",", ids.Select(i => i.ToString()).ToArray()) }]"));

if (ids.Any())
_entPublish.New(cb.Context.AppState).Publish(ids.ToArray());
entPublish.New(cb.Context.AppState).Publish(ids.ToArray());
else
l.A("no ids found, won\'t publish items");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ internal class AppCodeCompilerNetFull : AppCodeCompiler

public AppCodeCompilerNetFull(IHostingEnvironmentWrapper hostingEnvironment, IReferencedAssembliesProvider referencedAssembliesProvider)
{
ConnectServices(
ConnectLogs([
_hostingEnvironment = hostingEnvironment,
_referencedAssembliesProvider = referencedAssembliesProvider
);
]);

TempAssemblyFolderPath = Path.Combine(_hostingEnvironment.MapPath("~/App_Data"), "2sxc.bin");
// Ensure "2sxc.bin" folder exists to preserve dlls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ internal class CodeCompilerNetFull : CodeCompiler
public CodeCompilerNetFull(IServiceProvider serviceProvider, IRoslynBuildManager roslynBuildManager, LazySvc<SourceAnalyzer> sourceAnalyzer, LazySvc<IAppJsonService> appJson) : base(serviceProvider)
{

ConnectServices(
ConnectLogs([
_roslynBuildManager = roslynBuildManager,
_sourceAnalyzer = sourceAnalyzer,
_appJson = appJson
);
]);
}

protected internal override AssemblyResult GetAssembly(string relativePath, string className, HotBuildSpec spec)
Expand Down
2 changes: 1 addition & 1 deletion Src/Dnn/ToSic.Sxc.Dnn.Core/Dnn/Context/DnnContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void ConnectToRoot(ICodeApiService codeRoot)
Module = (moduleContext as Module<ModuleInfo>)?.GetContents();
// note: this may be a bug, I assume it should be Module.OwnerPortalId
Portal = PortalSettings.Current ??
(moduleContext != null ? new PortalSettings(Module.PortalID): null);
(Module != null ? new PortalSettings(Module.PortalID): null);
}

public ModuleInfo Module { get; private set; }
Expand Down
4 changes: 2 additions & 2 deletions Src/Dnn/ToSic.Sxc.Dnn.Core/Dnn/Context/DnnModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class DnnModule: Module<ModuleInfo>

public DnnModule(IAppStates appStates, LazySvc<AppFinder> appFinderLazy, ISite site): base("Dnn.Contnr")
{
ConnectServices(
ConnectLogs([
_appStates = appStates,
_appFinderLazy = appFinderLazy
);
]);
_site = site;
}

Expand Down
4 changes: 2 additions & 2 deletions Src/Dnn/ToSic.Sxc.Dnn.Core/Dnn/Context/DnnSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ internal sealed class DnnSite: Site<PortalSettings>, IZoneCultureResolverProWIP
/// </summary>
public DnnSite(LazySvc<IZoneMapper> zoneMapperLazy, LazySvc<ILinkPaths> linkPathsLazy, LazySvc<IEavFeaturesService> featuresSvc): base(DnnConstants.LogName)
{
ConnectServices(
ConnectLogs([
_featuresSvc = featuresSvc,
_zoneMapperLazy = zoneMapperLazy,
_linkPathsLazy = linkPathsLazy
);
]);
TryInitPortal(null);
}
private readonly LazySvc<IZoneMapper> _zoneMapperLazy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ internal class DnnUsersDsProvider : UsersDataSourceProvider

public DnnUsersDsProvider(LazySvc<DnnSecurity> dnnSecurity) : base("Dnn.Users")
{
ConnectServices(
ConnectLogs([
_dnnSecurity = dnnSecurity
);
]);
}

public override IEnumerable<CmsUserRaw> GetUsersInternal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ public MyServices(
LazySvc<DnnSecurity> dnnSecurity
) : base(parentServices)
{
ConnectServices(
ConnectLogs([
Site = site,
ZoneMapper = zoneMapper,
DnnSecurity = dnnSecurity
);
]);
}
}

public DnnUserProfile(MyServices services, IDataFactory dataFactory) : base(services, "Dnn.Profile")
{
ConnectServices(
ConnectLogs([
_dataFactory = dataFactory
);
]);
_services = services;
ProvideOut(GetList);
}
Expand Down
4 changes: 2 additions & 2 deletions Src/Dnn/ToSic.Sxc.Dnn.Core/Dnn/DnnModuleAndBlockBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ internal class DnnModuleAndBlockBuilder: ModuleAndBlockBuilder
{
public DnnModuleAndBlockBuilder(Generator<IModule> moduleGenerator, Generator<IContextOfBlock> contextGenerator, Generator<BlockFromModule> blockGenerator) : base(blockGenerator, DnnConstants.LogName)
{
ConnectServices(
ConnectLogs([
_moduleGenerator = moduleGenerator,
_contextGenerator = contextGenerator
);
]);
}
private readonly Generator<IModule> _moduleGenerator;
private readonly Generator<IContextOfBlock> _contextGenerator;
Expand Down
27 changes: 27 additions & 0 deletions Src/Dnn/ToSic.Sxc.Dnn.Core/Dnn/Features/DnnRequirements.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using ToSic.Eav.Internal.Features;
using ToSic.Eav.Internal.Requirements;
using ToSic.Eav.Plumbing;
using ToSic.Sxc.Engines;

namespace ToSic.Sxc.Dnn.Features;

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public class DnnRequirements(IRequirementsService requirements) : EngineRequirementsBase(requirements, "Eng.DnnReq")
{
internal bool RequirementsMet()
=> !RequirementsStatus().SafeAny();

private List<RequirementStatus> RequirementsStatus()
=> requirements.UnfulfilledRequirements([SysFeatureSuggestions.CSharp08]);

internal RenderEngineResult GetMessageForRequirements()
{
var l = Log.Fn<RenderEngineResult>();

if (RequirementsMet())
return l.ReturnNull("all seems ok");

var result = BuildRenderEngineResult(RequirementsStatus());
return l.Return(result, "error");
}
}
Loading

0 comments on commit e96aec6

Please sign in to comment.