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(); }
public HtmlString Render() { if (Entity.Type.Name == Settings.AttributeSetStaticNameContentBlockTypeName) { var cb = new EntityContentBlock(SxcInstance.ContentBlock, Entity); return(cb.SxcInstance.Render()); } else { return(new HtmlString("<!-- auto-render of item " + EntityId + " -->")); } }
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 static SxcInstance GetSxcOfApiRequest(HttpRequestMessage request) { string cbidHeader = "ContentBlockId"; var moduleInfo = request.FindModuleInfo(); // get url parameters and provide override values to ensure all configuration is // preserved in AJAX calls List <KeyValuePair <string, string> > urlParams = null; var requestParams = request.GetQueryNameValuePairs(); var origParams = requestParams.Where(p => p.Key == "originalparameters").ToList(); if (origParams.Any()) { var paramSet = origParams.First().Value; // Workaround for deserializing KeyValuePair -it requires lowercase properties(case sensitive), which seems to be a bug in some Newtonsoft.Json versions: http://stackoverflow.com/questions/11266695/json-net-case-insensitive-property-deserialization var items = Json.Deserialize <List <UpperCaseStringKeyValuePair> >(paramSet); urlParams = items.Select(a => new KeyValuePair <string, string>(a.Key, a.Value)).ToList(); //urlParams = requestParams // .Where(keyValuePair => keyValuePair.Key.IndexOf("orig", StringComparison.Ordinal) == 0) // .Select(pair => new KeyValuePair<string, string>(pair.Key.Substring(4), pair.Value)) // .ToList(); } // first, check the special overrides //var origparams = requestParams.Select(np => np.Key == "urlparameters").ToList(); //if (origparams.Any()) //{ // var paramSet = origparams.First(); //} // then add remaining params IContentBlock contentBlock = new ModuleContentBlock(moduleInfo, urlParams); // check if we need an inner block if (request.Headers.Contains(cbidHeader)) { var cbidh = request.Headers.GetValues(cbidHeader).FirstOrDefault(); int cbid; Int32.TryParse(cbidh, out cbid); if (cbid < 0) // negative id, so it's an inner block { contentBlock = new EntityContentBlock(contentBlock, cbid); } } return(contentBlock.SxcInstance); }
internal static SxcInstance GetSxcOfApiRequest(HttpRequestMessage request) { string cbidHeader = "ContentBlockId"; var moduleInfo = request.FindModuleInfo(); // get url parameters and provide override values to ensure all configuration is // preserved in AJAX calls List <KeyValuePair <string, string> > urlParams = null; var requestParams = request.GetQueryNameValuePairs(); var origParams = requestParams.Where(p => p.Key == "originalparameters").ToList(); if (origParams.Any()) { var paramSet = origParams.First().Value; var items = Json.Deserialize <List <KeyValuePair <string, string> > >(paramSet); urlParams = items.ToList(); //urlParams = requestParams // .Where(keyValuePair => keyValuePair.Key.IndexOf("orig", StringComparison.Ordinal) == 0) // .Select(pair => new KeyValuePair<string, string>(pair.Key.Substring(4), pair.Value)) // .ToList(); } // first, check the special overrides //var origparams = requestParams.Select(np => np.Key == "urlparameters").ToList(); //if (origparams.Any()) //{ // var paramSet = origparams.First(); //} // then add remaining params IContentBlock contentBlock = new ModuleContentBlock(moduleInfo, urlParams); // check if we need an inner block if (request.Headers.Contains(cbidHeader)) { var cbidh = request.Headers.GetValues(cbidHeader).FirstOrDefault(); int cbid; int.TryParse(cbidh, out cbid); if (cbid < 0) // negative id, so it's an inner block { contentBlock = new EntityContentBlock(contentBlock, cbid); } } return(contentBlock.SxcInstance); }
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()); }
public string GenerateContentBlock(int parentId, string field, int sortOrder, string app = "", Guid?guid = null) { var contentTypeName = Settings.AttributeSetStaticNameContentBlockTypeName; var values = new Dictionary <string, object> { { EntityContentBlock.CbPropertyTitle, "" }, { EntityContentBlock.CbPropertyApp, app }, { EntityContentBlock.CbPropertyShowChooser, true }, }; var entityId = CreateItemAndAddToList(parentId, field, sortOrder, contentTypeName, values, guid); // now return a rendered instance var newContentBlock = new EntityContentBlock(SxcContext.ContentBlock, entityId); return(newContentBlock.SxcInstance.Render().ToString()); }
internal static SxcInstance GetSxcOfApiRequest(HttpRequestMessage request, bool allowNoContextFound = false, Log log = null) { var cbidHeader = "ContentBlockId"; var moduleInfo = request.FindModuleInfo(); // get url parameters and provide override values to ensure all configuration is // preserved in AJAX calls List <KeyValuePair <string, string> > urlParams = null; var requestParams = request.GetQueryNameValuePairs(); var origParams = requestParams.Where(p => p.Key == "originalparameters").ToList(); if (origParams.Any()) { var paramSet = origParams.First().Value; // Workaround for deserializing KeyValuePair -it requires lowercase properties(case sensitive), which seems to be a bug in some Newtonsoft.Json versions: http://stackoverflow.com/questions/11266695/json-net-case-insensitive-property-deserialization var items = Json.Deserialize <List <UpperCaseStringKeyValuePair> >(paramSet); urlParams = items.Select(a => new KeyValuePair <string, string>(a.Key, a.Value)).ToList(); } if (allowNoContextFound & moduleInfo == null) { return(null); } var tenant = moduleInfo == null ? new DnnTenant(null) : new DnnTenant(new PortalSettings(moduleInfo.OwnerPortalID)); IContentBlock contentBlock = new ModuleContentBlock(new DnnInstanceInfo(moduleInfo), log, tenant, urlParams); // check if we need an inner block if (request.Headers.Contains(cbidHeader)) { var cbidh = request.Headers.GetValues(cbidHeader).FirstOrDefault(); int.TryParse(cbidh, out var cbid); if (cbid < 0) // negative id, so it's an inner block { contentBlock = new EntityContentBlock(contentBlock, cbid, log); } } return(contentBlock.SxcInstance); }
internal static SxcInstance GetSxcOfModuleContext(this HttpRequestMessage request) { string cbidHeader = "ContentBlockId"; var moduleInfo = request.FindModuleInfo(); IContentBlock contentBlock = new ModuleContentBlock(moduleInfo); // check if we need an inner block if (request.Headers.Contains(cbidHeader)) { var cbidh = request.Headers.GetValues(cbidHeader).FirstOrDefault(); int cbid; int.TryParse(cbidh, out cbid); if (cbid < 0) // negative id, so it's an inner block { contentBlock = new EntityContentBlock(contentBlock, cbid); } } return(contentBlock.SxcInstance); }