Don't show media tabs with no media on character page, make stats on user page more resiliant
This commit is contained in:
parent
b871a4fac2
commit
a38c9712e6
@ -27,10 +27,10 @@ use Aviat\AnimeClient\API\Kitsu;
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if (array_key_exists('anime', $data['media']) || array_key_exists('manga', $data['media'])): ?>
|
||||
<?php if ( ! (empty($data['media']['anime']) || empty($data['media']['manga']))): ?>
|
||||
<h3>Media</h3>
|
||||
<div class="tabs">
|
||||
<?php if (array_key_exists('anime', $data['media'])): ?>
|
||||
<?php if ( ! empty($data['media']['anime'])): ?>
|
||||
<input checked="checked" type="radio" id="media-anime" name="media-tabs" />
|
||||
<label for="media-anime">Anime</label>
|
||||
|
||||
@ -58,7 +58,7 @@ use Aviat\AnimeClient\API\Kitsu;
|
||||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (array_key_exists('manga', $data['media'])): ?>
|
||||
<?php if ( ! empty($data['media']['manga'])): ?>
|
||||
<input type="radio" id="media-manga" name="media-tabs" />
|
||||
<label for="media-manga">Manga</label>
|
||||
|
||||
|
@ -131,19 +131,38 @@ final class UserTransformer extends AbstractTransformer {
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function organizeStats($stats, $data): array
|
||||
private function organizeStats($stats, $data = []): array
|
||||
{
|
||||
// $timeOnAnime = $this->formatAnimeTime($orgData['attributes']['lifeSpentOnAnime']);
|
||||
$animeStats = [];
|
||||
$mangaStats = [];
|
||||
$otherStats = [];
|
||||
|
||||
return [
|
||||
if (array_key_exists('anime-amount-consumed', $stats))
|
||||
{
|
||||
$animeStats = [
|
||||
'Time spent watching anime:' => $this->formatAnimeTime($stats['anime-amount-consumed']['time']),
|
||||
'Anime series watched:' => number_format($stats['anime-amount-consumed']['media']),
|
||||
'Anime episodes watched:' => number_format($stats['anime-amount-consumed']['units']),
|
||||
];
|
||||
}
|
||||
|
||||
if (array_key_exists('manga-amount-consumed', $stats))
|
||||
{
|
||||
$mangaStats = [
|
||||
'Manga series read:' => number_format($stats['manga-amount-consumed']['media']),
|
||||
'Manga chapters read:' => number_format($stats['manga-amount-consumed']['units']),
|
||||
];
|
||||
}
|
||||
|
||||
if ( ! empty($data))
|
||||
{
|
||||
$otherStats = [
|
||||
'Posts:' => number_format($data['postsCount']),
|
||||
'Comments:' => number_format($data['commentsCount']),
|
||||
'Media Rated:' => number_format($data['ratingsCount']),
|
||||
];
|
||||
}
|
||||
|
||||
return array_merge($animeStats, $mangaStats, $otherStats);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user