InitData() private method

needed to initialize data - must always happen a bit later because the show-draft info isn't available when creating the first App-object. todo: later this should be moved to initialization of this object
private InitData ( bool showDrafts, IValueCollectionProvider configurationValues ) : void
showDrafts bool
configurationValues IValueCollectionProvider this is needed for providing parameters to the data-query-system
return void
示例#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
        }
示例#2
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
        }
        public AppAndDataHelpers(SexyContent sexy, ModuleInfo module, ViewDataSource data, App app)
        {
            _sexy = sexy;
            App   = app;
            Data  = data;
            Dnn   = new DnnHelper(module);
            List  = new List <Element>();

            if (data != 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;
                    }
                }
            }

            // 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 && SexyContent.HasEditPermission(module));
        }
示例#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);
        }