|
|
|
@ -39,8 +39,8 @@ function supportedversions_header_prive_css($flux) {
|
|
|
|
|
* @see https://www.spip.net/fr_article4014.html |
|
|
|
|
* @api |
|
|
|
|
* |
|
|
|
|
* @param Champ $p |
|
|
|
|
* @return Champ |
|
|
|
|
* @param StdClass $p |
|
|
|
|
* @return StdClass |
|
|
|
|
*/ |
|
|
|
|
function balise_SUPPORTED_VERSIONS_dist($p) { |
|
|
|
|
return balise_ENV_dist($p, '$GLOBALS["supportedversions"]'); |
|
|
|
@ -51,12 +51,53 @@ function balise_SUPPORTED_VERSIONS_dist($p) {
|
|
|
|
|
*/ |
|
|
|
|
class SupportedVersions |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* Configuration du calendrier (SVG, CSS, Dates). |
|
|
|
|
* |
|
|
|
|
* @var array<mixed>|null |
|
|
|
|
*/ |
|
|
|
|
protected static $config = null; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Date courante. |
|
|
|
|
* |
|
|
|
|
* @var DateTime |
|
|
|
|
*/ |
|
|
|
|
protected static $now; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Date de début du calendrier. |
|
|
|
|
* |
|
|
|
|
* @var DateTime |
|
|
|
|
*/ |
|
|
|
|
private static $minDate; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Date de fin du calendrier. |
|
|
|
|
* |
|
|
|
|
* @var DateTime |
|
|
|
|
*/ |
|
|
|
|
private static $maxDate; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Liste des années (format 'Y-m-d') du calendrier |
|
|
|
|
* |
|
|
|
|
* @var array<string> |
|
|
|
|
*/ |
|
|
|
|
private static $years; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Liste des versions issues du fichier $releasesFile. |
|
|
|
|
* |
|
|
|
|
* @var array<mixed> |
|
|
|
|
*/ |
|
|
|
|
private static $releases; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Chemin relatif du fichier JSON des versions à afficher |
|
|
|
|
* |
|
|
|
|
* @var string |
|
|
|
|
*/ |
|
|
|
|
protected static $releasesFile; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -94,7 +135,8 @@ class SupportedVersions
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Releases initialization |
|
|
|
|
self::$releases = json_decode(file_get_contents(find_in_path(self::$releasesFile)), true); |
|
|
|
|
$json = file_get_contents(find_in_path(self::$releasesFile)); |
|
|
|
|
self::$releases = $json ? json_decode($json, true) : []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -106,7 +148,7 @@ class SupportedVersions
|
|
|
|
|
* - Les branches avec une date de fin postérieure à la date de début de l'intervalle ou non prévue |
|
|
|
|
* |
|
|
|
|
* @param boolean $eol Ajoute les branches 'eol' à la sélection si true |
|
|
|
|
* @return array |
|
|
|
|
* @return array<mixed> les branches à afficher |
|
|
|
|
*/ |
|
|
|
|
public static function branchesToShow($eol = false) { |
|
|
|
|
// @codeCoverageIgnoreStart |
|
|
|
@ -115,10 +157,9 @@ class SupportedVersions
|
|
|
|
|
} |
|
|
|
|
// @codeCoverageIgnoreEnd |
|
|
|
|
|
|
|
|
|
$now = self::$now->format('Y-m-d'); |
|
|
|
|
return array_reduce( |
|
|
|
|
self::$releases, |
|
|
|
|
function ($branches, $release) use ($eol, $now) { |
|
|
|
|
function ($branches, $release) use ($eol) { |
|
|
|
|
if ($release['initial_release'] !== '') { |
|
|
|
|
$start = new DateTime($release['initial_release']); |
|
|
|
|
$state = self::state($release); |
|
|
|
@ -145,7 +186,7 @@ class SupportedVersions
|
|
|
|
|
/** |
|
|
|
|
* Filtre sélectionnant les données des branches en fin de vie. |
|
|
|
|
* |
|
|
|
|
* @return array |
|
|
|
|
* @return array<mixed> les branches en fin de vie à afficher |
|
|
|
|
*/ |
|
|
|
|
public static function eoledBranches() { |
|
|
|
|
// @codeCoverageIgnoreStart |
|
|
|
@ -184,7 +225,7 @@ class SupportedVersions
|
|
|
|
|
/** |
|
|
|
|
* Filtre fournissant les années (format 'Y-m-d') composant le calendrier. |
|
|
|
|
* |
|
|
|
|
* @return void |
|
|
|
|
* @return array<string> liste des années du calendrier (format 'Y-m-d') |
|
|
|
|
*/ |
|
|
|
|
public static function years() { |
|
|
|
|
// @codeCoverageIgnoreStart |
|
|
|
@ -271,8 +312,8 @@ class SupportedVersions
|
|
|
|
|
* Si la date est supérieure à la date du jour, l'état reste à 'security' |
|
|
|
|
* Sinon l'état est 'eol' |
|
|
|
|
* |
|
|
|
|
* @param array $valeurs tableau correspondant aux dates de la version |
|
|
|
|
* @return void |
|
|
|
|
* @param array<string> $valeurs tableau correspondant aux dates de la version |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public static function state(array $valeurs) { |
|
|
|
|
// @codeCoverageIgnoreStart |
|
|
|
@ -303,7 +344,7 @@ class SupportedVersions
|
|
|
|
|
* Filtre servant à calculer la coordonnées 'y' dans le calendrier pour une branche données. |
|
|
|
|
* |
|
|
|
|
* @param string $branch |
|
|
|
|
* @return void |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
public static function top($branch) { |
|
|
|
|
// @codeCoverageIgnoreStart |
|
|
|
@ -330,7 +371,7 @@ class SupportedVersions
|
|
|
|
|
* @codeCoverageIgnore |
|
|
|
|
* |
|
|
|
|
* @param string $branch |
|
|
|
|
* @return void |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
public static function topForText($branch) { |
|
|
|
|
if (!self::$config) { |
|
|
|
@ -339,7 +380,7 @@ class SupportedVersions
|
|
|
|
|
|
|
|
|
|
$top = self::top($branch) + (0.5 * self::$config['svg']['branch_height']); |
|
|
|
|
|
|
|
|
|
return $top; |
|
|
|
|
return intval($top); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -349,7 +390,7 @@ class SupportedVersions
|
|
|
|
|
* @codeCoverageIgnore |
|
|
|
|
* |
|
|
|
|
* @param int $margin_left |
|
|
|
|
* @return void |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
public static function width($margin_left) { |
|
|
|
|
if (!self::$config) { |
|
|
|
@ -368,24 +409,26 @@ class SupportedVersions
|
|
|
|
|
* @codeCoverageIgnore |
|
|
|
|
* |
|
|
|
|
* @param int $header_height |
|
|
|
|
* @return void |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
public static function height($header_height) { |
|
|
|
|
if (!self::$config) { |
|
|
|
|
self::init(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $header_height + |
|
|
|
|
return intval( |
|
|
|
|
$header_height + |
|
|
|
|
self::$config['svg']['footer_height'] + |
|
|
|
|
(count(self::branchesToShow(true)) * self::$config['svg']['branch_height']); |
|
|
|
|
(count(self::branchesToShow(true)) * self::$config['svg']['branch_height']) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Filtre calculant la largeur du rectangle, d'un état d'une branche. |
|
|
|
|
* |
|
|
|
|
* @param array $values |
|
|
|
|
* @param string $branch |
|
|
|
|
* @param string $state |
|
|
|
|
* @return int |
|
|
|
|
* @return int|string empty string or value |
|
|
|
|
*/ |
|
|
|
|
public static function rectWidth($branch, $state) { |
|
|
|
|
// @codeCoverageIgnoreStart |
|
|
|
|