private Dictionary<string, List<string>> BuildRegionMappings() { // format: region { schema, template } Dictionary<string, List<string>> regions = new Dictionary<string, List<string>>(); ComponentTemplatesFilter templateFilter = new ComponentTemplatesFilter(Engine.GetSession()) { BaseColumns = ListBaseColumns.Extended }; foreach (ComponentTemplate template in GetPublication().GetComponentTemplates(templateFilter)) { string regionName = GetRegionName(template); if (!regions.ContainsKey(regionName)) { regions.Add(regionName, new List<string>()); } StringBuilder allowedComponentTypes = new StringBuilder(); bool first = true; foreach (Schema schema in template.RelatedSchemas) { if (first) { first = false; } else { allowedComponentTypes.Append(","); } allowedComponentTypes.AppendFormat("{{\"Schema\":{0},\"Template\":{1}}}", JsonEncode(schema.Id.GetVersionlessUri().ToString()), JsonEncode(template.Id.GetVersionlessUri().ToString())); } // do not append empty strings (template.RelatedSchemas can be empty) if (allowedComponentTypes.Length > 0) { regions[regionName].Add(allowedComponentTypes.ToString()); } } return regions; }
protected virtual Dictionary<string, List<string>> ReadTemplateData() { //Generate a list of dynamic CT + id, separated by module Dictionary<string, List<string>> res = new Dictionary<string, List<string>>(); ComponentTemplatesFilter templateFilter = new ComponentTemplatesFilter(Engine.GetSession()) { BaseColumns = ListBaseColumns.Extended }; foreach (XmlElement item in GetPublication().GetListComponentTemplates(templateFilter).ChildNodes) { string id = item.GetAttribute("ID"); ComponentTemplate template = (ComponentTemplate)Engine.GetObject(id); //Only consider dynamic CTs if (template.IsRepositoryPublishable) { string module = GetModuleNameFromItem(template, _moduleRoot); if (module != null) { string key = module + "." + TemplateConfigName; if (!res.ContainsKey(key)) { res.Add(key, new List<string>()); } res[key].Add(String.Format("{0}:{1}", JsonEncode(Utility.GetKeyFromTemplate(template)), JsonEncode(template.Id.ItemId))); } } } return res; }
private Dictionary<string, List<string>> BuildRegionMappings() { // format: region { schema, template } Dictionary<string, List<string>> regions = new Dictionary<string, List<string>>(); var templateFilter = new ComponentTemplatesFilter(Engine.GetSession()) { BaseColumns = ListBaseColumns.Extended }; foreach (XmlElement item in GetPublication().GetListComponentTemplates(templateFilter).ChildNodes) { var id = item.GetAttribute("ID"); var template = (ComponentTemplate)Engine.GetObject(id); var region = GetRegionFromTemplate(template); if (!regions.ContainsKey(region)) { regions.Add(region, new List<string>()); } StringBuilder allowedComponentTypes = new StringBuilder(); bool first = true; foreach (var schema in template.RelatedSchemas) { if (first) { first = false; } else { allowedComponentTypes.Append(","); } allowedComponentTypes.AppendFormat("{{\"Schema\":{0},\"Template\":{1}}}", JsonEncode(schema.Id.GetVersionlessUri().ToString()), JsonEncode(template.Id.GetVersionlessUri().ToString())); } // do not append empty strings (template.RelatedSchemas can be empty) if (allowedComponentTypes.Length > 0) { regions[region].Add(allowedComponentTypes.ToString()); } } return regions; }