protected void DdlSelectLang_SelectedIndexChanged(object sender, EventArgs e) { Response.Clear(); string selectedLang = ((DropDownList)sender).SelectedItem.Value; // Save cookie ANOProfile.SaveCookies(selectedLang, CurrentUserIP, null); CustomSiteMapNode csm = new CustomSiteMapNode(); LangaugeSystem ls = new LangaugeSystem(); Page.Culture = selectedLang; Page.UICulture = selectedLang; cSiteMapNode homeSiteMapNode = csm.GetSiteMapNode(2, ls.GetLang(selectedLang).LangId); string getPath = homeSiteMapNode.SiteMapNodePath; if (homeSiteMapNode.SiteMapNodeRewrittedPath != null) { getPath = "http://" + selectedLang.Split('-')[0] + "." + GetDomain.GetDomainFromUrl(Request.Url.ToString()) + VirtualPathUtility.ToAbsolute(homeSiteMapNode.SiteMapNodeRewrittedPath); } Response.Redirect(getPath); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int langid = new SearchWar.LangSystem.LangaugeSystem().CurrentLangId; CustomSiteMapNode csm = new CustomSiteMapNode(); cSiteMapNode homeCSiteMapNode = csm.GetSiteMapNode(8, langid); string pathCreateUser = homeCSiteMapNode.SiteMapNodePath; if (!string.IsNullOrEmpty(homeCSiteMapNode.SiteMapNodeRewrittedPath)) { pathCreateUser = homeCSiteMapNode.SiteMapNodeRewrittedPath; } cSiteMapNode homeCSiteMapNode2 = csm.GetSiteMapNode(9, langid); string pathForgotpw = homeCSiteMapNode2.SiteMapNodePath; if (!string.IsNullOrEmpty(homeCSiteMapNode2.SiteMapNodeRewrittedPath)) { pathForgotpw = homeCSiteMapNode2.SiteMapNodeRewrittedPath; } ((HyperLink)UserLogin.FindControl("HyperCreateUser")).NavigateUrl = pathCreateUser; ((HyperLink)UserLogin.FindControl("HyperForgotPassword")).NavigateUrl = pathForgotpw; } }
/// <summary> /// Searching after path in database /// </summary> /// <param name="path">Insert path</param> /// <param name="langId">Insert langId</param> /// <returns>Return anonymous object</returns> protected cSiteMapNode SearchSiteMapNode(string path, int langId) { Searchwar_netEntities db = new Searchwar_netEntities(); // Get the CurrentPath if "path" is null if (string.IsNullOrEmpty(path)) { path = HttpContext.Current.Application["rawurl"].ToString(); } // Get UserRoles string[] roleNamesByUser = Roles.GetRolesForUser(); // Get the cSiteMapNode by the "path" cSiteMapNode cSiteMapNodeNode = (from s in db.SW_SiteMapNode join sd in db.SW_SiteMapNodeData on s.SiteMapNodeId equals sd.SiteMapNodeId where s.SiteMapNodePath.ToLower() == path.ToLower() && sd.LangId == langId && (s.SW_SiteMapNodeRoles.Count() != 0 ? s.SW_SiteMapNodeRoles.Where(r => roleNamesByUser.Contains(r.aspnet_Roles.RoleName)).Count() > 0 : true) == true select new cSiteMapNode { SiteMapNodeId = (int)s.SiteMapNodeId, SiteMapNodeSubId = (int?)s.SiteMapNodeSubId, SiteMapNodePath = (string)s.SiteMapNodePath, SiteMapNodeAddedUserId = (Guid)s.SiteMapNodeAddedUserId, SiteMapNodeEditUserId = (Guid)s.SiteMapNodeEditUserId, SiteMapNodeShow = (bool)s.SiteMapNodeShow, SiteMapNodeAddedDate = (DateTime)s.SiteMapNodeAddedDate, SiteMapNodeEditDate = (DateTime)s.SiteMapNodeEditDate, SiteMapNodeTitle = (string)sd.SiteMapNodeTitle, SiteMapNodeSort = (int)s.SiteMapNodeSort, LangId = (int)sd.LangId, SiteMapNodeRoles = s.SW_SiteMapNodeRoles.Where(r => r.SiteMapNodeId == s.SiteMapNodeId) // Check if user is allowed to see SiteMapNodes }).SingleOrDefault <cSiteMapNode>(); // Checking cSiteMapNode is in databasen if (cSiteMapNodeNode != null) { return(cSiteMapNodeNode); } else { throw (new ArgumentNullException("path", "Cant find '" + path + "' in database")); } }
/// <summary> /// Searching after path in database /// </summary> /// <param name="path">Insert path</param> /// <param name="siteMapNodeId"></param> /// <param name="langId">Insert langId</param> /// <returns>Return anonymous object</returns> protected cSiteMapNode GetSiteMapNode_Single(int siteMapNodeId, int langId) { Searchwar_netEntities db = new Searchwar_netEntities(); // Get UserRoles string[] roleNamesByUser = Roles.GetRolesForUser(); LangaugeSystem ls = new LangaugeSystem(); string langShortName = ls.CurrentLang; // Get the cSiteMapNode by the "path" cSiteMapNode cSiteMapNodeNode = (from s in db.SW_SiteMapNode join sd in db.SW_SiteMapNodeData on s.SiteMapNodeId equals sd.SiteMapNodeId where s.SiteMapNodeId == siteMapNodeId && sd.LangId == langId && (s.SW_SiteMapNodeRoles.Count() != 0 ? s.SW_SiteMapNodeRoles.Where(r => roleNamesByUser.Contains(r.aspnet_Roles.RoleName)).Count() > 0 : true) == true select new cSiteMapNode { SiteMapNodeId = (int)s.SiteMapNodeId, SiteMapNodeSubId = (int?)s.SiteMapNodeSubId, SiteMapNodePath = (string)s.SiteMapNodePath, SiteMapNodeRewrittedPath = (string)sd.SiteMapNodeRewriteUrl == null ? "" : "~/" + sd.SiteMapNodeRewriteUrl, SiteMapNodeAddedUserId = (Guid)s.SiteMapNodeAddedUserId, SiteMapNodeEditUserId = (Guid)s.SiteMapNodeEditUserId, SiteMapNodeShow = (bool)s.SiteMapNodeShow, SiteMapNodeAddedDate = (DateTime)s.SiteMapNodeAddedDate, SiteMapNodeEditDate = (DateTime)s.SiteMapNodeEditDate, SiteMapNodeTitle = (string)sd.SiteMapNodeTitle, SiteMapNodeSort = (int)s.SiteMapNodeSort, LangId = (int)sd.LangId, SiteMapNodeRoles = s.SW_SiteMapNodeRoles.Where(r => r.SiteMapNodeId == s.SiteMapNodeId) // Check if user is allowed to see SiteMapNodes }).SingleOrDefault <cSiteMapNode>(); // Checking cSiteMapNode is in databasen if (cSiteMapNodeNode != null) { return(cSiteMapNodeNode); } else { throw (new ArgumentNullException("siteMapNodeId", "Cant find '" + siteMapNodeId + "' in database")); } }
protected void CheckCurrentPath(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { // Get dataitem SiteMapNodePath cSiteMapNode cSiteMap = (cSiteMapNode)e.Item.DataItem; if (cSiteMap == null) { throw new NotImplementedException(); } string getPath = cSiteMap.SiteMapNodePath; int getLangId = cSiteMap.LangId; // Get Current SiteMapNodePath cSiteMapNode currentCSiteMap = new CustomSiteMapNode().GetCurrentSiteMapNode(getLangId); string getCurrentSiteMapNodePath = currentCSiteMap.SiteMapNodePath; // Check item SiteMapNodePath is current SiteMapNodePath if (getPath == getCurrentSiteMapNodePath) { // Change color HyperLink getCurrentHyper = (HyperLink)e.Item.FindControl("HyperNodePath"); getCurrentHyper.Attributes.Add("class", "selected"); } if (!string.IsNullOrEmpty(cSiteMap.SiteMapNodeRewrittedPath)) { string rewrittedPath = cSiteMap.SiteMapNodeRewrittedPath; if (!string.IsNullOrEmpty(rewrittedPath)) { getPath = rewrittedPath; } } // change url on path (Now with shortlang) HyperLink hyperNodePath = (HyperLink)e.Item.FindControl("HyperNodePath"); hyperNodePath.NavigateUrl = getPath; } }
/// <summary> /// Get parentpath of the inserted path /// </summary> /// <param name="path">Insert path</param> /// <returns>Return parentpath - anonymous object</returns> protected cSiteMapNode SearchParentSiteMapNode(string path) { Searchwar_netEntities db = new Searchwar_netEntities(); // Get UserRoles string[] roleNamesByUser = Roles.GetRolesForUser(); // Find the parentCSiteMapNode by "path" cSiteMapNode parentCSiteMapNode = (from s in db.SW_SiteMapNode join sd in db.SW_SiteMapNodeData on s.SiteMapNodeId equals sd.SiteMapNodeId join ss in db.SW_SiteMapNode on s.SiteMapNodeId equals ss.SiteMapNodeId where ss.SiteMapNodePath.ToLower() == path.ToLower() && (s.SW_SiteMapNodeRoles.Count() != 0 ? s.SW_SiteMapNodeRoles.Where(r => roleNamesByUser.Contains(r.aspnet_Roles.RoleName)).Count() > 0 : true) == true select new cSiteMapNode { SiteMapNodeId = (int)s.SiteMapNodeId, SiteMapNodeSubId = (int?)s.SiteMapNodeSubId, SiteMapNodePath = (string)s.SiteMapNodePath, SiteMapNodeAddedUserId = (Guid)s.SiteMapNodeAddedUserId, SiteMapNodeEditUserId = (Guid)s.SiteMapNodeEditUserId, SiteMapNodeShow = (bool)s.SiteMapNodeShow, SiteMapNodeAddedDate = (DateTime)s.SiteMapNodeAddedDate, SiteMapNodeEditDate = (DateTime)s.SiteMapNodeEditDate, SiteMapNodeTitle = (string)sd.SiteMapNodeTitle, LangId = (int)sd.LangId, SiteMapNodeRoles = s.SW_SiteMapNodeRoles.Where(r => r.SiteMapNodeId == s.SiteMapNodeId).ToList <SW_SiteMapNodeRole>() // Check if user is allowed to see SiteMapNodes }).SingleOrDefault <cSiteMapNode>(); // Checking cSiteMapNode is in database if (parentCSiteMapNode != null) { return(parentCSiteMapNode); } else { throw (new ArgumentNullException("Path", "Found no ParentPath in database for '" + path + "'")); } }
protected void Page_Load(object sender, EventArgs e) { // Select current langauge string currentLang = new LangaugeSystem().CurrentLang; // Show if javascript is disable ErrorJS.InnerText = GetLocalResourceObject("JavascriptBoxErrorMessageError").ToString(); // url for JS string pageId = Context.Request.AppRelativeCurrentExecutionFilePath.ToString(); string jsurl = ("~/js.axd?p=" + HttpUtility.UrlEncode(pageId)).ChangeToJsHost(); scriptsall.Scripts.Add(new System.Web.UI.ScriptReference(jsurl)); if (Page.IsPostBack) { return; } // get timezone ANO_User GetUserCookie = ANOProfile.GetCookieValues(CurrentUserIP); string currentZone = GetUserCookie.TimeZone; if (string.IsNullOrEmpty(currentZone)) { DivTimeZone.Visible = true; } else { DivTimeZone.Visible = false; } // check cache System.Collections.ObjectModel.ReadOnlyCollection <TimeZoneInfo> getTimeZones = (System.Collections.ObjectModel.ReadOnlyCollection <TimeZoneInfo>)Cache["masterpage_timezones"]; if (getTimeZones == null) { getTimeZones = TimeZoneInfo.GetSystemTimeZones(); if (getTimeZones != null) { // add Cache Cache.Add("masterpage_timezones", getTimeZones, null, TimeZoneManager.DateTimeNow.AddDays(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } DdlTimeZones.Items.Clear(); foreach (var zone in getTimeZones) { DdlTimeZones.Items.Add(new ListItem(zone.DisplayName.ToString(), zone.BaseUtcOffset.ToString())); } if (!string.IsNullOrEmpty(currentZone)) { DdlTimeZones.Items.FindByValue(currentZone).Selected = true; } // Insert Langauges in DropDownList DropDownList ddlLang = DdlSelectLang; ddlLang.Items.Clear(); // check cache List <SW_Lang> langs = (List <SW_Lang>)Cache["masterpage_langs"]; LangaugeSystem ls = new LangaugeSystem(); if (langs == null) { langs = ls.GetLangs(); if (langs != null) { // add Cache Cache.Add("masterpage_langs", langs, null, TimeZoneManager.DateTimeNow.AddDays(10), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } foreach (var lang in langs) { ddlLang.Items.Add(new ListItem(lang.LangName, lang.LangShortname)); } // check cache int?currentLangId = (int?)Cache["masterpage_LangId" + currentLang]; if (currentLangId.HasValue == false) { currentLangId = ls.GetLang(currentLang).LangId; if (currentLangId.HasValue == true) { // add Cache Cache.Add("masterpage_LangId" + currentLang, currentLangId, null, TimeZoneManager.DateTimeNow.AddDays(10), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } if (!string.IsNullOrEmpty(currentLang)) { DdlSelectLang.Items.FindByValue(currentLang).Selected = true; } // change url for logo (Now with shortlang) CustomSiteMapNode csm = new CustomSiteMapNode(); cSiteMapNode homeCSiteMapNode = csm.GetSiteMapNode(2, currentLangId.Value); string getPath = homeCSiteMapNode.SiteMapNodePath; if (!string.IsNullOrEmpty(homeCSiteMapNode.SiteMapNodeRewrittedPath)) { getPath = homeCSiteMapNode.SiteMapNodeRewrittedPath; } HyperImgLogo.NavigateUrl = getPath; // Insert menu data // check cache List <cSiteMapNode> sitemapnodes = (List <cSiteMapNode>)Cache["masterpage_nodes" + currentLangId]; if (sitemapnodes == null) { sitemapnodes = csm.GetSiteMapNodes((int)currentLangId, false); if (sitemapnodes != null) { // add Cache Cache.Add("masterpage_nodes" + currentLangId, sitemapnodes, null, TimeZoneManager.DateTimeNow.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } CMenu.DataSource = sitemapnodes; CMenu.CurrentUserIP = CurrentUserIP; CMenu.DataBind(); // Properties for metatags event SiteMapNodeMetatagsObject getMapMetaTags = null; cSiteMapNode getCurrentSiteMap = null; int currentSiteMapId; // Get CurrentSiteMapNode getCurrentSiteMap = csm.GetCurrentSiteMapNode((int)currentLangId); currentSiteMapId = getCurrentSiteMap.SiteMapNodeId; // Get Metatags for current cSiteMapNode // check cache getMapMetaTags = (SiteMapNodeMetatagsObject)Cache["masterpage_NodeMetatags" + currentSiteMapId.ToString() + currentLangId.ToString()]; SiteMapNodeMetaTags smm = new SiteMapNodeMetaTags(); if (getMapMetaTags == null) { getMapMetaTags = smm.GetMetaTags(currentSiteMapId, (int)currentLangId); if (getMapMetaTags != null) { // add cache Cache.Add("masterpage_NodeMetatags" + currentSiteMapId.ToString() + currentLangId.ToString(), getMapMetaTags, null, TimeZoneManager.DateTimeNow.AddDays(4), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } // Insert MetaTags string pageTitle = Request.Url.Host; if (getMapMetaTags != null) { MetaAuthor.Content = getMapMetaTags.MetaTagAuthor; MetaCache.Content = getMapMetaTags.MetaTagCache; MetaCopyright.Content = getMapMetaTags.MetaTagCopyright; MetaDescription.Content = getMapMetaTags.MetaTagDescription; MetaKeywords.Content = getMapMetaTags.MetaTagKeywords; MetaLanguage.Content = getMapMetaTags.MetaTagLanguage; MetaPublisher.Content = getMapMetaTags.MetaTagPublisher; MetaRobots.Content = getMapMetaTags.MetaTagRobots; MetaRevisitAfter.Content = getMapMetaTags.MetaTagRevisitAfter; MetaCacheControl.Content = getMapMetaTags.MetaTagCacheControl; pageTitle += " - " + getMapMetaTags.MetaTagTitle; } Page.Title = pageTitle; }