Exemplo n.º 1
0
        public XmlElement ToXml(XmlDocument xd)
        {
            XmlElement doc = xd.CreateElement("Stylesheet");

            doc.AppendChild(XmlHelper.AddTextNode(xd, "Name", this.Text));
            doc.AppendChild(XmlHelper.AddTextNode(xd, "FileName", this.Filename));
            doc.AppendChild(XmlHelper.AddCDataNode(xd, "Content", this.Content));

            if (this.Properties.Length > 0)
            {
                XmlElement props = xd.CreateElement("Properties");
                foreach (StylesheetProperty sp in this.Properties)
                {
                    XmlElement prop = xd.CreateElement("Property");
                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Name", sp.Text));
                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Alias", sp.Alias));
                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Value", sp.value));
                    props.AppendChild(prop);
                }
                doc.AppendChild(props);
            }


            return(doc);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Iterates over the NameValueCollection, appending each entry to an XmlTextNode.
        /// </summary>
        /// <param name="rootName">The name of the root node of the XmlDocument.</param>
        /// <param name="nvc">The NameValueCollection to be converted.</param>
        /// <returns>Returns a XPathNodeIterator object that represents the NameValueCollection.</returns>
        private static XPathNodeIterator ConvertNameValueCollectionToXPathNodeIterator(string rootName, NameValueCollection nvc)
        {
            var xd = new XmlDocument();

            xd.LoadXml(string.Concat("<", rootName, "/>"));

            if (nvc != null)
            {
                try
                {
                    for (int i = 0; i < nvc.Count; i++)
                    {
                        var node = XmlHelper.AddCDataNode(xd, nvc.GetKey(i), nvc.Get(i));
                        xd.DocumentElement.AppendChild(node);
                    }
                }
                catch (Exception ex)
                {
                    xd.DocumentElement.AppendChild(XmlHelper.AddTextNode(xd, "error", ex.Message));
                }
            }
            else
            {
                xd.DocumentElement.AppendChild(XmlHelper.AddTextNode(xd, "error", string.Concat("The ", rootName, " object is empty.")));
            }

            return(xd.CreateNavigator().Select("/"));
        }
Exemplo n.º 3
0
        public XmlNode ToXml(XmlDocument xmlDocument)
        {
            var xmlNode = xmlDocument.CreateElement("reputation");

            xmlNode.AppendChild(XmlHelper.AddTextNode(xmlDocument, "current", Total.ToString()));
            xmlNode.AppendChild(XmlHelper.AddCDataNode(xmlDocument, "total", Current.ToString()));
            return(xmlNode);
        }
Exemplo n.º 4
0
 public XmlNode GetTemplate(int Id, string Login, string Password)
 {
     if (ValidateCredentials(Login, Password) && UserHasAppAccess(DefaultApps.settings.ToString(), Login))
     {
         var t      = new cms.businesslogic.template.Template(Id);
         var xmlDoc = new XmlDocument();
         var tXml   = xmlDoc.CreateElement("template");
         tXml.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "id", t.Id.ToString()));
         tXml.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "master", t.MasterTemplate.ToString()));
         tXml.Attributes.Append(XmlHelper.AddAttribute(xmlDoc, "name", t.Text));
         tXml.AppendChild(XmlHelper.AddCDataNode(xmlDoc, "design", t.Design));
         return(tXml);
     }
     return(null);
 }
Exemplo n.º 5
0
        public XmlElement ToXml(XmlDocument xd)
        {
            XmlElement doc = xd.CreateElement("Template");

            doc.AppendChild(XmlHelper.AddTextNode(xd, "Name", this.Text));
            doc.AppendChild(XmlHelper.AddTextNode(xd, "Alias", this.Alias));
            if (this.MasterTemplate != 0)
            {
                doc.AppendChild(XmlHelper.AddTextNode(xd, "Master", new Template(this.MasterTemplate).Alias));
            }
            else
            {
                doc.AppendChild(XmlHelper.AddTextNode(xd, "Master", ""));
            }
            doc.AppendChild(XmlHelper.AddCDataNode(xd, "Design", this.Design));


            return(doc);
        }
Exemplo n.º 6
0
        private XmlElement CreateTaskNode(Task t, XmlDocument xd)
        {
            var d = new Document(t.Node.Id);
            var x = d.ToPreviewXml(xd);//  xd.CreateNode(XmlNodeType.Element, "node", "");

            var xTask = xd.CreateElement("task");

            xTask.SetAttributeNode(XmlHelper.AddAttribute(xd, "Id", t.Id.ToString()));
            xTask.SetAttributeNode(XmlHelper.AddAttribute(xd, "Date", t.Date.ToString("s")));
            xTask.SetAttributeNode(XmlHelper.AddAttribute(xd, "NodeId", t.Node.Id.ToString()));
            xTask.SetAttributeNode(XmlHelper.AddAttribute(xd, "TotalWords", cms.businesslogic.translation.Translation.CountWords(d.Id).ToString()));
            xTask.AppendChild(XmlHelper.AddCDataNode(xd, "Comment", t.Comment));
            string protocol = GlobalSettings.UseSSL ? "https" : "http";

            xTask.AppendChild(XmlHelper.AddTextNode(xd, "PreviewUrl", protocol + "://" + Request.ServerVariables["SERVER_NAME"] + SystemDirectories.Umbraco + "/translation/preview.aspx?id=" + t.Id.ToString()));
            //            d.XmlPopulate(xd, ref x, false);
            xTask.AppendChild(x);

            return(xTask);
        }
Exemplo n.º 7
0
        public static XmlElement ToXml(XmlDocument xd, MediaType mt)
        {
            if (mt == null)
            {
                throw new ArgumentNullException("Mediatype cannot be null");
            }

            if (xd == null)
            {
                throw new ArgumentNullException("XmlDocument cannot be null");
            }


            XmlElement doc = xd.CreateElement("MediaType");

            // build the info section (name and stuff)
            XmlElement info = xd.CreateElement("Info");

            doc.AppendChild(info);

            info.AppendChild(XmlHelper.AddTextNode(xd, "Name", mt.Text));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Alias", mt.Alias));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Icon", mt.IconUrl));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Thumbnail", mt.Thumbnail));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Description", mt.Description));

            // v6 property
            info.AppendChild(XmlHelper.AddTextNode(xd, "AllowAtRoot", mt.AllowAtRoot.ToString()));
            XmlElement structure = xd.CreateElement("Structure");

            foreach (int child in mt.AllowedChildContentTypeIDs.ToList())
            {
                structure.AppendChild(XmlHelper.AddTextNode(xd, "MediaType", new MediaType(child).Alias));
            }
            doc.AppendChild(structure);

            //
            // in v6 - media types can be nested.
            //
            if (mt.MasterContentType > 0)
            {
                MediaType pmt = new MediaType(mt.MasterContentType);

                if (pmt != null)
                {
                    info.AppendChild(XmlHelper.AddTextNode(xd, "Master", pmt.Alias));
                }
            }

            // stuff in the generic properties tab
            XmlElement props = xd.CreateElement("GenericProperties");

            foreach (PropertyType pt in mt.PropertyTypes)
            {
                // we only add properties that arn't in a parent (although media types are flat at the mo)
                if (pt.ContentTypeId == mt.Id)
                {
                    XmlElement prop = xd.CreateElement("GenericProperty");
                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Name", pt.Name));
                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Alias", pt.Alias));
                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Type", pt.DataTypeDefinition.DataType.Id.ToString()));

                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Definition", pt.DataTypeDefinition.UniqueId.ToString()));
                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Tab", ContentType.Tab.GetCaptionById(pt.TabId)));
                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Mandatory", pt.Mandatory.ToString()));
                    prop.AppendChild(XmlHelper.AddTextNode(xd, "Validation", pt.ValidationRegExp));
                    prop.AppendChild(XmlHelper.AddCDataNode(xd, "Description", pt.Description));

                    // add this property to the tree
                    props.AppendChild(prop);
                }
            }
            // add properties to the doc
            doc.AppendChild(props);

            // tabs
            XmlElement tabs = xd.CreateElement("Tabs");

            foreach (ContentType.TabI t in mt.getVirtualTabs.ToList())
            {
                //only add tabs that aren't from a master doctype
                if (t.ContentType == mt.Id)
                {
                    XmlElement tabx = xd.CreateElement("Tab");
                    tabx.AppendChild(xmlHelper.addTextNode(xd, "Id", t.Id.ToString()));
                    tabx.AppendChild(xmlHelper.addTextNode(xd, "Caption", t.Caption));
                    tabx.AppendChild(xmlHelper.addTextNode(xd, "Sort", t.SortOrder.ToString()));
                    tabs.AppendChild(tabx);
                }
            }
            doc.AppendChild(tabs);

            return(doc);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Appends the type of the content.
        /// </summary>
        /// <param name="xd">The XML document.</param>
        /// <param name="elementName">Name of the element.</param>
        /// <param name="contentType">The content type.</param>
        /// <param name="includeTabs">if set to <c>true</c> [include tabs].</param>
        /// <param name="includePropertyTypes">if set to <c>true</c> [include property types].</param>
        internal static void AppendContentType(XmlDocument xd, string elementName, ContentType contentType, bool includeTabs, bool includePropertyTypes)
        {
            var nodeContentType = XmlHelper.AddTextNode(xd, elementName, string.Empty);

            nodeContentType.AppendChild(XmlHelper.AddCDataNode(xd, "description", contentType.Description));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "id", contentType.Id.ToString()));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", contentType.Text));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", contentType.Alias));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "image", contentType.Image));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "thumbnail", contentType.Thumbnail));
            //// nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "master", contentType.MasterContentType.ToString()));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "hasChildren", contentType.HasChildren.ToString()));

            if (includeTabs)
            {
                var tabs = contentType.getVirtualTabs;
                if (tabs != null && tabs.Length > 0)
                {
                    var nodeTabs = XmlHelper.AddTextNode(xd, "tabs", string.Empty);

                    foreach (var tab in tabs)
                    {
                        var nodeTab = XmlHelper.AddTextNode(xd, "tab", string.Empty);
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "id", tab.Id.ToString()));
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "caption", tab.Caption));
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", tab.SortOrder.ToString()));

                        nodeTabs.AppendChild(nodeTab);
                    }

                    nodeContentType.AppendChild(nodeTabs);
                }
            }

            if (includePropertyTypes)
            {
                var propertyTypes = contentType.PropertyTypes;
                if (propertyTypes != null && propertyTypes.Count > 0)
                {
                    var nodePropertyTypes = XmlHelper.AddTextNode(xd, "propertyTypes", string.Empty);

                    foreach (PropertyType propertyType in propertyTypes)
                    {
                        var nodePropertyType = XmlHelper.AddTextNode(xd, "propertyType", string.Empty);
                        nodePropertyType.AppendChild(XmlHelper.AddCDataNode(xd, "description", propertyType.Description));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "id", propertyType.Id.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", propertyType.Name));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", propertyType.Alias));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "contentTypeId", propertyType.ContentTypeId.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", propertyType.Description));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "mandatory", propertyType.Mandatory.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", propertyType.SortOrder.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "tabId", propertyType.PropertyTypeGroup.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "regEx", propertyType.ValidationRegExp));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "dataTypeId", propertyType.DataTypeDefinition.Id.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "dataTypeGuid", propertyType.DataTypeDefinition.UniqueId.ToString()));

                        nodePropertyTypes.AppendChild(nodePropertyType);
                    }

                    nodeContentType.AppendChild(nodePropertyTypes);
                }
            }

            // add the content-type node to the XmlDocument.
            if (xd.DocumentElement != null)
            {
                xd.DocumentElement.AppendChild(nodeContentType);
            }
            else
            {
                xd.AppendChild(nodeContentType);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Appends the type of the document.
        /// </summary>
        /// <param name="xd">The XML document.</param>
        /// <param name="docType">The document type.</param>
        /// <param name="includeTabs">if set to <c>true</c> [include tabs].</param>
        /// <param name="includePropertyTypes">if set to <c>true</c> [include property types].</param>
        /// <param name="includeAllowedTemplates">if set to <c>true</c> [include allowed templates].</param>
        internal static void AppendDocumentType(XmlDocument xd, DocumentType docType, bool includeTabs, bool includePropertyTypes, bool includeAllowedTemplates)
        {
            var nodeDocType = XmlHelper.AddTextNode(xd, "DocumentType", string.Empty);

            nodeDocType.AppendChild(XmlHelper.AddCDataNode(xd, "description", docType.Description));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "id", docType.Id.ToString()));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", docType.Text));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", docType.Alias));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "image", docType.Image));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "thumbnail", docType.Thumbnail));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "master", docType.MasterContentType.ToString()));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "hasChildren", docType.HasChildren.ToString()));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "defaultTemplate", docType.DefaultTemplate.ToString()));

            if (includeTabs)
            {
                var tabs = docType.getVirtualTabs;
                if (tabs != null && tabs.Length > 0)
                {
                    var nodeTabs = XmlHelper.AddTextNode(xd, "tabs", string.Empty);

                    foreach (var tab in tabs)
                    {
                        var nodeTab = XmlHelper.AddTextNode(xd, "tab", string.Empty);
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "id", tab.Id.ToString()));
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "caption", tab.Caption));
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", tab.SortOrder.ToString()));

                        nodeTabs.AppendChild(nodeTab);
                    }

                    nodeDocType.AppendChild(nodeTabs);
                }
            }

            if (includePropertyTypes)
            {
                var propertyTypes = docType.PropertyTypes;
                if (propertyTypes != null && propertyTypes.Count > 0)
                {
                    var nodePropertyTypes = XmlHelper.AddTextNode(xd, "propertyTypes", string.Empty);

                    foreach (var propertyType in propertyTypes)
                    {
                        var nodePropertyType = XmlHelper.AddTextNode(xd, "propertyType", string.Empty);
                        nodePropertyType.AppendChild(XmlHelper.AddCDataNode(xd, "description", propertyType.Description));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "id", propertyType.Id.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", propertyType.Name));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", propertyType.Alias));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "contentTypeId", propertyType.ContentTypeId.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", propertyType.Description));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "mandatory", propertyType.Mandatory.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", propertyType.SortOrder.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "tabId", propertyType.TabId.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "regEx", propertyType.ValidationRegExp));

                        nodePropertyTypes.AppendChild(nodePropertyType);
                    }

                    nodeDocType.AppendChild(nodePropertyTypes);
                }
            }

            if (includeAllowedTemplates)
            {
                var templates = docType.allowedTemplates;
                if (templates != null && templates.Length > 0)
                {
                    var nodeTemplates = XmlHelper.AddTextNode(xd, "allowedTemplates", string.Empty);

                    foreach (var template in templates)
                    {
                        var nodeTemplate = XmlHelper.AddTextNode(xd, "template", string.Empty);
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "id", template.Id.ToString()));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "name", template.Text));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", template.Alias));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "masterPageFile", template.TemplateFilePath));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "masterTemplate", template.MasterTemplate.ToString()));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "hasChildren", template.HasChildren.ToString()));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", template.sortOrder.ToString()));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "isDefaultTemplate", (template.Id == docType.DefaultTemplate).ToString()));

                        nodeTemplates.AppendChild(nodeTemplate);
                    }

                    nodeDocType.AppendChild(nodeTemplates);
                }
            }

            if (xd.DocumentElement != null)
            {
                xd.DocumentElement.AppendChild(nodeDocType);
            }
            else
            {
                xd.AppendChild(nodeDocType);
            }
        }
Exemplo n.º 10
0
        public XmlElement ToXml(XmlDocument xd)
        {
            XmlElement doc = xd.CreateElement("DocumentType");

            // info section
            XmlElement info = xd.CreateElement("Info");

            doc.AppendChild(info);
            info.AppendChild(XmlHelper.AddTextNode(xd, "Name", GetRawText()));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Alias", Alias));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Icon", IconUrl));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Thumbnail", Thumbnail));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Description", GetRawDescription()));
            info.AppendChild(XmlHelper.AddTextNode(xd, "AllowAtRoot", AllowAtRoot.ToString()));

            //TODO: Add support for mixins!
            if (this.MasterContentType > 0)
            {
                DocumentType dt = new DocumentType(this.MasterContentType);

                if (dt != null)
                {
                    info.AppendChild(XmlHelper.AddTextNode(xd, "Master", dt.Alias));
                }
            }


            // templates
            XmlElement allowed = xd.CreateElement("AllowedTemplates");

            foreach (template.Template t in allowedTemplates)
            {
                allowed.AppendChild(XmlHelper.AddTextNode(xd, "Template", t.Alias));
            }
            info.AppendChild(allowed);
            if (DefaultTemplate != 0)
            {
                info.AppendChild(
                    XmlHelper.AddTextNode(xd, "DefaultTemplate", new template.Template(DefaultTemplate).Alias));
            }
            else
            {
                info.AppendChild(XmlHelper.AddTextNode(xd, "DefaultTemplate", ""));
            }

            // structure
            XmlElement structure = xd.CreateElement("Structure");

            doc.AppendChild(structure);

            foreach (int cc in AllowedChildContentTypeIDs.ToList())
            {
                structure.AppendChild(XmlHelper.AddTextNode(xd, "DocumentType", new DocumentType(cc).Alias));
            }

            // generic properties
            XmlElement pts = xd.CreateElement("GenericProperties");

            foreach (PropertyType pt in PropertyTypes)
            {
                //only add properties that aren't from master doctype
                if (pt.ContentTypeId == this.Id)
                {
                    XmlElement ptx = xd.CreateElement("GenericProperty");
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Name", pt.GetRawName()));
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Alias", pt.Alias));
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Type", pt.DataTypeDefinition.DataType.Id.ToString()));

                    //Datatype definition guid was added in v4 to enable datatype imports
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Definition", pt.DataTypeDefinition.UniqueId.ToString()));

                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Tab", Tab.GetCaptionById(pt.TabId)));
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Mandatory", pt.Mandatory.ToString()));
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Validation", pt.ValidationRegExp));
                    ptx.AppendChild(XmlHelper.AddCDataNode(xd, "Description", pt.GetRawDescription()));
                    pts.AppendChild(ptx);
                }
            }
            doc.AppendChild(pts);

            // tabs
            var tabs = xd.CreateElement("Tabs");

            foreach (var propertyTypeGroup in PropertyTypeGroups)
            {
                //only add tabs that aren't from a master doctype
                if (propertyTypeGroup.ContentTypeId == this.Id)
                {
                    var tabx = xd.CreateElement("Tab");
                    tabx.AppendChild(XmlHelper.AddTextNode(xd, "Id", propertyTypeGroup.Id.ToString()));
                    tabx.AppendChild(XmlHelper.AddTextNode(xd, "Caption", propertyTypeGroup.Name));
                    tabs.AppendChild(tabx);
                }
            }

            doc.AppendChild(tabs);
            return(doc);
        }
Exemplo n.º 11
0
        public XmlElement ToXml(XmlDocument xd)
        {
            XmlElement doc = xd.CreateElement("DocumentType");

            // info section
            XmlElement info = xd.CreateElement("Info");

            doc.AppendChild(info);
            info.AppendChild(XmlHelper.AddTextNode(xd, "Name", Text));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Alias", Alias));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Icon", IconUrl));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Thumbnail", Thumbnail));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Description", Description));

            // templates
            XmlElement allowed = xd.CreateElement("AllowedTemplates");

            foreach (template.Template t in allowedTemplates)
            {
                allowed.AppendChild(XmlHelper.AddTextNode(xd, "Template", t.Alias));
            }
            info.AppendChild(allowed);
            if (DefaultTemplate != 0)
            {
                info.AppendChild(
                    XmlHelper.AddTextNode(xd, "DefaultTemplate", new template.Template(DefaultTemplate).Alias));
            }
            else
            {
                info.AppendChild(XmlHelper.AddTextNode(xd, "DefaultTemplate", ""));
            }

            // structure
            XmlElement structure = xd.CreateElement("Structure");

            doc.AppendChild(structure);

            foreach (int cc in AllowedChildContentTypeIDs)
            {
                structure.AppendChild(XmlHelper.AddTextNode(xd, "DocumentType", new DocumentType(cc).Alias));
            }

            // generic properties
            XmlElement pts = xd.CreateElement("GenericProperties");

            foreach (PropertyType pt in PropertyTypes)
            {
                XmlElement ptx = xd.CreateElement("GenericProperty");
                ptx.AppendChild(XmlHelper.AddTextNode(xd, "Name", pt.Name));
                ptx.AppendChild(XmlHelper.AddTextNode(xd, "Alias", pt.Alias));
                ptx.AppendChild(XmlHelper.AddTextNode(xd, "Type", pt.DataTypeDefinition.DataType.Id.ToString()));
                ptx.AppendChild(XmlHelper.AddTextNode(xd, "Tab", Tab.GetCaptionById(pt.TabId)));
                ptx.AppendChild(XmlHelper.AddTextNode(xd, "Mandatory", pt.Mandatory.ToString()));
                ptx.AppendChild(XmlHelper.AddTextNode(xd, "Validation", pt.ValidationRegExp));
                ptx.AppendChild(XmlHelper.AddCDataNode(xd, "Description", pt.Description));
                pts.AppendChild(ptx);
            }
            doc.AppendChild(pts);

            // tabs
            XmlElement tabs = xd.CreateElement("Tabs");

            foreach (TabI t in getVirtualTabs)
            {
                XmlElement tabx = xd.CreateElement("Tab");
                tabx.AppendChild(XmlHelper.AddTextNode(xd, "Id", t.Id.ToString()));
                tabx.AppendChild(XmlHelper.AddTextNode(xd, "Caption", t.Caption));
                tabs.AppendChild(tabx);
            }
            doc.AppendChild(tabs);
            return(doc);
        }