|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace releases\php85; |
| 6 | + |
| 7 | +include_once __DIR__ . '/../../include/prepend.inc'; |
| 8 | + |
| 9 | +const LANGUAGES = [ |
| 10 | + 'en' => 'English', |
| 11 | + 'fr' => 'Français', |
| 12 | + 'ru' => 'Russian', |
| 13 | + 'pt_BR' => 'Brazilian Portuguese', |
| 14 | + 'nl' => 'Nederlands', |
| 15 | + 'es' => 'Spanish', |
| 16 | + 'tr' => 'Türkçe', |
| 17 | + 'uk' => 'Українська', |
| 18 | + 'zh' => '简体中文', |
| 19 | + 'ja' => '日本語', |
| 20 | +]; |
| 21 | + |
| 22 | +function common_header(string $description): void { |
| 23 | + global $MYSITE; |
| 24 | + |
| 25 | + $meta_image_path = \htmlspecialchars( |
| 26 | + \filter_var($MYSITE . 'images/php8/php_8_5_released.png', \FILTER_VALIDATE_URL)); |
| 27 | + $meta_description = \htmlspecialchars($description); |
| 28 | + |
| 29 | + \site_header("PHP 8.5 Release Announcement", [ |
| 30 | + 'current' => 'php8', |
| 31 | + 'css' => ['php85.css'], |
| 32 | + 'meta_tags' => <<<META |
| 33 | +<meta name="twitter:card" content="summary_large_image" /> |
| 34 | +<meta name="twitter:site" content="@official_php" /> |
| 35 | +<meta name="twitter:title" content="PHP 8.5 Released" /> |
| 36 | +<meta name="twitter:description" content="{$meta_description}" /> |
| 37 | +<meta name="twitter:creator" content="@official_php" /> |
| 38 | +<meta name="twitter:image:src" content="{$meta_image_path}" /> |
| 39 | +
|
| 40 | +<meta itemprop="name" content="PHP 8.5 Released" /> |
| 41 | +<meta itemprop="description" content="{$meta_description}" /> |
| 42 | +<meta itemprop="image" content="{$meta_image_path}" /> |
| 43 | +
|
| 44 | +<meta property="og:image" content="{$meta_image_path}" /> |
| 45 | +<meta property="og:description" content="{$meta_description}" /> |
| 46 | +META |
| 47 | + ]); |
| 48 | +} |
| 49 | + |
| 50 | +function language_chooser(string $currentLang): void { |
| 51 | + // Print out the form with all the options |
| 52 | + echo ' |
| 53 | + <form action="" method="get" id="changelang" name="changelang"> |
| 54 | + <fieldset> |
| 55 | + <label for="changelang-langs">Change language:</label> |
| 56 | + <select onchange="location = this.value + \'.php\'" name="lang" id="changelang-langs"> |
| 57 | +'; |
| 58 | + |
| 59 | + $tab = ' '; |
| 60 | + foreach (LANGUAGES as $lang => $text) { |
| 61 | + $selected = ($lang === $currentLang) ? ' selected="selected"' : ''; |
| 62 | + echo $tab, "<option value='$lang'$selected>$text</option>\n"; |
| 63 | + } |
| 64 | + |
| 65 | + echo ' </select> |
| 66 | + </fieldset> |
| 67 | + </form> |
| 68 | +'; |
| 69 | +} |
| 70 | + |
| 71 | +function message($code, $language = 'en') |
| 72 | +{ |
| 73 | + $original = require __DIR__ . '/languages/en.php'; |
| 74 | + if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) { |
| 75 | + $translation = require __DIR__ . '/languages/' . $language . '.php'; |
| 76 | + } |
| 77 | + |
| 78 | + return $translation[$code] ?? $original[$code] ?? $code; |
| 79 | +} |
0 commit comments