Commit:    4716c2ba20e7d9183e333711c560aca060f1d65f
Author:    Peter Cowburn <[email protected]>         Tue, 26 Mar 2019 21:46:22 
+0000
Parents:   30a519333fe0516dfe53306457b3db17f66e884d
Branches:  master

Link:       
http://git.php.net/?p=web/php.git;a=commitdiff;h=4716c2ba20e7d9183e333711c560aca060f1d65f

Log:
friendlier error page for manual pages under inactive languages (fix bug #77637)

Bugs:
https://bugs.php.net/77637

Changed paths:
  M  error.php
  M  include/errors.inc


Diff:
diff --git a/error.php b/error.php
index adefef1..c9cdb6f 100644
--- a/error.php
+++ b/error.php
@@ -635,6 +635,16 @@ if (preg_match("!^manual/(.+)/function\.(.+)-(.+).php$!", 
$URI, $array)) {
     }
 }
 
+// ============================================================================
+// For manual pages for inactive languages, point visitors to the English page
+if (preg_match("!^manual/([^/]+)/([^/]+).php$!", $URI, $match) &&
+    isset($INACTIVE_ONLINE_LANGUAGES[$match[1]])) {
+    $try = find_manual_page("en", $match[2]);
+    if ($try) {
+        error_inactive_manual_page($INACTIVE_ONLINE_LANGUAGES[$match[1]], 
$try);
+    }
+}
+
 
 // ============================================================================
 // 404 page for manual pages (eg. not built language)
diff --git a/include/errors.inc b/include/errors.inc
index 1c686ed..cc21370 100644
--- a/include/errors.inc
+++ b/include/errors.inc
@@ -34,6 +34,32 @@ function error_404_manual()
     exit;
 }
 
+// An error message page for manual pages from inactive languages
+function error_inactive_manual_page($lang_name, $en_page)
+{
+    global $MYSITE, $ACTIVE_ONLINE_LANGUAGES;
+    status_header(404);
+    site_header('Page gone', array("noindex"));
+    echo "<h1>Page gone</h1>\n" .
+         "<p>The " . htmlspecialchars($lang_name) . " manual page you are 
looking for (<strong>" .
+         htmlspecialchars(substr($MYSITE, 0, -1) . $_SERVER['REQUEST_URI']) .
+         "</strong>) is no longer available.</p>\n";
+    $en_url = htmlspecialchars(substr($MYSITE, 0, -1) . $en_page);
+    echo "<p>The English page is available at <a 
href=\"{$en_url}\">{$en_url}</a></p>\n";
+    echo "<p>Several other languages are also available:</p>\n";
+    echo "<ul>\n";
+    foreach ($ACTIVE_ONLINE_LANGUAGES as $alt_lang => $alt_lang_name) {
+        if ($alt_lang === "en") {
+            continue;
+        }
+        $alt_url = htmlspecialchars(substr($MYSITE, 0, -1) . 
str_replace("/en/", "/{$alt_lang}/", $en_page));
+        echo "<li><a href=\"{$alt_url}\">" . htmlspecialchars($alt_lang_name) 
. "</a></li>\n";
+    }
+    echo "</ul>\n";
+    site_footer();
+    exit;
+}
+
 // This service is not working right now
 function error_noservice()
 {


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to