protected override void Render(HtmlTextWriter writer)
        {
            string htmlOutput = string.Empty;

            try
            {
                // setup the outer wrappers
                htmlOutput += "<div class=\"wet-boew-menubar mb-mega\"><div><ul class=\"mb-menu\" data-ajax-replace=\"";

                if (SPContext.Current.Web.Locale.TwoLetterISOLanguageName == "en")
                {
                    htmlOutput += "/Navigation/menu-eng.txt\">";
                }
                else
                {
                    htmlOutput += "/Navigation/menu-fra.txt\">";
                }

                string langWeb = string.Empty;
                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    // figure out our language of the current label
                    PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);

                    if (publishingPage.PublishingWeb.Label != null)
                    {
                        langWeb = (publishingPage.PublishingWeb.Label.Title.Substring(0, 2).ToLower() == "en") ? "eng" : "fra";
                    }
                }
                else
                {
                    string cultISO = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
                    langWeb = (cultISO == "en") ? "eng" : "fra";
                }

                string webUrl = SPContext.Current.Web.Url;

                //TODO - Remove this debug logic;
#if DEBUG
                if (webUrl.Contains("l41-106306"))
                {
                    webUrl = webUrl.Replace("l41-106306", "localhost");
                }
#endif

                using (SPSite site = new SPSite(webUrl))
                {
                    htmlOutput += renderTopLevelLink(langWeb);

                    // setup the outer wrappers
                    htmlOutput += "</ul></div></div>";

                    writer.Write(htmlOutput);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex.Message + " " + ex.StackTrace);
            }
        }
Esempio n. 2
0
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);

            // allow third party applications to override the title of the current node in the breadcrumb
            SPCLF3.Master_Pages.CLF3PublishingMaster masterPage = (SPCLF3.Master_Pages.CLF3PublishingMaster) this.Page.Master;
            if (String.IsNullOrEmpty(masterPage.PageTitle))
            {
                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);
                    writer.WriteLine(publishingPage.Title);
                }
                else if (SPContext.Current.ListItem != null)
                {
                    writer.Write(SPContext.Current.ListItem.Title);
                }
                else if (SPContext.Current.List != null)
                {
                    writer.Write(SPContext.Current.List.Title);
                }
            }
            else
            {
                writer.WriteLine(masterPage.PageTitle);
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            string htmlOutput = string.Empty;

            try
            {
                // setup the outer wrappers
                htmlOutput += "<div class=\"wet-boew-menubar mb-mega\"><div><ul class=\"mb-menu\" data-ajax-replace=\"";

                if (SPContext.Current.Web.Locale.TwoLetterISOLanguageName == "en")
                {
                    htmlOutput += "/Lists/TopNavigation/menu-eng.txt\">";
                }
                else
                {
                    htmlOutput += "/Lists/TopNavigation/menu-fra.txt\">";
                }

                string langWeb = string.Empty;
                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    // figure out our language of the current label
                    PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);

                    if (publishingPage.PublishingWeb.Label != null)
                    {
                        langWeb = (publishingPage.PublishingWeb.Label.Title.Substring(0, 2).ToLower() == "en") ? "eng" : "fra";
                    }
                }
                else
                {
                    string cultISO = "";
                    if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("/eng/"))
                    {
                        cultISO = "en";
                    }
                    else
                    {
                        cultISO = "fr";
                    }
                    langWeb = (cultISO == "en") ? "eng" : "fra";
                }

                string webUrl = SPContext.Current.Web.Url;
                using (SPSite site = new SPSite(webUrl))
                {
                    htmlOutput += renderTopLevelLink(langWeb);

                    // setup the outer wrappers
                    htmlOutput += "</ul></div></div>";

                    writer.Write(htmlOutput);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex.Message + " " + ex.StackTrace);
            }
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            try
            {
                string langWeb = string.Empty;

                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    // figure out our language of the current label
                    PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);

                    if (publishingPage.PublishingWeb.Label != null)
                    {
                        langWeb = (publishingPage.PublishingWeb.Label.Title.Substring(0, 2).ToLower() == "en") ? "eng" : "fra";
                    }
                }
                else
                {
                    string cultISO = "";
                    if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("/eng/"))
                    {
                        cultISO = "en";
                    }
                    else
                    {
                        cultISO = "fr";
                    }
                    langWeb = (cultISO == "en") ? "eng" : "fra";
                }

                HtmlGenericControl pnlSearch = new HtmlGenericControl("div");
                pnlSearch.Attributes.Add("class", "form-group");

                txtSearchBox = new TextBox()
                {
                    CssClass = "form-control",
                };
                txtSearchBox.Attributes.Add("type", "search");
                txtSearchBox.Attributes.Add("size", "27");
                txtSearchBox.MaxLength = 150;
                txtSearchBox.Style.Add("margin-right", "5px");
                pnlSearch.Controls.Add(txtSearchBox);

                this.Controls.Add(pnlSearch);

                HtmlButton btnSearch = new HtmlButton();
                btnSearch.Attributes.Add("class", "btn btn-default");
                btnSearch.Attributes.Add("type", "submit");
                btnSearch.InnerText    = (langWeb == "fra") ? "Recherche" : "Search";
                btnSearch.ServerClick += btnSearch_ServerClick;

                this.Controls.Add(btnSearch);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 5
0
 protected override void Render(HtmlTextWriter writer)
 {
     if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
     {
         // Generate each metatag
         PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);
         foreach (MetaTag metaTag in PageMetadata.GetCustomMetaTags())
         {
             metaTag.Render(writer, publishingPage);
         }
     }
 }
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);

            // allow third party applications to override the title of the current node in the breadcrumb
            WET.Theme.Intranet.Master_Pages.WETIntranetPublishingMaster masterPage = (WET.Theme.Intranet.Master_Pages.WETIntranetPublishingMaster) this.Page.Master;
            if (String.IsNullOrEmpty(masterPage.PageTitle))
            {
                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);
                    writer.WriteLine(publishingPage.Title);
                }
                else if (SPContext.Current.ListItem != null)
                {
                    try
                    {
                        writer.Write(SPContext.Current.ListItem.Title);
                    }
                    catch
                    {
                        try
                        {
                            writer.Write(SPContext.Current.ListItem.DisplayName);
                        }
                        catch (Exception ex)
                        {
                            WET.Theme.Intranet.Objects.Logger.WriteLog("Page Title:" + ex.Message);
                        }
                    }
                }
                else if (SPContext.Current.List != null)
                {
                    writer.Write(SPContext.Current.List.Title);
                }
                else if (HttpContext.Current.Request != null)
                {
                    string curUrl = HttpContext.Current.Request.Url.ToString();
                    string fileNameNoExtension = curUrl.Split('/')[curUrl.Split('/').Length - 1].Split('.')[0];
                    string fakeTitle           = char.ToUpper(fileNameNoExtension[0]) + fileNameNoExtension.ToLower().Substring(1);
                    writer.Write(fakeTitle);
                }
                else
                {
                    writer.Write("Administrative Page");
                }
            }
            else
            {
                writer.WriteLine(masterPage.PageTitle);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Render this control to the output parameter specified.
 /// </summary>
 /// <param name="output"> The HTML writer to write out to </param>
 protected override void Render(HtmlTextWriter output)
 {
     //Create a link back to the root of the variation
     if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
     {
         PublishingPage page = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);
         if (page != null)
         {
             try
             {
                 // handle the homelink when variations are enabled
                 if (page.PublishingWeb.Label != null)
                 {
                     output.Write(
                         "<a href=\"" +
                         page.PublishingWeb.Label.TopWebUrl +
                         "\" style=\"font-size:1.5em;\">" +
                         HttpContext.GetGlobalResourceObject("WET", "SiteTitleText", SPContext.Current.Web.Locale).ToString() +
                         "</a>"
                         );
                 }
                 else
                 {
                     // when variations are not enabled
                     output.Write(
                         "<a href=\"" + SPContext.Current.Site.RootWeb.Url + "\" style=\"font-size:1.5em;\">" +
                         HttpContext.GetGlobalResourceObject("WET", "SiteTitleText", SPContext.Current.Web.Locale).ToString() +
                         "</a>"
                         );
                 }
             }
             catch (Exception ex)
             {
                 Logger.WriteLog(ex.Message + " " + ex.StackTrace);
             }
         }
     }
     else
     {
         // when variations are not enabled
         output.Write(
             "<a href=\"" + SPContext.Current.Site.RootWeb.Url + "\" style=\"font-size:1.5em;\">" +
             HttpContext.GetGlobalResourceObject("WET", "SiteTitleText", SPContext.Current.Web.Locale).ToString() +
             "</a>"
             );
     }
 }
        protected override void Render(HtmlTextWriter writer)
        {
            string htmlOutput = string.Empty;

            try
            {
                langWeb = string.Empty;
                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    // figure out our language of the current label
                    PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);

                    if (publishingPage.PublishingWeb.Label != null)
                    {
                        langWeb = (publishingPage.PublishingWeb.Label.Title.Substring(0, 2).ToLower() == "en") ? "Eng" : "Fra";
                    }
                }
                else
                {
                    string cultISO = "";
                    if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("/eng/"))
                    {
                        cultISO = "en";
                    }
                    else
                    {
                        cultISO = "fr";
                    }
                    langWeb = (cultISO == "en") ? "Eng" : "Fra";
                }

                htmlOutput += "<nav class=\"wb-menu visible-md visible-lg wb-init wb-data-ajax-replace-inited wb-menu-inited wb-navcurr-inited\" id=\"wb-sm\" role=\"navigation\" typeof=\"SiteNavigationElement\" data-trgt=\"mb-pnl\">\r\n";
                htmlOutput += "<div class=\"pnl-strt container visible-md visible-lg nvbar\">\r\n";
                htmlOutput += "<h2>Topics menu</h2>\r\n";
                htmlOutput += "<div class=\"row\">\r\n";
                htmlOutput += "<ul class=\"list-inline menu\" role=\"menubar\">\r\n";
                htmlOutput += renderTopLevelLinks();
                htmlOutput += "</ul></div></div>";
                htmlOutput += "</nav>";

                writer.Write(htmlOutput);
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex.Message + " " + ex.StackTrace);
            }
        }
 /// <summary>
 /// Render this control to the output parameter specified.
 /// </summary>
 /// <param name="output"> The HTML writer to write out to </param>
 protected override void Render(HtmlTextWriter output)
 {
     //get the placeholder that holds the meta tag content
     if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
     {
         PublishingPage page = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);
         if (page != null)
         {
             string sLastModifiedDate = page.LastModifiedDate.ToString("yyyy-MM-dd");
             output.Write(sLastModifiedDate);
         }
     }
     else
     {
         if (SPContext.Current.Web.LastItemModifiedDate != null)
         {
             string sLastModifiedDate = SPContext.Current.Web.LastItemModifiedDate.ToString("yyyy-MM-dd");
             output.Write(sLastModifiedDate);
         }
     }
 }
Esempio n. 10
0
        protected override void Render(HtmlTextWriter writer)
        {
            string htmlOutput = string.Empty;

            try
            {
                string langWeb = string.Empty;
                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    // figure out our language of the current label
                    PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);

                    if (publishingPage.PublishingWeb.Label != null)
                    {
                        langWeb = (publishingPage.PublishingWeb.Label.Title.Substring(0, 2).ToLower() == "en") ? "eng" : "fra";
                    }
                }
                else
                {
                    string cultISO = "";
                    if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("/eng/"))
                    {
                        cultISO = "en";
                    }
                    else
                    {
                        cultISO = "fr";
                    }
                    langWeb = (cultISO == "en") ? "eng" : "fra";
                }

                string dataAjaxFetch = "";
                if (SPContext.Current.Web.Locale.TwoLetterISOLanguageName == "en")
                {
                    dataAjaxFetch += "/TopNavigationFiles/menu-include-en.html";
                }
                else
                {
                    dataAjaxFetch += "/TopNavigationFiles/menu-include-fr.html";
                }

                htmlOutput += "<nav role=\"navigation\" id=\"wb-sm\" data-ajax-fetch=\"" + dataAjaxFetch + "\" data-trgt=\"mb-pnl\" class=\"wb-menu visible-md visible-lg\" typeof=\"SiteNavigationElement\">";
                htmlOutput += "<div class=\"container nvbar\">";
                htmlOutput += "<h2>Topics menu</h2>";
                htmlOutput += "<ul class=\"list-inline menu\">";
                htmlOutput += renderTopLevelLink(langWeb);
                htmlOutput += "</ul>";
                htmlOutput += "</div>";
                htmlOutput += "</nav>";

                string webUrl = SPContext.Current.Web.Url;
                using (SPSite site = new SPSite(webUrl))
                {
                    writer.Write(htmlOutput);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex.Message + " " + ex.StackTrace);
            }
        }
 protected override void OnInit(EventArgs e)
 {
     //Check whether there in a SPContext, and if this is a List Item
     if (SPContext.Current != null && SPContext.Current.ListItem != null)
     {
         //Check whether the current content type is or inherits from the Page content type
         SPContentTypeId pageContentTypeId = SPContext.Current.Web.AvailableContentTypes["Page"].Id;
         SPContentTypeId currentItemTypeId = SPContext.Current.ListItem.ContentTypeId;
         if (currentItemTypeId.Equals(pageContentTypeId) || currentItemTypeId.IsChildOf(pageContentTypeId))
         {
             //Get the PageHolderMain content place holder control
             ContentPlaceHolder placeHolderMain = (ContentPlaceHolder)this.Page.Master.FindControl("PlaceHolderMain");
             if (placeHolderMain != null)
             {
                 //Check whether the current item is a publishing page and is a New item or in Edit mode
                 if ((PublishingPage.IsPublishingPage(SPContext.Current.ListItem)) &&
                     (SPContext.Current.FormContext.FormMode == SPControlMode.Edit ||
                      SPContext.Current.FormContext.FormMode == SPControlMode.New))
                 {
                     //Get the custom column
                     SPField demoCustomColumn;
                     try
                     {
                         demoCustomColumn = SPContext.Current.ListItem.Fields["DemoCustomColumn"];
                     }
                     catch
                     {
                         demoCustomColumn = null;
                     }
                     if (demoCustomColumn != null)
                     {
                         //We have a page, in edit or new mode, with the demoCustomColumn.
                         //So render the custom field control
                         BaseFieldControl demoCustomColumnControl = demoCustomColumn.FieldRenderingControl;
                         demoCustomColumnControl.ID = demoCustomColumn.InternalName;
                         placeHolderMain.Controls.Add(new LiteralControl("<div class=\"edit-mode-panel\">"));
                         placeHolderMain.Controls.Add(demoCustomColumnControl);
                         placeHolderMain.Controls.Add(new LiteralControl("</div>"));
                     }
                 }
                 else if ((PublishingPage.IsPublishingPage(SPContext.Current.ListItem)) &&
                          (SPContext.Current.FormContext.FormMode == SPControlMode.Display))
                 {
                     //Get the custom column
                     SPField demoCustomColumn;
                     try
                     {
                         demoCustomColumn = (SPFieldText)SPContext.Current.ListItem.Fields["DemoCustomColumn"];
                     }
                     catch
                     {
                         demoCustomColumn = null;
                     }
                     if (demoCustomColumn != null)
                     {
                         //We have a page, in display mode, with the demoCustomColumn.
                         //So render the value of the field. You can add custom rendering markup
                         //here. In this case, the <div> tag renders the text in red.
                         placeHolderMain.Controls.Add(new LiteralControl("<div style=\"color: red;\">"));
                         placeHolderMain.Controls.Add(new LiteralControl(SPContext.Current.ListItem["DemoCustomColumn"].ToString()));
                         placeHolderMain.Controls.Add(new LiteralControl("</div>"));
                     }
                 }
             }
         }
     }
     base.OnInit(e);
 }
Esempio n. 12
0
        protected override void Render(HtmlTextWriter writer)
        {
            string currentNavClass = string.Empty;
            string selectedNav     = string.Empty;

            try
            {
                // setup the outer wrappers
                string htmlOutput = string.Empty;

                // figure out our language of the current label
                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);
                    string         langWeb        = string.Empty;
                    if (publishingPage.PublishingWeb.Label != null)
                    {
                        langWeb = (publishingPage.PublishingWeb.Label.Title.Substring(0, 2).ToLower() == "en") ? "eng" : "fra";
                    }
                    else
                    {
                        langWeb = "eng";
                    }

                    currentNavClass = "class=\"nav-current\"";
                    selectedNav     = SPContext.Current.ListItemServerRelativeUrl;

                    SPList            WETLeftNavigation = null;
                    List <SPListItem> firstLevelCollItem;

                    try
                    {
                        WETLeftNavigation = SPContext.Current.Web.Lists["WETLeftNavigation"];

                        firstLevelCollItem = (from SPListItem li in WETLeftNavigation.Items
                                              where Convert.ToString(li["Level"]).IndexOf(".") == -1
                                              orderby li["SortOrder"]
                                              select li).ToList <SPListItem>();

                        foreach (SPListItem oItem_1 in firstLevelCollItem)
                        {
                            //Ensure that this is a first level link by checking number of dots in Level value. Must be 0
                            string      level        = oItem_1["Level"].ToString();
                            List <char> list         = level.ToList <char>();
                            int         numberOfDots = list.Count <char>(c => c == '.');

                            if ((numberOfDots == 0))
                            {
                                //renderfirstlevelLink
                                htmlOutput += renderTopLevelLink(WETLeftNavigation, oItem_1, level, langWeb, selectedNav);
                            }
                        }
                    }
                    finally
                    {
                    }
                    htmlOutput += "<br /><br /><br />";
                    writer.Write(htmlOutput);
                }
                else
                {
                    //Nik20121026 - Handles the case where the site's template is a collaboration one;
                    string langWeb = string.Empty;
                    string cultISO = "";
                    if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("/eng/"))
                    {
                        cultISO = "en";
                    }
                    else
                    {
                        cultISO = "fr";
                    }

                    langWeb = (cultISO == "en") ? "eng" : "fra";

                    currentNavClass = "class=\"nav-current\"";
                    selectedNav     = SPContext.Current.ListItemServerRelativeUrl;

                    SPList            WETLeftNavigation = null;
                    List <SPListItem> firstLevelCollItem;

                    try
                    {
                        WETLeftNavigation = SPContext.Current.Web.Lists["WETLeftNavigation"];

                        firstLevelCollItem = (from SPListItem li in WETLeftNavigation.Items
                                              where Convert.ToString(li["Level"]).IndexOf(".") == -1
                                              orderby li["SortOrder"]
                                              select li).ToList <SPListItem>();

                        foreach (SPListItem oItem_1 in firstLevelCollItem)
                        {
                            //Ensure that this is a first level link by checking number of dots in Level value. Must be 0
                            string      level        = oItem_1["Level"].ToString();
                            List <char> list         = level.ToList <char>();
                            int         numberOfDots = list.Count <char>(c => c == '.');

                            if ((numberOfDots == 0))
                            {
                                //renderfirstlevelLink
                                htmlOutput += renderTopLevelLink(WETLeftNavigation, oItem_1, level, langWeb, selectedNav);
                            }
                        }
                    }
                    finally
                    {
                    }

                    writer.Write(htmlOutput);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex.Message + " " + ex.StackTrace);
            }
        }
Esempio n. 13
0
        // Creates content in the following manner
        // 1:  all links not in folders will be rendered in the first div in the order added to the list
        //<div id="cn-ft-tctr">
        //    <ul>
        //        <li class="terms"><a href="#" rel="license">Terms and conditions</a></li>
        //        <li class="trans"><a href="#">Transparency</a></li>
        //    </ul>
        //</div>
        //<div class="clear"></div>
        // 2:  all folders will be rendered with the link with the title matching the folder name being the link for the folder
        // 3:  if no link matches the folder name, it will be rendered as text and not a link
        // 4:  all other links in folders will be rendered in the order they are added to the folder as <LI> items
        //<section>
        //    <div class="span-2">
        //        <h4 class="col-head"><a href="#">About us</a></h4>
        //        <ul>
        //            <li><a href="#">Our Mandate</a></li>
        //            <li><a href="#">Our Minister</a></li>
        //        </ul>
        //    </div>
        //</section>
        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void Render(HtmlTextWriter output)
        {
            string topLinksHTML = string.Empty;
            string sectionsHTML = string.Empty;

            //Create a link back to the root of the variation
            if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
            {
                try
                {
                    if (PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                    {
                        PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);
                        // Check to see if Variations are enabled or not.... if the label is null then no variations
                        string langWeb = (publishingPage.PublishingWeb.Label == null) ?
                                         string.Empty :
                                         (publishingPage.PublishingWeb.Label.Language.Substring(0, 2).ToLower() == "en") ? "eng" : "fra";
                        string webUrl = string.Empty;
                        SPList cLFFooterNavigation = null;
                        SPListItemCollection collListItems;

                        try
                        {
                            if (langWeb != string.Empty)
                            {
                                SPWebCollection webs    = SPContext.Current.Site.RootWeb.Webs;
                                SPWeb           tempWeb = webs[langWeb];
                                webUrl = tempWeb.Url;
                                tempWeb.Dispose();
                            }
                            else
                            {
                                webUrl = SPContext.Current.Site.RootWeb.Url;
                            }

                            using (SPSite site = new SPSite(webUrl))
                            {
                                using (SPWeb web = site.OpenWeb())
                                {
                                    cLFFooterNavigation = web.Lists.TryGetList("CLF3FooterNavigation");

                                    SPQuery oQuery = new SPQuery();
                                    oQuery.Query = "<Where><IsNotNull><FieldRef Name='NavURL'/></IsNotNull></Where>" +
                                                   "<OrderBy><FieldRef Name='RowOrder' /></OrderBy>";

                                    if (cLFFooterNavigation != null)
                                    {
                                        collListItems = cLFFooterNavigation.GetItems(oQuery);

                                        int counter = 0;
                                        foreach (SPListItem item in collListItems)
                                        {
                                            counter += 1;

                                            string linkRel = string.Empty;
                                            // set the rel = license for terms and conditions being the title of the link

                                            if (item.Title.ToLower() == HttpContext.GetGlobalResourceObject("WET4", "TermsAndConditionsText", SPContext.Current.Web.Locale).ToString().ToLower())
                                            {
                                                linkRel = " rel=\"license\"";
                                            }
                                            else
                                            {
                                                linkRel = string.Empty;
                                            }

                                            // then this is one of the top links... add it to the
                                            // <li class="terms"><a href="#" rel="license">Terms and conditions</a></li>
                                            topLinksHTML += "<li><a href=\"" + item["NavURL"].ToString() + "\"" + linkRel + ">" + item.Title + "</a></li>";
                                        }

                                        // now do the sections
                                        foreach (SPListItem aFolderItem in cLFFooterNavigation.Folders)
                                        {
                                            // its one of the folders... render it and add it to sectionsHTML
                                            sectionsHTML += renderSection(aFolderItem.Folder, cLFFooterNavigation);
                                        }
                                    }
                                }
                            }
                        }
                        finally
                        {
                        }
                        // write out the topLinksHTML to output
                        if (!string.IsNullOrEmpty(topLinksHTML))
                        {
                            output.Write("<ul id=\"gc-tctr\" class=\"list-inline\">" + topLinksHTML + "</ul><div class=\"row\">");
                        }

                        // write out the sectionsHTML to output as is..
                        output.Write(sectionsHTML);

                        if (!string.IsNullOrEmpty(topLinksHTML))
                        {
                            output.Write("</div>");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLog(ex.Message + " " + ex.StackTrace);
                }
            }
            else
            {
                //Nik20121026 - The current site's template is a collaboration one;
                // Check to see if Variations are enabled or not.... if the label is null then no variations
                SPList cLFFooterNavigation = null;
                SPListItemCollection collListItems;

                try
                {
                    cLFFooterNavigation = SPContext.Current.Web.Lists["CLF3FooterNavigation"];
                    SPQuery oQuery = new SPQuery();
                    oQuery.Query = "<Where><IsNotNull><FieldRef Name='NavURL'/></IsNotNull></Where>" +
                                   "<OrderBy><FieldRef Name='RowOrder' /></OrderBy>";

                    if (cLFFooterNavigation != null)
                    {
                        collListItems = cLFFooterNavigation.GetItems(oQuery);

                        int counter = 0;
                        foreach (SPListItem item in collListItems)
                        {
                            counter += 1;

                            string linkRel = string.Empty;

                            if (item.Title.ToLower() == HttpContext.GetGlobalResourceObject("WET4", "TermsAndConditionsText", SPContext.Current.Web.Locale).ToString().ToLower())
                            {
                                linkRel = " rel=\"license\"";
                            }
                            else
                            {
                                linkRel = string.Empty;
                            }

                            // then this is one of the top links... add it to the
                            // <li class="terms"><a href="#" rel="license">Terms and conditions</a></li>
                            topLinksHTML += "<li><a href=\"" + item["NavURL"].ToString() + "\"" + linkRel + ">" + item.Title + "</a></li>";
                        }

                        // now do the sections
                        foreach (SPListItem aFolderItem in cLFFooterNavigation.Folders)
                        {
                            // its one of the folders... render it and add it to sectionsHTML
                            sectionsHTML += renderSection(aFolderItem.Folder, cLFFooterNavigation);
                        }
                    }
                }
                catch { }
                // write out the topLinksHTML to output
                if (!string.IsNullOrEmpty(topLinksHTML))
                {
                    output.Write("<ul id=\"gc-tctr\" class=\"list-inline\">" + topLinksHTML + "</ul><div class=\"row\">");
                }

                // write out the sectionsHTML to output as is..
                output.Write(sectionsHTML);

                if (!string.IsNullOrEmpty(topLinksHTML))
                {
                    output.Write("</div>");
                }
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            try
            {
                PublishingPage publishingPage;
                PublishingPage targetPage;
                string         currentLang = "";
                if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("/eng/"))
                {
                    currentLang = "en";
                }
                else
                {
                    currentLang = "fr";
                }

                // Figure out what variation we are in and link back to the other language using the
                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);
                    VariationLabel label = publishingPage.PublishingWeb.Label;

                    //repass the querystring
                    string queryString = "";
                    if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.ToString()))
                    {
                        queryString = "?" + HttpContext.Current.Request.QueryString.ToString();
                    }

                    // controls on the page can override the query string parameter if needed
                    if (this.Page.Master != null)
                    {
                        Master_Pages.WETIntranetPublishingMaster masterPage = (Master_Pages.WETIntranetPublishingMaster) this.Page.Master;
                        if (!String.IsNullOrEmpty(masterPage.LanguageFlipQueryString))
                        {
                            queryString = masterPage.LanguageFlipQueryString;
                        }
                    }
                    if (label == null)
                    {
                        // no variations... use the current users local
                        string langlabel       = HttpContext.GetGlobalResourceObject("WET", "OtherLanguageText", SPContext.Current.Web.Locale).ToString();
                        string Languagecontrol = "";

                        if (currentLang.Equals("en"))
                        {
                            Languagecontrol = "<a href=\"" + publishingPage.Uri.AbsoluteUri + queryString + "\" lang=\"" + currentLang + "\" xml:lang=\"" + currentLang + "\" onclick=\"javascript:OnSelectionChange(1036); return false;\"><span>" + langlabel + "</span></a>";
                        }
                        else
                        {
                            Languagecontrol = "<a href=\"" + publishingPage.Uri.AbsoluteUri + queryString + "\" lang=\"" + currentLang + "\" xml:lang=\"" + currentLang + "\" onclick=\"javascript:OnSelectionChange(1033); return false;\"><span>" + langlabel + "</span></a>";
                        }
                        this.Controls.Add(new LiteralControl(Languagecontrol));
                    }
                    else
                    {
                        // handle the variations
                        // find our root publishing web

                        PublishingWeb topPubWeb = publishingPage.PublishingWeb;
                        while (topPubWeb.IsRoot == false)
                        {
                            topPubWeb = topPubWeb.ParentPublishingWeb;
                        }

                        // iterate through the variation urls and find the lable from the other language
                        foreach (PublishingWeb aPubWeb in topPubWeb.GetPublishingWebs())
                        {
                            if (aPubWeb.Label != null && (aPubWeb.Label.Title != publishingPage.PublishingWeb.Label.Title) &&
                                ((aPubWeb.Label.Title.ToLower() == "eng") || (aPubWeb.Label.Title.ToLower() == "fra")))
                            {
                                // then we have the pubweb from the other variation...
                                label = aPubWeb.Label;
                                break;
                            }
                        }
                        if (label == null)
                        {
                            throw new System.ArgumentException(HttpContext.GetGlobalResourceObject("WET", "Error_CantFindPubWebLabel", SPContext.Current.Web.Locale).ToString(), "listItem");
                        }
                        else
                        {
                            targetPage = publishingPage.GetVariation(label);
                            if (targetPage != null)
                            {
                                string currenturl = HttpContext.Current.Request.Path.ToString().ToLower();

                                string reverseurl = targetPage.Uri.AbsoluteUri;
                                string langlabel  = HttpContext.GetGlobalResourceObject("WET", "OtherLanguageText", SPContext.Current.Web.Locale).ToString();
                                string propLang   = (publishingPage.PublishingWeb.Label.Language.Substring(0, 2) == "en") ? "fr" : "en";

                                this.Controls.Add(new LiteralControl("<script type=\"text/javascript\">" + System.Environment.NewLine +
                                                                     "function OnSelectionChange2(value){" +
                                                                     System.Environment.NewLine + "var today = new Date();" +
                                                                     System.Environment.NewLine + "var oneYear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);" +
                                                                     System.Environment.NewLine + "var url = \"" + reverseurl + queryString + "\";" +
                                                                     System.Environment.NewLine + "document.cookie = \"lcid=\" + value + \";path=/;expires=\" + oneYear.toGMTString();" +
                                                                     System.Environment.NewLine + "window.location.href = url;" +
                                                                     System.Environment.NewLine + "}" +
                                                                     System.Environment.NewLine +
                                                                     "</script>"));
                                string lang           = publishingPage.PublishingWeb.Label.Language.Substring(0, 2);
                                string controlContent = "";
                                if (lang == "en")
                                {
                                    controlContent = @"<section id=""wb-lng"">
                                      <h2>Language selection</h2>     
                                         <ul class=""list-inline"">
                                        <li><a lang=""fr"" href=""" + reverseurl + queryString + @""" onclick=""javascript: OnSelectionChange2(1036); return false;"">Fran&ccedil;ais</a></li>
                                         </ul>
                                    </section>";
                                }
                                else
                                {
                                    {
                                        controlContent = @"<section id=""wb-lng"">
                                        <h2>S&eacute;lection de langue</h2>     
                                         <ul class=""list-inline"">
                                        <li><a lang=""en"" href=""" + reverseurl + queryString + @""" onclick=""javascript: OnSelectionChange2(1033); return false;"">English</a></li>
                                        </ul>
                                    </section>";
                                    }
                                }
                                this.Controls.Add(new LiteralControl(controlContent));
                            }
                        }
                    }
                }
                else
                {
                    //repass the querystring
                    string queryString = "";
                    if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.ToString()))
                    {
                        queryString = "?" + HttpContext.Current.Request.QueryString.ToString();
                    }

                    // controls on the page can override the query string parameter if needed
                    if (this.Page.Master != null)
                    {
                        Master_Pages.WETIntranetPublishingMaster masterPage = (Master_Pages.WETIntranetPublishingMaster) this.Page.Master;
                        if (!String.IsNullOrEmpty(masterPage.LanguageFlipQueryString))
                        {
                            queryString = masterPage.LanguageFlipQueryString;
                        }
                    }

                    string url = SPContext.Current.Web.Url;
                    // no variations... use the current users local
                    string langlabel = HttpContext.GetGlobalResourceObject("WET", "OtherLanguageText", SPContext.Current.Web.Locale).ToString();

                    string Languagecontrol = "";
                    if (currentLang.Equals("en"))
                    {
                        Languagecontrol = "<a href=\"" + url + queryString + "\" lang=\"" + currentLang + "\" xml:lang=\"" + currentLang + "\" onclick=\"javascript:OnSelectionChange(1036); return false;\"><span>" + langlabel + "</span></a>";
                    }
                    else
                    {
                        Languagecontrol = "<a href=\"" + url + queryString + "\" lang=\"" + currentLang + "\" xml:lang=\"" + currentLang + "\" onclick=\"javascript:OnSelectionChange(1033); return false;\"><span>" + langlabel + "</span></a>";
                    }
                    this.Controls.Add(new LiteralControl(Languagecontrol));
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex.Message + " " + ex.StackTrace);
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            string selectedNav = string.Empty;

            try
            {
                // setup the outer wrappers
                string htmlOutput = string.Empty;

                // figure out our language of the current label
                if (SPContext.Current.ListItem != null && PublishingPage.IsPublishingPage(SPContext.Current.ListItem))
                {
                    PublishingPage publishingPage = PublishingPage.GetPublishingPage(SPContext.Current.ListItem);
                    string         langWeb        = string.Empty;
                    if (publishingPage.PublishingWeb.Label != null)
                    {
                        langWeb = (publishingPage.PublishingWeb.Label.Title.Substring(0, 2).ToLower() == "en") ? "eng" : "fra";
                    }
                    else
                    {
                        langWeb = "eng";
                    }

                    SPList            WETLeftNavigation = null;
                    List <SPListItem> firstLevelCollItem;

                    try
                    {
                        WETLeftNavigation = SPContext.Current.Web.Lists["WETLeftNavigation"];

                        firstLevelCollItem = (from SPListItem li in WETLeftNavigation.Items
                                              where Convert.ToString(li["Level"]).IndexOf(".") == -1
                                              orderby li["SortOrder"]
                                              select li).ToList <SPListItem>();

                        foreach (SPListItem oItem_1 in firstLevelCollItem)
                        {
                            //Ensure that this is a first level link by checking number of dots in Level value. Must be 0
                            string      level        = oItem_1["Level"].ToString();
                            List <char> list         = level.ToList <char>();
                            int         numberOfDots = list.Count <char>(c => c == '.');

                            if ((numberOfDots == 0))
                            {
                                //renderfirstlevelLink
                                htmlOutput += renderTopLevelLink(WETLeftNavigation, oItem_1, level, langWeb);
                            }
                        }
                    }
                    finally
                    {
                    }
                    htmlOutput += "<br /><br /><br />";
                    writer.Write(htmlOutput);

                    // Nik20131114 - Need to use javascript to highlight the current section in the left menu, because with anchors ('#') we cannot
                    //               make a decision server side;
                    string selectorScript = "<script type=\"text/javascript\" src=\"/Style Library/js/leftmenuselector.js\"><" + "/" + "script>";

                    writer.Write(selectorScript);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex.Message + " " + ex.StackTrace);
            }
        }