Add trailer videos to anime detail pages

This commit is contained in:
Timothy Warren 2018-01-31 10:55:20 -05:00
parent a6dc8caaa0
commit e6b534078f
3 changed files with 30 additions and 23 deletions

View File

@ -76,12 +76,18 @@
</tbody>
</table>
<?php endif ?>
<?php if ( ! empty($show_data['trailer_id'])): ?>
<hr />
<h4>Trailer</h4>
<iframe width="560" height="315" src="https://www.youtube.com/embed/<?= $show_data['trailer_id'] ?>" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<?php endif ?>
</div>
</section>
<?php if (count($characters) > 0): ?>
<hr />
<h2>Characters</h2>
<section class="align_left media-wrap">
<section class="align_center media-wrap">
<?php foreach($characters as $id => $char): ?>
<?php if ( ! empty($char['image']['original'])): ?>
<article class="character">

View File

@ -31,9 +31,9 @@ class AnimeTransformer extends AbstractTransformer {
* @param array $item API library item
* @return array
*/
public function transform($item)
public function transform($item): array
{
$item['included'] = JsonAPI::organizeIncludes($item['included']);
$genres = $item['included']['categories'] ?? [];
$item['genres'] = array_column($genres, 'title') ?? [];
@ -42,21 +42,22 @@ class AnimeTransformer extends AbstractTransformer {
$titles = Kitsu::filterTitles($item);
return [
'id' => $item['id'],
'slug' => $item['slug'],
'title' => $titles[0],
'titles' => $titles,
'status' => Kitsu::getAiringStatus($item['startDate'], $item['endDate']),
'cover_image' => $item['posterImage']['small'],
'show_type' => $this->string($item['showType'])->upperCaseFirst()->__toString(),
'episode_count' => $item['episodeCount'],
'episode_length' => $item['episodeLength'],
'synopsis' => $item['synopsis'],
'age_rating' => $item['ageRating'],
'age_rating_guide' => $item['ageRatingGuide'],
'url' => "https://kitsu.io/anime/{$item['slug']}",
'cover_image' => $item['posterImage']['small'],
'episode_count' => $item['episodeCount'],
'episode_length' => $item['episodeLength'],
'genres' => $item['genres'],
'streaming_links' => Kitsu::parseStreamingLinks($item['included'])
'id' => $item['id'],
'show_type' => $this->string($item['showType'])->upperCaseFirst()->__toString(),
'slug' => $item['slug'],
'status' => Kitsu::getAiringStatus($item['startDate'], $item['endDate']),
'streaming_links' => Kitsu::parseStreamingLinks($item['included']),
'synopsis' => $item['synopsis'],
'title' => $titles[0],
'titles' => $titles,
'trailer_id' => $item['youtubeVideoId'],
'url' => "https://kitsu.io/anime/{$item['slug']}",
];
}
}

View File

@ -149,7 +149,7 @@ class Controller {
* @throws NotFoundException
* @return void
*/
public function setSessionRedirect(string $url = NULL)
public function setSessionRedirect(string $url = NULL): void
{
$serverParams = $this->request->getServerParams();
@ -252,13 +252,13 @@ class Controller {
$csp = [
"default-src 'self'",
"object-src 'none'",
"child-src 'none'",
"frame-src *.youtube.com",
];
$view->addHeader('Content-Security-Policy', implode('; ', $csp));
$view->appendOutput($this->loadPartial($view, 'header', $data));
if (array_key_exists('message', $data) && is_array($data['message']))
if (array_key_exists('message', $data) && \is_array($data['message']))
{
$view->appendOutput($this->loadPartial($view, 'message', $data['message']));
}
@ -300,7 +300,7 @@ class Controller {
* @throws \Aviat\Ion\Di\NotFoundException
* @return void
*/
public function errorPage(int $httpCode, string $title, string $message, string $long_message = "")
public function errorPage(int $httpCode, string $title, string $message, string $long_message = ''): void
{
$this->outputHTML('error', [
'title' => $title,
@ -314,7 +314,7 @@ class Controller {
*
* @return void
*/
public function redirectToDefaultRoute()
public function redirectToDefaultRoute(): void
{
$defaultType = $this->config->get(['routes', 'route_config', 'default_list']) ?? 'anime';
$this->redirect($this->urlGenerator->defaultUrl($defaultType), 303);
@ -328,7 +328,7 @@ class Controller {
* @param string $type
* @return void
*/
public function setFlashMessage(string $message, string $type = "info")
public function setFlashMessage(string $message, string $type = 'info'): void
{
static $messages;
@ -406,7 +406,7 @@ class Controller {
* @throws DoubleRenderException
* @return void
*/
protected function outputJSON($data = 'Empty response', int $code = 200)
protected function outputJSON($data = 'Empty response', int $code = 200): void
{
(new JsonView($this->container))
->setStatusCode($code)
@ -421,7 +421,7 @@ class Controller {
* @param int $code
* @return void
*/
protected function redirect(string $url, int $code)
protected function redirect(string $url, int $code): void
{
$http = new HttpView($this->container);
$http->redirect($url, $code);