示例#1
0
 public static Skin GetSkin(PageBase Page)
 {
     Skin ctlSkin = null;
     string skinSource = Null.NullString;
     if ((Page.Request.QueryString["SkinSrc"] != null))
     {
         skinSource = SkinController.FormatSkinSrc(Common.Globals.QueryStringDecode(Page.Request.QueryString["SkinSrc"]) + ".ascx", Page.PortalSettings);
         ctlSkin = LoadSkin(Page, skinSource);
     }
     if (ctlSkin == null)
     {
         if (Page.Request.Cookies["_SkinSrc" + Page.PortalSettings.PortalId.ToString()] != null)
         {
             if (!String.IsNullOrEmpty(Page.Request.Cookies["_SkinSrc" + Page.PortalSettings.PortalId.ToString()].Value))
             {
                 skinSource = SkinController.FormatSkinSrc(Page.Request.Cookies["_SkinSrc" + Page.PortalSettings.PortalId.ToString()].Value + ".ascx", Page.PortalSettings);
                 ctlSkin = LoadSkin(Page, skinSource);
             }
         }
     }
     if (ctlSkin == null)
     {
         if (Common.Globals.IsAdminSkin())
         {
             skinSource = SkinController.FormatSkinSrc(Page.PortalSettings.DefaultAdminSkin, Page.PortalSettings);
         }
         else
         {
             skinSource = Page.PortalSettings.ActiveTab.SkinSrc;
         }
         if (!String.IsNullOrEmpty(skinSource))
         {
             skinSource = SkinController.FormatSkinSrc(skinSource, Page.PortalSettings);
             ctlSkin = LoadSkin(Page, skinSource);
         }
     }
     if (ctlSkin == null)
     {
         skinSource = SkinController.FormatSkinSrc(SkinController.GetDefaultPortalSkin(), Page.PortalSettings);
         ctlSkin = LoadSkin(Page, skinSource);
     }
     Page.PortalSettings.ActiveTab.SkinPath = SkinController.FormatSkinPath(skinSource);
     ctlSkin.ID = "dnn";
     return ctlSkin;
 }
示例#2
0
 private static Skin LoadSkin(PageBase Page, string SkinPath)
 {
     Skin ctlSkin = null;
     try
     {
         string SkinSrc = SkinPath;
         if (SkinPath.ToLower().IndexOf(Common.Globals.ApplicationPath) != -1)
         {
             SkinPath = SkinPath.Remove(0, Common.Globals.ApplicationPath.Length);
         }
         ctlSkin = ControlUtilities.LoadControl<Skin>(Page, SkinPath);
         ctlSkin.SkinSrc = SkinSrc;
         ctlSkin.DataBind();
     }
     catch (Exception exc)
     {
         PageLoadException lex = new PageLoadException("Unhandled error loading page.", exc);
         if (TabPermissionController.CanAdminPage())
         {
             Label SkinError = (Label)Page.FindControl("SkinError");
             SkinError.Text = string.Format(Localization.GetString("SkinLoadError", Localization.GlobalResourceFile), SkinPath, Page.Server.HtmlEncode(exc.Message));
             SkinError.Visible = true;
         }
         Exceptions.LogException(lex);
     }
     return ctlSkin;
 }