Пример #1
0
        public SectionTemplate(XNode sectionNode, int languageCode, EntityMetadata entityMetadata, ICellTemplateFactory cellTemplateFactory, TableLayoutRowTemplateFactory rowTemplateFactory)
            : base(sectionNode, languageCode, entityMetadata, cellTemplateFactory)
        {
            rowTemplateFactory.ThrowOnNull("rowTemplateFactory");

            RowTemplateFactory = rowTemplateFactory;

            string description;

            if (sectionNode.TryGetLanguageSpecificLabelValue(this.LanguageCode, out description))
            {
                Label = description;
            }

            bool showLabel;

            if (sectionNode.TryGetBooleanAttributeValue(".", "showlabel", out showLabel))
            {
                ShowLabel = showLabel;
            }

            bool showBar;

            if (sectionNode.TryGetBooleanAttributeValue(".", "showbar", out showBar))
            {
                ShowBar = showBar;
            }
        }
Пример #2
0
 /// <summary>
 /// TableLayoutSectionTemplate class initialization.
 /// </summary>
 /// <param name="sectionNode"></param>
 /// <param name="languageCode"></param>
 /// <param name="entityMetadata"></param>
 /// <param name="cellTemplateFactory"></param>
 /// <param name="rowTemplateFactory"></param>
 /// <param name="webformMetadata"></param>
 public TableLayoutSectionTemplate(XNode sectionNode, int languageCode, EntityMetadata entityMetadata, ICellTemplateFactory cellTemplateFactory, TableLayoutRowTemplateFactory rowTemplateFactory, IEnumerable <Entity> webformMetadata) : base(sectionNode, languageCode, entityMetadata, cellTemplateFactory, rowTemplateFactory)
 {
     _webformMetadata = webformMetadata;
 }
Пример #3
0
        public override void InstantiateIn(Control container)
        {
            var tabTable = new HtmlGenericControl("div");

            string tabName;
            var    tabLabel        = string.Empty;
            var    tabCssClassName = string.Empty;

            if (Node.TryGetAttributeValue(".", "name", out tabName))
            {
                tabTable.Attributes.Add("data-name", tabName);

                if (_webformMetadata != null)
                {
                    var tabWebFormMetadata = _webformMetadata.FirstOrDefault(wfm => wfm.GetAttributeValue <string>("adx_tabname") == tabName);

                    if (tabWebFormMetadata != null)
                    {
                        var label = tabWebFormMetadata.GetAttributeValue <string>("adx_label");

                        if (!string.IsNullOrWhiteSpace(label))
                        {
                            tabLabel = Localization.GetLocalizedString(label, LanguageCode);
                        }

                        tabCssClassName = tabWebFormMetadata.GetAttributeValue <string>("adx_cssclass") ?? string.Empty;
                    }
                }
            }

            tabTable.Attributes.Add("class", !string.IsNullOrWhiteSpace(tabCssClassName) ? string.Join(" ", "tab clearfix", tabCssClassName) : "tab clearfix");

            if (ShowLabel)
            {
                var caption = new HtmlGenericControl("h2")
                {
                    InnerHtml = string.IsNullOrWhiteSpace(tabLabel) ? Label : tabLabel
                };
                caption.Attributes.Add("class", "tab-title");
                container.Controls.Add(caption);
            }

            container.Controls.Add(tabTable);

            foreach (var columnElement in Node.XPathSelectElements("columns/column"))
            {
                var col = new HtmlGenericControl("div");
                col.Attributes.Add("class", "tab-column");
                tabTable.Controls.Add(col);

                var xAttribute = columnElement.Attribute("width");
                if (xAttribute != null)
                {
                    col.Style.Add("width", xAttribute.Value);
                }

                var wrapper = new HtmlGenericControl("div");
                col.Controls.Add(wrapper);

                var rowTemplateFactory = new TableLayoutRowTemplateFactory(LanguageCode);

                var sectionTemplates = columnElement.XPathSelectElements("sections/section")
                                       .Select(section => new TableLayoutSectionTemplate(section, LanguageCode, EntityMetadata, CellTemplateFactory, rowTemplateFactory, _webformMetadata)
                {
                    MappingFieldCollection = MappingFieldCollection
                });

                foreach (var template in sectionTemplates)
                {
                    template.InstantiateIn(wrapper);
                }
            }
        }