2020-04-21 19:22:56 -04:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
/**
|
|
|
|
* Hummingbird Anime List Client
|
|
|
|
*
|
|
|
|
* An API client for Kitsu to manage anime and manga watch lists
|
|
|
|
*
|
2020-12-10 17:06:50 -05:00
|
|
|
* PHP version 7.4+
|
2020-04-21 19:22:56 -04:00
|
|
|
*
|
|
|
|
* @package HummingbirdAnimeClient
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2021-01-13 01:52:03 -05:00
|
|
|
* @copyright 2015 - 2021 Timothy J. Warren
|
2020-04-21 19:22:56 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2020-12-10 17:06:50 -05:00
|
|
|
* @version 5.2
|
2020-04-21 19:22:56 -04:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Aviat\AnimeClient\Controller;
|
|
|
|
|
|
|
|
use Aviat\AnimeClient\Controller as BaseController;
|
|
|
|
use Aviat\AnimeClient\Model\Anime as AnimeModel;
|
|
|
|
use Aviat\AnimeClient\Model\Manga as MangaModel;
|
|
|
|
use Aviat\Ion\Di\ContainerInterface;
|
|
|
|
use Aviat\Ion\Di\Exception\ContainerException;
|
|
|
|
use Aviat\Ion\Di\Exception\NotFoundException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller for Anime-related pages
|
|
|
|
*/
|
|
|
|
final class History extends BaseController {
|
|
|
|
/**
|
|
|
|
* The anime list model
|
|
|
|
* @var AnimeModel
|
|
|
|
*/
|
|
|
|
protected AnimeModel $animeModel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The manga list model
|
|
|
|
* @var MangaModel
|
|
|
|
*/
|
|
|
|
protected MangaModel $mangaModel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param ContainerInterface $container
|
|
|
|
* @throws ContainerException
|
|
|
|
* @throws NotFoundException
|
|
|
|
*/
|
|
|
|
public function __construct(ContainerInterface $container)
|
|
|
|
{
|
|
|
|
parent::__construct($container);
|
|
|
|
|
|
|
|
$this->animeModel = $container->get('anime-model');
|
|
|
|
$this->mangaModel = $container->get('manga-model');
|
|
|
|
}
|
|
|
|
|
2020-04-22 11:39:44 -04:00
|
|
|
public function index(string $type = 'anime'): void
|
2020-04-21 19:22:56 -04:00
|
|
|
{
|
2020-04-22 11:39:44 -04:00
|
|
|
if (method_exists($this, $type))
|
|
|
|
{
|
|
|
|
$this->$type();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->notFound(
|
|
|
|
$this->config->get('whose_list') .
|
|
|
|
"'s List · History · " .
|
|
|
|
'History Not Found',
|
|
|
|
'History Not Found'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function anime(): void
|
|
|
|
{
|
|
|
|
$this->baseData = array_merge($this->baseData, [
|
|
|
|
'menu_name' => 'anime_list',
|
|
|
|
'other_type' => 'manga',
|
|
|
|
'url_type' => 'anime',
|
|
|
|
]);
|
|
|
|
|
2020-04-21 19:22:56 -04:00
|
|
|
// $this->outputJSON($this->animeModel->getHistory());
|
|
|
|
// return;
|
2020-04-22 11:39:44 -04:00
|
|
|
$this->outputHTML('history', [
|
2020-04-21 19:22:56 -04:00
|
|
|
'title' => $this->formatTitle(
|
|
|
|
$this->config->get('whose_list') . "'s Anime List",
|
|
|
|
'Anime',
|
|
|
|
'Watching History'
|
|
|
|
),
|
|
|
|
'items' => $this->animeModel->getHistory(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2020-04-22 11:39:44 -04:00
|
|
|
private function manga(): void
|
2020-04-21 19:22:56 -04:00
|
|
|
{
|
2020-04-22 11:39:44 -04:00
|
|
|
$this->baseData = array_merge($this->baseData, [
|
|
|
|
'menu_name' => 'manga_list',
|
|
|
|
'other_type' => 'anime',
|
|
|
|
'url_type' => 'manga',
|
|
|
|
]);
|
|
|
|
|
|
|
|
// $this->outputJSON($this->mangaModel->getHistory());
|
|
|
|
// return;
|
|
|
|
$this->outputHTML('history', [
|
2020-04-21 19:22:56 -04:00
|
|
|
'title' => $this->formatTitle(
|
|
|
|
$this->config->get('whose_list') . "'s Manga List",
|
|
|
|
'Manga',
|
|
|
|
'Reading History'
|
|
|
|
),
|
|
|
|
'items' => $this->mangaModel->getHistory(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|