Beispiel #1
0
        protected override void RenderContents(HtmlTextWriter output)
        {
            output.Write("<div class=\"navbar\">");
            if (DesignMode)
            {
                output.Write("<a href=\"#\">Links</a><a href=\"#\">Go</a><a href=\"#\">Here</a>");
            }
            else
            {
                CompiledSecurityInfo level = CompiledSecurityInfo.CompileAccessLevel(DatabaseManager.Current, Page.User);
                string appPath = Page.Request.ApplicationPath;

                if (appPath == "/")
                    appPath = "";

                output.Write("<a href=\"" + appPath + "/Default.aspx\">Home</a>");
                if (level["CanAccessBackend"])
                    output.Write("<a href=\"" + appPath + "/Admin/Default.aspx\">Admin Panel</a>");

                string scopes = "";
                foreach (int scope in level.Scopes)
                {
                    scopes += scope + ",";
                }

                scopes = scopes.Remove(scopes.Length - 1);

                using (SqlCommand cmd = DatabaseManager.Current.CreateCommand("SELECT * FROM NavbarLinks WHERE Scope IS NULL OR Scope IN (" + scopes + ")"))
                {
                    using (SqlDataReader r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            NavbarLink link = new NavbarLink(r);
                            output.Write("<a href=\"" + link.Url + "\" target=\"_blank\">" + link.Text + "</a>");
                        }
                    }
                }
            }

            output.Write("</div>");
        }
 public static NavbarLink <THelper> SetDisabled <THelper>(this NavbarLink <THelper> navbarLink, bool disabled = true)
     where THelper : BootstrapHelper <THelper>
 {
     navbarLink.Disabled = disabled;
     return(navbarLink);
 }
 public static NavbarLink <THelper> SetActive <THelper>(this NavbarLink <THelper> navbarLink, bool active = true)
     where THelper : BootstrapHelper <THelper>
 {
     navbarLink.Active = active;
     return(navbarLink);
 }