|
| 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 | + 'ru' => 'Русский', |
| 12 | +]; |
| 13 | + |
| 14 | +function common_header(string $description): void { |
| 15 | + global $MYSITE, $lang; |
| 16 | + |
| 17 | + $meta_image_path = \htmlspecialchars( |
| 18 | + \filter_var($MYSITE . 'images/php8/php_8_5_released.png', \FILTER_VALIDATE_URL)); |
| 19 | + $meta_description = \htmlspecialchars($description); |
| 20 | + |
| 21 | + $languages = []; |
| 22 | + foreach (LANGUAGES as $code => $text) { |
| 23 | + $languages[] = ['name' => $text, 'selected' => $lang === $code, 'url' => '/releases/8.5/' . $code . '.php']; |
| 24 | + } |
| 25 | + |
| 26 | + \site_header("PHP 8.5 Release Announcement", [ |
| 27 | + 'current' => 'php85', |
| 28 | + 'css' => ['prism.css', 'php85.css'], |
| 29 | + 'js_files' => ['js/ext/prism.js'], |
| 30 | + 'language_switcher' => $languages, |
| 31 | + 'theme_switcher' => true, |
| 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 message($code, $language = 'en', array $interpolations = []) |
| 51 | +{ |
| 52 | + $original = require __DIR__ . '/languages/en.php'; |
| 53 | + if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) { |
| 54 | + $translation = require __DIR__ . '/languages/' . $language . '.php'; |
| 55 | + } |
| 56 | + |
| 57 | + $message = $translation[$code] ?? $original[$code] ?? $code; |
| 58 | + |
| 59 | + foreach ($interpolations as $name => $value) { |
| 60 | + $message = str_replace("{{$name}}", $value, $message); |
| 61 | + } |
| 62 | + |
| 63 | + return $message; |
| 64 | +} |
0 commit comments