This is an instance-context of a Content-Module. It basically encapsulates the instance-state, incl. IDs of Zone & App, the App, EAV-Context, Template, Content-Groups (if available), Environment and OriginalModule (in case it's from another portal) It is needed for just about anything, because without this set of information it would be hard to get anything done . Note that it also adds the current-user to the state, so that the system can log data-changes to this user
Inheritance: ISxcInstance
        public AppAndDataHelpers(SxcInstance sexy, ModuleInfo module, Log parentLog) : base("Sxc.AppHlp", parentLog ?? sexy?.Log)
        {
            // ModuleInfo module = sexy.ModuleInfo;
            // Init things than require module-info or similar, but not 2sxc
            Dnn  = new DnnHelper(module);
            Link = new DnnLinkHelper(Dnn);

            // todo: maybe init App & App.Data, as they don't really require a working 2sxc

            if (sexy == null)
            {
                return;
            }

            ViewDataSource data = sexy.Data;

            _sxcInstance = sexy;
            App          = sexy.App;  // app;
            Data         = sexy.Data; // data;
            Sxc          = new SxcHelper(sexy);
            Edit         = new InPageEditingHelper(sexy);

            // If PortalSettings is null - for example, while search index runs - HasEditPermission would fail
            // But in search mode, it shouldn't show drafts, so this is ok.
            // Note that app could be null, if a user is in admin-ui of a module which hasn't actually be configured yet
            App?.InitData(PortalSettings.Current != null && sexy.Environment.Permissions.UserMayEditContent, sexy.Environment.PagePublishing /*new Environment.Dnn7.PagePublishing(Log)*/.IsEnabled(module.ModuleID), data.ConfigurationProvider);

            #region Assemble the mapping of the data-stream "default"/Presentation to the List object and the "ListContent" too
            List = new List <Element>();
            if (data != null && sexy.Template != null)
            {
                if (data.Out.ContainsKey("Default"))
                {
                    var entities = data.List.Select(e => e.Value);
                    var elements = entities.Select(GetElementFromEntity).ToList();
                    List = elements;

                    if (elements.Any())
                    {
                        Content = elements.First().Content;
                        //Presentation = elements.First().Presentation;
                    }
                }

                if (data.Out.ContainsKey(AppConstants.ListContent))
                {
                    var listEntity  = data[AppConstants.ListContent].List.Select(e => e.Value).FirstOrDefault();
                    var listElement = listEntity != null?GetElementFromEntity(listEntity) : null;

                    if (listElement != null)
                    {
                        ListContent = listElement.Content;
                        // ListPresentation = listElement.Presentation;
                    }
                }
            }
            #endregion
        }
Beispiel #2
0
        internal SxcInstance(IContentBlock cb, SxcInstance runtimeInstance)
        {
            ContentBlock = cb;
            ModuleInfo   = runtimeInstance.ModuleInfo;
            // Build up the environment. If we know the module context, then use permissions from there
            Environment.Permissions = runtimeInstance.Environment.Permissions;

            // url-override of view / data
            CheckTemplateOverrides();   // allow view change on apps
        }
Beispiel #3
0
        internal SxcInstance(IContentBlock cb, SxcInstance runtimeInstance)
        {
            ContentBlock = cb;
            // Inherit various context information from the original SxcInstance
            ModuleInfo = runtimeInstance.ModuleInfo;
            Parameters = runtimeInstance.Parameters;
            Environment.Permissions = runtimeInstance.Environment.Permissions;

            // url-override of view / data
            CheckTemplateOverrides();   // allow view change on apps
        }
Beispiel #4
0
        /// <summary>s
        /// Process View if a Template has been set
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_PreRender(object sender, EventArgs e)
        {
            try
            {
                // check things if it's a module of this portal (ensure everything is ok, etc.)
                var isSharedModule = ModuleConfiguration.PortalID != ModuleConfiguration.OwnerPortalID;
                if (!isSharedModule && !SxcInstance.ContentBlock.ContentGroupExists && SxcInstance.App != null)
                {
                    new DnnStuffToRefactor().EnsureTenantIsConfigured(SxcInstance, Server, ControlPath);
                }

                var renderNaked = Request.QueryString["standalone"] == "true";
                if (renderNaked)
                {
                    SxcInstance.RenderWithDiv = false;
                }
                var renderedTemplate = SxcInstance.Render().ToString();

                // call this after rendering templates, because the template may change what resources are registered
                RegisterResources();

                // optional detailed logging
                try
                {
                    if (Request.QueryString["debug"] == "true")
                    {
                        // only attach debug, if it has been enabled for the current time period
                        if (UserInfo.IsSuperUser || Logging.EnableLogging(GlobalConfiguration.Configuration
                                                                          .Properties))
                        {
                            renderedTemplate += HtmlLog();
                        }
                    }
                }
                catch { /* ignore */ }

                // If standalone is specified, output just the template without anything else
                if (renderNaked)
                {
                    SendStandalone(renderedTemplate);
                }
                else
                {
                    phOutput.Controls.Add(new LiteralControl(renderedTemplate));
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        protected AppAndDataHelpersBase(SxcInstance sxcInstance, ITenant tenant, Log parentLog) : base("Sxc.AppHlp", parentLog ?? sxcInstance?.Log)
        {
            if (sxcInstance == null)
            {
                return;
            }

            SxcInstance = sxcInstance;
            _tenant     = tenant;
            App         = sxcInstance.App;
            Data        = sxcInstance.Data;
            Sxc         = new SxcHelper(sxcInstance);
            Edit        = new InPageEditingHelper(sxcInstance, Log);
        }
Beispiel #6
0
        public AppAndDataHelpers(SxcInstance sexy)
        {
            ModuleInfo     module = sexy.ModuleInfo;
            ViewDataSource data   = sexy.Data;

            _sxcInstance = sexy;
            App          = sexy.App;  // app;
            Data         = sexy.Data; // data;
            Dnn          = new DnnHelper(module);
            Link         = new DnnLinkHelper(Dnn);
            Sxc          = new SxcHelper(sexy);
            Edit         = new InPageEditingHelper(sexy);

            // If PortalSettings is null - for example, while search index runs - HasEditPermission would fail
            // But in search mode, it shouldn't show drafts, so this is ok.
            App.InitData(PortalSettings.Current != null && sexy.Environment.Permissions.UserMayEditContent /*SecurityHelpers.HasEditPermission(module)*/, data.ConfigurationProvider);

            #region Assemble the mapping of the data-stream "default"/Presentation to the List object and the "ListContent" too
            List = new List <Element>();
            if (data != null && sexy.Template != null)
            {
                if (data.Out.ContainsKey("Default"))
                {
                    var entities = data.List.Select(e => e.Value);
                    var elements = entities.Select(GetElementFromEntity).ToList();
                    List = elements;

                    if (elements.Any())
                    {
                        Content      = elements.First().Content;
                        Presentation = elements.First().Presentation;
                    }
                }

                if (data.Out.ContainsKey("ListContent"))
                {
                    var listEntity  = data["ListContent"].List.Select(e => e.Value).FirstOrDefault();
                    var listElement = listEntity != null?GetElementFromEntity(listEntity) : null;

                    if (listElement != null)
                    {
                        ListContent      = listElement.Content;
                        ListPresentation = listElement.Presentation;
                    }
                }
            }
            #endregion
        }
Beispiel #7
0
        public AppAndDataHelpers(SxcInstance sexy, ModuleInfo module, Log parentLog) : base("Sxc.AppHlp", parentLog ?? sexy?.Log)
        {
            // Init things than require module-info or similar, but not 2sxc
            Dnn  = new DnnHelper(module);
            Link = new DnnLinkHelper(Dnn);

            if (sexy == null)
            {
                return;
            }

            _sxcInstance = sexy;
            App          = sexy.App;
            Data         = sexy.Data;
            Sxc          = new SxcHelper(sexy);
            Edit         = new InPageEditingHelper(sexy);

            // If PortalSettings is null - for example, while search index runs - HasEditPermission would fail
            // But in search mode, it shouldn't show drafts, so this is ok.
            // Note that app could be null, if a user is in admin-ui of a module which hasn't actually be configured yet
            App?.InitData(PortalSettings.Current != null && sexy.Environment.Permissions.UserMayEditContent,
                          PortalSettings.Current != null && sexy.Environment.PagePublishing.IsEnabled(module.ModuleID),
                          Data.ConfigurationProvider);
        }
Beispiel #8
0
 public SxcHelper(SxcInstance sexy)
 {
     _sexy = sexy;
 }
Beispiel #9
0
        }                                           // must be internal for further use cases

        /// <summary>
        /// Constructor with EntityModel and DimensionIds
        /// </summary>
        public DynamicEntity(ToSic.Eav.Interfaces.IEntity entityModel, string[] dimensions, SxcInstance sexy)
        {
            Entity      = entityModel;
            _dimensions = dimensions;
            SxcInstance = sexy;
        }
Beispiel #10
0
 public SxcHelper(SxcInstance sexy)
 {
     _sexy = sexy;
 }
Beispiel #11
0
 public AppAndDataHelpers(SxcInstance sexy) : this(sexy, sexy.ModuleInfo, null)
 {
 }
Beispiel #12
0
        internal SxcInstance SxcInstance { get; }   // must be internal for further use cases

        /// <summary>
        /// Constructor with EntityModel and DimensionIds
        /// </summary>
        public DynamicEntity(IEntity entityModel, string[] dimensions, SxcInstance sexy)
        {
            Entity = entityModel;
            _dimensions = dimensions;
            SxcInstance = sexy;
        }
Beispiel #13
0
        }                                           // must be internal for further use cases

        /// <summary>
        /// Constructor with EntityModel and DimensionIds
        /// </summary>
        public DynamicEntity(IEntity entityModel, string[] dimensions, SxcInstance sexy)
        {
            Entity      = entityModel;
            _dimensions = dimensions;
            SxcInstance = sexy;
        }
Beispiel #14
0
        internal SxcInstance(IContentBlock cb, SxcInstance runtimeInstance)
        {
            ContentBlock = cb;
            // Inherit various context information from the original SxcInstance
            ModuleInfo = runtimeInstance.ModuleInfo;
            Parameters = runtimeInstance.Parameters;
            Environment.Permissions = runtimeInstance.Environment.Permissions;

            // url-override of view / data
            CheckTemplateOverrides();   // allow view change on apps
        }
Beispiel #15
0
 public SxcHelper(SxcInstance sxcInstance)
 {
     SxcInstance = sxcInstance;
 }