HummingBirdAnimeClient/app/views/anime/list.php

113 lines
3.8 KiB
PHP
Raw Permalink Normal View History

2020-08-26 15:22:14 -04:00
<?php use function Aviat\AnimeClient\colNotEmpty; ?>
2018-08-10 20:09:28 -04:00
<main class="media-list">
<?php if ($_->isAuthenticated()): ?>
<a class="bracketed" href="<?= $_->urlFromRoute('anime.add.get') ?>">Add Item</a>
<?php endif ?>
<?php if (empty($sections)): ?>
<h3>There's nothing here!</h3>
<?php else: ?>
<br />
<label>Filter: <input type='text' class='media-filter' /></label>
<br />
<?php foreach ($sections as $name => $items): ?>
<h2><?= $name ?></h2>
2017-09-14 17:33:24 -04:00
<?php if (empty($items)): ?>
<h3>There's nothing here!</h3>
<?php else: ?>
2020-04-30 15:35:32 -04:00
<?php
2020-08-26 15:22:14 -04:00
$hasNotes = colNotEmpty($items, 'notes');
2020-04-30 15:35:32 -04:00
?>
<table class='media-wrap'>
2017-09-14 17:33:24 -04:00
<thead>
<tr>
<?php if($_->isAuthenticated()): ?>
<td class="no-border">&nbsp;</td>
2016-01-06 11:08:56 -05:00
<?php endif ?>
2017-09-14 17:33:24 -04:00
<th>Title</th>
<th>Airing Status</th>
<th class='numeric'>Score</th>
2017-09-14 17:33:24 -04:00
<th>Type</th>
<th class='numeric'>Progress</th>
<th class='rating'>Age Rating</th>
2020-04-30 15:35:32 -04:00
<th>Attributes</th>
<?php if($hasNotes): ?><th>Notes</th><?php endif ?>
2017-09-14 17:33:24 -04:00
</tr>
</thead>
<tbody>
<?php foreach($items as $item): ?>
<?php if ($item['private'] && ! $_->isAuthenticated()) continue; ?>
2017-09-14 17:33:24 -04:00
<tr id="a-<?= $item['id'] ?>">
<?php if ($_->isAuthenticated()): ?>
2017-09-14 17:33:24 -04:00
<td>
<a class="bracketed" href="<?= $_->urlFromRoute('edit', [
2017-09-14 17:33:24 -04:00
'controller' => 'anime',
'id' => $item['id'],
'status' => $item['watching_status']
]) ?>">Edit</a>
</td>
<?php endif ?>
<td class="align-left justify">
<a href="<?= $_->urlFromRoute('anime.details', ['id' => $item['anime']['slug']]) ?>">
<?= $item['anime']['title'] ?>
2017-09-14 17:33:24 -04:00
</a>
2020-04-30 15:35:32 -04:00
<br />
<?= implode('<br />', $item['anime']['titles']) ?>
2017-09-14 17:33:24 -04:00
</td>
<td><?= $item['airing']['status'] ?></td>
<td><?= $item['user_rating'] ?> / 10 </td>
<td><?= $item['anime']['show_type'] ?></td>
2017-09-14 17:33:24 -04:00
<td id="<?= $item['anime']['slug'] ?>">
Episodes: <br />
<span class="completed_number"><?= $item['episodes']['watched'] ?></span>&nbsp;/&nbsp;<span class="total_number"><?= $item['episodes']['total'] ?></span>
</td>
<td><?= $item['anime']['age_rating'] ?></td>
<td>
<?php foreach($item['anime']['streaming_links'] as $link): ?>
<?php if ($link['meta']['link'] !== FALSE): ?>
<a href="<?= $link['link'] ?>" title="Stream '<?= $item['anime']['title'] ?>' on <?= $link['meta']['name'] ?>">
<?= $_->h->img("/public/images/{$link['meta']['image']}", [
2020-04-30 15:35:32 -04:00
'class' => 'small-streaming-logo',
'width' => 25,
'height' => 25,
'alt' => "{$link['meta']['name']} logo",
2020-04-10 20:01:46 -04:00
]) ?>
2017-09-14 17:33:24 -04:00
</a>
<?php else: ?>
<?= $_->h->img("/public/images/{$link['meta']['image']}", [
2020-04-30 15:35:32 -04:00
'class' => 'small-streaming-logo',
'width' => 25,
'height' => 25,
'alt' => "{$link['meta']['name']} logo",
2020-04-10 20:01:46 -04:00
]) ?>
2017-09-14 17:33:24 -04:00
<?php endif ?>
<?php endforeach ?>
2020-04-30 15:35:32 -04:00
<br />
<ul>
2020-05-04 16:46:27 -04:00
<?php if ($item['rewatched'] > 0): ?>
<?php if ($item['rewatched'] == 1): ?>
<li>Rewatched once</li>
<?php elseif ($item['rewatched'] == 2): ?>
<li>Rewatched twice</li>
<?php elseif ($item['rewatched'] == 3): ?>
<li>Rewatched thrice</li>
<?php else: ?>
<li>Rewatched <?= $item['rewatched'] ?> times</li>
<?php endif ?>
<?php endif ?>
2020-04-30 15:35:32 -04:00
<?php foreach(['private','rewatching'] as $attr): ?>
<?php if($item[$attr]): ?><li><?= ucfirst($attr); ?></li><?php endif ?>
<?php endforeach ?>
</ul>
2017-09-14 17:33:24 -04:00
</td>
<?php if ($hasNotes): ?><td><p><?= $_->escape->html($item['notes']) ?></p></td><?php endif ?>
2017-09-14 17:33:24 -04:00
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php endif ?>
<?php endforeach ?>
<?php endif ?>
</main>
<script defer="defer" src="<?= $_->assetUrl('js/tables.min.js') ?>"></script>