private void _constructor(IContentBlock parent, Eav.Interfaces.IEntity cbDefinition) { Parent = parent; ParseContentBlockDefinition(cbDefinition); ParentId = parent.ParentId; ContentBlockId = -cbDefinition.EntityId; // Ensure we know what portal the stuff is coming from Tenant = Parent.App.Tenant; ZoneId = Parent.ZoneId; AppId = AppHelpers.GetAppIdFromGuidName(ZoneId, _appName); // should be 0 if unknown, must test if (AppId == Settings.DataIsMissingInDb) { _dataIsMissing = true; return; } // 2018-09-22 new, must come before the AppId == 0 check SxcInstance = new SxcInstance(this, Parent.SxcInstance.EnvInstance, Parent.SxcInstance.Parameters, Log); if (AppId == 0) { return; } // 2018-09-22 old // try to load the app - if possible //App = new App(Tenant, ZoneId, AppId); //Configuration = ConfigurationProvider.GetConfigProviderForModule(ParentId, App, SxcInstance); // maybe ensure that App.Data is ready //var userMayEdit = SxcInstance.UserMayEdit; //var publishingEnabled = SxcInstance.Environment.PagePublishing.IsEnabled(Parent.SxcInstance.EnvInstance.Id); //App.InitData(userMayEdit, publishingEnabled, Configuration); // 2018-09-22 new App = new App(Tenant, ZoneId, AppId, ConfigurationProvider.Build(SxcInstance, false), true, Log); ContentGroup = App.ContentGroupManager.GetContentGroupOrGeneratePreview(_contentGroupGuid, _previewTemplateGuid); // handle cases where the content group is missing - usually because of uncomplete import if (ContentGroup.DataIsMissing) { _dataIsMissing = true; App = null; return; } // use the content-group template, which already covers stored data + module-level stored settings SxcInstance.SetTemplateOrOverrideFromUrl(ContentGroup.Template); }
/// <summary> /// Create a module-content block /// </summary> /// <param name="instanceInfo">the dnn module-info</param> /// <param name="parentLog">a parent-log; can be null but where possible you should wire one up</param> /// <param name="tenant"></param> /// <param name="overrideParams">optional override parameters</param> public ModuleContentBlock(IInstanceInfo instanceInfo, Log parentLog, ITenant tenant = null, IEnumerable <KeyValuePair <string, string> > overrideParams = null) : base(parentLog, "CB.Mod") { InstanceInfo = instanceInfo ?? throw new Exception("Need valid Instance/ModuleInfo / ModuleConfiguration of runtime"); ParentId = instanceInfo.Id; ContentBlockId = ParentId; // url-params _urlParams = overrideParams ?? DnnWebForms.Helpers.SystemWeb.GetUrlParams(); // Ensure we know what portal the stuff is coming from // PortalSettings is null, when in search mode Tenant = tenant; // important: don't use the SxcInstance.Environment, as it would try to init the Sxc-object before the app is known, causing various side-effects var tempEnv = Factory.Resolve <IEnvironmentFactory>().Environment(parentLog); ZoneId = tempEnv.ZoneMapper.GetZoneId(tenant.Id); // use tenant as reference, as it can be different from instance.TennantId AppId = Factory.Resolve <IMapAppToInstance>().GetAppIdFromInstance(instanceInfo, ZoneId) ?? 0; // fallback/undefined YET Log.Add($"parent#{ParentId}, content-block#{ContentBlockId}, z#{ZoneId}, a#{AppId}"); if (AppId == Settings.DataIsMissingInDb) { _dataIsMissing = true; Log.Add("data is missing, will stop here"); return; } if (AppId != 0) { Log.Add("real app, will load data"); // try to load the app - if possible App = new App(Tenant, ZoneId, AppId, parentLog: Log); Configuration = ConfigurationProvider.GetConfigProviderForModule(InstanceInfo.Id, App, SxcInstance); // maybe ensure that App.Data is ready var userMayEdit = SxcInstance.UserMayEdit;// Factory.Resolve<IPermissions>().UserMayEditContent(SxcInstance.InstanceInfo); App.InitData(userMayEdit, SxcInstance.Environment.PagePublishing.IsEnabled(InstanceInfo.Id), Configuration); ContentGroup = App.ContentGroupManager.GetInstanceContentGroup(instanceInfo.Id, instanceInfo.PageId); if (ContentGroup.DataIsMissing) { _dataIsMissing = true; App = null; return; } SxcInstance.SetTemplateOrOverrideFromUrl(ContentGroup.Template); } }
private void _constructor(IContentBlock parent, Eav.Interfaces.IEntity cbDefinition) { Parent = parent; ParseContentBlockDefinition(cbDefinition); ParentId = parent.ParentId; ContentBlockId = -cbDefinition.EntityId; // "mod:" + ParentId + "-ent:" + cbDefinition.EntityId; // Ensure we know what portal the stuff is coming from PortalSettings = Parent.App.OwnerPortalSettings; ZoneId = Parent.ZoneId; AppId = AppHelpers.GetAppIdFromGuidName(ZoneId, _appName); // should be 0 if unknown, must test if (AppId == Settings.DataIsMissingInDb) { _dataIsMissing = true; return; } if (AppId != 0) { // try to load the app - if possible App = new App(ZoneId, AppId, PortalSettings); Configuration = ConfigurationProvider.GetConfigProviderForModule(ParentId, App, SxcInstance); // maybe ensure that App.Data is ready App.InitData(SxcInstance.Environment.Permissions.UserMayEditContent, SxcInstance.Environment.PagePublishing /*new Environment.Dnn7.PagePublishing(Log)*/.IsEnabled(Parent.SxcInstance.ModuleInfo.ModuleID), Configuration /* Data.ConfigurationProvider*/); ContentGroup = App.ContentGroupManager.GetContentGroupOrGeneratePreview(_contentGroupGuid, _previewTemplateGuid); // handle cases where the content group is missing - usually because of uncomplete import if (ContentGroup.DataIsMissing) { _dataIsMissing = true; App = null; return; } // use the content-group template, which already covers stored data + module-level stored settings //Template = ContentGroup.Template; SxcInstance.SetTemplateOrOverrideFromUrl(ContentGroup.Template); } }
/// <summary> /// Create a module-content block /// </summary> /// <param name="moduleInfo">the dnn module-info</param> /// <param name="parentLog">a parent-log; can be null but where possible you should wire one up</param> /// <param name="overrideParams">optional override parameters</param> public ModuleContentBlock(ModuleInfo moduleInfo, Log parentLog, IEnumerable <KeyValuePair <string, string> > overrideParams = null) : base(parentLog, "CB.Mod") { ModuleInfo = moduleInfo ?? throw new Exception("Need valid ModuleInfo / ModuleConfiguration of runtime"); ParentId = moduleInfo.ModuleID; ContentBlockId = ParentId; // url-params _urlParams = overrideParams ?? DnnWebForms.Helpers.SystemWeb.GetUrlParams(); // Ensure we know what portal the stuff is coming from // PortalSettings is null, when in search mode PortalSettings = PortalSettings.Current == null || moduleInfo.OwnerPortalID != moduleInfo.PortalID ? new PortalSettings(moduleInfo.OwnerPortalID) : PortalSettings.Current; // important: don't use the SxcInstance.Environment, as it would try to init the Sxc-object before the app is known, causing various side-effects ZoneId = new Environment.DnnEnvironment(Log).ZoneMapper.GetZoneId(moduleInfo.OwnerPortalID); // ZoneHelpers.GetZoneId(moduleInfo.OwnerPortalID) ?? 0; // new AppId = AppHelpers.GetAppIdFromModule(moduleInfo, ZoneId) ?? 0; // fallback/undefined YET Log.Add($"parent#{ParentId}, content-block#{ContentBlockId}, z#{ZoneId}, a#{AppId}"); if (AppId == Settings.DataIsMissingInDb) { _dataIsMissing = true; Log.Add("data is missing, will stop here"); return; } if (AppId != 0) { Log.Add("real app, will load data"); // try to load the app - if possible App = new App(ZoneId, AppId, PortalSettings, parentLog: Log); Configuration = ConfigurationProvider.GetConfigProviderForModule(moduleInfo.ModuleID, App, SxcInstance); // maybe ensure that App.Data is ready App.InitData(SxcInstance.Environment.Permissions.UserMayEditContent, SxcInstance.Environment.PagePublishing /*new Environment.Dnn7.PagePublishing(Log)*/.IsEnabled(moduleInfo.ModuleID), Configuration); var res = App.ContentGroupManager.GetContentGroupForModule(moduleInfo.ModuleID, moduleInfo.TabID); var contentGroupGuid = res.Item1; var previewTemplateGuid = res.Item2; ContentGroup = App.ContentGroupManager.GetContentGroupOrGeneratePreview(contentGroupGuid, previewTemplateGuid); //ContentGroup = App.ContentGroupManager.GetContentGroupForModule(moduleInfo.ModuleID, moduleInfo.TabID); if (ContentGroup.DataIsMissing) { _dataIsMissing = true; App = null; return; } // use the content-group template, which already covers stored data + module-level stored settings //Template = ContentGroup.Template; SxcInstance.SetTemplateOrOverrideFromUrl(ContentGroup.Template); //SxcInstance.CheckTemplateOverrides(); // 2017-09-14 2dm disabled, as the TemplateChooser State isn't a thing any more // set show-status of the template/view picker //var showStatus = moduleInfo.ModuleSettings[Settings.SettingsShowTemplateChooser]; //bool show; //if (bool.TryParse((showStatus ?? true).ToString(), out show)) // ShowTemplateChooser = show; } }