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