예제 #1
0
        private void AddModuleToContentPane(Control pane, PageModule module, string ctrlKey, bool editMode)
        {
            string defId = module.ModuleDefinitionID;
            if(!PortalConfiguration.ModuleDefinitions.ContainsKey(defId))
            {
                ShowError(pane, String.Format("Module definition '{0}' could not be found", defId));
                return;
            }

            ModuleDefinition definition = PortalConfiguration.ModuleDefinitions[defId];
            ModuleControl control = null;
            if(String.IsNullOrEmpty(ctrlKey))
                control = definition.DefaultControl;
            else
            {
                if(definition.Controls.ContainsKey(ctrlKey))
                    control = definition.Controls[ctrlKey];
            }

            if(control == null)
                return;

            // container
            string containerName = editMode ?
                PortalConfiguration.SiteSettings["AdminContainer"] : PortalConfiguration.SiteSettings["PortalContainer"];

            if (!editMode && !String.IsNullOrEmpty(module.ContainerSrc))
                containerName = module.ContainerSrc;

			if (editMode && !String.IsNullOrEmpty(module.AdminContainerSrc))
				containerName = module.AdminContainerSrc;

            // load container
            string containerPath = "~/" + CONTAINERS_FOLDER + "/" + this.Theme + "/" + containerName;
            Control ctrlContainer = null;
            try
            {
                ctrlContainer = LoadControl(containerPath);
            }
            catch (Exception ex)
            {
                ShowError(pane, String.Format("Container '{0}' could not be loaded: {1}", containerPath, ex.ToString()));
                return;
            }

            string title = module.Title;
            if (editMode || String.IsNullOrEmpty(title))
            {
                // get control title
                title = control.Title;
            }

            string iconFile = module.IconFile;
            if (editMode || String.IsNullOrEmpty(iconFile))
            {
                // get control icon
                iconFile = control.IconFile;
            }

            // set title
            Label lblModuleTitle = (Label)ctrlContainer.FindControl(MODULE_TITLE_CONTROL_ID);
			if (lblModuleTitle != null)
			{
				lblModuleTitle.Text = GetLocalizedModuleTitle(title);
			}

            // set icon
            System.Web.UI.WebControls.Image imgModuleIcon = (System.Web.UI.WebControls.Image)ctrlContainer.FindControl(MODULE_ICON_CONTROL_ID);
            if (imgModuleIcon != null)
            {
                if (String.IsNullOrEmpty(iconFile))
                {
                    imgModuleIcon.Visible = false;
                }
                else
                {
                    string iconPath = "~/" + THEMES_FOLDER + "/" + this.Theme + "/" + ICONS_FOLDER + "/" + iconFile;
                    imgModuleIcon.ImageUrl = iconPath;
                }
            }

            Control contentPane = ctrlContainer.FindControl(CONTENT_PANE_NAME);
            if (contentPane != null)
            {
                string controlName = control.Src;
                string controlPath = "~/" + DESKTOP_MODULES_FOLDER + "/" + controlName;
                if (!String.IsNullOrEmpty(controlName))
                {
                    PortalControlBase ctrlControl = null;
                    try
                    {
                        ctrlControl = (PortalControlBase)LoadControl(controlPath);
                        ctrlControl.Module = module;
                        ctrlControl.ContainerControl = ctrlContainer;
                        contentPane.Controls.Add(ctrlControl);
                    }
                    catch (Exception ex)
                    {
                        ShowError(contentPane, String.Format("Control '{0}' could not be loaded: {1}", controlPath, ex.ToString()));
                    }
                }
            }


            // add controls to the pane
            pane.Controls.Add(ctrlContainer);
        }
예제 #2
0
        private void AddModuleToContentPane(Control pane, PageModule module, string ctrlKey, bool editMode)
        {
            string defId = module.ModuleDefinitionID;

            if (!PortalConfiguration.ModuleDefinitions.ContainsKey(defId))
            {
                ShowError(pane, String.Format("Module definition '{0}' could not be found", defId));
                return;
            }

            ModuleDefinition definition = PortalConfiguration.ModuleDefinitions[defId];
            ModuleControl    control    = null;

            if (String.IsNullOrEmpty(ctrlKey))
            {
                control = definition.DefaultControl;
            }
            else
            {
                if (definition.Controls.ContainsKey(ctrlKey))
                {
                    control = definition.Controls[ctrlKey];
                }
            }

            if (control == null)
            {
                return;
            }

            // container
            string containerName = editMode ?
                                   PortalConfiguration.SiteSettings["AdminContainer"] : PortalConfiguration.SiteSettings["PortalContainer"];

            if (!editMode && !String.IsNullOrEmpty(module.ContainerSrc))
            {
                containerName = module.ContainerSrc;
            }

            if (editMode && !String.IsNullOrEmpty(module.AdminContainerSrc))
            {
                containerName = module.AdminContainerSrc;
            }

            // load container
            string  containerPath = "~/" + CONTAINERS_FOLDER + "/" + this.Theme + "/" + containerName;
            Control ctrlContainer = null;

            try
            {
                ctrlContainer = LoadControl(containerPath);
            }
            catch (Exception ex)
            {
                ShowError(pane, String.Format("Container '{0}' could not be loaded: {1}", containerPath, ex.ToString()));
                return;
            }

            string title = module.Title;

            if (editMode || String.IsNullOrEmpty(title))
            {
                // get control title
                title = control.Title;
            }

            string iconFile = module.IconFile;

            if (editMode || String.IsNullOrEmpty(iconFile))
            {
                // get control icon
                iconFile = control.IconFile;
            }

            // set title
            Label lblModuleTitle = (Label)ctrlContainer.FindControl(MODULE_TITLE_CONTROL_ID);

            if (lblModuleTitle != null)
            {
                lblModuleTitle.Text = GetLocalizedModuleTitle(title);
            }

            // set icon
            System.Web.UI.WebControls.Image imgModuleIcon = (System.Web.UI.WebControls.Image)ctrlContainer.FindControl(MODULE_ICON_CONTROL_ID);
            if (imgModuleIcon != null)
            {
                if (String.IsNullOrEmpty(iconFile))
                {
                    imgModuleIcon.Visible = false;
                }
                else
                {
                    string iconPath = "~/" + THEMES_FOLDER + "/" + this.Theme + "/" + ICONS_FOLDER + "/" + iconFile;
                    imgModuleIcon.ImageUrl = iconPath;
                }
            }

            Control contentPane = ctrlContainer.FindControl(CONTENT_PANE_NAME);

            if (contentPane != null)
            {
                string controlName = control.Src;
                string controlPath = "~/" + DESKTOP_MODULES_FOLDER + "/" + controlName;
                if (!String.IsNullOrEmpty(controlName))
                {
                    PortalControlBase ctrlControl = null;
                    try
                    {
                        ctrlControl                  = (PortalControlBase)LoadControl(controlPath);
                        ctrlControl.Module           = module;
                        ctrlControl.ContainerControl = ctrlContainer;
                        contentPane.Controls.Add(ctrlControl);
                    }
                    catch (Exception ex)
                    {
                        ShowError(contentPane, String.Format("Control '{0}' could not be loaded: {1}", controlPath, ex.ToString()));
                    }
                }
            }


            // add controls to the pane
            pane.Controls.Add(ctrlContainer);
        }
예제 #3
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);
            }
        }
예제 #4
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);
            }
        }