Beispiel #1
0
        private void SetupCss()
        {
            if (Page.Master == null)
            {
                return;
            }

            StyleSheetCombiner style = Page.Master.FindControl("StyleSheetCombiner") as StyleSheetCombiner;

            if (style != null)
            {
                style.IncludeTwitterCss = true;
            }

            //try
            //{
            //    Control head = Page.Master.FindControl("Head1");
            //    if (head == null) { return; }

            //    if (head.FindControl("twittercss") == null)
            //    {
            //        Literal cssLink = new Literal();
            //        cssLink.ID = "twittercsss";
            //        cssLink.Text = "\n<link rel='stylesheet' type='text/css' href='http://widgets.twimg.com/j/1/widget.css' />";

            //            head.Controls.Add(cssLink);

            //    }
            //}
            //catch (HttpException) { }
        }
        override protected void OnPreInit(EventArgs e)
        {
            SetMasterInBasePage = false;

            base.OnPreInit(e);

            try
            {
                SetupMasterPage();
            }
            catch (HttpException ex)
            {
                log.Error(String.Format("{0} - Error setting master page. Will try settingto default skin", SiteUtils.GetIP4Address()), ex);
                SetupFailsafeMasterPage();
            }

            StyleSheetCombiner styleCombiner = (StyleSheetCombiner)Master.FindControl("StyleSheetCombiner");

            if (styleCombiner != null)
            {
                styleCombiner.AllowPageOverride = allowPageOverride;
            }

            this.Load += new EventHandler(Page_Load);
        }
Beispiel #3
0
        public static void SetupStyle(
            List <MarkupCss> markupCss,
            ModuleConfiguration config,
            SuperFlexiDisplaySettings displaySettings,
            string clientID,
            int moduleID,
            int pageID,
            Page page,
            Control control)
        {
            string styleLinkFormat = "\n<link rel=\"stylesheet\" href=\"{0}\" media=\"{2}\" data-name=\"{1}\">";
            string rawCSSFormat    = "\n<style type=\"text/css\" data-name=\"{1}\" media=\"{2}\">\n{0}\n</style>";

            foreach (MarkupCss style in markupCss)
            {
                StringBuilder sbStyleText = new StringBuilder();
                StringBuilder sbStyleName = new StringBuilder();

                sbStyleName.Append(String.IsNullOrWhiteSpace(style.Name) ? clientID + "flexiStyle_" + markupCss.IndexOf(style) : "flexiStyle_" + style.Name);
                SuperFlexiHelpers.ReplaceStaticTokens(sbStyleName, config, false, displaySettings, moduleID, pageID, out sbStyleName);
                string scriptName = sbStyleName.ToString();
                if (!String.IsNullOrWhiteSpace(style.Url))
                {
                    sbStyleText.Append(string.Format(styleLinkFormat,
                                                     style.Url.Replace("$_SitePath_$", "/Data/Sites/" + CacheHelper.GetCurrentSiteSettings().SiteId.ToString() + "/"),
                                                     scriptName, style.Media));
                }
                else if (!String.IsNullOrWhiteSpace(style.CSS))
                {
                    sbStyleText.Append(string.Format(rawCSSFormat, style.CSS, scriptName, style.Media));
                }

                SuperFlexiHelpers.ReplaceStaticTokens(sbStyleText, config, false, displaySettings, moduleID, pageID, out sbStyleText);

                LiteralControl theLiteral = new LiteralControl();
                theLiteral.Text = sbStyleText.ToString();

                StyleSheetCombiner ssc = (StyleSheetCombiner)page.Header.FindControl("StyleSheetCombiner");

                if (ssc != null)
                {
                    int sscIndex = page.Header.Controls.IndexOf(ssc);
                    if (style.RenderAboveSSC)
                    {
                        page.Header.Controls.AddAt(sscIndex, theLiteral);
                    }
                    else
                    {
                        page.Header.Controls.AddAt(sscIndex + 1, theLiteral);
                    }
                }
                else
                {
                    page.Header.Controls.AddAt(0, theLiteral);
                }
            }
        }
Beispiel #4
0
        protected override void OnPreInit(EventArgs e)
        {
            EnsureSiteSettings();

            if (siteSettings.MyPageSkin.Length == 0)
            {
                base.OnPreInit(e);
                return;
            }

            bool isPreviewSkin = (Request.Params.Get("skin") != null);

            SetMasterInBasePage = isPreviewSkin;

            base.OnPreInit(e);

            if (isPreviewSkin)
            {
                return;
            }


            if (siteSettings.MyPageSkin.Length > 0)
            {
                SiteUtils.SetMasterPage(this, siteSettings, siteSettings.MyPageSkin);
            }
            else
            {
                SiteUtils.SetMasterPage(this, siteSettings, siteSettings.Skin);
            }

            MPLeftPane  = (ContentPlaceHolder)Master.FindControl("leftContent");
            MPContent   = (ContentPlaceHolder)Master.FindControl("mainContent");
            MPRightPane = (ContentPlaceHolder)Master.FindControl("rightContent");
            MPPageEdit  = (ContentPlaceHolder)Master.FindControl("pageEditContent");
            AltPane1    = (ContentPlaceHolder)Master.FindControl("altContent1");
            AltPane2    = (ContentPlaceHolder)Master.FindControl("altContent2");

            StyleSheetCombiner style = Page.Master.FindControl("StyleSheetCombiner") as StyleSheetCombiner;

            if (style == null)
            {
                return;
            }

            if (siteSettings.MyPageSkin.Length > 0)
            {
                style.OverrideSkinName = siteSettings.MyPageSkin;
            }
            else
            {
                style.OverrideSkinName = siteSettings.Skin;
            }
        }
Beispiel #5
0
        protected override void OnPreInit(EventArgs e)
        {
            EnsureSiteSettings();

            if (siteSettings.MyPageSkin.Length == 0)
            {
                base.OnPreInit(e);
                return;
            }

            bool isPreviewSkin = (Request.Params.Get("skin") != null);

            SetMasterInBasePage = isPreviewSkin;

            base.OnPreInit(e);

            if (isPreviewSkin)
            {
                return;
            }

            MasterPageFile = SiteUtils.GetMyPageMasterPage(siteSettings);

            if (Global.RegisteredVirtualThemes)
            {
                this.Theme = "mypage" + siteSettings.SiteId.ToInvariantString();
            }

            MPLeftPane  = (ContentPlaceHolder)Master.FindControl("leftContent");
            MPContent   = (ContentPlaceHolder)Master.FindControl("mainContent");
            MPRightPane = (ContentPlaceHolder)Master.FindControl("rightContent");
            MPPageEdit  = (ContentPlaceHolder)Master.FindControl("pageEditContent");
            AltPane1    = (ContentPlaceHolder)Master.FindControl("altContent1");
            AltPane2    = (ContentPlaceHolder)Master.FindControl("altContent2");

            StyleSheetCombiner style = Page.Master.FindControl("StyleSheetCombiner") as StyleSheetCombiner;

            if (style == null)
            {
                return;
            }

            if (siteSettings.MyPageSkin.Length > 0)
            {
                style.OverrideSkinName = siteSettings.MyPageSkin;
            }
            else
            {
                style.OverrideSkinName = siteSettings.Skin;
            }

            AddClassToBody("mypage");
        }
        private void SetupCss()
        {
            if (assumeScriptsAreLoaded)
            {
                return;
            }

            //<link href="/ClientScript/greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" />
            if (Page.Master == null)
            {
                return;
            }


            StyleSheetCombiner style = Page.Master.FindControl("StyleSheetCombiner") as StyleSheetCombiner;

            if (style != null)
            {
                style.IncludeGreyBoxCss = true;
            }


            //Control head = Page.Master.FindControl("Head1");
            //if (head == null) { return; }

            //try
            //{
            //    if (head.FindControl("gb_styles") == null)
            //    {
            //        Literal cssLink = new Literal();
            //        cssLink.ID = "gb_styles";
            //        cssLink.Text = "\n<link rel='stylesheet' type='text/css' href='"
            //            + Page.ResolveUrl(scriptBaseUrl + "gb_styles.css")
            //             + "' media='all' />";

            //        head.Controls.Add(cssLink);
            //    }
            //}
            //catch (HttpException) { }
        }
Beispiel #7
0
        public static void SetupStyle(
            List <MarkupCss> markupCss,
            ModuleConfiguration config,
            SuperFlexiDisplaySettings displaySettings,
            string clientID,
            int moduleID,
            int pageID,
            Page page,
            Control control)
        {
            string styleLinkFormat = "\n<link rel=\"stylesheet\" href=\"{0}\" media=\"{2}\" data-name=\"{1}\">";
            string rawCSSFormat    = "\n<style type=\"text/css\" data-name=\"{1}\" media=\"{2}\">\n{0}\n</style>";

            foreach (MarkupCss style in markupCss)
            {
                StringBuilder sbStyleText = new StringBuilder();
                StringBuilder sbStyleName = new StringBuilder();

                sbStyleName.Append(String.IsNullOrWhiteSpace(style.Name) ? clientID + "flexiStyle_" + markupCss.IndexOf(style) : "flexiStyle_" + style.Name);
                SuperFlexiHelpers.ReplaceStaticTokens(sbStyleName, config, false, displaySettings, moduleID, pageID, out sbStyleName);
                string styleName = sbStyleName.ToString();
                if (!String.IsNullOrWhiteSpace(style.Url))
                {
                    string styleUrl = string.Empty;

                    if (style.Url.StartsWith("/") ||
                        style.Url.StartsWith("http://") ||
                        style.Url.StartsWith("https://"))
                    {
                        styleUrl = style.Url;
                    }
                    else if (style.Url.StartsWith("~/"))
                    {
                        styleUrl = WebUtils.ResolveServerUrl(style.Url);
                    }
                    else if (style.Url.StartsWith("$_SitePath_$"))
                    {
                        styleUrl = style.Url.Replace("$_SitePath_$", "/Data/Sites/" + CacheHelper.GetCurrentSiteSettings().SiteId.ToString() + "/");
                    }
                    else
                    {
                        styleUrl = new Uri(config.SolutionLocationUrl, style.Url).ToString();
                    }
                    //else if (File.Exists(System.Web.Hosting.HostingEnvironment.MapPath(config.MarkupDefinitionFile)))
                    //{
                    //	FileInfo fileInfo = new FileInfo(System.Web.Hosting.HostingEnvironment.MapPath(config.MarkupDefinitionFile));
                    //	styleUrl = WebUtils.ResolveServerUrl(Path.Combine(fileInfo.DirectoryName.Replace(System.Web.Hosting.HostingEnvironment.MapPath("~"), "~/"), style.Url));
                    //}

                    sbStyleText.Append(string.Format(styleLinkFormat, styleUrl, styleName, style.Media));
                }
                else if (!String.IsNullOrWhiteSpace(style.CSS))
                {
                    sbStyleText.Append(string.Format(rawCSSFormat, style.CSS, styleName, style.Media));
                }

                SuperFlexiHelpers.ReplaceStaticTokens(sbStyleText, config, false, displaySettings, moduleID, pageID, out sbStyleText);

                LiteralControl theLiteral = new LiteralControl();
                theLiteral.Text = sbStyleText.ToString();

                StyleSheetCombiner ssc = (StyleSheetCombiner)page.Header.FindControl("StyleSheetCombiner");

                if (ssc != null)
                {
                    int sscIndex = page.Header.Controls.IndexOf(ssc);
                    if (style.RenderAboveSSC)
                    {
                        page.Header.Controls.AddAt(sscIndex, theLiteral);
                    }
                    else
                    {
                        page.Header.Controls.AddAt(sscIndex + 1, theLiteral);
                    }
                }
                else
                {
                    page.Header.Controls.AddAt(0, theLiteral);
                }
            }
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            siteSettings = CacheHelper.GetCurrentSiteSettings();

            SkinBaseUrl = SiteUtils.GetSkinBaseUrl(Page);

            isMobileDevice = SiteUtils.IsMobileDevice();

            isNonCmsBasePage = Page is NonCmsBasePage;

            if (Page is CmsPage)
            {
                isCmsPage   = true;
                currentPage = CacheHelper.GetCurrentPage();
            }
            else if (!isNonCmsBasePage)
            {
                currentPage = CacheHelper.GetPage(WebUtils.ParseInt32FromQueryString("pageid", -1));
            }

            if (siteSettings == null)
            {
                return;
            }

            siteMapDataSource = (SiteMapDataSource)this.FindControl("SiteMapData");
            if (siteMapDataSource == null)
            {
                return;
            }

            siteMapDataSource.SiteMapProvider
                = "mojosite" + siteSettings.SiteId.ToInvariantString();

            try {
                rootNode = siteMapDataSource.Provider.RootNode;
            }
            catch (HttpException) {
                return;
            }

            Control c = this.FindControl("StyleSheetCombiner");

            if ((c != null) && (c is StyleSheetCombiner))
            {
                StyleSheetCombiner style = c as StyleSheetCombiner;
                useArtisteer3 = style.UseArtisteer3;
                hideEmptyAlt1 = style.HideEmptyAlt1;
                hideEmptyAlt2 = style.HideEmptyAlt2;
            }

            if (!useArtisteer3)
            {
                Control l = this.FindControl("LayoutDisplaySettings1");
                if ((l != null) && (l is LayoutDisplaySettings))
                {
                    LayoutDisplaySettings layoutSettings = l as LayoutDisplaySettings;
                    leftSideNoRightSideCss                = layoutSettings.LeftSideNoRightSideCss;
                    rightSideNoLeftSideCss                = layoutSettings.RightSideNoLeftSideCss;
                    leftAndRightNoCenterCss               = layoutSettings.LeftAndRightNoCenterCss;
                    leftOnlyCss                           = layoutSettings.LeftOnlyCss;
                    rightOnlyCss                          = layoutSettings.RightOnlyCss;
                    centerNoLeftSideCss                   = layoutSettings.CenterNoLeftSideCss;
                    centerNoRightSideCss                  = layoutSettings.CenterNoRightSideCss;
                    centerNoLeftOrRightSideCss            = layoutSettings.CenterNoLeftOrRightSideCss;
                    centerWithLeftAndRightSideCss         = layoutSettings.CenterWithLeftAndRightSideCss;
                    emptyCenterCss                        = layoutSettings.EmptyCenterCss;
                    hideEmptyCenterIfOnlySidesHaveContent = layoutSettings.HideEmptyCenterIfOnlySidesHaveContent;
                }
            }


            SetupLayout();
        }
Beispiel #9
0
        private void CountVisibleMenus()
        {
            // Count menus if they exist within a content pane and are visible
            if ((SiteMenu1 != null) && SiteMenu1.Visible)
            {
                // printable view skin doesn't have a menu so it is null there
                if (SiteMenu1.Parent.ID == "divLeft")
                {
                    leftModuleCount++;
                }
                if (SiteMenu1.Parent.ID == "divRight")
                {
                    rightModuleCount++;
                }
            }

            Control c = this.FindControl("PageMenu1");

            if (
                (c != null) &&
                (c.Visible)
                )
            {
                PageMenuControl p = (PageMenuControl)c;
                if ((!p.IsSubMenu) || (SiteUtils.TopPageHasChildren(rootNode, p.StartingNodeOffset)))
                {
                    if (c.Parent.ID == "divLeft")
                    {
                        leftModuleCount++;
                    }
                    if (c.Parent.ID == "divRight")
                    {
                        rightModuleCount++;
                    }
                }
            }

            c = this.FindControl("PageMenu2");
            if (
                (c != null) &&
                (c.Visible)
                )
            {
                PageMenuControl p = (PageMenuControl)c;
                if (SiteUtils.TopPageHasChildren(rootNode, p.StartingNodeOffset))
                {
                    if (c.Parent.ID == "divLeft")
                    {
                        leftModuleCount++;
                    }
                    if (c.Parent.ID == "divRight")
                    {
                        rightModuleCount++;
                    }
                }
            }

            c = this.FindControl("PageMenu3");
            if (
                (c != null) &&
                (c.Visible)
                )
            {
                PageMenuControl p = (PageMenuControl)c;
                if (SiteUtils.TopPageHasChildren(rootNode, p.StartingNodeOffset))
                {
                    if (c.Parent.ID == "divLeft")
                    {
                        leftModuleCount++;
                    }
                    if (c.Parent.ID == "divRight")
                    {
                        rightModuleCount++;
                    }
                }
            }

            c = this.FindControl("pnlMenu");
            if ((c != null) && (c.Parent.ID == "divLeft"))
            {
                leftModuleCount++;
            }

            c = this.FindControl("StyleSheetCombiner");
            if ((c != null) && (c is StyleSheetCombiner))
            {
                StyleSheetCombiner style = c as StyleSheetCombiner;
                if (style.AlwaysShowLeftColumn)
                {
                    leftModuleCount++;
                }
                if (style.AlwaysShowRightColumn)
                {
                    rightModuleCount++;
                }
            }
        }
Beispiel #10
0
        public static void SetupStyle(
            List <MarkupCss> markupCss,
            ModuleConfiguration config,
            SuperFlexiDisplaySettings displaySettings,
            bool isEditable,
            string clientID,
            SiteSettings siteSettings,
            Module module,
            PageSettings pageSettings,
            Page page,
            Control control)
        {
            string styleLinkFormat = "\n<link rel=\"stylesheet\" href=\"{0}\" media=\"{2}\" data-name=\"{1}\">";
            string rawCSSFormat    = "\n<style type=\"text/css\" data-name=\"{1}\" media=\"{2}\">\n{0}\n</style>";

            foreach (MarkupCss style in markupCss)
            {
                StringBuilder sbStyleText = new StringBuilder();
                StringBuilder sbStyleName = new StringBuilder();

                sbStyleName.Append(string.IsNullOrWhiteSpace(style.Name) ? clientID + "flexiStyle_" + markupCss.IndexOf(style) : "flexiStyle_" + style.Name);
                ReplaceStaticTokens(sbStyleName, config, false, displaySettings, module, pageSettings, siteSettings, out sbStyleName);
                string styleName = sbStyleName.ToString();
                if (!string.IsNullOrWhiteSpace(style.Url))
                {
                    string styleUrl = string.Empty;

                    if (style.Url.StartsWith("/") ||
                        style.Url.StartsWith("http://") ||
                        style.Url.StartsWith("https://"))
                    {
                        styleUrl = style.Url;
                    }
                    else if (style.Url.StartsWith("~/"))
                    {
                        styleUrl = WebUtils.ResolveServerUrl(style.Url, siteSettings.UseSslOnAllPages);
                    }
                    else if (style.Url.StartsWith("$_SitePath_$"))
                    {
                        styleUrl = style.Url.Replace("$_SitePath_$", "/Data/Sites/" + CacheHelper.GetCurrentSiteSettings().SiteId.ToString() + "/");
                    }
                    else
                    {
                        styleUrl = new Uri(config.SolutionLocationUrl, style.Url).ToString();
                    }

                    sbStyleText.Append(string.Format(styleLinkFormat, styleUrl, styleName, style.Media));
                }
                else if (!string.IsNullOrWhiteSpace(style.CSS))
                {
                    sbStyleText.Append(string.Format(rawCSSFormat, style.CSS, styleName, style.Media));
                }

                ReplaceStaticTokens(sbStyleText, config, false, displaySettings, module, pageSettings, siteSettings, out sbStyleText);

                LiteralControl theLiteral = new LiteralControl();
                theLiteral.Text = sbStyleText.ToString();

                StyleSheetCombiner ssc = (StyleSheetCombiner)page.Header.FindControl("StyleSheetCombiner");

                if (ssc != null)
                {
                    int sscIndex = page.Header.Controls.IndexOf(ssc);
                    if (style.RenderAboveSSC)
                    {
                        page.Header.Controls.AddAt(sscIndex, theLiteral);
                    }
                    else
                    {
                        page.Header.Controls.AddAt(sscIndex + 1, theLiteral);
                    }
                }
                else
                {
                    page.Header.Controls.AddAt(0, theLiteral);
                }
            }
        }
Beispiel #11
0
        override protected void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            bool isDesignTime = false;

            try
            {
                isDesignTime = this.DesignMode;
            }
            catch (NotImplementedException)
            {
                //mono needed hack as this error is raised
            }

            if (!isDesignTime && HttpContext.Current != null)
            {
                try
                {
                    if (WebConfigSettings.AllowForcingPreferredHostName)
                    {
                        EnsureSiteSettings();
                        if (
                            (siteSettings != null) &&
                            (siteSettings.PreferredHostName.Length > 0)
                            )
                        {
                            string requestedHostName = WebUtils.GetHostName();
                            if (siteSettings.PreferredHostName != requestedHostName)
                            {
                                Response.Redirect("http://" + siteSettings.PreferredHostName, true);
                                return;
                            }
                        }
                    }

                    SetupMasterPage();
                }
                catch (HttpException ex)
                {
                    log.Error("Error setting master page. Will try setting to default skin."
                              + CultureInfo.CurrentCulture.ToString() + " - " + SiteUtils.GetIP4Address(), ex);

                    SetupFailsafeMasterPage();
                }
            }


            if (setMasterInBasePage)
            {
                //StyleSheetControl = (StyleSheet)Master.FindControl("StyleSheet");
                //if (StyleSheetControl != null)
                //{
                //    StyleSheetControl.LiteralStyleSheetLink.Text
                //        = SiteUtils.GetStyleSheetLinks(allowSkinOverride);
                //}

                StyleSheetCombiner styleCombiner = (StyleSheetCombiner)Master.FindControl("StyleSheetCombiner");
                if (styleCombiner != null)
                {
                    styleCombiner.AllowPageOverride = allowSkinOverride;
                }
            }
        }