public static GetDestination ( System.PageInfo page ) : System.PageInfo | ||
page | System.PageInfo | The source Page. |
return | System.PageInfo |
/// <summary> /// Verifies the need for a page redirection, and performs it when appropriate. /// </summary> private void VerifyAndPerformPageRedirection() { if (currentPage == null) { return; } // Force formatting so that the destination can be detected Content.GetFormattedPageContent(currentPage, true); PageInfo dest = Redirections.GetDestination(currentPage, out var fragment); if (dest == null) { return; } if (dest != null) { if (Request["NoRedirect"] != "1") { var fullUrl = dest.FullName + Settings.PageExtension + "?From=" + currentPage.FullName; if (!string.IsNullOrEmpty(fragment)) { fullUrl += "#" + fragment; } UrlTools.Redirect(fullUrl, false); } else { // Write redirection hint var sb = new StringBuilder(); sb.Append(@"<div id=""RedirectionDiv"">"); sb.Append(Properties.Messages.ThisPageRedirectsTo); sb.Append(": "); sb.Append(@"<a href="""); var fullUrl = UrlTools.BuildUrl("++", Tools.UrlEncode(dest.FullName), Settings.PageExtension, "?From=", Tools.UrlEncode(currentPage.FullName)); if (!string.IsNullOrEmpty(fragment)) { fullUrl += "#" + fragment; } sb.Append(fullUrl); sb.Append(@""">"); PageContent k = Content.GetPageContent(dest, true); sb.Append(FormattingPipeline.PrepareTitle(k.Title, false, FormattingContext.PageContent, currentPage)); sb.Append("</a></div>"); var literal = new Literal(); literal.Text = sb.ToString(); plhContent.Controls.Add(literal); } } }
/// <summary> /// Verifies the need for a page redirection, and performs it when appropriate. /// </summary> private void VerifyAndPerformPageRedirection() { if (currentPage == null) { return; } // Force formatting so that the destination can be detected FormattedContent.GetFormattedPageContent(currentWiki, currentPage); PageContent dest = Redirections.GetDestination(currentPage.FullName); if (dest == null) { return; } if (dest != null) { if (Request["NoRedirect"] != "1") { UrlTools.Redirect(dest.FullName + GlobalSettings.PageExtension + "?From=" + currentPage.FullName, false); } else { // Write redirection hint StringBuilder sb = new StringBuilder(); sb.Append(@"<div id=""RedirectionDiv"">"); sb.Append(Properties.Messages.ThisPageRedirectsTo); sb.Append(": "); sb.Append(@"<a href="""); UrlTools.BuildUrl(currentWiki, sb, "++", Tools.UrlEncode(dest.FullName), GlobalSettings.PageExtension, "?From=", Tools.UrlEncode(currentPage.FullName)); sb.Append(@""">"); sb.Append(FormattingPipeline.PrepareTitle(currentWiki, dest.Title, false, FormattingContext.PageContent, currentPage.FullName)); sb.Append("</a></div>"); Literal literal = new Literal(); literal.Text = sb.ToString(); plhContent.Controls.Add(literal); } } }