|
|
|
@ -68,6 +68,21 @@ class SupportedVersions
|
|
|
|
|
self::$releases = json_decode(file_get_contents(find_in_path(self::$releasesFile)), true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Filtre qui sélectionne les branches qu'on souhaite afficher. |
|
|
|
|
* |
|
|
|
|
* Par défaut, le filtre sélection les maintenues à la date courante, |
|
|
|
|
* c'est-à-dire les branches stable ou security. |
|
|
|
|
* |
|
|
|
|
* le paramètre sert à inclure les branches non-maintenues dans la limite |
|
|
|
|
* des bornes sur calendrier |
|
|
|
|
* |
|
|
|
|
* les branches futures sont sélectionnées à condition qu'un date prévisionnelle de sortie existe |
|
|
|
|
* et qu'elle soit dans les limite des bornes du calendrier |
|
|
|
|
* |
|
|
|
|
* @param boolean $includeEol embed eol branches if true. |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public static function branchesToShow($eol = false) { |
|
|
|
|
// @codeCoverageIgnoreStart |
|
|
|
|
if (!self::$config) { |
|
|
|
@ -79,11 +94,20 @@ class SupportedVersions
|
|
|
|
|
return array_reduce( |
|
|
|
|
self::$releases, |
|
|
|
|
function ($branches, $release) use ($eol, $now) { |
|
|
|
|
if ($release['initial_release'] != '') { |
|
|
|
|
if ($eol && $release['eol'] != '' && new DateTime($release['eol']) > self::$minDate) { |
|
|
|
|
$branches[] = $release; |
|
|
|
|
} elseif ($release['eol'] == '' || $release['eol'] > $now) { |
|
|
|
|
$branches[] = $release; |
|
|
|
|
if ($release['initial_release'] !== '') { |
|
|
|
|
$start = new DateTime($release['initial_release']); |
|
|
|
|
$state = self::state($release); |
|
|
|
|
$statesToShow = ['future', 'stable', 'security']; |
|
|
|
|
if ($eol) { |
|
|
|
|
array_push($statesToShow, 'eol'); |
|
|
|
|
} |
|
|
|
|
if (in_array($state, $statesToShow)) { |
|
|
|
|
$end = ($release['eol'] !== '') ? new DateTime($release['eol']) : ''; |
|
|
|
|
$limit = (new DateTime(self::$minDate->format('Y-m-d')))->sub(new DateInterval('P1D')); |
|
|
|
|
$end = max(($end ? $end : self::$maxDate), $limit); |
|
|
|
|
if (self::inCalendar($start, $end)) { |
|
|
|
|
$branches[] = $release; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -116,14 +140,8 @@ class SupportedVersions
|
|
|
|
|
|
|
|
|
|
//Calendar Part |
|
|
|
|
|
|
|
|
|
protected static function dateHorizCoord(DateTime $date) { |
|
|
|
|
$diff = $date->diff(self::$minDate); |
|
|
|
|
if (!$diff->invert) { |
|
|
|
|
return self::$config['svg']['margin_left']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return self::$config['svg']['margin_left'] + |
|
|
|
|
($diff->days / (365.24 / self::$config['svg']['year_width'])); |
|
|
|
|
protected static function inCalendar(DateTime $start, DateTime $end) { |
|
|
|
|
return $start < self::$maxDate && $end >= self::$minDate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function years() { |
|
|
|
@ -143,15 +161,43 @@ class SupportedVersions
|
|
|
|
|
} |
|
|
|
|
// @codeCoverageIgnoreEnd |
|
|
|
|
|
|
|
|
|
if ($date) { |
|
|
|
|
return self::dateHorizCoord(date_create_from_format('Y-m-d', $date)); |
|
|
|
|
} |
|
|
|
|
$horizCoord = $date ? |
|
|
|
|
new DateTime($date) : |
|
|
|
|
self::$maxDate; |
|
|
|
|
|
|
|
|
|
return self::dateHorizCoord(self::$maxDate); |
|
|
|
|
return self::dateHorizCoord($horizCoord); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//SVG Part |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Renvoie la coordonnée x d'une date dans le calendrier svg. |
|
|
|
|
* |
|
|
|
|
* - coordonnée 'x' de début du calendrier si la date est antérieure à la date de début du calendrier |
|
|
|
|
* - coordonnée 'x' de fin du calendrier si la date est postérieure à la date de fin du calendrier |
|
|
|
|
* |
|
|
|
|
* @uses width |
|
|
|
|
* |
|
|
|
|
* @param DateTime $date |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
protected static function dateHorizCoord(DateTime $date) { |
|
|
|
|
$diff = $date->diff(self::$minDate); |
|
|
|
|
if (!$diff->invert) { |
|
|
|
|
return self::$config['svg']['margin_left']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$diff2 = self::$maxDate->diff($date); |
|
|
|
|
if (!$diff2->invert) { |
|
|
|
|
return self::$config['svg']['margin_left'] + |
|
|
|
|
self::width(self::$config['svg']['margin_left']) + |
|
|
|
|
self::$config['svg']['year_width']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return self::$config['svg']['margin_left'] + |
|
|
|
|
intval($diff->days / (365.24 / self::$config['svg']['year_width'])); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Filtre qui détermine l'état d'une version par rapport à la date du jour. |
|
|
|
|
* |
|
|
|
@ -190,7 +236,7 @@ class SupportedVersions
|
|
|
|
|
$bug = $valeurs['active_support'] ? new DateTime($valeurs['active_support']) : null; |
|
|
|
|
$security = $valeurs['eol'] ? new DateTime($valeurs['eol']) : null; |
|
|
|
|
|
|
|
|
|
if ($initial && $initial < self::$now) { |
|
|
|
|
if ($initial && $initial <= self::$now) { |
|
|
|
|
$state = 'stable'; |
|
|
|
|
} |
|
|
|
|
if ($bug && $bug < self::$now) { |
|
|
|
@ -269,33 +315,120 @@ class SupportedVersions
|
|
|
|
|
(count(self::branchesToShow(true)) * self::$config['svg']['branch_height']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function stableOrGradient($date) { |
|
|
|
|
/** |
|
|
|
|
* Filtre calculant la largeur du rectangle, d'un état d'une branche. |
|
|
|
|
* |
|
|
|
|
* @param array $values |
|
|
|
|
* @param string $state |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
public static function rectWidth($branch, $state) { |
|
|
|
|
// @codeCoverageIgnoreStart |
|
|
|
|
if (!self::$config) { |
|
|
|
|
self::init(); |
|
|
|
|
} |
|
|
|
|
// @codeCoverageIgnoreEnd |
|
|
|
|
$gradient = ''; |
|
|
|
|
// Etat inconnu |
|
|
|
|
if (!in_array($state, ['security', 'stable', 'future'])) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
$filteredBranches = array_filter(self::$releases, function ($release) use ($branch) { |
|
|
|
|
return $branch === $release['branch']; |
|
|
|
|
}); |
|
|
|
|
$values = array_pop($filteredBranches); |
|
|
|
|
|
|
|
|
|
// Branche inconnue |
|
|
|
|
if (!isset($values)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($date == '' || new DateTime($date) > self::$maxDate) { |
|
|
|
|
$gradient .= '-gradient'; |
|
|
|
|
$endDate = $values['eol']; |
|
|
|
|
$startDate = $values['initial_release']; |
|
|
|
|
if ($state == 'security') { |
|
|
|
|
$startDate = $values['active_support']; |
|
|
|
|
} |
|
|
|
|
if ($state == 'stable') { |
|
|
|
|
$endDate = $values['active_support'] ? $values['active_support'] : $endDate; |
|
|
|
|
} |
|
|
|
|
$startDate = new DateTime($startDate); |
|
|
|
|
$endDate = new DateTime($endDate); |
|
|
|
|
|
|
|
|
|
return 'stable'.$gradient; |
|
|
|
|
if (strrpos(self::stateOrGradient($values['branch'], $state), '-gradient')) { |
|
|
|
|
$endDate = self::$maxDate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$rectWidth = intval( |
|
|
|
|
self::dateHorizCoord($endDate) - self::dateHorizCoord($startDate) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $rectWidth > 0 ? $rectWidth : ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function securityOrGradient($date) { |
|
|
|
|
/** |
|
|
|
|
* Filtre calculant la class CSS d'un rectangle SVG de l'état d'une branche. |
|
|
|
|
* |
|
|
|
|
* Si la branche est inconnue, renvoie une chaine vide (''). |
|
|
|
|
* Si l'état n'est pas affichable, renvoie une chaine vide (''). |
|
|
|
|
* Si cycle de vie de la branche est en dehors des bornes du calendrier, renvoie une chaine vide (''). |
|
|
|
|
* - i.e. : fin de vie avant la date de début, sortie effective ou prévue après la date de fin |
|
|
|
|
* Si l'état de la branche se termine dans les bornes du calendrier, renvoie l'état. |
|
|
|
|
* - i.e : stable, security, future |
|
|
|
|
* Si l'état de la branche n'a pas de fin prévue, renvoie l'état et la mention gradient. |
|
|
|
|
* - i.e. : stable-gradient, security-gradient, future-gradient. |
|
|
|
|
* |
|
|
|
|
* @param string $branch |
|
|
|
|
* @param string $state |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public static function stateOrGradient($branch, $state) { |
|
|
|
|
// @codeCoverageIgnoreStart |
|
|
|
|
if (!self::$config) { |
|
|
|
|
self::init(); |
|
|
|
|
} |
|
|
|
|
// @codeCoverageIgnoreEnd |
|
|
|
|
$gradient = ''; |
|
|
|
|
// Etat inconnu |
|
|
|
|
if (!in_array($state, ['security', 'stable', 'future'])) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
$filteredBranches = array_filter(self::$releases, function ($release) use ($branch) { |
|
|
|
|
return $branch === $release['branch']; |
|
|
|
|
}); |
|
|
|
|
$values = array_pop($filteredBranches); |
|
|
|
|
|
|
|
|
|
// Branche inconnue |
|
|
|
|
if (!isset($values)) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$endDate = $values['eol']; |
|
|
|
|
$startDate = $values['initial_release']; |
|
|
|
|
if ($state == 'security') { |
|
|
|
|
$startDate = $values['active_support']; |
|
|
|
|
} |
|
|
|
|
if ($state == 'stable') { |
|
|
|
|
$endDate = $values['active_support'] ? $values['active_support'] : $endDate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($date == '' || new DateTime($date) > self::$maxDate) { |
|
|
|
|
$gradient .= '-gradient'; |
|
|
|
|
// Date de début de l'état non prévue |
|
|
|
|
if ($startDate === '') { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
if (!self::inCalendar(new DateTime($startDate), new DateTime($endDate))) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$originalState = self::state($values); |
|
|
|
|
if ($state !== 'future' && $originalState == 'future') { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
if ($state === 'future' && $originalState !== 'future') { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 'security'.$gradient; |
|
|
|
|
if ($endDate === '' || new DateTime($endDate) > self::$maxDate) { |
|
|
|
|
$state .= '-gradient'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $state; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|