protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string szRedirect = string.Empty; string szComponents = util.GetStringParam(Request, szParamComponents); int id = util.GetIntParam(Request, "id", LogbookEntry.idFlightNone); if (id != -1) { Response.Redirect(String.Format(CultureInfo.InvariantCulture, "{0}/{1}{2}", Request.Path, id, String.IsNullOrEmpty(szComponents) ? string.Empty : String.Format(CultureInfo.InvariantCulture, "?{0}={1}", szParamComponents, szComponents)), true); return; } else if (!String.IsNullOrEmpty(Request.PathInfo) && Int32.TryParse(Request.PathInfo.Substring(1), out id)) { id = Convert.ToInt32(Request.PathInfo.Substring(1), CultureInfo.InvariantCulture); } LogbookEntry le = new LogbookEntry(); // load the flight, redirect home on any error. if (id > 0 && le.FLoadFromDB(id, User.Identity.Name, LogbookEntry.LoadTelemetryOption.MetadataOrDB, true)) { PublicFlight = le; hdnID.Value = id.ToString(CultureInfo.InvariantCulture); if (!le.fIsPublic && (String.Compare(le.User, User.Identity.Name, StringComparison.OrdinalIgnoreCase) != 0)) // not public and this isn't the owner... { szRedirect = "~/public/MapRoute2.aspx?sm=1&Airports=" + HttpUtility.UrlEncode(le.Route); } SetComponentsDisplay(szComponents); lblComments.Text = le.Comment.Linkify(); fbComment.URI = Branding.PublicFlightURL(id); string szRoute = le.Route; lnkRoute.Text = HttpUtility.HtmlEncode(szRoute); lnkRoute.NavigateUrl = "~/Public/MapRoute2.aspx?sm=1&Airports=" + HttpUtility.UrlEncode(szRoute); Profile pf = MyFlightbook.Profile.GetUser(le.User); lnkUser.Text = pf.UserFullName; lnkUser.NavigateUrl = pf.PublicFlightsURL(Request.Url.Host).AbsoluteUri; btnEdit.Visible = (le.User == User.Identity.Name); lblHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.LocalizedJoinWithDash, le.Date.ToShortDateString(), le.TailNumDisplay); SetImages(le); string szDescription = le.SocialMediaComment.Length > 0 ? le.SocialMediaComment : Resources.LogbookEntry.PublicFlightHeader; this.Master.Title = szDescription; this.Master.AddMeta("description", szDescription); mfbMiniFacebook.FlightEntry = le; lblError.Text = string.Empty; this.Master.SelectedTab = tabID.tabHome; ShowMap(le); } else { szRedirect = "~/Default.aspx"; } if (szRedirect.Length > 0) { Response.Redirect(szRedirect); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string szRedirect = string.Empty; int id = util.GetIntParam(Request, "id", LogbookEntry.idFlightNone); string szComponents = util.GetStringParam(Request, szParamComponents); if (id != -1) { Response.Redirect(String.Format(CultureInfo.InvariantCulture, "{0}/{1}{2}", Request.Path, id, String.IsNullOrEmpty(szComponents) ? string.Empty : String.Format(CultureInfo.InvariantCulture, "?{0}={1}", szParamComponents, szComponents)), true); return; } else if (!String.IsNullOrEmpty(Request.PathInfo) && Int32.TryParse(Request.PathInfo.Substring(1), out id)) { id = Convert.ToInt32(Request.PathInfo.Substring(1), CultureInfo.InvariantCulture); } LogbookEntry le = new LogbookEntry(); // load the flight, redirect home on any error. if (id > 0 && le.FLoadFromDB(id, User.Identity.Name, LogbookEntry.LoadTelemetryOption.MetadataOrDB, true)) { PublicFlight = le; hdnID.Value = id.ToString(CultureInfo.InvariantCulture); if (!le.fIsPublic && (String.Compare(le.User, User.Identity.Name, StringComparison.OrdinalIgnoreCase) != 0)) // not public and this isn't the owner... { szRedirect = "~/public/MapRoute2.aspx?sm=1&Airports=" + HttpUtility.UrlEncode(le.Route); } // display only selected components, if necessary if (!String.IsNullOrEmpty(szComponents)) { // turn off the header/footer to display only the requested components this.Master.HasFooter = this.Master.HasHeader = false; FullPageBottom.Visible = FullPageTop.Visible = false; divImages.Visible = pnlFB.Visible = pnlDetails.Visible = divMap.Visible = mfbAirportServices1.Visible = lnkShowMapOnly.Visible = imgsliderFlights.Visible = mfbVideoEntry1.Visible = false; ShowComponents(szComponents.Split(',')); } lblComments.Text = le.Comment.Linkify(); fbComment.URI = Branding.PublicFlightURL(id); string szRoute = le.Route; lnkRoute.Text = HttpUtility.HtmlEncode(szRoute); lnkRoute.NavigateUrl = "~/Public/MapRoute2.aspx?sm=1&Airports=" + HttpUtility.UrlEncode(szRoute); Profile pf = MyFlightbook.Profile.GetUser(le.User); lnkUser.Text = pf.UserFullName; lnkUser.NavigateUrl = pf.PublicFlightsURL(Request.Url.Host).AbsoluteUri; btnEdit.Visible = (le.User == User.Identity.Name); lblHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.LocalizedJoinWithDash, le.Date.ToShortDateString(), le.TailNumDisplay); if (this.Master.IsMobileSession()) { mfbIlAirplane.Columns = mfbIlFlight.Columns = 1; } mfbIlFlight.Key = hdnID.Value; mfbIlFlight.Refresh(); mfbIlAirplane.Key = le.AircraftID.ToString(CultureInfo.InvariantCulture); mfbIlAirplane.AltText = le.TailNumDisplay; UserAircraft ua = new UserAircraft(le.User); Aircraft ac = ua.GetUserAircraftByID(le.AircraftID) ?? new Aircraft(le.AircraftID); mfbIlAirplane.DefaultImage = ac.DefaultImage; mfbIlAirplane.Refresh(); List <MFBImageInfo> lst = new List <MFBImageInfo>(mfbIlFlight.Images.ImageArray); lst.AddRange(mfbIlAirplane.Images.ImageArray); imgsliderFlights.Images = lst; imgsliderFlights.Visible = lst.Count > 0; string szDescription = le.SocialMediaComment.Length > 0 ? le.SocialMediaComment : Resources.LogbookEntry.PublicFlightHeader; this.Master.Title = szDescription; this.Master.AddMeta("description", szDescription); mfbMiniFacebook.FlightEntry = le; lblError.Text = ""; this.Master.SelectedTab = tabID.tabHome; mfbVideoEntry1.Videos.Clear(); foreach (VideoRef vid in le.Videos) { mfbVideoEntry1.Videos.Add(vid); } ShowMap(le); } else { szRedirect = "~/Default.aspx"; } if (szRedirect.Length > 0) { Response.Redirect(szRedirect); } } }