Ejemplo n.º 1
0
        public EntityContentBlock(IContentBlock parent, int contentBlockId)
        {
            contentBlockId = Math.Abs(contentBlockId);                               // for various reasons this can be introduced as a negative value, make sure we neutralize that
            var cbDef = parent.SxcInstance.App.Data["Default"].List[contentBlockId]; // get the content-block definition

            _constructor(parent, cbDef);
        }
Ejemplo n.º 2
0
        private void _constructor(IContentBlock parent, 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.GetAppIdFromName(ZoneId, _appName); // should be 0 if unknown, must test

            if (AppId != 0)
            {
                // try to load the app - if possible
                App          = new App(ZoneId, AppId, PortalSettings);
                ContentGroup = App.ContentGroupManager.GetContentGroupOrGeneratePreview(_contentGroupGuid, _previewTemplateGuid);

                // use the content-group template, which already covers stored data + module-level stored settings
                Template = ContentGroup.Template;

                // maybe ensure that App.Data is ready
                App.InitData(SxcInstance.Environment.Permissions.UserMayEditContent, Data.ConfigurationProvider);
            }
        }
Ejemplo n.º 3
0
 internal ClientInfosError(IContentBlock cb)
 {
     if (cb.DataIsMissing)
     {
         type = "DataIsMissing";
     }
 }
Ejemplo n.º 4
0
        public EntityContentBlock(IContentBlock parent, int contentBlockId, Log parentLog) : base(parentLog, "CB.Ent")
        {
            contentBlockId = Math.Abs(contentBlockId);                        // for various reasons this can be introduced as a negative value, make sure we neutralize that
            var cbDef = parent.SxcInstance.App.Data.List.One(contentBlockId); // get the content-block definition

            _constructor(parent, cbDef);
        }
Ejemplo n.º 5
0
 internal ClientInfoContentBlock(IContentBlock contentBlock, string parentFieldName, int indexInField)
 {
     ShowTemplatePicker = contentBlock.ShowTemplateChooser;
     IsEntity           = contentBlock.ParentIsEntity;
     Id = contentBlock.ContentBlockId;
     ParentFieldName      = parentFieldName;
     ParentFieldSortOrder = indexInField;
 }
        public List <CF> Query <CF>(contentRelationQueryType qType, contentRelationType qRelation, IContentElement qReference, int limit = -1)
        {
            List <CF>          output   = new List <CF>();
            contentElementList elements = Query(qRelation, qReference, limit);

            foreach (IContentElement element in elements)
            {
                switch (qType)
                {
                case contentRelationQueryType.gatherFlags:

                    IContentToken ict = element as IContentToken;
                    if (ict != null)
                    {
                        output.AddRange(ict.flags.getEnumListFromFlags <CF>());                 // output.populateWith(ict.flags);
                    }
                    break;

                case contentRelationQueryType.gatherSentenceFlags:
                    IContentSentence ics = element as IContentSentence;
                    if (ics != null)
                    {
                        output.AddRange(ics.sentenceFlags.getEnumListFromFlags <CF>());                 // output.populateWith(ics.sentenceFlags);
                    }
                    break;

                case contentRelationQueryType.gatherParagraphFlags:
                    IContentParagraph icp = element as IContentParagraph;
                    if (icp != null)
                    {
                        output.AddRange(icp.flags.getEnumListFromFlags <CF>());                 // output.populateWith(icp.flags);
                    }
                    // output.populateWith(icp.flags);
                    break;

                case contentRelationQueryType.gatherBlockTags:
                    IContentBlock icb = element as IContentBlock;
                    if (icb != null)
                    {
                        output.AddRange(icb.flags.getEnumListFromFlags <CF>());                 // output.populateWith(icb.flags);
                    }
                    break;

                case contentRelationQueryType.gatherOrigins:
                    throw new NotImplementedException("gatherOrigin");

                    //IContentToken icto = element as IContentToken;
                    //if (icto != null) output.Add((CF)icto.origin);
                    break;

                default:
                    //output.populateWith(element.flags);
                    break;
                }
            }
            return(output);
        }
Ejemplo n.º 7
0
        protected bool IsVisible(IContentBlock contentBlock)
        {
            if (contentBlock == null || !contentBlock.Enabled)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
 // public bool DataIsMissing;
 internal ClientInfoContentBlock(IContentBlock contentBlock, string parentFieldName, int indexInField)
 {
     ShowTemplatePicker = contentBlock.ShowTemplateChooser;
     IsEntity = contentBlock.ParentIsEntity;
     Id = contentBlock.ContentBlockId;
     ParentFieldName = parentFieldName;
     ParentFieldSortOrder = indexInField;
     // DataIsMissing = contentBlock.DataIsMissing;
 }
Ejemplo n.º 9
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
        }
Ejemplo n.º 10
0
        private async Task DeleteBlock(IContentBlock block)
        {
            var num = block.OrderNo;

            block.OrderNo = 0;

            await BlockData.UpdateOrderNo(new List <IContentBlock>() { block });

            await UpdateBlocksBelowDeleted(num);
        }
Ejemplo n.º 11
0
 internal ClientInfoContentBlock(IContentBlock contentBlock, string parentFieldName, int indexInField, PublishingMode versioningRequirements)
 {
     ShowTemplatePicker = contentBlock.ShowTemplateChooser;
     IsEntity           = contentBlock.ParentIsEntity;
     Id = contentBlock.ContentBlockId;
     ParentFieldName        = parentFieldName;
     ParentFieldSortOrder   = indexInField;
     VersioningRequirements = versioningRequirements.ToString();
     PartOfPage             = contentBlock.ParentId == contentBlock.ContentBlockId; // if the CBID is the moduleId, then it's part of page
 }
Ejemplo n.º 12
0
Archivo: Simple.cs Proyecto: 2sic/2sxc
        internal static IHtmlString Render(IContentBlock parentCb, IEntity entity)
        {
            // if not the expected content-type, just output a hidden html placeholder
            if (entity.Type.Name != Settings.AttributeSetStaticNameContentBlockTypeName)
                return new HtmlString(string.Format(EmptyMessage, entity.EntityId));

            // render it
            var cb = new EntityContentBlock(parentCb, entity);
            return cb.SxcInstance.Render();
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 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
        }
Ejemplo n.º 15
0
        public ActionResult ContentBlock()
        {
            // Get datasource model data from glass mapper
            IContentBlock datasourceItem = _glassMapperService.GetDataSourceItem <IContentBlock>();

            if (datasourceItem != null)
            {
                _logger.DebugInfo(string.Format("Added General Content Block to page with following data source: {0}", datasourceItem.FullPath));
                return(PartialView("~/Views/Feature/GeneralContent/ContentBlock.cshtml", datasourceItem));
            }
            return(PartialView("~/Views/Common/NoDataSourceItem.cshtml"));
        }
Ejemplo n.º 16
0
        internal SxcInstance(IContentBlock cb, ModuleInfo runtimeModuleInfo)
        {
            ContentBlock = cb;
            ModuleInfo   = runtimeModuleInfo;
            // Build up the environment. If we know the module context, then use permissions from there
            // modinfo is null in cases where things are not known yet, portalsettings are null in search-scenarios
            Environment.Permissions = (ModuleInfo != null) && (PortalSettings.Current != null)
                ? (IPermissions) new Permissions(ModuleInfo)
                : new Environment.None.Permissions();

            // url-override of view / data
            CheckTemplateOverrides();   // allow view change on apps
        }
Ejemplo n.º 17
0
        internal static IHtmlString Render(IContentBlock parentCb, IEntity entity)
        {
            // if not the expected content-type, just output a hidden html placeholder
            if (entity.Type.Name != Settings.AttributeSetStaticNameContentBlockTypeName)
            {
                return(new HtmlString(string.Format(EmptyMessage, entity.EntityId)));
            }

            // render it
            var cb = new EntityContentBlock(parentCb, entity);

            return(cb.SxcInstance.Render());
        }
Ejemplo n.º 18
0
        internal SxcInstance(IContentBlock cb,
                             IInstanceInfo envInstance,
                             IEnumerable <KeyValuePair <string, string> > urlparams = null,
                             Log parentLog = null)
        {
            Log          = new Log("Sxc.Instnc", parentLog, $"get SxcInstance for a:{cb?.AppId} cb:{cb?.ContentBlockId}");
            EnvFac       = Factory.Resolve <IEnvironmentFactory>();
            Environment  = EnvFac.Environment(parentLog);
            ContentBlock = cb;
            EnvInstance  = envInstance;

            // keep url parameters, because we may need them later for view-switching and more
            Parameters = urlparams;
        }
Ejemplo n.º 19
0
        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);
            }
        }
Ejemplo n.º 20
0
        internal static IHtmlString Render(IContentBlock parentCb, Eav.Interfaces.IEntity entity, Log parentLog)
        {
            var log = new Log("Htm.Render", parentLog, "simple");

            // if not the expected content-type, just output a hidden html placeholder
            if (entity.Type.Name != Settings.AttributeSetStaticNameContentBlockTypeName)
            {
                log.Add("empty, will return hidden html placeholder");
                return(new HtmlString(string.Format(EmptyMessage, entity.EntityId)));
            }

            // render it
            log.Add("found, will render");
            var cb = new EntityContentBlock(parentCb, entity, log);

            return(cb.SxcInstance.Render());
        }
Ejemplo n.º 21
0
        internal SxcInstance(IContentBlock cb, ModuleInfo runtimeModuleInfo, IEnumerable<KeyValuePair<string, string>> urlparams = null)
        {
            ContentBlock = cb;
            ModuleInfo = runtimeModuleInfo;

            // try to get url parameters, because we may need them later for view-switching and more
            Parameters = urlparams;
            //if (Parameters == null)
            //    Parameters = HttpContext.Current?.Request?.QueryString; // todo: reduce dependency on context-current...
            // Build up the environment. If we know the module context, then use permissions from there
            // modinfo is null in cases where things are not known yet, portalsettings are null in search-scenarios
            Environment.Permissions = (ModuleInfo != null) && (PortalSettings.Current != null)
                ? (IPermissions)new Permissions(ModuleInfo)
                : new Environment.None.Permissions();

            // url-override of view / data
            CheckTemplateOverrides();   // allow view change on apps
        }
Ejemplo n.º 22
0
        private async Task MoveUp(IContentBlock block)
        {
            var blockOnTop = ActiveBlocks.Where(x => x.OrderNo == block.OrderNo - 1).FirstOrDefault();

            if (blockOnTop is not null)
            {
                blockOnTop.OrderNo++;
                block.OrderNo--;

                var blocksToUpdate = new List <IContentBlock>()
                {
                    blockOnTop,
                    block
                };

                await BlockData.UpdateOrderNo(blocksToUpdate);
            }
        }
Ejemplo n.º 23
0
        private async Task MoveDown(IContentBlock block)
        {
            var blockBelow = ActiveBlocks.Where(x => x.OrderNo == block.OrderNo + 1).FirstOrDefault();

            if (blockBelow is not null)
            {
                blockBelow.OrderNo--;
                block.OrderNo++;

                var blocksToUpdate = new List <IContentBlock>()
                {
                    blockBelow,
                    block
                };

                await BlockData.UpdateOrderNo(blocksToUpdate);
            }
        }
Ejemplo n.º 24
0
        internal SxcInstance(IContentBlock cb, ModuleInfo runtimeModuleInfo, IEnumerable <KeyValuePair <string, string> > urlparams = null)
        {
            ContentBlock = cb;
            ModuleInfo   = runtimeModuleInfo;

            // try to get url parameters, because we may need them later for view-switching and more
            Parameters = urlparams;
            //if (Parameters == null)
            //    Parameters = HttpContext.Current?.Request?.QueryString; // todo: reduce dependency on context-current...
            // Build up the environment. If we know the module context, then use permissions from there
            // modinfo is null in cases where things are not known yet, portalsettings are null in search-scenarios
            Environment.Permissions = (ModuleInfo != null) && (PortalSettings.Current != null)
                ? (IPermissions) new Permissions(ModuleInfo)
                : new Environment.None.Permissions();

            // url-override of view / data
            CheckTemplateOverrides();   // allow view change on apps
        }
Ejemplo n.º 25
0
        public override void primaryFlaging(params object[] resources)
        {
            items.ForEach(x => x.primaryFlaging(resources));

            if (items.Count == 1)
            {
                IContentSentence sen = (IContentSentence)items[0];
                if (sen.sentenceFlags.HasFlag(contentSentenceFlag.title))
                {
                    flags |= contentParagraphFlag.heading;
                    if (parent is IContentBlock)
                    {
                        IContentBlock bl = parent as IContentBlock;
                        bl.title += sen.content;
                    }
                }
            }
            // throw new System.NotImplementedException();
        }
Ejemplo n.º 26
0
        private void _constructor(IContentBlock parent, 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);
                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;

                // maybe ensure that App.Data is ready
                App.InitData(SxcInstance.Environment.Permissions.UserMayEditContent, Data.ConfigurationProvider);
            }
        }
Ejemplo n.º 27
0
 internal ClientInfosError(IContentBlock cb)
 {
     if (cb.DataIsMissing)
     {
         type = "DataIsMissing";
     }
 }
Ejemplo n.º 28
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
        }
Ejemplo n.º 29
0
        private void PreviewBlock(IContentBlock block)
        {
            BlockData.Blocks = ActiveBlocks;

            NavMan.NavigateTo($"/projects/view/{block.OrderNo}/");
        }
Ejemplo n.º 30
0
 public EntityContentBlock(IContentBlock parent, int contentBlockId)
 {
     contentBlockId = Math.Abs(contentBlockId); // for various reasons this can be introduced as a negative value, make sure we neutralize that
     var cbDef = parent.SxcInstance.App.Data["Default"].List[contentBlockId];  // get the content-block definition
     _constructor(parent, cbDef);
 }
Ejemplo n.º 31
0
 public EntityContentBlock(IContentBlock parent, IEntity cbDefinition)
 {
     _constructor(parent, cbDefinition);
 }
Ejemplo n.º 32
0
 public EntityContentBlock(IContentBlock parent, IEntity cbDefinition)
 {
     _constructor(parent, cbDefinition);
 }
Ejemplo n.º 33
0
 public EntityContentBlock(IContentBlock parent, Eav.Interfaces.IEntity cbDefinition, Log parentLog = null) : base(parentLog, "CB.Ent")
     => _constructor(parent, cbDefinition);