/// <summary>
        /// Loads the Portal Definition
        /// </summary>
        /// <returns>Portal Definition</returns>
        public static PortalDefinition Load()
        {
            // Lookup in Cache
            PortalDefinition pd = (PortalDefinition)System.Web.HttpContext.Current.Cache["PortalSettings"];

            if (pd != null)
            {
                return(pd);
            }

            // Load Portaldefinition
            XmlTextReader xmlReader = null;

            try
            {
                xmlReader = new XmlTextReader(Config.PortalDefinitionPhysicalPath);
                pd        = (PortalDefinition)xmlPortalDef.Deserialize(xmlReader);

                UpdatePortalDefinitionProperties(pd.tabs, null);

                // Add to Cache
                System.Web.HttpContext.Current.Cache.Insert("PortalSettings", pd,
                                                            new System.Web.Caching.CacheDependency(Config.PortalDefinitionPhysicalPath));
            }
            finally
            {
                if (xmlReader != null)
                {
                    xmlReader.Close();
                }
            }

            return(pd);
        }
        public static void DeleteTab(string reference)
        {
            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab t = pd.GetTab(reference);

            if (t.parent == null) // Root Tab
            {
                for (int i = 0; i < pd.tabs.Count; i++)
                {
                    if (((PortalDefinition.Tab)pd.tabs[i]).reference == reference)
                    {
                        pd.tabs.RemoveAt(i);
                        break;
                    }
                }
            }
            else
            {
                PortalDefinition.Tab pt = t.parent;
                for (int i = 0; i < pt.tabs.Count; i++)
                {
                    if (((PortalDefinition.Tab)pt.tabs[i]).reference == reference)
                    {
                        pt.tabs.RemoveAt(i);
                        break;
                    }
                }
            }

            pd.Save();
        }
Exemple #3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Load Protal Definition and the current Tab
            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab currentTab = pd.GetTab(Request["TabRef"]);
            if (currentTab == null)
            {
                return;
            }

            // Great, we are a top level Tab
            if (currentTab.parent == null)
            {
                return;
            }

            ArrayList tabList = new ArrayList();

            while (currentTab != null)
            {
                DisplayTabItem dt = new DisplayTabItem();
                tabList.Insert(0, dt);

                dt.m_Text = currentTab.title;
                dt.m_URL  = Portal.API.Config.GetTabUrl(currentTab.reference);

                // one up...
                currentTab = currentTab.parent;
            }

            // Bind Repeater
            tabpath.DataSource = tabList;
            tabpath.DataBind();
        }
Exemple #4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            TabMainMenuContainer.Visible = Page.User.IsInRole(Portal.API.Config.AdminRole);

            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab t = PortalDefinition.CurrentTab;

            if (t.left.Count == 0)
            {
                TabMiddle.Style["margin-left"] = "0em";
            }
            if (t.right.Count == 0)
            {
                TabMiddle.Style["margin-right"] = "0em";
            }

            bool showPath = true;

            try
            {
                if (!bool.TryParse(System.Configuration.ConfigurationManager.AppSettings["ShowSubTabPath"], out showPath))
                {
                    showPath = true;
                }
            }
            catch (System.Configuration.ConfigurationErrorsException) { }
            if (showPath)
            {
                TabPath.Controls.Add(LoadControl("TabPath.ascx"));
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Load Protal Definition and the current Tab
            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab currentTab = pd.GetTab(Request["TabRef"]);

            // Foreach Tab...
            ArrayList tabList    = new ArrayList();
            ArrayList subTabList = new ArrayList();

            foreach (PortalDefinition.Tab t in pd.tabs)
            {
                DisplayTabItem dt = BuildDisplayTabItem(t);
                if (dt != null)
                {
                    // Set current Tab Property
                    if (currentTab == null)
                    {
                        if (tabList.Count == 1)
                        {
                            // First tab -> default
                            dt.CurrentTab = true;
                        }
                    }
                    else
                    {
                        dt.CurrentTab = currentTab.RootTab == t;
                    }
                    tabList.Add(dt);

                    if (dt.CurrentTab && Config.TabMenuShowSubTabs)
                    {
                        foreach (PortalDefinition.Tab st in t.tabs)
                        {
                            DisplayTabItem sdt = BuildDisplayTabItem(st);
                            if (sdt != null)
                            {
                                subTabList.Add(sdt);
                            }
                        }
                    }
                }
            }             // foreach(tab)

            // Bind Repeater
            Tabs.DataSource = tabList;
            Tabs.DataBind();

            if (subTabList.Count > 0)
            {
                TabMenu_SubTab.Visible = true;
                SubTabs.DataSource     = subTabList;
                SubTabs.DataBind();
            }
            else
            {
                TabMenu_SubTab.Visible = false;
            }
        }
Exemple #6
0
        /// <summary>
        /// Returns the requested Tab.
        /// If the user has no right null is returned.
        /// </summary>
        /// <param name="tabRef"></param>
        /// <returns></returns>
        public static PortalDefinition.Tab GetEditTab(string tabRef)
        {
            PortalDefinition.Tab editTab = null;

            if (HttpContext.Current.User.IsInRole(Config.AdminRole))
            {
                PortalDefinition pd = PortalDefinition.Load();
                editTab = pd.GetTab(tabRef);
            }
            return(editTab);
        }
		private DisplayTabItem BuildDisplayTabItem(PortalDefinition.Tab t)
		{
			if(UserManagement.HasViewRights(Page.User, t.roles))
			{
				// User may view the tab, create a Display Item
        DisplayTabItem dt = new DisplayTabItem(t, false);

				return dt;
			}

			return null;
		}
Exemple #8
0
        protected void OnAddTab(object sender, EventArgs args)
        {
            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab t = PortalDefinition.Tab.Create();

            pd.GetTab(Request["TabRef"]).tabs.Add(t);

            pd.Save();

            Response.Redirect(Helper.GetEditTabLink(t.reference));
        }
Exemple #9
0
        protected void OnDeleteTab(object sender, EventArgs args)
        {
            PortalDefinition.Tab t = PortalDefinition.CurrentTab;
            PortalDefinition.DeleteTab(t.reference);

            if (t.parent == null)
            {
                Response.Redirect(Helper.GetTabLink(""));
            }
            else
            {
                Response.Redirect(Helper.GetTabLink(t.parent.reference));
            }
        }
Exemple #10
0
        protected void OnAddRightModule(object sender, EventArgs args)
        {
            PortalDefinition pd = PortalDefinition.Load();

            // Do NOT use GetCurrentTab! You will be unable to save
            PortalDefinition.Tab t = pd.GetTab(Request["TabRef"]);

            PortalDefinition.Module m = PortalDefinition.Module.Create();
            t.right.Add(m);

            pd.Save();

            Response.Redirect(Helper.GetEditModuleLink(m.reference));
        }
        protected void OnAddMiddleModule(object sender, EventArgs args)
        {
            PortalDefinition pd = PortalDefinition.Load();

            // Do NOT use GetCurrentTab! You will be unable to save
            PortalDefinition.Tab t = pd.GetTab(Request["TabRef"]);

            PortalDefinition.Module m = new PortalDefinition.Module();
            m.reference = Guid.NewGuid().ToString();
            t.middle.Add(m);

            pd.Save();

            Response.Redirect(Helper.GetEditModuleLink(m.reference));
        }
        override protected void OnInit(EventArgs e)
        {
            PortalDefinition.Tab tab = PortalDefinition.GetCurrentTab();

            if (UserManagement.HasViewRights(Page.User, tab.roles))
            {
                // Render
                RenderModules(left, tab, tab.left);
                RenderModules(middle, tab, tab.middle);
                RenderModules(right, tab, tab.right);
            }

            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            InitializeComponent();
            base.OnInit(e);
        }
        protected void OnMoveRight(object sender, System.EventArgs args)
        {
            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab t = pd.GetTab(Request["TabRef"]);

            for (int i = 0; i < 2; i++)
            {
                ArrayList a = null;
                switch (i)
                {
                case 0:
                    a = t.left;
                    break;

                case 1:
                    a = t.middle;
                    break;
                }

                for (int idx = 0; idx < a.Count; idx++)
                {
                    if (((PortalDefinition.Module)a[idx]).reference == ModuleDef.reference)
                    {
                        PortalDefinition.Module m = (PortalDefinition.Module)a[idx];
                        a.RemoveAt(idx);
                        if (i == 0)
                        {
                            t.middle.Insert(t.middle.Count, m);
                        }
                        else if (i == 1)
                        {
                            t.right.Insert(t.right.Count, m);
                        }
                        else
                        {
                            throw new InvalidOperationException("Invalid Column");
                        }

                        pd.Save();
                        Server.Transfer(Request.Url.PathAndQuery);
                        return;
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ApplyAutoLogin();

            string moduleType = Server.UrlDecode(Request.QueryString["Type"]);
            string moduleRef  = Server.UrlDecode(Request.QueryString["Module"]);

            // Check the required attributes and redirect, if not specified.
            if (String.IsNullOrEmpty(moduleType) || String.IsNullOrEmpty(moduleRef))
            {
                Response.Redirect(Portal.API.Config.MainPage);
            }

            // Check if the user has access to the Module.
            PortalDefinition portDef = PortalDefinition.Load();

            if (CheckAccess(portDef.tabs, moduleType, moduleRef))
            {
                IDownloadProcessor downloadObj = null;

                // Hardcoded at the moment. Possible replacement with dynamic creation i.e. the activator class.
                if (0 == "FileBrowser".CompareTo(Request.QueryString["Type"]))
                {
                    downloadObj = new Portal.Modules.FileBrowser.Download();
                }

                // Process the Download.
                if (downloadObj != null)
                {
                    Response.Clear();
                    try
                    {
                        downloadObj.Process(Request, Response, moduleType, moduleRef);
                    }
                    catch (Exception exc)
                    {
                        Response.Clear();
                        errorMessage.Text = exc.Message;
                        return;
                    }
                    Response.End();
                    return;
                }
            }
            errorMessage.Text = "File not found or access denied";
        }
        protected void OnMoveDown(object sender, System.EventArgs args)
        {
            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab t = pd.GetTab(Request["TabRef"]);

            for (int i = 0; i < 3; i++)
            {
                ArrayList a = null;
                switch (i)
                {
                case 0:
                    a = t.left;
                    break;

                case 1:
                    a = t.middle;
                    break;

                case 2:
                    a = t.right;
                    break;
                }

                for (int idx = 0; idx < a.Count; idx++)
                {
                    if (((PortalDefinition.Module)a[idx]).reference == ModuleDef.reference)
                    {
                        if (idx >= a.Count - 1)
                        {
                            return;
                        }

                        PortalDefinition.Module m = (PortalDefinition.Module)a[idx];
                        a.RemoveAt(idx);
                        a.Insert(idx + 1, m);

                        pd.Save();
                        Server.Transfer(Request.Url.PathAndQuery);
                        return;
                    }
                }
            }
        }
    public DisplayTabItem(PortalDefinition.Tab t, bool currTab)
    {
      m_Text = t.title;
      m_CurrentTab = currTab;
      m_URL = Helper.GetTabLink(t.reference);
      m_Reference = t.reference;

      // Check if image exist.
      if (t.imgPathInactive.Trim() != string.Empty)
      {
        // if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(t.imgPathInactive)))
        m_ImgPathI = t.imgPathInactive;
      }
      if (t.imgPathActive.Trim() != string.Empty)
      {
        // if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(t.imgPathActive)))
        m_ImgPathA = t.imgPathActive;
      }
    }
Exemple #17
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Load Protal Definition and the current Tab
            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab currentTab = pd.GetTab(Request["TabRef"]);

            // Foreach Tab...
            ArrayList tabList = new ArrayList();

            foreach (PortalDefinition.Tab t in pd.tabs)
            {
                if (UserManagement.HasViewRights(Page.User, t.roles))
                {
                    // User may view the tab, create a Display Item
                    DisplayTabItem dt = new DisplayTabItem();
                    tabList.Add(dt);

                    dt.m_Text = t.title;

                    // Set current Tab Property
                    if (currentTab == null)
                    {
                        if (tabList.Count == 1)
                        {
                            // First tab -> default
                            dt.m_CurrentTab = true;
                        }
                    }
                    else
                    {
                        dt.m_CurrentTab = currentTab.GetRootTab() == t;
                    }

                    dt.m_URL = Helper.GetTabLink(t.reference);
                }         // if(User may view)
            }             // foreach(tab)

            // Bind Repeater
            Tabs.DataSource = tabList;
            Tabs.DataBind();
        }
Exemple #18
0
        /// <summary>
        /// Loads the Portal Definition
        /// </summary>
        /// <returns>Portal Definition</returns>
        public static PortalDefinition Load()
        {
            XmlTextReader    xmlReader = null;
            PortalDefinition pd        = null;

            try
            {
                xmlReader = new XmlTextReader(Config.GetPortalDefinitionPhysicalPath());
                pd        = (PortalDefinition)xmlPortalDef.Deserialize(xmlReader);
                xmlReader.Close();

                UpdatePortalDefinitionProperties(pd.tabs, null);
            }
            catch (Exception e)
            {
                if (xmlReader != null)
                {
                    xmlReader.Close();
                }
                throw new Exception(e.Message, e);
            }

            return(pd);
        }
Exemple #19
0
        /// <summary>
        /// Returns the proper edit ascx Control. Uses the current Page to load the Control.
        /// If the user has no right a error control is returned
        /// </summary>
        /// <param name="p">The current Page</param>
        /// <returns>Edit ascx Control</returns>
        internal static Control GetEditControl(Page p)
        {
            PortalDefinition.Tab    tab = PortalDefinition.GetCurrentTab();
            PortalDefinition.Module m   = tab.GetModule(p.Request["ModuleRef"]);

            if (!UserManagement.HasEditRights(HttpContext.Current.User, m.roles))
            {
                // No rights, return a error Control
                Label l = new Label();
                l.CssClass = "Error";
                l.Text     = "Access denied!";
                return(l);
            }
            m.LoadModuleSettings();
            Module em = null;

            if (m.moduleSettings != null)
            {
                // Module Settings are present, use custom ascx Control
                em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + m.moduleSettings.editCtrl);
            }
            else
            {
                // Use default ascx control (Edit[type].ascx)
                em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + "Edit" + m.type + ".ascx");
            }

            // Initialize the control
            em.InitModule(
                tab.reference,
                m.reference,
                Config.GetModuleVirtualPath(m.type),
                true);

            return(em);
        }
 /// <summary>
 /// Initializes the Control
 /// </summary>
 /// <param name="md"></param>
 internal void SetModuleConfig(PortalDefinition.Module md)
 {
     ModuleDef = md;
     lnkEditLink.ModuleRef = md.reference;
 }
Exemple #21
0
        /// <summary>
        /// Returns the current Tab.
        /// The current HTTPContext is used to determinate the current Tab (TabRef=[ref])
        /// </summary>
        /// <returns>The current Tab or the default Tab</returns>
        public static Tab GetCurrentTab()
        {
            PortalDefinition pd = Load();

            return(pd.GetTab(HttpContext.Current.Request["TabRef"]));
        }
    /// <summary>
    /// Überprüft ob diese Url im angegebenen Modul konfiguriert ist.
    /// </summary>
    /// <param name="szTab"></param>
    /// <param name="HostingModule"></param>
    /// <param name="szUrl"></param>
    /// <returns></returns>
    private bool UrlExist(string szTab, PortalDefinition.Module HostingModule, string szUrl)
    {
      bool bUrlFound = false;

      // Wir laden das Modul in den Speicher, damit wir einfach auf die Konfiguration zugrefen können.
      Portal.API.Module Md = (Portal.API.Module)LoadControl(Config.GetModuleVirtualPath(HostingModule.type) + 
                              HostingModule.type + ".ascx");

      // Modul initialisieren.
      Md.InitModule(szTab, HostingModule.reference, HostingModule.type, 
                    Config.GetModuleDataVirtualPath(HostingModule.type), false);

      // Konfiguration laden.
      DataSet ModConfig = Md.ReadConfig();
      if(ModConfig != null)
      {
        // Nun iterieren wir über alle Url's in diesem Module.
        foreach(DataRow Entry in ModConfig.Tables["news"].Rows)
        {
          if(szUrl == (string) Entry["Url"])
            return true;
        }
      }

      return bUrlFound;
    }
Exemple #23
0
 public static string GetEditLink(PortalDefinition.Module module)
 {
   // Link depends on the Edit Type (Inplace / Fullscreen).
   bool isInplace = module.moduleSettings != null && module.moduleSettings.IsInplaceEdit;
   if (isInplace)
   {
     return Config.GetTabUrl(HttpContext.Current.Request["TabRef"]) + "?Edit=Content&ModuleRef="
                                                                 + module.reference + "&TabRef=";
   }
   else
   {
     return "EditPageTable.aspx?ModuleRef=" + module.reference + "&TabRef=" + HttpContext.Current.Request["TabRef"];
   }
 }
Exemple #24
0
 /// <summary>
 /// Checks if this module is requested to appear in edit mode.
 /// </summary>
 public static bool IsEditModuleRequested(PortalDefinition.Module module)
 {
   HttpRequest request = HttpContext.Current.Request;
   string editMode = request["Edit"];
   string moduleRef = request["ModuleRef"];
   bool dataAvailable = !string.IsNullOrEmpty(editMode) && !string.IsNullOrEmpty(moduleRef);
   return dataAvailable  && editMode == "Content" && moduleRef == module.reference
     && module.moduleSettings.HasEditCtrl;
 }
 public abstract void SetModuleConfig(PortalDefinition.Module md);
		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);
					}
				}
			}
		}
 /// <summary>
 /// Initializes the Control
 /// </summary>
 /// <param name="md"></param>
 public override void SetModuleConfig(PortalDefinition.Module md)
 {
     ModuleDef = md;
     lnkEditLink.Module = md;
 }
        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
                }
            }
        }