Skip to content

Commit c4a333b

Browse files
committed
Add minor links to sidebar and unify rendering (changelog)
1 parent e7d818b commit c4a333b

File tree

5 files changed

+46
-43
lines changed

5 files changed

+46
-43
lines changed

ChangeLog-4.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22
$_SERVER['BASE_PAGE'] = 'ChangeLog-4.php';
33
include_once __DIR__ . '/include/prepend.inc';
44
include_once __DIR__ . '/include/changelogs.inc';
5-
site_header("PHP 4 ChangeLog", array("current" => "docs", "css" => array("changelog.css"), "layout_span" => 12));
6-
?>
7-
8-
<h1>PHP 4 ChangeLog</h1>
9-
10-
<a href="#PHP_4_4">4.4</a> |
11-
<a href="#PHP_4_3">4.3</a> | <a href="#PHP_4_2">4.2</a> |
12-
<a href="#PHP_4_1">4.1</a> | <a href="#PHP_4_0">4.0</a>
135

6+
$MINOR_VERSIONS = ['4.4', '4.3', '4.2', '4.1', '4.0'];
7+
changelog_header(4, $MINOR_VERSIONS);
8+
?>
149
<a name="PHP_4_4"></a>
1510

1611
<section class="version" id="4.4.9"><!-- {{{ 4.4.9 -->
@@ -3884,4 +3879,4 @@ interface modules (Zeev)</li>
38843879

38853880
<?php
38863881

3887-
site_footer(['sidebar' => changelog_sidebar(4)]);
3882+
changelog_footer(4, $MINOR_VERSIONS);

ChangeLog-5.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
$_SERVER['BASE_PAGE'] = 'ChangeLog-5.php';
33
include_once __DIR__ . '/include/prepend.inc';
44
include_once __DIR__ . '/include/changelogs.inc';
5-
site_header("PHP 5 ChangeLog", array("current" => "docs", "css" => array("changelog.css"), "layout_span" => 12));
6-
?>
7-
8-
<h1>PHP 5 ChangeLog</h1>
9-
10-
<a href="#PHP_5_6">5.6</a> |
11-
<a href="#PHP_5_5">5.5</a> | <a href="#PHP_5_4">5.4</a> |
12-
<a href="#PHP_5_3">5.3</a> | <a href="#PHP_5_2">5.2</a> |
13-
<a href="#PHP_5_1">5.1</a> | <a href="#PHP_5_0">5.0</a>
145

6+
$MINOR_VERSIONS = ['5.6', '5.5', '5.4', '5.3', '5.2', '5.1', '5.0'];
7+
changelog_header(5, $MINOR_VERSIONS);
8+
?>
159
<a name="PHP_5_6"></a>
1610
<section class="version" id="5.6.40"><!-- {{{ 5.6.40 -->
1711
<h3>Version 5.6.40</h3>
@@ -15959,4 +15953,4 @@ functions if "zend" is specified as the module name. (Ilia)</li>
1595915953

1596015954
<?php
1596115955

15962-
site_footer(['sidebar' => changelog_sidebar(5)]);
15956+
changelog_footer(5, $MINOR_VERSIONS);

ChangeLog-7.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
$_SERVER['BASE_PAGE'] = 'ChangeLog-7.php';
33
include_once __DIR__ . '/include/prepend.inc';
44
include_once __DIR__ . '/include/changelogs.inc';
5-
site_header("PHP 7 ChangeLog", array("current" => "docs", "css" => array("changelog.css"), "layout_span" => 12));
6-
?>
7-
<h1>PHP 7 ChangeLog</h1>
8-
9-
<a href="#PHP_7_4">7.4</a> |
10-
<a href="#PHP_7_3">7.3</a> | <a href="#PHP_7_2">7.2</a> |
11-
<a href="#PHP_7_1">7.1</a> | <a href="#PHP_7_0">7.0</a>
125

6+
$MINOR_VERSIONS = ['7.4', '7.3', '7.2', '7.1', '7.0'];
7+
changelog_header(7, $MINOR_VERSIONS);
8+
?>
139
<a name="PHP_7_4"></a>
1410

1511
<section class="version" id="7.4.20"><!-- {{{ 7.4.20 -->
@@ -10232,5 +10228,4 @@
1023210228
<!-- }}} --></section>
1023310229

1023410230
<?php
10235-
10236-
site_footer(['sidebar' => changelog_sidebar(7)]);
10231+
changelog_footer(7, $MINOR_VERSIONS);

ChangeLog-8.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
$_SERVER['BASE_PAGE'] = 'ChangeLog-8.php';
33
include_once __DIR__ . '/include/prepend.inc';
44
include_once __DIR__ . '/include/changelogs.inc';
5-
site_header("PHP 8 ChangeLog", array("current" => "docs", "css" => array("changelog.css"), "layout_span" => 12));
6-
?>
7-
<h1>PHP 8 ChangeLog</h1>
8-
9-
<a href="#PHP_8_0">8.0</a>
105

6+
$MINOR_VERSIONS = ['8.0'];
7+
changelog_header(8, $MINOR_VERSIONS);
8+
?>
119
<a name="PHP_8_0"></a>
1210

1311
<section class="version" id="8.0.7"><!-- {{{ 8.0.7 -->
@@ -754,5 +752,4 @@
754752
<!-- }}} --></section>
755753

756754
<?php
757-
758-
site_footer(['sidebar' => changelog_sidebar(8)]);
755+
changelog_footer(8, $MINOR_VERSIONS);

include/changelogs.inc

+30-8
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,37 @@ function release_date($in) {
3434
echo "<time class='releasedate' datetime='{$for_tools}'>{$human_readable}</time>";
3535
}
3636

37-
function changelog_sidebar(?int $current = null): string {
38-
$majors = [8, 7, 5, 4];
39-
$ret = "<div class=\"panel\">ChangeLogs<div class=\"body\"><ul>\n";
40-
foreach ($majors as $major) {
41-
if ($major === $current) {
42-
$ret .= " <li><b>PHP {$major}.x</b></li>\n";
37+
function changelog_makelink(string $branch): string {
38+
return '<a href="#PHP_' . urlencode(strtr($branch, '.', '_')) . '">' . htmlentities($branch) . '</a>';
39+
}
40+
41+
function changelog_header(int $major_version, array $minor_versions): void {
42+
site_header("PHP {$major_version} ChangeLog", [
43+
'current' => 'docs',
44+
'css' => ['changelog.css'],
45+
'layout_span' => 12,
46+
]);
47+
echo "<h1>PHP {$major_version} ChangeLog</h1>\n";
48+
$glue = '';
49+
foreach($minor_versions as $branch) {
50+
echo $glue, changelog_makelink($branch);
51+
$glue = ' | ';
52+
}
53+
echo "\n";
54+
}
55+
56+
function changelog_footer(int $current_major, array $minor_versions): void {
57+
$sidebar = "<div class=\"panel\">ChangeLogs<div class=\"body\"><ul>\n";
58+
foreach ([8, 7, 5, 4] as $major) {
59+
if ($major === $current_major) {
60+
$sidebar .= " <li><b>PHP {$major}.x</b>\n <ul>";
61+
foreach ($minor_versions as $branch) {
62+
$sidebar .= " <li>" . changelog_makelink($branch) . "</li>\n";
63+
}
64+
$sidebar .= " </ul></li>\n";
4365
} else {
44-
$ret .= " <li><a href=\"/ChangeLog-{$major}.php\">PHP {$major}.x</a></li>\n";
66+
$sidebar .= " <li><a href=\"/ChangeLog-{$major}.php\">PHP {$major}.x</a></li>\n";
4567
}
4668
}
47-
return $ret .= "</ul></body></body>\n";
69+
site_footer(['sidebar' => "$sidebar</ul></div></div>"]);
4870
}

0 commit comments

Comments
 (0)