Beispiel #1
0
        private void RenderModules(HtmlTableCell td, PortalDefinition.Tab tab, ArrayList modules)
        {
            if (modules.Count == 0)
            {
                td.Visible = false;
                return;
            }
            foreach (PortalDefinition.Module md in modules)
            {
                if (UserManagement.HasViewRights(Page.User, md.roles))
                {
                    md.LoadModuleSettings();

                    // Initialize the Module
                    Control m       = null;
                    bool    visible = false;
                    try
                    {
                        // Is the Edit Mode Requested?
                        if (Helper.IsEditModuleRequested(md))
                        {
                            // Load the Edit Mode of the module.
                            m = Helper.GetEditControl(Page);
                        }

                        if (m == null)
                        {
                            // Load the View of the module.
                            if (md.moduleSettings == null)
                            {
                                m = LoadControl(Config.GetModuleVirtualPath(md.type) + md.type + ".ascx");
                            }
                            else
                            {
                                m = LoadControl(Config.GetModuleVirtualPath(md.type) + md.moduleSettings.ctrl);
                            }

                            ((Module)m).InitModule(tab.reference, md.reference, md.type,
                                                   Config.GetModuleDataVirtualPath(md.type), UserManagement.HasEditRights(Page.User, md.roles));

                            visible = ((Module)m).IsVisible();
                        }
                        else
                        {
                            visible = true;
                        }

                        if (visible)
                        {
                            // Add ModuleContainer
                            HtmlGenericControl cont = new HtmlGenericControl("div");
                            cont.Attributes.Add("class", "ModuleContainer");
                            td.Controls.Add(cont);

                            // Add Module Header
                            ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx");
                            mh.SetModuleConfig(md);
                            cont.Controls.Add(mh);

                            // Add Module Body Container
                            HtmlGenericControl bodyCont = new HtmlGenericControl("div");
                            bodyCont.Attributes.Add("class", "Module");
                            cont.Controls.Add(bodyCont);

                            // Add Module
                            HtmlGenericControl div = new HtmlGenericControl("div");
                            div.Controls.Add(m);
                            bodyCont.Controls.Add(div);
                        }
                    }
                    catch (Exception e)
                    {
                        if (Config.ShowModuleExceptions)
                        {
                            throw new Exception(e.Message, e);
                        }
                        // Add ModuleContainer
                        HtmlGenericControl cont = new HtmlGenericControl("div");
                        cont.Attributes.Add("class", "ModuleContainer");
                        cont.Controls.Add(m);
                        td.Controls.Add(cont);

                        // Add Module Header
                        ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx");
                        mh.SetModuleConfig(md);
                        cont.Controls.Add(mh);

                        // Add Error Module
                        ModuleFailed mf = (ModuleFailed)LoadControl("ModuleFailed.ascx");
                        while (e != null)
                        {
                            mf.Message += e.GetType().Name + ": ";
                            mf.Message += e.Message + "<br>";
                            e           = e.InnerException;
                        }

                        mf.Message = mf.Message.Remove(mf.Message.Length - 4, 4);

                        HtmlGenericControl div = new HtmlGenericControl("div");
                        div.Attributes.Add("class", "Module");
                        div.Controls.Add(mf);
                        cont.Controls.Add(div);
                    }
                }
            }
        }
        private void RenderModules(HtmlTableCell td, PortalDefinition.Tab tab, ArrayList modules)
        {
            if (modules.Count == 0)
            {
                td.Visible = false;
                return;
            }
            foreach (PortalDefinition.Module md in modules)
            {
                if (UserManagement.HasViewRights(Page.User, md.roles))
                {
                    md.LoadModuleSettings();

                    // Initialize the Module
                    Module m = null;
#if !DEBUG
                    try
                    {
#endif
                    if (md.moduleSettings == null)
                    {
                        m = (Module)LoadControl(Config.GetModuleVirtualPath(md.type) + md.type + ".ascx");
                    }
                    else
                    {
                        m = (Module)LoadControl(Config.GetModuleVirtualPath(md.type) + md.moduleSettings.ctrl);
                    }
                    m.InitModule(tab.reference, md.reference,
                                 Config.GetModuleVirtualPath(md.type),
                                 UserManagement.HasEditRights(Page.User, md.roles));
                    if (m.IsVisible())
                    {
                        // Add Module Header
                        ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx");
                        mh.SetModuleConfig(md);
                        td.Controls.Add(mh);

                        // Add Module
                        HtmlGenericControl div = new HtmlGenericControl("div");
                        div.Attributes.Add("class", "Module");
                        div.Controls.Add(m);
                        td.Controls.Add(div);
                    }
#if !DEBUG
                }
                catch (Exception e)
                {
                    // Add Module Header
                    ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx");
                    mh.SetModuleConfig(md);
                    td.Controls.Add(mh);

                    // Add Error Module
                    ModuleFailed mf = (ModuleFailed)LoadControl("ModuleFailed.ascx");
                    while (e != null)
                    {
                        mf.Message += e.GetType().Name + ": ";
                        mf.Message += e.Message + "<br>";
                        e           = e.InnerException;
                    }

                    mf.Message = mf.Message.Remove(mf.Message.Length - 4, 4);

                    HtmlGenericControl div = new HtmlGenericControl("div");
                    div.Attributes.Add("class", "Module");
                    div.Controls.Add(mf);
                    td.Controls.Add(div);
                }
#endif
                }
            }
        }