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); }
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); } }
internal ClientInfosError(IContentBlock cb) { if (cb.DataIsMissing) { type = "DataIsMissing"; } }
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); }
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); }
protected bool IsVisible(IContentBlock contentBlock) { if (contentBlock == null || !contentBlock.Enabled) { return(false); } return(true); }
// 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; }
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 }
private async Task DeleteBlock(IContentBlock block) { var num = block.OrderNo; block.OrderNo = 0; await BlockData.UpdateOrderNo(new List <IContentBlock>() { block }); await UpdateBlocksBelowDeleted(num); }
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 }
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(); }
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); }
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 }
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")); }
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 }
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()); }
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; }
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); } }
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()); }
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 }
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); } }
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); } }
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 }
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(); }
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); } }
private void PreviewBlock(IContentBlock block) { BlockData.Blocks = ActiveBlocks; NavMan.NavigateTo($"/projects/view/{block.OrderNo}/"); }
public EntityContentBlock(IContentBlock parent, IEntity cbDefinition) { _constructor(parent, cbDefinition); }
public EntityContentBlock(IContentBlock parent, Eav.Interfaces.IEntity cbDefinition, Log parentLog = null) : base(parentLog, "CB.Ent") => _constructor(parent, cbDefinition);