diff --git a/app/views/manga/details.php b/app/views/manga/details.php index 2b204b7b..11790bfe 100644 --- a/app/views/manga/details.php +++ b/app/views/manga/details.php @@ -35,4 +35,26 @@

+
+ 0): ?> +

Characters

+
+ + +
+ generate('character', ['slug' => $char['slug']]) ?> + a($link, $char['name']); ?> +
+ + img($char['image']['original'], [ + 'width' => '225' + ]) ?> + +
+ + +
+ +
+ \ No newline at end of file diff --git a/src/API/Kitsu/Model.php b/src/API/Kitsu/Model.php index 26d7d203..3ea4a08a 100644 --- a/src/API/Kitsu/Model.php +++ b/src/API/Kitsu/Model.php @@ -257,7 +257,15 @@ class Model { public function getManga(string $mangaId): array { $baseData = $this->getRawMediaData('manga', $mangaId); - return $this->mangaTransformer->transform($baseData); + + if (empty($baseData)) + { + return []; + } + + $transformed = $this->mangaTransformer->transform($baseData); + $transformed['included'] = $baseData['included']; + return $transformed; } /** @@ -636,6 +644,12 @@ class Model { ]; $data = $this->getRequest("{$type}/{$id}", $options); + + if (empty($data['data'])) + { + return []; + } + $baseData = $data['data']['attributes']; $baseData['included'] = $data['included']; return $baseData; @@ -657,7 +671,7 @@ class Model { ], 'include' => ($type === 'anime') ? 'genres,mappings,streamingLinks,animeCharacters.character' - : 'genres,mappings', + : 'genres,mappings,mangaCharacters.character,castings.character', ] ]; diff --git a/src/Controller/Anime.php b/src/Controller/Anime.php index ad81bc9f..514a039c 100644 --- a/src/Controller/Anime.php +++ b/src/Controller/Anime.php @@ -288,8 +288,11 @@ class Anime extends BaseController { } $this->outputHTML('anime/details', [ - 'title' => $this->config->get('whose_list') . "'s Anime List" . - ' · Anime · ' . $data['titles'][0], + 'title' => $this->formatTitle( + $this->config->get('whose_list') . "'s Anime List", + 'Anime', + $data['titles'][0] + ), 'characters' => $characters, 'data' => $data, ]); diff --git a/src/Controller/Character.php b/src/Controller/Character.php index dff0561e..b6204ce8 100644 --- a/src/Controller/Character.php +++ b/src/Controller/Character.php @@ -30,7 +30,6 @@ class Character extends BaseController { { return $this->notFound( $this->formatTitle( - $this->config->get('whose_list') . "'s Anime List", 'Characters', 'Character not found' ), @@ -40,7 +39,6 @@ class Character extends BaseController { $this->outputHTML('character', [ 'title' => $this->formatTitle( - $this->config->get('whose_list') . "'s Anime List", 'Characters', $data['data'][0]['attributes']['name'] ), diff --git a/src/Controller/Manga.php b/src/Controller/Manga.php index f41ca754..e9bc0f01 100644 --- a/src/Controller/Manga.php +++ b/src/Controller/Manga.php @@ -269,6 +269,27 @@ class Manga extends Controller { public function details($manga_id) { $data = $this->model->getManga($manga_id); + $characters = []; + + if (empty($data)) + { + return $this->notFound( + $this->config->get('whose_list') . + "'s Manga List · Manga · " . + 'Manga not found', + 'Manga Not Found' + ); + } + + // dump($data); + + foreach($data['included'] as $included) + { + if ($included['type'] === 'characters') + { + $characters[$included['id']] = $included['attributes']; + } + } $this->outputHTML('manga/details', [ 'title' => $this->formatTitle( @@ -276,6 +297,7 @@ class Manga extends Controller { 'Manga', $data['title'] ), + 'characters' => $characters, 'data' => $data, ]); }