1<?php 2 3declare(strict_types=1); 4 5namespace releases\php81; 6 7include_once __DIR__ . '/../../include/prepend.inc'; 8 9const LANGUAGES = [ 10 'en' => 'English', 11 'es' => 'Español', 12 'de' => 'Deutsch', 13 'pt_BR' => 'Português do Brasil', 14 'ru' => 'Русский', 15 'zh' => '简体中文', 16 'ka' => 'ქართული', 17 'ja' => '日本語', 18]; 19 20function common_header(string $description): void { 21 global $MYSITE; 22 23 $meta_image_path = \htmlspecialchars( 24 \filter_var($MYSITE . 'images/php8/php_8_1_released.png', \FILTER_VALIDATE_URL)); 25 $meta_description = \htmlspecialchars($description); 26 27 \site_header("PHP 8.1.0 Release Announcement", [ 28 'current' => 'php8', 29 'css' => ['php8.css'], 30 'meta_tags' => <<<META 31<meta name="twitter:card" content="summary_large_image" /> 32<meta name="twitter:site" content="@official_php" /> 33<meta name="twitter:title" content="PHP 8.1 Released" /> 34<meta name="twitter:description" content="{$meta_description}" /> 35<meta name="twitter:creator" content="@official_php" /> 36<meta name="twitter:image:src" content="{$meta_image_path}" /> 37 38<meta itemprop="name" content="PHP 8.1 Released" /> 39<meta itemprop="description" content="{$meta_description}" /> 40<meta itemprop="image" content="{$meta_image_path}" /> 41 42<meta property="og:image" content="{$meta_image_path}" /> 43<meta property="og:description" content="{$meta_description}" /> 44META 45 ]); 46} 47 48function language_chooser(string $currentLang): void { 49 // Print out the form with all the options 50 echo ' 51 <form action="" method="get" id="changelang" name="changelang"> 52 <fieldset> 53 <label for="changelang-langs">Change language:</label> 54 <select onchange="location = this.value + \'.php\'" name="lang" id="changelang-langs"> 55'; 56 57 $tab = ' '; 58 foreach (LANGUAGES as $lang => $text) { 59 $selected = ($lang === $currentLang) ? ' selected="selected"' : ''; 60 echo $tab, "<option value='$lang'$selected>$text</option>\n"; 61 } 62 63 echo ' </select> 64 </fieldset> 65 </form> 66'; 67} 68 69function message($code, $language = 'en') 70{ 71 $original = require __DIR__ . '/languages/en.php'; 72 if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) { 73 $translation = require __DIR__ . '/languages/' . $language . '.php'; 74 } 75 76 return $translation[$code] ?? $original[$code] ?? $code; 77} 78