/// <summary> /// Standard constructor /// </summary> /// <param name="blockBuilder">CMS Block which is used in this code.</param> /// <param name="compatibility">compatibility level - changes behaviour if level 9 or 10</param> /// <param name="parentLog">parent logger for logging what's happening</param> public DnnDynamicCode(IBlockBuilder blockBuilder, int compatibility = 10, ILog parentLog = null) : base(blockBuilder, new DnnTenant(null), compatibility, parentLog ?? blockBuilder?.Log) { // Init things than require module-info or similar, but not 2sxc var instance = blockBuilder?.Container; Dnn = new DnnContext(instance); Link = new DnnLinkHelper(Dnn); }
private void PrepCore(IApp app, Guid entityGuid, string fieldName, bool usePortalRoot) { Log.Add("PrepCore(...)"); var dnn = new DnnContext(BlockBuilder?.Container); var tenant = new DnnTenant(dnn.Portal); AdamAppContext = new AdamAppContext(tenant, app, BlockBuilder, 10, Log); ContainerContext = usePortalRoot ? new ContainerOfTenant(AdamAppContext) as ContainerBase : new ContainerOfField(AdamAppContext, entityGuid, fieldName); }
internal static IBlock GetCmsBlock(HttpRequestMessage request, bool allowNoContextFound, ILog log) { var wrapLog = log.Call <IBlock>(parameters: $"request:..., {nameof(allowNoContextFound)}: {allowNoContextFound}"); //const string headerId = "ContentBlockId"; var moduleInfo = request.FindModuleInfo(); if (allowNoContextFound & moduleInfo == null) { return(wrapLog("request ModuleInfo not found, allowed", null)); } if (moduleInfo == null) { log.Add("context/module not found"); } var container = new DnnContainer().Init(moduleInfo, log); var tenant = moduleInfo == null ? new DnnTenant(null) : new DnnTenant().Init(moduleInfo.OwnerPortalID); var context = new DnnContext(tenant, container, new DnnUser(), GetOverrideParams(request)); IBlock block = new BlockFromModule().Init(context, log); // check if we need an inner block if (request.Headers.Contains(WebApiConstants.HeaderContentBlockId)) { var blockHeaderId = request.Headers.GetValues(WebApiConstants.HeaderContentBlockId).FirstOrDefault(); int.TryParse(blockHeaderId, out var blockId); if (blockId < 0) // negative id, so it's an inner block { log.Add($"Inner Content: {blockId}"); block = new BlockFromEntity().Init(block, blockId, log); } } return(wrapLog("ok", block)); }
protected string LocalizeString(string text) { return(DnnContext.LocalizeString(text)); }