Add staff section on Manga detail pages
All checks were successful
timw4mail/HummingBirdAnimeClient/develop This commit looks good

This commit is contained in:
Timothy Warren 2018-10-29 15:17:48 -04:00
parent 679c369427
commit bd4cfaafe1
3 changed files with 49 additions and 20 deletions

View File

@ -73,4 +73,39 @@
</section>
<?php endforeach ?>
<?php endif ?>
<?php if (count($staff) > 0): ?>
<br />
<hr />
<h2>Staff</h2>
<?php foreach ($staff as $role => $people): ?>
<h3><?= $role ?></h3>
<section class='media-wrap flex flex-wrap flex-justify-start'>
<?php foreach ($people as $pid => $person): ?>
<article class='character person'>
<?php $link = $url->generate('person', ['id' => $pid]) ?>
<div class="name">
<a href="<?= $link ?>">
<?= $person['name'] ?>
</a>
</div>
<a href="<?= $link ?>">
<picture>
<source
srcset="<?= $urlGenerator->assetUrl("images/people/{$pid}.webp") ?>"
type="image/webp"
>
<source
srcset="<?= $urlGenerator->assetUrl("images/people/{$pid}.jpg") ?>"
type="image/jpeg"
>
<img src="<?= $urlGenerator->assetUrl("images/people/{$pid}.jpg") ?>" alt="" />
</picture>
</a>
</article>
<?php endforeach ?>
</section>
<?php endforeach ?>
<?php endif ?>
</main>

View File

@ -16,8 +16,6 @@
namespace Aviat\AnimeClient\Controller;
use function Aviat\AnimeClient\getLocalImg;
use Aviat\AnimeClient\Controller as BaseController;
use Aviat\AnimeClient\API\JsonAPI;
use Aviat\Ion\ArrayWrapper;

View File

@ -294,8 +294,6 @@ final class Manga extends Controller {
return;
}
// dd($data['included']);
if (array_key_exists('mediaCharacters', $data['included']))
{
$mediaCharacters = $data['included']['mediaCharacters'];
@ -318,27 +316,25 @@ final class Manga extends Controller {
if (array_key_exists('mediaStaff', $data['included']))
{
foreach ($data['included']['mediaStaff'] as $id => $person)
foreach ($data['included']['mediaStaff'] as $id => $staffing)
{
$personDetails = [];
foreach ($person['relationships']['person']['people'] as $p)
$role = $staffing['attributes']['role'];
foreach($staffing['relationships']['person']['people'] as $personId => $personDetails)
{
$personDetails = $p['attributes'];
}
$role = $person['attributes']['role'];
if ( ! array_key_exists($role, $staff))
{
$staff[$role] = [];
}
$staff[$role][$id] = [
'name' => $personDetails['name'] ?? '??',
'image' => $personDetails['image'],
$staff[$role][$personId] = [
'id' => $personId,
'name' => $personDetails['attributes']['name'] ?? '??',
'image' => $personDetails['attributes']['image'],
];
}
}
}
if ( ! empty($characters['main']))
{