Commit:    f1a3ca46cc851552bcad7ce28f6df9e3993a1452
Author:    Adam Harvey <[email protected]>         Mon, 27 Oct 2014 13:12:28 -0700
Parents:   06658b4306535fc66190d71c3dcd3de60a0db588
Branches:  master

Link:       
http://git.php.net/?p=web/php.git;a=commitdiff;h=f1a3ca46cc851552bcad7ce28f6df9e3993a1452

Log:
Add a draft supported versions page, as suggested on Internals.

Changed paths:
  A  images/supported-versions.php
  M  include/branches.inc
  A  styles/supported-versions.css
  A  supported-versions.php

diff --git a/images/supported-versions.php b/images/supported-versions.php
new file mode 100644
index 0000000..7fadf26
--- /dev/null
+++ b/images/supported-versions.php
@@ -0,0 +1,150 @@
+<?php
+include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
+include_once $_SERVER['DOCUMENT_ROOT'] . '/include/branches.inc';
+
+// Sizing constants.
+$margin_left = 80;
+$margin_right = 50;
+$header_height = 24;
+$year_width = 120;
+$branch_height = 30;
+$footer_height = 24;
+
+function branches_to_show() {
+       // Basically: show all 5.3+ branches with EOL dates > min_date().
+       $branches = array();
+
+       // Flatten out the majors.
+       foreach (get_all_branches() as $major => $major_branches) {
+               foreach ($major_branches as $branch => $version) {
+                       if (version_compare($branch, '5.3', 'ge') && 
get_branch_security_eol_date($branch) > min_date()) {
+                               $branches[$branch] = $version;
+                       }
+               }
+       }
+
+       ksort($branches);
+       return $branches;
+}
+
+function min_date() {
+       $now = new DateTime('January 1');
+       return $now->sub(new DateInterval('P3Y'));
+}
+
+function max_date() {
+       $now = new DateTime('January 1');
+       return $now->add(new DateInterval('P5Y'));
+}
+
+function date_horiz_coord(DateTime $date) {
+       $diff = $date->diff(min_date());
+       if (!$diff->invert) {
+               return $GLOBALS['margin_left'];
+       }
+       return $GLOBALS['margin_left'] + ($diff->days / (365.24 / 
$GLOBALS['year_width']));
+}
+
+$branches = branches_to_show();
+$i = 0;
+foreach ($branches as $branch => $version) {
+       $branches[$branch]['top'] = $header_height + ($branch_height * $i++);
+}
+
+if (!isset($non_standalone)) {
+       header('Content-Type: image/svg+xml');
+       echo '<?xml version="1.0"?>';
+}
+
+$years = iterator_to_array(new DatePeriod(min_date(), new DateInterval('P1Y'), 
max_date()));
+$width = $margin_left + $margin_right + ((count($years) - 1) * $year_width);
+$height = $header_height + $footer_height + (count($branches) * 
$branch_height);
+?>
+<svg xmlns="http://www.w3.org/2000/svg"; viewbox="0 0 <?php echo $width ?> 
<?php echo $height ?>" width="<?php echo $width ?>" height="<?php echo $height 
?>">
+       <style type="text/css">
+               <![CDATA[
+                       @import url(/fonts/Fira/fira.css);
+
+                       text {
+                               fill: #333;
+                               font-family: "Fira Sans", "Source Sans Pro", 
Helvetica, Arial, sans-serif;
+                               font-size: <?php echo (2 / 3) * $header_height; 
?>px;
+                       }
+
+                       .branches rect.security {
+                               fill: #f93;
+                       }
+
+                       .branches rect.stable {
+                               fill: #9c9;
+                       }
+
+                       .branch-labels text {
+                               alignment-baseline: central;
+                       }
+
+                       .today line {
+                               stroke: #f33;
+                               stroke-dasharray: 7,7;
+                               stroke-width: 3px;
+                       }
+
+                       .today text {
+                               fill: #f33;
+                               text-anchor: middle;
+                       }
+
+                       .years line {
+                               stroke: black;
+                       }
+
+                       .years text {
+                               text-anchor: middle;
+                       }
+               ]]>
+       </style>
+
+       <!-- Branch labels -->
+       <g class="branch-labels">
+               <?php foreach ($branches as $branch => $version): ?>
+                       <text x="0" y="<?php echo $version['top'] + (0.5 * 
$branch_height) ?>">
+                               <?php echo htmlspecialchars($branch) ?>
+                       </text>
+               <?php endforeach ?>
+       </g>
+
+       <!-- Branch blocks -->
+       <g class="branches">
+               <?php foreach ($branches as $branch => $version): ?>
+                       <?php
+                       $x_release = 
date_horiz_coord(get_branch_release_date($branch));
+                       $x_bug = 
date_horiz_coord(get_branch_bug_eol_date($branch));
+                       $x_eol = 
date_horiz_coord(get_branch_security_eol_date($branch));
+                       ?>
+                       <rect class="stable" x="<?php echo $x_release ?>" 
y="<?php echo $version['top'] ?>" width="<?php echo $x_bug - $x_release ?>" 
height="<?php echo $branch_height ?>" />
+                       <rect class="security" x="<?php echo $x_bug ?>" 
y="<?php echo $version['top'] ?>" width="<?php echo $x_eol - $x_bug ?>" 
height="<?php echo $branch_height ?>" />
+               <?php endforeach ?>
+       </g>
+
+       <!-- Year lines -->
+       <g class="years">
+               <?php foreach ($years as $date): ?>
+                       <line x1="<?php echo date_horiz_coord($date) ?>" 
y1="<?php echo $header_height ?>" x2="<?php echo date_horiz_coord($date) ?>" 
y2="<?php echo $header_height + (count($branches) * $branch_height) ?>" />
+                       <text x="<?php echo date_horiz_coord($date) ?>" 
y="<?php echo 0.8 * $header_height; ?>">
+                               <?php echo $date->format('j M Y') ?>
+                       </text>
+               <?php endforeach ?>
+       </g>
+
+       <!-- Today -->
+       <g class="today">
+               <?php
+               $now = new DateTime;
+               $x = date_horiz_coord($now);
+               ?>
+               <line x1="<?php echo $x ?>" y1="<?php echo $header_height ?>" 
x2="<?php echo $x ?>" y2="<?php echo $header_height + (count($branches) * 
$branch_height) ?>" />
+               <text x="<?php echo $x ?>" y="<?php echo $header_height + 
(count($branches) * $branch_height) + (0.8 * $footer_height) ?>">
+                       <?php echo 'Today: '.$now->format('j M Y') ?>
+               </text>
+       </g>
+</svg>
diff --git a/include/branches.inc b/include/branches.inc
index 03e47ed..dd5e33d 100644
--- a/include/branches.inc
+++ b/include/branches.inc
@@ -52,6 +52,39 @@ function version_number_to_branch($version) {
        }
 }
 
+function get_all_branches() {
+       $branches = array();
+
+       foreach ($GLOBALS['OLDRELEASES'] as $major => $releases) {
+               foreach ($releases as $version => $release) {
+                       if ($branch = version_number_to_branch($version)) {
+                               if (!isset($branches[$major][$branch]) || 
version_compare($version, $branches[$major][$branch]['version'], 'gt')) {
+                                       $branches[$major][$branch] = $release;
+                                       $branches[$major][$branch]['version'] = 
$version;
+                               }
+                       }
+               }
+       }
+
+       foreach ($GLOBALS['RELEASES'] as $major => $releases) {
+               foreach ($releases as $version => $release) {
+                       if ($branch = version_number_to_branch($version)) {
+                               if (!isset($branches[$major][$branch]) || 
version_compare($version, $branches[$major][$branch]['version'], 'gt')) {
+                                       $branches[$major][$branch] = $release;
+                                       $branches[$major][$branch]['version'] = 
$version;
+                               }
+                       }
+               }
+       }
+
+       krsort($branches);
+       foreach ($branches as $major => &$branch) {
+               krsort($branch);
+       }
+
+       return $branches;
+}
+
 function get_active_branches() {
        $branches = array();
 
@@ -136,3 +169,78 @@ function get_eol_branches($always_include = null) {
 
        return $branches;
 }
+
+/* $branch is expected to have at least two components: MAJOR.MINOR or
+ * MAJOR.MINOR.REVISION (the REVISION will be ignored if provided). This will
+ * return either null (if no release exists on the given branch), or the usual
+ * version metadata from $RELEASES for a single release. */
+function get_initial_release($branch) {
+       $branch = version_number_to_branch($branch);
+       if (!$branch) {
+               return null;
+       }
+       $major = substr($branch, 0, strpos($branch, '.'));
+
+       if (isset($GLOBALS['OLDRELEASES'][$major]["$branch.0"])) {
+               return $GLOBALS['OLDRELEASES'][$major]["$branch.0"];
+       }
+
+       /* If there's only been one release on the branch, it won't be in
+        * $OLDRELEASES yet, so let's check $RELEASES. */
+       if (isset($GLOBALS['RELEASES'][$major]["$branch.0"])) {
+               return $GLOBALS['RELEASES'][$major]["$branch.0"];
+       }
+
+       // Shrug.
+       return null;
+}
+
+function get_branch_bug_eol_date($branch) {
+       // Hardcode 5.3.
+       if (strncmp($branch, '5.3', 3) == 0) {
+               return new DateTime('2013-07-11');
+       }
+
+       $date = get_branch_release_date($branch);
+
+       return $date ? $date->add(new DateInterval('P2Y')) : null;
+}
+
+function get_branch_security_eol_date($branch) {
+       // Hardcode 5.3.
+       if (strncmp($branch, '5.3', 3) == 0) {
+               return new DateTime('2014-08-14');
+       }
+
+       $date = get_branch_release_date($branch);
+
+       return $date ? $date->add(new DateInterval('P3Y')) : null;
+}
+
+function get_branch_release_date($branch) {
+       $initial = get_initial_release($branch);
+
+       return $initial ? new DateTime($initial['date']) : null;
+}
+
+function get_branch_support_state($branch) {
+       $initial = get_branch_release_date($branch);
+       $bug = get_branch_bug_eol_date($branch);
+       $security = get_branch_security_eol_date($branch);
+
+       if ($initial && $bug && $security) {
+               $now = new DateTime;
+
+               if ($now >= $security) {
+                       return 'eol';
+               } elseif ($now >= $bug) {
+                       return 'security';
+               } elseif ($now >= $initial) {
+                       return 'stable';
+               } else {
+                       return 'future';
+               }
+       }
+
+       return null;
+}
diff --git a/styles/supported-versions.css b/styles/supported-versions.css
new file mode 100644
index 0000000..41f5911
--- /dev/null
+++ b/styles/supported-versions.css
@@ -0,0 +1,18 @@
+/* Branches page */
+
+table.standard tr.eol td:first-child {
+       background: #f99;
+}
+
+table.standard tr.security td:first-child {
+       background: #f93;
+}
+
+table.standard tr.stable td:first-child {
+       background: #9c9;
+}
+
+svg {
+       max-width: 100%;
+       height: auto;
+}
diff --git a/supported-versions.php b/supported-versions.php
new file mode 100644
index 0000000..22c8e7c
--- /dev/null
+++ b/supported-versions.php
@@ -0,0 +1,103 @@
+<?php
+$_SERVER['BASE_PAGE'] = 'supported-versions.php';
+
+include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
+include_once $_SERVER['DOCUMENT_ROOT'] . '/include/branches.inc';
+
+site_header('Supported Versions', array('css' => 
array('supported-versions.css')));
+?>
+
+<h1>Supported Versions</h1>
+
+<p>
+       Each release branch of PHP is fully supported for two years from its 
initial
+       stable release. During this period, bugs and security issues that have 
been
+       reported are fixed and are released in regular point releases.
+</p>
+
+<p>
+       After this two year period of active support, each branch is then 
supported
+       for an additional year for critical security issues only. Releases 
during
+       this period are made on an as-needed basis: there may be multiple point
+       releases, or none, depending on the number of reports.
+</p>
+
+<p>
+       Once the three years of support are completed, the branch reaches its 
end of
+       life and is no longer supported. <a href="/eol.php">A table of end of 
life
+       branches is available.</a>
+</p>
+
+<h3>Currently Supported Versions</h3>
+
+<table class="standard">
+       <thead>
+               <tr>
+                       <th>Branch</th>
+                       <th colspan="2">Initial Release</th>
+                       <th colspan="2">Active Support Until</th>
+                       <th colspan="2">Security Support Until</th>
+               </tr>
+       </thead>
+       <tbody>
+               <?php foreach (get_active_branches() as $major => $releases): ?>
+                       <?php ksort($releases) ?>
+                       <?php foreach ($releases as $branch => $release): ?>
+                               <?php
+                               $state = get_branch_support_state($branch);
+                               $initial = get_branch_release_date($branch);
+                               $until = get_branch_bug_eol_date($branch);
+                               $eol = get_branch_security_eol_date($branch);
+                               ?>
+                               <tr class="<?php echo $state ?>">
+                                       <td>
+                                               <a href="/downloads.php#v<?php 
echo htmlspecialchars($release['version']) ?>">
+                                                       <?php echo 
htmlspecialchars($branch) ?>
+                                               </a>
+                                       </td>
+                                       <td><?php echo 
htmlspecialchars($initial->format('j M Y')) ?></td>
+                                       <td><em><?php echo 
htmlspecialchars(format_interval($initial, null)) ?></em></td>
+                                       <td><?php echo 
htmlspecialchars($until->format('j M Y')) ?></td>
+                                       <td><em><?php echo 
htmlspecialchars(format_interval($until, null)) ?></em></td>
+                                       <td><?php echo 
htmlspecialchars($eol->format('j M Y')) ?></td>
+                                       <td><em><?php echo 
htmlspecialchars(format_interval($eol, null)) ?></em></td>
+                               </tr>
+                       <?php endforeach ?>
+               <?php endforeach ?>
+       </tbody>
+</table>
+
+<p>
+       Or, visualised as a calendar:
+</p>
+
+<?php
+/* Chrome doesn't handle @font-face directives in SVG files included via <img>
+ * tags (which is odd, since it does handle them when you view the SVG files by
+ * themselves). Instead, we'll just pull the SVG into the page inline, thereby
+ * ensuring that we have the same text formatting as the rest of the page. */
+
+$non_standalone = true;
+include $_SERVER['DOCUMENT_ROOT'] . '/images/supported-versions.php';
+?>
+
+<h4>Key</h4>
+
+<table class="standard">
+       <tr class="stable">
+               <td>Active support</td>
+               <td>
+                       A release that is being actively supported. Reported 
bugs and security
+                       issues are fixed and regular point releases are made.
+               </td>
+       </tr>
+       <tr class="security">
+               <td>Security fixes only</td>
+               <td>
+                       A release that is supported for critical security 
issues only. Releases
+                       are only made on an as-needed basis.
+               </td>
+       </tr>
+</table>
+
+<?php site_footer(); ?>
-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to