diff --git a/docs.php b/docs.php index 04dd13107..3119d5bf7 100644 --- a/docs.php +++ b/docs.php @@ -1,4 +1,7 @@ "docs"]); $langname) { +$lastlang = array_key_last(Languages::ACTIVE_ONLINE_LANGUAGES); +foreach (Languages::ACTIVE_ONLINE_LANGUAGES as $langcode => $langname) { if (!file_exists($_SERVER["DOCUMENT_ROOT"] . "/manual/{$langcode}/index.php")) { continue; } // Make preferred language bold - if ($langcode == $LANG) { echo ""; } + if ($langcode === $LANG) { echo ""; } echo '' . $langname . ''; - echo ($lastlang != $langname) ? ",\n" : "\n"; + echo ($lastlang !== $langcode) ? ",\n" : "\n"; - if ($langcode == $LANG) { echo ""; } + if ($langcode === $LANG) { echo ""; } } ?> diff --git a/download-docs.php b/download-docs.php index 0d31fd10f..9abfc80f5 100644 --- a/download-docs.php +++ b/download-docs.php @@ -1,9 +1,12 @@ $language) { - if (isset($INACTIVE_ONLINE_LANGUAGES[$langcode]) && $MYSITE !== 'http://docs.php.net/') { +foreach (Languages::LANGUAGES as $langcode => $language) { + if (isset(Languages::INACTIVE_ONLINE_LANGUAGES[$langcode]) && $MYSITE !== 'http://docs.php.net/') { continue; } @@ -180,7 +183,7 @@ if (count($found_formats) == 0) { $cellclass = ""; } - echo "\n" . $LANGUAGES[$langcode] . "\n"; + echo "\n" . Languages::LANGUAGES[$langcode] . "\n"; foreach ($formats as $formatname => $extension) { diff --git a/error.php b/error.php index 2801188f1..423135a29 100644 --- a/error.php +++ b/error.php @@ -9,11 +9,11 @@ */ +use phpweb\I18n\Languages; use phpweb\UserPreferences; // Ensure that our environment is set up include_once __DIR__ . '/include/prepend.inc'; -include_once __DIR__ . '/include/languages.inc'; include_once __DIR__ . '/include/errors.inc'; // Get URI for this request, strip leading slash @@ -79,7 +79,7 @@ if (preg_match("!(.*\\.php)3$!", $URI, $array)) { // default language manual accessibility on mirror sites through /manual/filename) // @todo do we rely on this? how about removing it... if (preg_match("!^manual/([^/]*)$!", $URI, $array)) { - if (!isset($INACTIVE_ONLINE_LANGUAGES[$array[1]])) { + if (!isset(Languages::INACTIVE_ONLINE_LANGUAGES[$array[1]])) { mirror_redirect("/manual/$LANG/$array[1]"); } } elseif (preg_match("!^manual/html/([^/]+)$!", $URI, $array)) { @@ -705,10 +705,10 @@ 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]])) { + isset(Languages::INACTIVE_ONLINE_LANGUAGES[$match[1]])) { $try = find_manual_page("en", $match[2]); if ($try) { - error_inactive_manual_page($INACTIVE_ONLINE_LANGUAGES[$match[1]], $try); + error_inactive_manual_page(Languages::INACTIVE_ONLINE_LANGUAGES[$match[1]], $try); } } diff --git a/include/errors.inc b/include/errors.inc index 17fd86912..76637c2da 100644 --- a/include/errors.inc +++ b/include/errors.inc @@ -5,6 +5,8 @@ not available. */ +use phpweb\I18n\Languages; + // A 'good looking' 404 error message page function error_404(): void { @@ -37,7 +39,7 @@ function error_404_manual(): void // An error message page for manual pages from inactive languages function error_inactive_manual_page($lang_name, $en_page): void { - global $MYSITE, $ACTIVE_ONLINE_LANGUAGES; + global $MYSITE; status_header(404); site_header('Page gone', ["noindex"]); echo "

Page gone

\n" . @@ -48,7 +50,7 @@ function error_inactive_manual_page($lang_name, $en_page): void echo "

The English page is available at {$en_url}

\n"; echo "

Several other languages are also available:

\n"; echo "