示例#1
0
        private SiteMapNode CreateNodeFromPage(PortalPage page)
        {
            string url = String.IsNullOrEmpty(page.Url) ? DEFAULT_PAGE_URL + page.Name : page.Url;

            string localizedName = DefaultPage.GetLocalizedPageName(page.Name);

            NameValueCollection attrs = new NameValueCollection();

            attrs["target"] = page.Target;
            attrs["align"]  = page.Align;

            SiteMapNode node = new SiteMapNode(this, page.Name,
                                               url,
                                               localizedName,
                                               localizedName, page.Roles, attrs, null, null);

            if (!page.Enabled)
            {
                node.Url = "";
            }

            if (IsNodeAccessibleToUser(HttpContext.Current, node))
            {
                return(node);
            }
            return(null);
        }
示例#2
0
        // Implement the GetParentNode method.
        public override SiteMapNode GetParentNode(SiteMapNode node)
        {
            string pid = node.Key;

            if (pid == ROOT_NODE_KEY)
            {
                return(null);
            }

            // find page
            if (PortalConfiguration.Site.Pages.ContainsKey(pid))
            {
                PortalPage page = PortalConfiguration.Site.Pages[pid];
                if (page.ParentPage != null)
                {
                    return(CreateNodeFromPage(page.ParentPage));
                }
            }
            return(null);
        }
示例#3
0
        protected void Page_Init(object sender, EventArgs e)
        {
            // get page info
            string pid = CurrentPageID;

            if (PortalConfiguration.Site.Pages[pid] == null)
            {
                ShowError(skinPlaceHolder, String.Format("Page with ID '{0}' is not found", HttpUtility.HtmlEncode(pid)));
                return;
            }

            PortalPage page = PortalConfiguration.Site.Pages[pid];

            // check if page is accessible to user
            if (!IsAccessibleToUser(Context, page.Roles))
            {
                // redirect to login page
                string returnUrl = Request.RawUrl;
                Response.Redirect(DEFAULT_PAGE + "?" + PAGE_ID_PARAM + "=" +
                                  PortalConfiguration.SiteSettings["LoginPage"] + "&ReturnUrl=" + Server.UrlEncode(returnUrl));
            }

            Title = String.Format("{0} - {1}",
                                  PortalConfiguration.SiteSettings["PortalName"],
                                  PageTitleProvider.Instance.ProcessPageTitle(GetLocalizedPageTitle(page.Name)));

            // load skin
            bool editMode = (ModuleControlID != "" && ModuleID > 0);

            string skinName = page.SkinSrc;

            if (!editMode)
            {
                // browse skin
                if (String.IsNullOrEmpty(skinName))
                {
                    // load portal skin
                    skinName = PortalConfiguration.SiteSettings["PortalSkin"];
                }
            }
            else
            {
                // edit skin
                if (!String.IsNullOrEmpty(page.AdminSkinSrc))
                {
                    skinName = page.AdminSkinSrc;
                }
                else
                {
                    skinName = PortalConfiguration.SiteSettings["AdminSkin"];
                }
            }

            // load skin control
            string  skinPath = "~/" + SKINS_FOLDER + "/" + this.Theme + "/" + skinName;
            Control ctrlSkin = null;

            try
            {
                ctrlSkin = LoadControl(skinPath);
                skinPlaceHolder.Controls.Add(ctrlSkin);
            }
            catch (Exception ex)
            {
                ShowError(skinPlaceHolder, String.Format("Can't load {0} skin: {1}", skinPath, ex.ToString()));
                return;
            }

            // load page modules
            if (!editMode)
            {
                // browse mode
                foreach (string paneId in page.ContentPanes.Keys)
                {
                    // try to find content pane
                    Control ctrlPane = ctrlSkin.FindControl(paneId);
                    if (ctrlPane != null)
                    {
                        // insert modules
                        ContentPane pane = page.ContentPanes[paneId];
                        foreach (PageModule module in pane.Modules)
                        {
                            if (IsAccessibleToUser(Context, module.ViewRoles))
                            {
                                // add module
                                if (module.Settings.Contains("UseDefault"))
                                {
                                    string useDefault = Convert.ToString(module.Settings["UseDefault"]).ToLower(CultureInfo.InvariantCulture);
                                    AddModuleToContentPane(ctrlPane, module, useDefault, editMode);
                                }
                                else
                                {
                                    AddModuleToContentPane(ctrlPane, module, "", editMode);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // edit mode
                // find ContentPane
                Control ctrlPane = ctrlSkin.FindControl(CONTENT_PANE_NAME);
                if (ctrlPane != null)
                {
                    // add "edit" module
                    if (PortalConfiguration.Site.Modules.ContainsKey(ModuleID))
                    {
                        AddModuleToContentPane(ctrlPane, PortalConfiguration.Site.Modules[ModuleID],
                                               ModuleControlID, editMode);
                    }
                }
            }
        }
        private SiteMapNode CreateNodeFromPage(PortalPage page)
        {
			string url = String.IsNullOrEmpty(page.Url) ? DEFAULT_PAGE_URL + page.Name : page.Url;

            string localizedName = DefaultPage.GetLocalizedPageName(page.Name);

            NameValueCollection attrs = new NameValueCollection();
            attrs["target"] = page.Target;
            attrs["align"] = page.Align;

            SiteMapNode node = new SiteMapNode(this, page.Name,
                url,
                localizedName,
                localizedName, page.Roles, attrs, null, null);

            if (!page.Enabled)
                node.Url = "";

            if (IsNodeAccessibleToUser(HttpContext.Current, node))
            {
                return node;
            }
            return null;
        }
示例#5
0
 public void Add(PortalPage page)
 {
     BaseAdd(page.Name, page);
 }
        private static void ParsePagesRecursively(string path, SiteStructure site, XmlNodeList xmlPages, PortalPage parentPage)
        {
            foreach (XmlNode xmlPage in xmlPages)
            {
                PortalPage page = new PortalPage();
                page.ParentPage = parentPage;

                // page properties
                if (xmlPage.Attributes["name"] == null)
                    throw new Exception(String.Format("Page name is not specified. File: {0}, Node: {1}",
                        path, xmlPage.OuterXml));
                page.Name = xmlPage.Attributes["name"].Value;

                if (xmlPage.Attributes["roles"] == null)
                    page.Roles.Add("*");
                else
                    page.Roles.AddRange(xmlPage.Attributes["roles"].Value.Split(ROLES_DELIMITERS.ToCharArray()));

                page.Enabled = (xmlPage.Attributes["enabled"] != null) ? Boolean.Parse(xmlPage.Attributes["enabled"].Value) : true;
                page.Hidden = (xmlPage.Attributes["hidden"] != null) ? Boolean.Parse(xmlPage.Attributes["hidden"].Value) : false;
                page.SkinSrc = (xmlPage.Attributes["skin"] != null) ? xmlPage.Attributes["skin"].Value : null;
				page.AdminSkinSrc = (xmlPage.Attributes["adminskin"] != null) ? xmlPage.Attributes["adminskin"].Value : null;

                if (xmlPage.Attributes["url"] != null)
					page.Url = xmlPage.Attributes["url"].Value;

                if (xmlPage.Attributes["target"] != null)
                    page.Target = xmlPage.Attributes["target"].Value;

                // content panes
                XmlNodeList xmlContentPanes = xmlPage.SelectNodes("Content");
                foreach (XmlNode xmlContentPane in xmlContentPanes)
                {
                    ContentPane pane = new ContentPane();
                    if (xmlContentPane.Attributes["id"] == null)
                        throw new Exception(String.Format("ContentPane ID is not specified. File: {0}, Node: {1}",
                            path, xmlContentPane.ParentNode.OuterXml));
                    pane.Id = xmlContentPane.Attributes["id"].Value;
                    page.ContentPanes.Add(pane.Id, pane);

                    // page modules
                    XmlNodeList xmlModules = xmlContentPane.SelectNodes("Module");
                    foreach (XmlNode xmlModule in xmlModules)
                    {
                        PageModule module = new PageModule();
                        module.ModuleId = site.Modules.Count + 1;
                        module.Page = page;
                        site.Modules.Add(module.ModuleId, module);

                        if (xmlModule.Attributes["moduleDefinitionID"] == null)
                            throw new Exception(String.Format("ModuleDefinition ID is not specified. File: {0}, Node: {1}",
                                path, xmlModule.ParentNode.OuterXml));
						module.ModuleDefinitionID = xmlModule.Attributes["moduleDefinitionID"].Value.ToLower(CultureInfo.InvariantCulture);

                        if (xmlModule.Attributes["title"] != null)
                            module.Title = xmlModule.Attributes["title"].Value;

                        if (xmlModule.Attributes["icon"] != null)
                            module.IconFile = xmlModule.Attributes["icon"].Value;

                        if (xmlModule.Attributes["container"] != null)
                            module.ContainerSrc = xmlModule.Attributes["container"].Value;

						if (xmlModule.Attributes["admincontainer"] != null)
							module.AdminContainerSrc = xmlModule.Attributes["admincontainer"].Value;

                        if (xmlModule.Attributes["viewRoles"] == null)
                            module.ViewRoles.Add("*");
                        else
                            module.ViewRoles.AddRange(xmlModule.Attributes["viewRoles"].Value.Split(ROLES_DELIMITERS.ToCharArray()));

                        if (xmlModule.Attributes["editRoles"] == null)
                            module.EditRoles.Add("*");
                        else
                            module.EditRoles.AddRange(xmlModule.Attributes["editRoles"].Value.Split(ROLES_DELIMITERS.ToCharArray()));

                        // settings
                        XmlNodeList xmlSettings = xmlModule.SelectNodes("Settings/Add");
                        foreach (XmlNode xmlSetting in xmlSettings)
                        {
                            module.Settings[xmlSetting.Attributes["name"].Value] = xmlSetting.Attributes["value"].Value;
                        }

						XmlNode xmlModuleData = xmlModule.SelectSingleNode("ModuleData");
                        if (xmlModuleData != null)
                        {
                            // check reference
                            if (xmlModuleData.Attributes["ref"] != null)
                            {
                                // load referenced module data
                                xmlModuleData = xmlModule.OwnerDocument.SelectSingleNode(
                                    "Pages/ModulesData/ModuleData[@id='" + xmlModuleData.Attributes["ref"].Value + "']");
                            }
                            module.LoadXmlModuleData(xmlModuleData.OuterXml);
                        }

                        pane.Modules.Add(module);
                    }
                }

                // add page to te array
                if (parentPage != null)
                    parentPage.Pages.Add(page);

                site.Pages.Add(page);

                // process children
                XmlNodeList xmlChildPages = xmlPage.SelectNodes("Pages/Page");
                ParsePagesRecursively(path, site, xmlChildPages, page);
            }
        }
示例#7
0
		public void Add(PortalPage page)
		{
			BaseAdd(page.Name, page);
		}
示例#8
0
        private static void ParsePagesRecursively(string path, SiteStructure site, XmlNodeList xmlPages, PortalPage parentPage)
        {
            foreach (XmlNode xmlPage in xmlPages)
            {
                PortalPage page = new PortalPage();
                page.ParentPage = parentPage;

                // page properties
                if (xmlPage.Attributes["name"] == null)
                {
                    throw new Exception(String.Format("Page name is not specified. File: {0}, Node: {1}",
                                                      path, xmlPage.OuterXml));
                }
                page.Name = xmlPage.Attributes["name"].Value;

                if (xmlPage.Attributes["roles"] == null)
                {
                    page.Roles.Add("*");
                }
                else
                {
                    page.Roles.AddRange(xmlPage.Attributes["roles"].Value.Split(ROLES_DELIMITERS.ToCharArray()));
                }

                page.Enabled      = (xmlPage.Attributes["enabled"] != null) ? Boolean.Parse(xmlPage.Attributes["enabled"].Value) : true;
                page.Hidden       = (xmlPage.Attributes["hidden"] != null) ? Boolean.Parse(xmlPage.Attributes["hidden"].Value) : false;
                page.SkinSrc      = (xmlPage.Attributes["skin"] != null) ? xmlPage.Attributes["skin"].Value : null;
                page.AdminSkinSrc = (xmlPage.Attributes["adminskin"] != null) ? xmlPage.Attributes["adminskin"].Value : null;

                if (xmlPage.Attributes["url"] != null)
                {
                    page.Url = xmlPage.Attributes["url"].Value;
                }

                if (xmlPage.Attributes["target"] != null)
                {
                    page.Target = xmlPage.Attributes["target"].Value;
                }

                // content panes
                XmlNodeList xmlContentPanes = xmlPage.SelectNodes("Content");
                foreach (XmlNode xmlContentPane in xmlContentPanes)
                {
                    ContentPane pane = new ContentPane();
                    if (xmlContentPane.Attributes["id"] == null)
                    {
                        throw new Exception(String.Format("ContentPane ID is not specified. File: {0}, Node: {1}",
                                                          path, xmlContentPane.ParentNode.OuterXml));
                    }
                    pane.Id = xmlContentPane.Attributes["id"].Value;
                    page.ContentPanes.Add(pane.Id, pane);

                    // page modules
                    XmlNodeList xmlModules = xmlContentPane.SelectNodes("Module");
                    foreach (XmlNode xmlModule in xmlModules)
                    {
                        PageModule module = new PageModule();
                        module.ModuleId = site.Modules.Count + 1;
                        module.Page     = page;
                        site.Modules.Add(module.ModuleId, module);

                        if (xmlModule.Attributes["moduleDefinitionID"] == null)
                        {
                            throw new Exception(String.Format("ModuleDefinition ID is not specified. File: {0}, Node: {1}",
                                                              path, xmlModule.ParentNode.OuterXml));
                        }
                        module.ModuleDefinitionID = xmlModule.Attributes["moduleDefinitionID"].Value.ToLower(CultureInfo.InvariantCulture);

                        if (xmlModule.Attributes["title"] != null)
                        {
                            module.Title = xmlModule.Attributes["title"].Value;
                        }

                        if (xmlModule.Attributes["icon"] != null)
                        {
                            module.IconFile = xmlModule.Attributes["icon"].Value;
                        }

                        if (xmlModule.Attributes["container"] != null)
                        {
                            module.ContainerSrc = xmlModule.Attributes["container"].Value;
                        }

                        if (xmlModule.Attributes["admincontainer"] != null)
                        {
                            module.AdminContainerSrc = xmlModule.Attributes["admincontainer"].Value;
                        }

                        if (xmlModule.Attributes["viewRoles"] == null)
                        {
                            module.ViewRoles.Add("*");
                        }
                        else
                        {
                            module.ViewRoles.AddRange(xmlModule.Attributes["viewRoles"].Value.Split(ROLES_DELIMITERS.ToCharArray()));
                        }

                        if (xmlModule.Attributes["editRoles"] == null)
                        {
                            module.EditRoles.Add("*");
                        }
                        else
                        {
                            module.EditRoles.AddRange(xmlModule.Attributes["editRoles"].Value.Split(ROLES_DELIMITERS.ToCharArray()));
                        }

                        // settings
                        XmlNodeList xmlSettings = xmlModule.SelectNodes("Settings/Add");
                        foreach (XmlNode xmlSetting in xmlSettings)
                        {
                            module.Settings[xmlSetting.Attributes["name"].Value] = xmlSetting.Attributes["value"].Value;
                        }

                        XmlNode xmlModuleData = xmlModule.SelectSingleNode("ModuleData");
                        if (xmlModuleData != null)
                        {
                            // check reference
                            if (xmlModuleData.Attributes["ref"] != null)
                            {
                                // load referenced module data
                                xmlModuleData = xmlModule.OwnerDocument.SelectSingleNode(
                                    "Pages/ModulesData/ModuleData[@id='" + xmlModuleData.Attributes["ref"].Value + "']");
                            }
                            module.LoadXmlModuleData(xmlModuleData.OuterXml);
                        }

                        pane.Modules.Add(module);
                    }
                }

                // add page to te array
                if (parentPage != null)
                {
                    parentPage.Pages.Add(page);
                }

                site.Pages.Add(page);

                // process children
                XmlNodeList xmlChildPages = xmlPage.SelectNodes("Pages/Page");
                ParsePagesRecursively(path, site, xmlChildPages, page);
            }
        }