public string[] FetchControlLists(string[] controlListIds, string cultureName) { //CommonUtilities.ConfirmNotNull(cultureName, "cultureName"); //ULS.SendTraceTag(0x3670356d, ULSCat.msoulscat_CMS_Publishing, ULSTraceLevel.Medium, "SharepointPublishingToolboxService.FetchControlLists(, {0})", new object[] { cultureName }); SPUtility.EnsureAuthentication(SPContext.Current.Site.RootWeb); CultureInfo culture = new CultureInfo(cultureName); //CommonUtilities.ConfirmNotNull(controlListIds, "controlListIds"); SPContentTypeCollection contentTypes = this.GetContentTypes(); TagNameCreator tagCreator = new TagNameCreator(); string[] strArray = new string[controlListIds.Length]; for (int i = 0; i < controlListIds.Length; i++) { string str = controlListIds[i]; if (str == publishingControlspanelTypeIdentifier.ToString()) { strArray[i] = ""; } else if (contentTypes != null) { SPContentTypeId id = new SPContentTypeId(str); SPContentType contentType = contentTypes[id]; if (contentType == null) { //string message = Resources.GetFormattedStringEx("ErrorContentTypeNotFound", culture, new object[] { str }); //ULS.SendTraceTag(0x3670356e, ULSCat.msoulscat_CMS_Publishing, ULSTraceLevel.Unexpected, "The content type {0} is not found", new object[] { str }); SoapException exception = new SoapException("ContentType is Empty", SoapException.ClientFaultCode); throw exception; } strArray[i] = GetInfoFromCT(contentType, contentTypes, tagCreator, culture); } } //ULS.SendTraceTag(0x3670356f, ULSCat.msoulscat_CMS_Publishing, ULSTraceLevel.Medium, "SharepointPublishingToolboxService.GetCustomControlLists ends"); return(strArray); }
private static string GetInfoFromCT(SPContentType contentType, SPContentTypeCollection contentTypes, TagNameCreator tagCreator, CultureInfo culture) { string str4; StringWriter w = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture); XmlTextWriter writer2 = new XmlTextWriter(w); try { writer2.WriteStartDocument(); writer2.WriteStartElement("ControlsList"); TagInfo info = null; TagInfo tag = null; foreach (SPField field in FilterOutPageFields(contentType, contentTypes)) { if (field.Hidden) // && (field.Group != "Publishing Content Columns") || field.Group != "HTML5 Columns") { continue; } System.Type fieldRenderingControlType = GetFieldRenderingControlType(field); tag = tagCreator.GetTag(fieldRenderingControlType); if (info != tag) { if (info != null) { writer2.WriteEndElement(); } info = tag; writer2.WriteStartElement("Assembly"); writer2.WriteAttributeString("Name", tag.assemblyName); writer2.WriteAttributeString("Namespace", tag.namespaceName); writer2.WriteAttributeString("TagPrefix", tag.name); } writer2.WriteStartElement("Control"); string title = field.Title; string str2 = field.Id.ToString(); writer2.WriteAttributeString("Name", title); writer2.WriteAttributeString("Title", field.Title); string str3 = ""; //Resources.GetFormattedStringEx("ToolboxControlDescription", culture, new object[] { field.Title, field.TypeAsString }); writer2.WriteAttributeString("Description", str3); writer2.WriteAttributeString("Template", string.Format(culture, "<{{0}}:{0} FieldName=\"{1}\" runat=\"server\"></{{0}}:{0}>", new object[] { fieldRenderingControlType.Name, str2 })); writer2.WriteEndElement(); } if (tag != null) { writer2.WriteEndElement(); } writer2.WriteEndElement(); writer2.WriteEndDocument(); str4 = w.GetStringBuilder().ToString(); } finally { /* * if (writer2 != null) * { * writer2.Close(); * } */ if (w != null) { w.Close(); } } return(str4); }