|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +namespace releases\php82; |
| 4 | + |
| 5 | +include_once __DIR__ . '/../../include/prepend.inc'; |
| 6 | + |
| 7 | +function language_redirect(string $currentLang): void { |
| 8 | + // We don't use the general language selection of php.net, |
| 9 | + // so soldier on with this one. |
| 10 | + return; |
| 11 | +} |
| 12 | + |
| 13 | +function common_header(string $description): void { |
| 14 | + global $MYSITE; |
| 15 | + |
| 16 | + $meta_image_path = \htmlspecialchars( |
| 17 | + \filter_var($MYSITE . 'images/php8/php_8_1_released.png', \FILTER_VALIDATE_URL)); |
| 18 | + $meta_description = \htmlspecialchars($description); |
| 19 | + |
| 20 | + \site_header("PHP 8.2.0 Release Announcement", [ |
| 21 | + 'current' => 'php8', |
| 22 | + 'css' => ['php8.css'], |
| 23 | + 'meta_tags' => <<<META |
| 24 | +<meta name="twitter:card" content="summary_large_image" /> |
| 25 | +<meta name="twitter:site" content="@official_php" /> |
| 26 | +<meta name="twitter:title" content="PHP 8.2 Released" /> |
| 27 | +<meta name="twitter:description" content="{$meta_description}" /> |
| 28 | +<meta name="twitter:creator" content="@official_php" /> |
| 29 | +<meta name="twitter:image:src" content="{$meta_image_path}" /> |
| 30 | +
|
| 31 | +<meta itemprop="name" content="PHP 8.2 Released" /> |
| 32 | +<meta itemprop="description" content="{$meta_description}" /> |
| 33 | +<meta itemprop="image" content="{$meta_image_path}" /> |
| 34 | +
|
| 35 | +<meta property="og:image" content="{$meta_image_path}" /> |
| 36 | +<meta property="og:description" content="{$meta_description}" /> |
| 37 | +META |
| 38 | + ]); |
| 39 | +} |
| 40 | + |
| 41 | +function language_chooser(string $currentLang): void { |
| 42 | + $LANGUAGES = [ |
| 43 | + 'en' => 'English', |
| 44 | + ]; |
| 45 | + |
| 46 | + // Print out the form with all the options |
| 47 | + echo ' |
| 48 | + <form action="" method="get" id="changelang" name="changelang"> |
| 49 | + <fieldset> |
| 50 | + <label for="changelang-langs">Change language:</label> |
| 51 | + <select onchange="location = this.value + \'.php\'" name="lang" id="changelang-langs"> |
| 52 | +'; |
| 53 | + |
| 54 | + $tab = ' '; |
| 55 | + foreach ($LANGUAGES as $lang => $text) { |
| 56 | + $selected = ($lang === $currentLang) ? ' selected="selected"' : ''; |
| 57 | + echo $tab, "<option value='$lang'$selected>$text</option>\n"; |
| 58 | + } |
| 59 | + |
| 60 | + echo ' </select> |
| 61 | + </fieldset> |
| 62 | + </form> |
| 63 | +'; |
| 64 | +} |
| 65 | + |
| 66 | +function message($code, $language = 'en') |
| 67 | +{ |
| 68 | + $original = require __DIR__ . '/languages/en.php'; |
| 69 | + if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) { |
| 70 | + $translation = require __DIR__ . '/languages/' . $language . '.php'; |
| 71 | + } |
| 72 | + |
| 73 | + return $translation[$code] ?? $original[$code] ?? $code; |
| 74 | +} |
0 commit comments