[web-php] master: Add minor links to sidebar and unify rendering (changelog)

From: Date: Sat, 05 Jun 2021 04:23:39 +0000
Subject: [web-php] master: Add minor links to sidebar and unify rendering (changelog)
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-29353@lists.php.net to get a copy of this message
Author: Sara Golemon (sgolemon) Date: 2021-06-05T04:23:25Z Commit: https://github.com/php/web-php/commit/c4a333b300b4fe12c1404a98984c849332881e92 Raw diff: https://github.com/php/web-php/commit/c4a333b300b4fe12c1404a98984c849332881e92.diff Add minor links to sidebar and unify rendering (changelog) Changed paths: M ChangeLog-4.php M ChangeLog-5.php M ChangeLog-7.php M ChangeLog-8.php M include/changelogs.inc Diff: diff --git a/ChangeLog-4.php b/ChangeLog-4.php index c738c59df..fb07e5b11 100644 --- a/ChangeLog-4.php +++ b/ChangeLog-4.php @@ -2,15 +2,10 @@ $_SERVER['BASE_PAGE'] = 'ChangeLog-4.php'; include_once __DIR__ . '/include/prepend.inc'; include_once __DIR__ . '/include/changelogs.inc'; -site_header("PHP 4 ChangeLog", array("current" => "docs", "css" => array("changelog.css"), "layout_span" => 12)); -?> - -<h1>PHP 4 ChangeLog</h1> - -<a href="#PHP_4_4">4.4</a> | -<a href="#PHP_4_3">4.3</a> | <a href="#PHP_4_2">4.2</a> | -<a href="#PHP_4_1">4.1</a> | <a href="#PHP_4_0">4.0</a> +$MINOR_VERSIONS = ['4.4', '4.3', '4.2', '4.1', '4.0']; +changelog_header(4, $MINOR_VERSIONS); +?> <a name="PHP_4_4"></a> <section class="version" id="4.4.9"><!-- {{{ 4.4.9 --> @@ -3884,4 +3879,4 @@ interface modules (Zeev)</li> <?php -site_footer(['sidebar' => changelog_sidebar(4)]); +changelog_footer(4, $MINOR_VERSIONS); diff --git a/ChangeLog-5.php b/ChangeLog-5.php index 110be660d..8ee46d9c0 100644 --- a/ChangeLog-5.php +++ b/ChangeLog-5.php @@ -2,16 +2,10 @@ $_SERVER['BASE_PAGE'] = 'ChangeLog-5.php'; include_once __DIR__ . '/include/prepend.inc'; include_once __DIR__ . '/include/changelogs.inc'; -site_header("PHP 5 ChangeLog", array("current" => "docs", "css" => array("changelog.css"), "layout_span" => 12)); -?> - -<h1>PHP 5 ChangeLog</h1> - -<a href="#PHP_5_6">5.6</a> | -<a href="#PHP_5_5">5.5</a> | <a href="#PHP_5_4">5.4</a> | -<a href="#PHP_5_3">5.3</a> | <a href="#PHP_5_2">5.2</a> | -<a href="#PHP_5_1">5.1</a> | <a href="#PHP_5_0">5.0</a> +$MINOR_VERSIONS = ['5.6', '5.5', '5.4', '5.3', '5.2', '5.1', '5.0']; +changelog_header(5, $MINOR_VERSIONS); +?> <a name="PHP_5_6"></a> <section class="version" id="5.6.40"><!-- {{{ 5.6.40 --> <h3>Version 5.6.40</h3> @@ -15959,4 +15953,4 @@ functions if "zend" is specified as the module name. (Ilia)</li> <?php -site_footer(['sidebar' => changelog_sidebar(5)]); +changelog_footer(5, $MINOR_VERSIONS); diff --git a/ChangeLog-7.php b/ChangeLog-7.php index 9b34586fe..6028a7d3c 100644 --- a/ChangeLog-7.php +++ b/ChangeLog-7.php @@ -2,14 +2,10 @@ $_SERVER['BASE_PAGE'] = 'ChangeLog-7.php'; include_once __DIR__ . '/include/prepend.inc'; include_once __DIR__ . '/include/changelogs.inc'; -site_header("PHP 7 ChangeLog", array("current" => "docs", "css" => array("changelog.css"), "layout_span" => 12)); -?> -<h1>PHP 7 ChangeLog</h1> - -<a href="#PHP_7_4">7.4</a> | -<a href="#PHP_7_3">7.3</a> | <a href="#PHP_7_2">7.2</a> | -<a href="#PHP_7_1">7.1</a> | <a href="#PHP_7_0">7.0</a> +$MINOR_VERSIONS = ['7.4', '7.3', '7.2', '7.1', '7.0']; +changelog_header(7, $MINOR_VERSIONS); +?> <a name="PHP_7_4"></a> <section class="version" id="7.4.20"><!-- {{{ 7.4.20 --> @@ -10232,5 +10228,4 @@ <!-- }}} --></section> <?php - -site_footer(['sidebar' => changelog_sidebar(7)]); +changelog_footer(7, $MINOR_VERSIONS); diff --git a/ChangeLog-8.php b/ChangeLog-8.php index 5d99ccc38..2d1bc7071 100644 --- a/ChangeLog-8.php +++ b/ChangeLog-8.php @@ -2,12 +2,10 @@ $_SERVER['BASE_PAGE'] = 'ChangeLog-8.php'; include_once __DIR__ . '/include/prepend.inc'; include_once __DIR__ . '/include/changelogs.inc'; -site_header("PHP 8 ChangeLog", array("current" => "docs", "css" => array("changelog.css"), "layout_span" => 12)); -?> -<h1>PHP 8 ChangeLog</h1> - -<a href="#PHP_8_0">8.0</a> +$MINOR_VERSIONS = ['8.0']; +changelog_header(8, $MINOR_VERSIONS); +?> <a name="PHP_8_0"></a> <section class="version" id="8.0.7"><!-- {{{ 8.0.7 --> @@ -754,5 +752,4 @@ <!-- }}} --></section> <?php - -site_footer(['sidebar' => changelog_sidebar(8)]); +changelog_footer(8, $MINOR_VERSIONS); diff --git a/include/changelogs.inc b/include/changelogs.inc index e868f9681..994133192 100644 --- a/include/changelogs.inc +++ b/include/changelogs.inc @@ -34,15 +34,37 @@ function release_date($in) { echo "<time class='releasedate' datetime='{$for_tools}'>{$human_readable}</time>"; } -function changelog_sidebar(?int $current = null): string { - $majors = [8, 7, 5, 4]; - $ret = "<div class=\"panel\">ChangeLogs<div class=\"body\"><ul>\n"; - foreach ($majors as $major) { - if ($major === $current) { - $ret .= " <li><b>PHP {$major}.x</b></li>\n"; +function changelog_makelink(string $branch): string { + return '<a href="#PHP_' . urlencode(strtr($branch, '.', '_')) . '">' . htmlentities($branch) . '</a>'; +} + +function changelog_header(int $major_version, array $minor_versions): void { + site_header("PHP {$major_version} ChangeLog", [ + 'current' => 'docs', + 'css' => ['changelog.css'], + 'layout_span' => 12, + ]); + echo "<h1>PHP {$major_version} ChangeLog</h1>\n"; + $glue = ''; + foreach($minor_versions as $branch) { + echo $glue, changelog_makelink($branch); + $glue = ' | '; + } + echo "\n"; +} + +function changelog_footer(int $current_major, array $minor_versions): void { + $sidebar = "<div class=\"panel\">ChangeLogs<div class=\"body\"><ul>\n"; + foreach ([8, 7, 5, 4] as $major) { + if ($major === $current_major) { + $sidebar .= " <li><b>PHP {$major}.x</b>\n <ul>"; + foreach ($minor_versions as $branch) { + $sidebar .= " <li>" . changelog_makelink($branch) . "</li>\n"; + } + $sidebar .= " </ul></li>\n"; } else { - $ret .= " <li><a href=\"/ChangeLog-{$major}.php\">PHP {$major}.x</a></li>\n"; + $sidebar .= " <li><a href=\"/ChangeLog-{$major}.php\">PHP {$major}.x</a></li>\n"; } } - return $ret .= "</ul></body></body>\n"; + site_footer(['sidebar' => "$sidebar</ul></div></div>"]); }

« previous php.webmaster (#29353) next »