示例#1
0
        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
        }
        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);
        }
示例#3
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
        }
示例#4
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);
        }