1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @var yii\web\View |
5
|
|
|
* @var \hiqdev\assetpackagist\models\AssetPackage $package |
6
|
|
|
*/ |
7
|
|
|
use Composer\Semver\VersionParser; |
8
|
|
|
use yii\helpers\Html; |
9
|
|
|
|
10
|
|
|
?> |
11
|
|
|
|
12
|
|
|
<?php |
13
|
|
|
$releases = $package->getReleases(); |
14
|
|
|
|
15
|
|
|
hiqdev\assetpackagist\components\PackageUtil::sort($releases); |
16
|
|
|
|
17
|
|
|
$stability_colors = [ |
18
|
|
|
'stable' => 'success', |
19
|
|
|
'RC' => 'primary', |
20
|
|
|
'beta' => 'info', |
21
|
|
|
'alpha' => 'warning', |
22
|
|
|
'dev' => 'default', |
23
|
|
|
]; |
24
|
|
|
?> |
25
|
|
|
|
26
|
|
|
<div class="versions"> |
27
|
|
|
<?php if (!empty($releases)) : ?> |
28
|
|
|
<?= Html::tag('div', Yii::t('app', '✔ This package is OK to use!'), [ |
29
|
|
|
'class' => 'package-ok', |
30
|
|
|
]) ?> |
31
|
|
|
<?php endif ?> |
32
|
|
|
|
33
|
|
|
<br><br> |
34
|
|
|
<b>Last updated:</b> <?= Yii::$app->formatter->asDateTime($package->getUpdateTime()) ?> (<?= Yii::$app->formatter->asRelativeTime($package->getUpdateTime()) ?>) |
35
|
|
|
<br> |
36
|
|
|
<b>Legend:</b> |
37
|
|
|
<?php foreach ($stability_colors as $stability => $color) : ?> |
38
|
|
|
<?= Html::tag('span', $stability, ['class' => 'label label-' . $color]) . ' ' ?> |
39
|
|
|
<?php endforeach ?> |
40
|
|
|
<br><br> |
41
|
|
|
|
42
|
|
|
<?php if (Yii::$app->session->hasFlash('rate-limited')) : ?> |
43
|
|
|
<div class="alert alert-warning too-fast-update" role="alert"> |
44
|
|
|
<h4><?= Yii::t('app', 'Wow, you are very fast!') ?></h4> |
45
|
|
|
<p><?= Yii::t('app', 'The package was updated recently. Could you wait another 10 minutes before fetching it again, please?') ?></p> |
46
|
|
|
</div> |
47
|
|
|
<?php Yii::$app->session->removeFlash('rate-limited') ?> |
48
|
|
|
<?php endif ?> |
49
|
|
|
|
50
|
|
|
<table class="table"> |
51
|
|
|
<thead> |
52
|
|
|
<tr> |
53
|
|
|
<th><?= Yii::t('app', 'Version') ?></th> |
54
|
|
|
<th colspan="2"><?= Yii::t('app', 'Commit SHA') ?></th> |
55
|
|
|
</tr> |
56
|
|
|
</thead> |
57
|
|
|
<tbody> |
58
|
|
|
<?php foreach ((array) $releases as $version => $release) : ?> |
59
|
|
|
<tr> |
60
|
|
|
<th> |
61
|
|
|
<?php |
62
|
|
|
$stability = VersionParser::parseStability($release['version_normalized']); |
63
|
|
|
echo Html::tag('span', $version, ['class' => 'label label-' . $stability_colors[$stability]]); |
64
|
|
|
?> |
65
|
|
|
</th> |
66
|
|
|
<td> |
67
|
|
|
<code><?= $release['source']['reference'] ?: $release['dist']['reference'] ?: 'n/a' ?></code> |
68
|
|
|
</td> |
69
|
|
|
<td> |
70
|
|
|
<?php |
71
|
|
|
$links = []; |
72
|
|
View Code Duplication |
if ($release['dist']['url']) { |
|
|
|
|
73
|
|
|
$links[] = Html::a(Yii::t('app', 'Get ZIP'), $release['dist']['url']); |
74
|
|
|
} |
75
|
|
View Code Duplication |
if ($release['source']['url']) { |
|
|
|
|
76
|
|
|
$links[] = Html::a(Yii::t('app', 'see sources'), $release['source']['url']); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
echo implode(' or ', $links); |
80
|
|
|
?> |
81
|
|
|
</td> |
82
|
|
|
</tr> |
83
|
|
|
<?php endforeach ?> |
84
|
|
|
</tbody> |
85
|
|
|
</table> |
86
|
|
|
</div> |
87
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.