Пример #1
0
        private void MapDefinedMarkup(XmlNode node, bool isMobile = false)
        {
            if (node != null)
            {
                //bool desktopOnly = false;
                XmlAttributeCollection attrCollection = node.Attributes;

                if (attrCollection["name"] != null)
                {
                    markupDefinitionName = attrCollection["name"].Value;
                }

                if (attrCollection["moduleClass"] != null)
                {
                    if (isMobile)
                    {
                        mobileInstanceCssClass += " " + attrCollection["moduleClass"].Value;
                    }
                    else
                    {
                        instanceCssClass += " " + attrCollection["moduleClass"].Value;
                    }
                }
                useStandardMarkupOnDesktopOnly = XmlUtils.ParseBoolFromAttribute(attrCollection, "desktopOnly", useStandardMarkupOnDesktopOnly);
                useHeader   = XmlUtils.ParseBoolFromAttribute(attrCollection, "useHeader", useHeader);
                useFooter   = XmlUtils.ParseBoolFromAttribute(attrCollection, "useFooter", useFooter);
                allowImport = XmlUtils.ParseBoolFromAttribute(attrCollection, "allowImport", allowImport);
                allowExport = XmlUtils.ParseBoolFromAttribute(attrCollection, "allowExport", allowExport);
                if (attrCollection["itemViewRolesFieldName"] != null)
                {
                    ItemViewRolesFieldName = attrCollection["itemViewRolesFieldName"].Value;
                }
                if (attrCollection["itemEditRolesFieldName"] != null)
                {
                    ItemEditRolesFieldName = attrCollection["itemEditRolesFieldName"].Value;
                }
                //renderModuleLinksWithModuleTitle = XmlUtils.ParseBoolFromAttribute(attrCollection, "renderModuleLinksWithModuleTitle", renderModuleLinksWithModuleTitle);

                if (attrCollection["editPageClass"] != null)
                {
                    editPageCssClass += " " + attrCollection["editPageClass"].Value;
                }
                if (attrCollection["editPageTitle"] != null)
                {
                    editPageTitle = attrCollection["editPageTitle"].Value;
                }
                if (attrCollection["editPageUpdateButtonText"] != null)
                {
                    editPageUpdateButtonText = attrCollection["editPageUpdateButtonText"].Value;
                }
                if (attrCollection["editPageSaveButtonText"] != null)
                {
                    editPageSaveButtonText = attrCollection["editPageSaveButtonText"].Value;
                }
                if (attrCollection["editPageDeleteButtonText"] != null)
                {
                    editPageDeleteButtonText = attrCollection["editPageDeleteButtonText"].Value;
                }
                if (attrCollection["editPageCancelLinkText"] != null)
                {
                    editPageCancelLinkText = attrCollection["editPageCancelLinkText"].Value;
                }
                if (attrCollection["editPageDeleteWarning"] != null)
                {
                    editPageDeleteWarning = attrCollection["editPageDeleteWarning"].Value;
                }
                if (attrCollection["importPageTitle"] != null)
                {
                    importPageTitle = attrCollection["importPageTitle"].Value;
                }
                if (attrCollection["exportPageTitle"] != null)
                {
                    exportPageTitle = attrCollection["exportPageTitle"].Value;
                }
                if (attrCollection["importPageCancelLinkText"] != null)
                {
                    importPageCancelLinkText = attrCollection["importPageCancelLinkText"].Value;
                }
                log.Debug($"current siteid={siteId.ToString()}. invariant siteid={siteId.ToInvariantString()}");
                if (attrCollection["fieldDefinitionSrc"] != null)
                {
                    fieldDefinitionSrc = attrCollection["fieldDefinitionSrc"].Value.Replace("$_SitePath_$", "/Data/Sites/" + siteId.ToInvariantString());
                }
                if (attrCollection["fieldDefinitionGuid"] != null)
                {
                    fieldDefinitionGuid = Guid.Parse(attrCollection["fieldDefinitionGuid"].Value);
                }
                if (attrCollection["jsonRenderLocation"] != null)
                {
                    jsonRenderLocation = attrCollection["jsonRenderLocation"].Value;
                }
                if (attrCollection["jsonLabelObjects"] != null)
                {
                    jsonLabelObjects = Convert.ToBoolean(attrCollection["jsonLabelObjects"].Value);
                }
                if (attrCollection["headerLocation"] != null)
                {
                    headerLocation = attrCollection["headerLocation"].Value;
                }
                if (attrCollection["footerLocation"] != null)
                {
                    footerLocation = attrCollection["footerLocation"].Value;
                }
                if (attrCollection["hideOuterWrapperPanel"] != null)
                {
                    hideOuterWrapperPanel = Convert.ToBoolean(attrCollection["hideOuterWrapperPanel"].Value);
                }
                if (attrCollection["hideInnerWrapperPanel"] != null)
                {
                    hideInnerWrapperPanel = Convert.ToBoolean(attrCollection["hideInnerWrapperPanel"].Value);
                }
                if (attrCollection["hideOuterBodyPanel"] != null)
                {
                    hideOuterBodyPanel = Convert.ToBoolean(attrCollection["hideOuterBodyPanel"].Value);
                }
                if (attrCollection["hideInnerBodyPanel"] != null)
                {
                    hideInnerBodyPanel = Convert.ToBoolean(attrCollection["hideInnerBodyPanel"].Value);
                }
                if (attrCollection["showSaveAsNewButton"] != null)
                {
                    showSaveAsNew = Convert.ToBoolean(attrCollection["showSaveAsNewButton"].Value);
                }
                if (attrCollection["maxItems"] != null)
                {
                    maxItems = Convert.ToInt32(attrCollection["maxItems"].Value);
                }
                if (attrCollection["processItems"] != null)
                {
                    processItems = Convert.ToBoolean(attrCollection["processItems"].Value);
                }

                MarkupDefinition workingMarkupDefinition = new MarkupDefinition();
                if (isMobile && !useStandardMarkupOnDesktopOnly)
                {
                    // do this so mobile settings are added to desktop
                    workingMarkupDefinition = (MarkupDefinition)markupDefinition.Clone();
                }

                foreach (XmlNode childNode in node)
                {
                    if (!String.IsNullOrWhiteSpace(childNode.InnerText) || !String.IsNullOrWhiteSpace(childNode.InnerXml))
                    {
                        switch (childNode.Name)
                        {
                        case "ModuleTitleMarkup":
                            workingMarkupDefinition.ModuleTitleMarkup = childNode.InnerText.Trim();
                            break;

                        case "ModuleTitleFormat":
                            workingMarkupDefinition.ModuleTitleFormat = childNode.InnerText.Trim();
                            break;

                        case "ModuleLinksFormat":
                            workingMarkupDefinition.ModuleLinksFormat = childNode.InnerText.Trim();
                            break;

                        case "ModuleInstanceMarkupTop":
                            workingMarkupDefinition.ModuleInstanceMarkupTop = childNode.InnerText.Trim();
                            break;

                        case "ModuleInstanceMarkupBottom":
                            workingMarkupDefinition.ModuleInstanceMarkupBottom = childNode.InnerText.Trim();
                            break;

                        case "InstanceFeaturedImageFormat":
                            workingMarkupDefinition.InstanceFeaturedImageFormat = childNode.InnerText.Trim();
                            break;

                        case "HeaderContentFormat":
                            workingMarkupDefinition.HeaderContentFormat = childNode.InnerText.Trim();
                            break;

                        case "FooterContentFormat":
                            workingMarkupDefinition.FooterContentFormat = childNode.InnerText.Trim();
                            break;

                        case "ItemMarkup":
                            workingMarkupDefinition.ItemMarkup = childNode.InnerText.Trim();
                            break;

                        case "ItemsRepeaterMarkup":
                            workingMarkupDefinition.ItemsRepeaterMarkup = childNode.InnerText.Trim();
                            XmlAttributeCollection repeaterAttribs = childNode.Attributes;
                            if (repeaterAttribs["itemsPerGroup"] != null)
                            {
                                workingMarkupDefinition.ItemsPerGroup = XmlUtils.ParseInt32FromAttribute(repeaterAttribs, "itemsPerGroup", workingMarkupDefinition.ItemsPerGroup);
                            }
                            break;

                        case "ItemsWrapperFormat":
                            workingMarkupDefinition.ItemsWrapperFormat = childNode.InnerText.Trim();
                            break;

                        case "ModuleSettingsLinkFormat":
                            workingMarkupDefinition.ModuleSettingsLinkFormat = childNode.InnerText.Trim();
                            break;

                        case "AddItemLinkFormat":
                            workingMarkupDefinition.AddItemLinkFormat = childNode.InnerText.Trim();
                            break;

                        case "EditHeaderLinkFormat":
                            workingMarkupDefinition.EditHeaderLinkFormat = childNode.InnerText.Trim();
                            break;

                        case "EditFooterLinkFormat":
                            workingMarkupDefinition.EditFooterLinkFormat = childNode.InnerText.Trim();
                            break;

                        case "ItemEditLinkFormat":
                            workingMarkupDefinition.ItemEditLinkFormat = childNode.InnerText.Trim();
                            break;

                        case "ImportInstructions":
                            importInstructions = childNode.InnerText.Trim();
                            break;

                        case "ExportInstructions":
                            exportInstructions = childNode.InnerText.Trim();
                            break;

                        case "ImportLinkFormat":
                            workingMarkupDefinition.ImportLinkFormat = childNode.InnerText.Trim();
                            break;

                        case "ExportLinkFormat":
                            workingMarkupDefinition.ExportLinkFormat = childNode.InnerText.Trim();
                            break;

                        case "GlobalViewMarkup":
                            workingMarkupDefinition.GlobalViewMarkup = childNode.InnerText.Trim();
                            break;

                        case "GlobalViewItemMarkup":
                            workingMarkupDefinition.GlobalViewItemMarkup = childNode.InnerText.Trim();
                            break;

                        case "CheckBoxListMarkup":
                        case "RadioButtonListMarkup":
                            CheckBoxListMarkup cblm = new CheckBoxListMarkup();

                            XmlAttributeCollection cblmAttribs = childNode.Attributes;
                            if (cblmAttribs["field"] != null)
                            {
                                cblm.Field = cblmAttribs["field"].Value;
                            }
                            if (cblmAttribs["token"] != null)
                            {
                                cblm.Token = cblmAttribs["token"].Value;
                            }

                            foreach (XmlNode cblmNode in childNode)
                            {
                                switch (cblmNode.Name)
                                {
                                case "Separator":
                                    cblm.Separator = cblmNode.InnerText.Trim();
                                    break;

                                case "Content":
                                    cblm.Markup = cblmNode.InnerText.Trim();
                                    break;
                                }
                            }
                            checkBoxListMarkups.Add(cblm);
                            break;

                        case "Scripts":
                            if (isMobile)
                            {
                                mobileMarkupScripts = SuperFlexiHelpers.ParseScriptsFromXmlNode(childNode);
                            }
                            else
                            {
                                markupScripts = SuperFlexiHelpers.ParseScriptsFromXmlNode(childNode);
                            }
                            //SetupDefinedScripts(childNode, isMobile);
                            //rawScript = childNode.InnerText;
                            break;

                        case "Styles":
                            markupCSS = SuperFlexiHelpers.ParseCssFromXmlNode(childNode);
                            break;
                        }
                    }
                }

                if (isMobile)
                {
                    mobileMarkupDefinition = workingMarkupDefinition;
                }
                else
                {
                    markupDefinition = workingMarkupDefinition;
                }
            }
        }