Beispiel #1
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["configInfo"] != null)
                {
                    pageItem.configInfo = attributeCollection["configInfo"].Value;
                }

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

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

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

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

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

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

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

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

                try
                {
                    if (attributeCollection["contentInstaller"] != null && typeof(IContentInstaller).IsAssignableFrom(Type.GetType(attributeCollection["contentInstaller"].Value)))
                    {
                        pageItem.installer = Activator.CreateInstance(Type.GetType(attributeCollection["contentInstaller"].Value)) as IContentInstaller;
                    }
                }
                catch (Exception ex) // we don't want it to fail during site creation even if not all content is created due to errors here.
                {
                    log.Error(ex);
                }



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

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

                    case "top":
                    case "altcontent1":
                        pageItem.location = "altcontent1";
                        break;

                    case "bottom":
                    case "altcontent2":
                        pageItem.location = "altcontent2";
                        break;

                    case "center":
                    case "contentpane":
                    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;
                    }
                }


                // tni-20130624: handling module settings
                XmlNodeList moduleSettings = pageItemNode.SelectNodes("./moduleSetting");
                foreach (XmlNode moduleSetting in moduleSettings)
                {
#if NET35
                    if (moduleSetting.Attributes["settingKey"] != null &&
                        !string.IsNullOrEmpty(moduleSetting.Attributes["settingKey"].Value) &&
                        moduleSetting.Attributes["settingValue"] != null &&
                        moduleSetting.Attributes["settingValue"].Value != null)
                    {
                        pageItem.moduleSettings[moduleSetting.Attributes["settingKey"].Value] =
                            moduleSetting.Attributes["settingValue"].Value;
                    }
#else
                    if (moduleSetting.Attributes["settingKey"] != null &&
                        !string.IsNullOrWhiteSpace(moduleSetting.Attributes["settingKey"].Value) &&
                        moduleSetting.Attributes["settingValue"] != null &&
                        moduleSetting.Attributes["settingValue"].Value != null)
                    {
                        pageItem.moduleSettings[moduleSetting.Attributes["settingKey"].Value] =
                            moduleSetting.Attributes["settingValue"].Value;
                    }
#endif
                }

                // No parse error handling like done above..
                if (attributeCollection["moduleGuid"] != null)
                {
#if NET35
                    pageItem.moduleGuid = new Guid(attributeCollection["moduleGuid"].Value);
#else
                    Guid.TryParse(attributeCollection["moduleGuid"].Value, out pageItem.moduleGuid);
#endif
                }

                if (attributeCollection["moduleGuidToPublish"] != null)
                {
#if NET35
                    pageItem.moduleGuidToPublish = new Guid(attributeCollection["moduleGuidToPublish"].Value);
#else
                    Guid.TryParse(attributeCollection["moduleGuidToPublish"].Value, out pageItem.moduleGuidToPublish);
#endif
                }
                //

                contentPage.PageItems.Add(pageItem);
            }
        }
Beispiel #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["configInfo"] != null)
                {
                    pageItem.configInfo = attributeCollection["configInfo"].Value;
                }

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

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

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

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

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

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

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

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

                try
                {
                    if (attributeCollection["contentInstaller"] != null && typeof(IContentInstaller).IsAssignableFrom(Type.GetType(attributeCollection["contentInstaller"].Value)))
                    {
                        pageItem.installer = Activator.CreateInstance(Type.GetType(attributeCollection["contentInstaller"].Value)) as IContentInstaller;
                    }
                }
                catch (Exception ex) // we don't want it to fail during site creation even if not all content is created due to errors here.
                {
                    log.Error(ex);
                }

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

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

                        case "top":
                        case "altcontent1":
                            pageItem.location = "altcontent1";
                            break;

                        case "bottom":
                        case "altcontent2":
                            pageItem.location = "altcontent2";
                            break;

                        case "center":
                        case "contentpane":
                        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;
                    }
                }

                // tni-20130624: handling module settings
                XmlNodeList moduleSettings = pageItemNode.SelectNodes("./moduleSetting");
                foreach (XmlNode moduleSetting in moduleSettings)
                {
            #if NET35
                    if (moduleSetting.Attributes["settingKey"] != null &&
                        !string.IsNullOrEmpty(moduleSetting.Attributes["settingKey"].Value) &&
                        moduleSetting.Attributes["settingValue"] != null &&
                        moduleSetting.Attributes["settingValue"].Value != null)
                    {
                        pageItem.moduleSettings[moduleSetting.Attributes["settingKey"].Value] =
                            moduleSetting.Attributes["settingValue"].Value;
                    }
            #else

                    if (moduleSetting.Attributes["settingKey"] != null &&
                        !string.IsNullOrWhiteSpace(moduleSetting.Attributes["settingKey"].Value) &&
                        moduleSetting.Attributes["settingValue"] != null &&
                        moduleSetting.Attributes["settingValue"].Value != null)
                    {
                        pageItem.moduleSettings[moduleSetting.Attributes["settingKey"].Value] =
                            moduleSetting.Attributes["settingValue"].Value;
                    }
            #endif
                }

                // No parse error handling like done above..
                if (attributeCollection["moduleGuid"] != null)
                {
            #if NET35
                    pageItem.moduleGuid = new Guid(attributeCollection["moduleGuid"].Value);
            #else
                    Guid.TryParse(attributeCollection["moduleGuid"].Value, out pageItem.moduleGuid);
            #endif
                }

                if (attributeCollection["moduleGuidToPublish"] != null)
                {
            #if NET35
                    pageItem.moduleGuidToPublish = new Guid(attributeCollection["moduleGuidToPublish"].Value);
            #else

                    Guid.TryParse(attributeCollection["moduleGuidToPublish"].Value, out pageItem.moduleGuidToPublish);
            #endif
                }
                //

                contentPage.PageItems.Add(pageItem);

            }
        }
Beispiel #3
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);
                    }
                }
            }
        }