public static ContentPageConfiguration GetConfig()
        {
            ContentPageConfiguration contentPageConfig = new ContentPageConfiguration();

            String configFolderName = "~/Setup/initialcontent/pages/";

            string pathToConfigFolder = HostingEnvironment.MapPath(configFolderName);

            if (!Directory.Exists(pathToConfigFolder)) return contentPageConfig;

            DirectoryInfo directoryInfo = new DirectoryInfo(pathToConfigFolder);

            FileInfo[] pageFiles = directoryInfo.GetFiles("*.config");

            foreach (FileInfo fileInfo in pageFiles)
            {
                if (WebConfigSettings.ContentPagesToSkip.Contains(fileInfo.Name)) { continue; }

                XmlDocument contentConfigFile = new XmlDocument();
                contentConfigFile.Load(fileInfo.FullName);

                ContentPage.LoadPages(
                    contentPageConfig,
                    contentConfigFile.DocumentElement);

            }

            return contentPageConfig;
        }
        public static ContentPageConfiguration GetConfig()
        {
            ContentPageConfiguration contentPageConfig = new ContentPageConfiguration();

            String configFolderName = "~/Setup/initialcontent/pages/";

            string pathToConfigFolder = HostingEnvironment.MapPath(configFolderName);

            if (!Directory.Exists(pathToConfigFolder))
            {
                return(contentPageConfig);
            }


            DirectoryInfo directoryInfo = new DirectoryInfo(pathToConfigFolder);

            FileInfo[] pageFiles = directoryInfo.GetFiles("*.config");

            foreach (FileInfo fileInfo in pageFiles)
            {
                if (WebConfigSettings.ContentPagesToSkip.Contains(fileInfo.Name))
                {
                    continue;
                }

                XmlDocument contentConfigFile = new XmlDocument();
                contentConfigFile.Load(fileInfo.FullName);

                ContentPage.LoadPages(
                    contentPageConfig,
                    contentConfigFile.DocumentElement);
            }

            return(contentPageConfig);
        }
Exemplo n.º 3
0
        public static void LoadPages(
            ContentPageConfiguration contentPageConfig,
            XmlNode documentElement)
        {
            if (HttpContext.Current == null)
            {
                return;
            }
            if (documentElement.Name != "siteContent")
            {
                return;
            }

            XmlNode pagesNode = null;

            foreach (XmlNode node in documentElement.ChildNodes)
            {
                if (node.Name == "pages")
                {
                    pagesNode = node;
                    break;
                }
            }

            if (pagesNode == null)
            {
                return;
            }

            foreach (XmlNode node in pagesNode.ChildNodes)
            {
                if (node.Name == "page")
                {
                    LoadPage(contentPageConfig, node, null);
                }
            }
        }
Exemplo n.º 4
0
        public static void LoadPages(
            ContentPageConfiguration contentPageConfig,
            XmlNode documentElement)
        {
            if (HttpContext.Current == null) return;
            if (documentElement.Name != "siteContent") return;

            XmlNode pagesNode = null;

            foreach (XmlNode node in documentElement.ChildNodes)
            {
                if (node.Name == "pages")
                {
                    pagesNode = node;
                    break;
                }
            }

            if(pagesNode == null) return;

            foreach (XmlNode node in pagesNode.ChildNodes)
            {
                if (node.Name == "page")
                {
                    LoadPage(contentPageConfig, node, null);
                }

            }
        }
Exemplo n.º 5
0
        public static void LoadPage(
            ContentPageConfiguration contentPageConfig,
            XmlNode node, 
            ContentPage parentPage)
        {
            ContentPage contentPage = new ContentPage();

            XmlAttributeCollection attributeCollection = node.Attributes;

            if (attributeCollection["resourceFile"] != null)
            {
                contentPage.resourceFile = attributeCollection["resourceFile"].Value;
            }

            if (attributeCollection["name"] != null)
            {
                contentPage.name = attributeCollection["name"].Value;
            }

            if (attributeCollection["title"] != null)
            {
                contentPage.title = attributeCollection["title"].Value;
            }

            if (attributeCollection["url"] != null)
            {
                contentPage.url = attributeCollection["url"].Value;
            }

            if (attributeCollection["menuImage"] != null)
            {
                contentPage.menuImage = attributeCollection["menuImage"].Value;
            }

            if (attributeCollection["pageOrder"] != null)
            {
                int sort = 1;
                if (int.TryParse(attributeCollection["pageOrder"].Value,
                    out sort))
                {
                    contentPage.pageOrder = sort;
                }
            }

            if (attributeCollection["visibleToRoles"] != null)
            {
                contentPage.visibleToRoles = attributeCollection["visibleToRoles"].Value;
            }

            if (attributeCollection["editRoles"] != null)
            {
                contentPage.editRoles = attributeCollection["editRoles"].Value;
            }

            if (attributeCollection["draftEditRoles"] != null)
            {
                contentPage.draftEditRoles = attributeCollection["draftEditRoles"].Value;
            }

            if (attributeCollection["createChildPageRoles"] != null)
            {
                contentPage.createChildPageRoles = attributeCollection["createChildPageRoles"].Value;
            }

            if (attributeCollection["pageMetaKeyWords"] != null)
            {
                contentPage.pageMetaKeyWords = attributeCollection["pageMetaKeyWords"].Value;
            }

            if (attributeCollection["pageMetaDescription"] != null)
            {
                contentPage.pageMetaDescription = attributeCollection["pageMetaDescription"].Value;
            }

            if (
                (attributeCollection["requireSSL"] != null)
                && (attributeCollection["requireSSL"].Value.ToLower() == "true")
                )
            {
                contentPage.requireSSL = true;
            }

            if (
                (attributeCollection["showBreadcrumbs"] != null)
                && (attributeCollection["showBreadcrumbs"].Value.ToLower() == "true")
                )
            {
                contentPage.showBreadcrumbs = true;
            }

             if (
                (attributeCollection["includeInMenu"] != null)
                && (attributeCollection["includeInMenu"].Value.ToLower() == "false")
                )
            {
                contentPage.includeInMenu = false;
            }

            if (
                (attributeCollection["isClickable"] != null)
                && (attributeCollection["isClickable"].Value.ToLower() == "false")
                )
            {
                contentPage.isClickable = false;
            }

             if (
                (attributeCollection["includeInSiteMap"] != null)
                && (attributeCollection["includeInSiteMap"].Value.ToLower() == "false")
                )
            {
                contentPage.includeInSiteMap = false;
            }

            if (
                (attributeCollection["includeInChildPagesSiteMap"] != null)
                && (attributeCollection["includeInChildPagesSiteMap"].Value.ToLower() == "false")
                )
            {
                contentPage.includeInChildPagesSiteMap = false;
            }

            if (
                (attributeCollection["allowBrowserCaching"] != null)
                && (attributeCollection["allowBrowserCaching"].Value.ToLower() == "false")
                )
            {
                contentPage.allowBrowserCaching = false;
            }

            if (
                (attributeCollection["showChildPageBreadcrumbs"] != null)
                && (attributeCollection["showChildPageBreadcrumbs"].Value.ToLower() == "true")
                )
            {
                contentPage.showChildPageBreadcrumbs = true;
            }

            if (
                (attributeCollection["showHomeCrumb"] != null)
                && (attributeCollection["showHomeCrumb"].Value.ToLower() == "true")
                )
            {
                contentPage.showHomeCrumb = true;
            }

            if (
                (attributeCollection["showChildPagesSiteMap"] != null)
                && (attributeCollection["showChildPagesSiteMap"].Value.ToLower() == "true")
                )
            {
                contentPage.showChildPagesSiteMap = true;
            }

            if (
                (attributeCollection["hideFromAuthenticated"] != null)
                && (attributeCollection["hideFromAuthenticated"].Value.ToLower() == "true")
                )
            {
                contentPage.hideFromAuthenticated = true;
            }

            if (
                (attributeCollection["enableComments"] != null)
                && (attributeCollection["enableComments"].Value.ToLower() == "true")
                )
            {
                contentPage.enableComments = true;
            }

            if (attributeCollection["bodyCssClass"] != null)
            {
                contentPage.bodyCssClass = attributeCollection["bodyCssClass"].Value;
            }

            if (attributeCollection["menuCssClass"] != null)
            {
                contentPage.menuCssClass = attributeCollection["menuCssClass"].Value;
            }

            foreach (XmlNode contentFeatureNode in node.ChildNodes)
            {
                if (contentFeatureNode.Name == "contentFeature")
                {
                    ContentPageItem.LoadPageItem(
                        contentPage,
                        contentFeatureNode);
                }
            }

            XmlNode childPagesNode = null;

            foreach (XmlNode n in node.ChildNodes)
            {
                if (n.Name == "childPages")
                {
                    childPagesNode = n;
                    break;
                }
            }

            if (parentPage == null)
            {
                contentPageConfig.ContentPages.Add(contentPage);
            }
            else
            {
                parentPage.ChildPages.Add(contentPage);
            }

            if (childPagesNode != null)
            {
                foreach (XmlNode c in childPagesNode.ChildNodes)
                {
                    if (c.Name == "page")
                    {
                        LoadPage(contentPageConfig, c, contentPage);
                    }
                }
            }
        }
Exemplo n.º 6
0
        public static void LoadPage(
            ContentPageConfiguration contentPageConfig,
            XmlNode node,
            ContentPage parentPage)
        {
            ContentPage contentPage = new ContentPage();

            XmlAttributeCollection attributeCollection = node.Attributes;

            if (attributeCollection["resourceFile"] != null)
            {
                contentPage.resourceFile = attributeCollection["resourceFile"].Value;
            }

            if (attributeCollection["name"] != null)
            {
                contentPage.name = attributeCollection["name"].Value;
            }


            if (attributeCollection["title"] != null)
            {
                contentPage.title = attributeCollection["title"].Value;
            }


            if (attributeCollection["url"] != null)
            {
                contentPage.url = attributeCollection["url"].Value;
            }

            if (attributeCollection["menuImage"] != null)
            {
                contentPage.menuImage = attributeCollection["menuImage"].Value;
            }

            if (attributeCollection["pageOrder"] != null)
            {
                int sort = 1;
                if (int.TryParse(attributeCollection["pageOrder"].Value,
                                 out sort))
                {
                    contentPage.pageOrder = sort;
                }
            }

            if (attributeCollection["visibleToRoles"] != null)
            {
                contentPage.visibleToRoles = attributeCollection["visibleToRoles"].Value;
            }

            if (attributeCollection["editRoles"] != null)
            {
                contentPage.editRoles = attributeCollection["editRoles"].Value;
            }

            if (attributeCollection["draftEditRoles"] != null)
            {
                contentPage.draftEditRoles = attributeCollection["draftEditRoles"].Value;
            }

            if (attributeCollection["createChildPageRoles"] != null)
            {
                contentPage.createChildPageRoles = attributeCollection["createChildPageRoles"].Value;
            }

            if (attributeCollection["pageMetaKeyWords"] != null)
            {
                contentPage.pageMetaKeyWords = attributeCollection["pageMetaKeyWords"].Value;
            }

            if (attributeCollection["pageMetaDescription"] != null)
            {
                contentPage.pageMetaDescription = attributeCollection["pageMetaDescription"].Value;
            }

            if (
                (attributeCollection["requireSSL"] != null) &&
                (attributeCollection["requireSSL"].Value.ToLower() == "true")
                )
            {
                contentPage.requireSSL = true;
            }

            if (
                (attributeCollection["showBreadcrumbs"] != null) &&
                (attributeCollection["showBreadcrumbs"].Value.ToLower() == "true")
                )
            {
                contentPage.showBreadcrumbs = true;
            }

            if (
                (attributeCollection["includeInMenu"] != null) &&
                (attributeCollection["includeInMenu"].Value.ToLower() == "false")
                )
            {
                contentPage.includeInMenu = false;
            }

            if (
                (attributeCollection["isClickable"] != null) &&
                (attributeCollection["isClickable"].Value.ToLower() == "false")
                )
            {
                contentPage.isClickable = false;
            }

            if (
                (attributeCollection["includeInSiteMap"] != null) &&
                (attributeCollection["includeInSiteMap"].Value.ToLower() == "false")
                )
            {
                contentPage.includeInSiteMap = false;
            }

            if (
                (attributeCollection["includeInChildPagesSiteMap"] != null) &&
                (attributeCollection["includeInChildPagesSiteMap"].Value.ToLower() == "false")
                )
            {
                contentPage.includeInChildPagesSiteMap = false;
            }

            if (
                (attributeCollection["allowBrowserCaching"] != null) &&
                (attributeCollection["allowBrowserCaching"].Value.ToLower() == "false")
                )
            {
                contentPage.allowBrowserCaching = false;
            }

            if (
                (attributeCollection["showChildPageBreadcrumbs"] != null) &&
                (attributeCollection["showChildPageBreadcrumbs"].Value.ToLower() == "true")
                )
            {
                contentPage.showChildPageBreadcrumbs = true;
            }

            if (
                (attributeCollection["showHomeCrumb"] != null) &&
                (attributeCollection["showHomeCrumb"].Value.ToLower() == "true")
                )
            {
                contentPage.showHomeCrumb = true;
            }

            if (
                (attributeCollection["showChildPagesSiteMap"] != null) &&
                (attributeCollection["showChildPagesSiteMap"].Value.ToLower() == "true")
                )
            {
                contentPage.showChildPagesSiteMap = true;
            }

            if (
                (attributeCollection["hideFromAuthenticated"] != null) &&
                (attributeCollection["hideFromAuthenticated"].Value.ToLower() == "true")
                )
            {
                contentPage.hideFromAuthenticated = true;
            }

            if (
                (attributeCollection["enableComments"] != null) &&
                (attributeCollection["enableComments"].Value.ToLower() == "true")
                )
            {
                contentPage.enableComments = true;
            }

            if (attributeCollection["bodyCssClass"] != null)
            {
                contentPage.bodyCssClass = attributeCollection["bodyCssClass"].Value;
            }

            if (attributeCollection["menuCssClass"] != null)
            {
                contentPage.menuCssClass = attributeCollection["menuCssClass"].Value;
            }


            foreach (XmlNode contentFeatureNode in node.ChildNodes)
            {
                if (contentFeatureNode.Name == "contentFeature")
                {
                    ContentPageItem.LoadPageItem(
                        contentPage,
                        contentFeatureNode);
                }
            }

            XmlNode childPagesNode = null;

            foreach (XmlNode n in node.ChildNodes)
            {
                if (n.Name == "childPages")
                {
                    childPagesNode = n;
                    break;
                }
            }

            if (parentPage == null)
            {
                contentPageConfig.ContentPages.Add(contentPage);
            }
            else
            {
                parentPage.ChildPages.Add(contentPage);
            }

            if (childPagesNode != null)
            {
                foreach (XmlNode c in childPagesNode.ChildNodes)
                {
                    if (c.Name == "page")
                    {
                        LoadPage(contentPageConfig, c, contentPage);
                    }
                }
            }
        }