コード例 #1
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")
                {
                    ContentPage contentPage = new ContentPage();

                    XmlAttributeCollection attributeCollection
                        = node.Attributes;

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

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


                    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"].ToString().ToLower() == "true")
                        )
                    {
                        contentPage.requireSSL = true;
                    }


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

                    if (contentPage.pageGuid == Guid.Empty)
                    {
                        log.Error("could not install page " + contentPage.Name
                                  + ". Invalid PageGuid.");
                        return;
                    }


                    contentPageConfig.ContentPages.Add(contentPage);
                }
            }
        }
コード例 #2
0
        public static void LoadPageItem(
            ContentPage contentPage,
            XmlNode pageItemNode)
        {
            if (contentPage == null)
            {
                return;
            }
            if (pageItemNode == null)
            {
                return;
            }

            if (pageItemNode.Name == "contentFeature")
            {
                ContentPageItem pageItem = new ContentPageItem();

                XmlAttributeCollection attributeCollection
                    = pageItemNode.Attributes;

                if (attributeCollection["featureGuid"] != null)
                {
                    pageItem.featureGuid = new Guid(attributeCollection["featureGuid"].Value);
                }

                if (attributeCollection["contentTitle"] != null)
                {
                    pageItem.contentTitle = attributeCollection["contentTitle"].Value;
                }

                if (attributeCollection["contentTemplate"] != null)
                {
                    pageItem.contentTemplate = attributeCollection["contentTemplate"].Value;
                }

                if (attributeCollection["location"] != null)
                {
                    string location = attributeCollection["location"].Value;
                    switch (location)
                    {
                    case "right":
                        pageItem.location = "rightpane";
                        break;

                    case "left":
                        pageItem.location = "leftpane";
                        break;

                    case "center":
                    default:
                        pageItem.location = "contentpane";
                        break;
                    }
                }

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

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

                contentPage.PageItems.Add(pageItem);
            }
        }