Skip to content

Commit

Permalink
Special Weapons sorted by their "rank"
Browse files Browse the repository at this point in the history
  • Loading branch information
fetus-hina committed Nov 17, 2023
1 parent e2de87d commit b02b1a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
16 changes: 5 additions & 11 deletions actions/api/info/Weapon3Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use function strnatcasecmp;
use function version_compare;

use const SORT_ASC;
use const SORT_DESC;

final class Weapon3Action extends Action
Expand Down Expand Up @@ -67,17 +68,10 @@ private function getLangs(): array

private function getSpecials(): array
{
return ArrayHelper::sort(
Special3::find()->with(['special3Aliases'])->all(),
function (Special3 $a, Special3 $b): int {
$aN = Yii::t('app-special3', $a->name);
$bN = Yii::t('app-special3', $b->name);
return strnatcasecmp($aN, $bN)
?: strcmp($aN, $bN)
?: strnatcasecmp($a->name, $b->name)
?: strcmp($a->name, $b->name);
},
);
return Special3::find()
->with(['special3Aliases'])
->orderBy(['rank' => SORT_ASC])
->all();
}

private function getSubweapons(): array
Expand Down
7 changes: 6 additions & 1 deletion views/api-info/weapon3/special.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<table class="table table-striped table-condensed table-sortable">
<thead>
<tr>
<th></th>
<th data-sort="int" data-sort-onload="yes"></th>
<th data-sort="string"><code>key</code></th>
<th data-sort="string"><?= Html::encode(Yii::t('app', 'Aliases')) ?></th>
<?php foreach ($langs as $i => $lang) { ?>
Expand All @@ -48,6 +48,11 @@
<?= Html::tag(
'td',
Icon::s3Special($sp),
[
'data' => [
'sort-value' => $sp->rank,
],
],
) . "\n" ?>
<?= Html::tag(
'td',
Expand Down

0 comments on commit b02b1a3

Please sign in to comment.