-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdraw.php
180 lines (150 loc) · 4.84 KB
/
draw.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
require_once './utils.php';
function generateGenericLink($addr, $text)
{
return "<a href='$addr' class='ext-link'><span class='icon'></span>" . $text . "</a>";
}
function generateDependencyLink ($code, $name)
{
return generateGenericLink("https://repology.org/metapackage/$code", $name);
}
function generateDistroReleaseLink($distro)
{
if (isset($distro['link']))
return generateGenericLink($distro['link'], $distro['name']);
return $distro['name'];
}
function generateVersionText($dependency_code, $distro_code, $minRequired = False)
{
global $g_LatestVersions;
global $g_VersionsByDistro;
if (!isset($g_VersionsByDistro[$distro_code]) || !isset($g_VersionsByDistro[$distro_code][$dependency_code]))
return '<span class="version notavailable"><span>-</span></span>';
switch (version_compare2($g_VersionsByDistro[$distro_code][$dependency_code], $g_LatestVersions[$dependency_code]))
{
case -1: // Old
if ($minRequired && version_compare2($g_VersionsByDistro[$distro_code][$dependency_code], $minRequired) == -1)
$class = "lessthanminimum";
else
$class = "oldversion";
break;
case 0: // Latest
$class = "latestversion";
break;
case 1: // Newer
$class = "nonstandardversion";
break;
}
return '<span class="version ' . $class . '"><span>' . $g_VersionsByDistro[$distro_code][$dependency_code] . '</span></span>';
}
function getEOL($distro)
{
if (!isset($distro['eol']))
return "-";
if ($distro['eol'] == "inf")
return "∞";
$outFormat = "M Y";
switch (substr_count($distro['eol'], '-'))
{
case 0:
return $distro['eol'];
case 1:
return date_create_from_format("!Y-m", $distro['eol'])->format($outFormat);
case 2:
return date_create_from_format("!Y-m-d", $distro['eol'])->format($outFormat);
default:
return "-";
}
}
// Horizontal Header: Dependency Name
echo "<tr>\n";
echo "\t<th colspan='3'><b>Dependencies</b></th>\n";
foreach ($g_Dependencies as $dependency)
{
echo "\t<th id='dep__" . $dependency['code'] . "'>";
echo generateDependencyLink($dependency['code'], $dependency['name']);
if (isset($dependency['alt-code']))
{
$names = [];
for ($i = 0; $i < count($dependency['alt-code']); ++$i)
$names[] = generateDependencyLink($dependency['alt-code'][$i], $dependency['alt-name'][$i]);
echo "<br/>(" . implode(" / ", $names) . ")";
}
echo "</th>\n";
}
echo "</tr>\n";
// Horizontal Header: Dependency Version
echo "<tr>\n";
echo "\t<th colspan='3'><b>Min. Required Version</b></th>\n";
foreach ($g_Dependencies as $dependency)
{
echo "\t<th>";
if (isset($dependency['minRequired']))
echo $dependency['minRequired'];
echo "</th>\n";
}
echo "</tr>\n";
echo "<tr>\n";
echo "\t<th colspan='2'><b>Distributions</b></th>\n";
echo "\t<th><b>EOL</b></th>\n";
echo "</tr>\n";
// Repo Entries
foreach ($g_Distros as $distro)
{
echo "\n<!-- " . strtoupper($distro['name']) . "-->\n";
// No separate releases
if (!isset($distro['releases']))
{
// This supports distros that don't have a repology code, but have
// hard-coded versions stored in the distros.json file instead.
if (!isset($distro['code']))
$distro['code'] = md5($distro['name']);
echo "<tr id='distro__" . $distro['code'] . "'>\n";
echo "\t<th colspan='2'>" . generateDistroReleaseLink($distro) . "</th>\n";
echo "\t<td>" . getEOL($distro) . "</td>\n";
foreach ($g_Dependencies as $dependency)
{
$minRequired = isset($dependency['minRequired']) ? $dependency['minRequired'] : False;
echo "\t<td>";
if (isset($dependency['alt-code']) and
(isset($dependency['always-show-alt']) and $dependency['always-show-alt'] or
isset($distro['alt']) and in_array($dependency['code'], $distro['alt'])))
{
echo "<span class='altdeps'></span>";
}
echo "</td>\n";
}
echo "</tr>\n";
continue;
}
// Separate releases
echo "<tr id='distro__" . $distro['releases'][0]['code'] . "'>\n";
echo "\t<th rowspan='" . count($distro['releases']) . "'>" . generateDistroReleaseLink($distro) . "</th>\n";
$first = True;
foreach ($distro["releases"] as $release)
{
// This supports releases that don't have a repology code, but have
// hard-coded versions stored in the distros.json file instead.
if (!isset($release['code']))
$release['code'] = md5($release['name']);
if (!$first)
echo "<tr id='distro__" . $release['code'] . "'>\n";
$first = False;
echo "\t<th><i>" . generateDistroReleaseLink($release) . "</i></th>\n";
echo "\t<td>" . getEOL($release) . "</td>\n";
foreach ($g_Dependencies as $dependency)
{
$minRequired = isset($dependency['minRequired']) ? $dependency['minRequired'] : False;
echo "\t<td>";
if (isset($dependency['alt-code']) and
(isset($dependency['always-show-alt']) and $dependency['always-show-alt'] or
isset($release['alt']) and in_array($dependency['code'], $release['alt'])))
{
echo "<span class='altdeps'></span>";
}
echo "</td>\n";
}
echo "</tr>\n";
}
}
?>