Пример #1
0
        private string GetContentFromWidget(MetaWidgetTypes widgetTypeE)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XmlNode parentNode = xmlDoc.CreateElement("WidgetList", "");

            // Get all item tabs
            var tabs = Controls.All().OfType <HtmlGenericControl>().Where(h => h.ID != null && (h.ID.StartsWith("tab-")));

            foreach (var tab in tabs)
            {
                XmlNode childNode = xmlDoc.CreateElement("ListItem", "");
                if (widgetTypeE == MetaWidgetTypes.ItemList)
                {
                    var title   = tab.Controls.All().OfType <HtmlInputText>().First(h => h.ID != null && (h.ID.StartsWith("title-")));
                    var content = tab.Controls.All().OfType <HtmlTextArea>().First(h => h.ID != null && (h.ID.StartsWith("content-")));

                    if (title != null)
                    {
                        if (!String.IsNullOrWhiteSpace(title.Value))
                        {
                            XmlNode titleNode = xmlDoc.CreateElement("Title", "");
                            titleNode.InnerText = (title != null) ? title.Value : "";
                            XmlNode contentNode = xmlDoc.CreateElement("Content", "");
                            contentNode.InnerText = (content != null) ? content.InnerHtml : "";

                            childNode.AppendChild(titleNode);
                            childNode.AppendChild(contentNode);
                            parentNode.AppendChild(childNode);
                        }
                    }
                }
                if (widgetTypeE == MetaWidgetTypes.Wiki)
                {
                    var title       = tab.Controls.All().OfType <HtmlInputText>().First(h => h.ID != null && (h.ID.StartsWith("title-")));
                    var subTitle    = tab.Controls.All().OfType <HtmlInputText>().First(h => h.ID != null && (h.ID.StartsWith("subtitle-")));
                    var contentPage = tab.Controls.All().OfType <HtmlSelect>().First(h => h.ID != null && (h.ID.StartsWith("pagecontent-")));

                    if (title != null)
                    {
                        if (!String.IsNullOrWhiteSpace(title.Value))
                        {
                            XmlNode titleNode = xmlDoc.CreateElement("Title", "");
                            titleNode.InnerText = (title != null) ? title.Value : "";
                            XmlNode subTitleNode = xmlDoc.CreateElement("SubTitle", "");
                            subTitleNode.InnerText = (subTitle != null) ? subTitle.Value : "";
                            XmlNode contentPageNode = xmlDoc.CreateElement("ContentPage", "");
                            contentPageNode.InnerText = (contentPage != null) ? contentPage.Value : "";
                            XmlNode modifiedNode = xmlDoc.CreateElement("ModifiedDate", "");
                            modifiedNode.InnerText = DateTime.Today.ToString("yyyy-MM-dd");

                            childNode.AppendChild(titleNode);
                            childNode.AppendChild(subTitleNode);
                            childNode.AppendChild(contentPageNode);
                            childNode.AppendChild(modifiedNode);
                            parentNode.AppendChild(childNode);
                        }
                    }
                }
            }

            xmlDoc.AppendChild(parentNode);
            return(xmlDoc.InnerXml);
        }
Пример #2
0
 private List <ThumbView> AllThumbs()
 => Controls.All <ThumbView>().ToList();