Fix anime releases view

This commit is contained in:
DariusIII
2018-05-23 10:10:54 +02:00
parent cb54475d40
commit b3f141e435
5 changed files with 108 additions and 70 deletions
+1
View File
@@ -1,4 +1,5 @@
2018-05-23 DariusIII
* Fix: Fix anime releases view
* Fix: Fix viewanime page variable call
* Chg: Update php-coveralls/php-coveralls to latest version
2018-05-22 DariusIII
+98 -65
View File
@@ -9,29 +9,49 @@ use Illuminate\Http\Request;
class AnimeController extends BasePageController
{
public function __construct(Request $request)
/**
* @var \Blacklight\AniDB
*/
protected $aniDb;
/**
* @var \Blacklight\Releases
*/
protected $releases;
/**
* AnimeController constructor.
*
* @throws \Exception
*/
public function __construct()
{
parent::__construct($request);
parent::__construct();
$this->aniDb = new AniDB();
$this->releases = new Releases();
}
/**
* @param \Illuminate\Http\Request $request
*
* @throws \Exception
*/
public function index(Request $request)
public function showAnime(Request $request)
{
$this->setPrefs();
$releases = new Releases();
$aniDB = new AniDB();
if ($request->has('id') && ctype_digit($request->input('id'))) {
// force the category to TV_ANIME as it should be for anime, as $catarray was NULL and we know the category for sure for anime
$aniDbReleases = $releases->animeSearch($request->input('id'), 0, 1000, '', [Category::TV_ANIME], -1);
$aniDbInfo = $aniDB->getAnimeInfo($request->input('id'));
$aniDbReleases = $this->releases->animeSearch($request->input('id'), 0, 1000, '', [Category::TV_ANIME], -1);
$aniDbInfo = $this->aniDb->getAnimeInfo($request->input('id'));
$title = $aniDbInfo['title'];
$meta_title = 'View Anime '.$aniDbInfo['title'];
$meta_keywords = 'view,anime,anidb,description,details';
$meta_description = 'View '.$aniDbInfo['title'].' Anime';
if (! $releases && ! $aniDbInfo) {
if (! $this->releases && ! $aniDbInfo) {
$this->show404();
} elseif (! $aniDbInfo) {
$this->smarty->assign('nodata', 'No AniDB information for this series.');
@@ -41,66 +61,24 @@ class AnimeController extends BasePageController
$this->smarty->assign('anidb', $aniDbInfo);
$this->smarty->assign('animeEpisodeTitles', $aniDbReleases);
$this->smarty->assign([
'animeAnidbid' => $aniDbInfo['anidbid'],
'animeTitle' => $aniDbInfo['title'],
'animeType' => $aniDbInfo['type'],
'animePicture' => $aniDbInfo['picture'],
'animeStartDate' => $aniDbInfo['startdate'],
'animeEndDate' => $aniDbInfo['enddate'],
'animeDescription' => $aniDbInfo['description'],
'animeRating' => $aniDbInfo['rating'],
'animeRelated' => $aniDbInfo['related'],
'animeSimilar' => $aniDbInfo['similar'],
'animeCategories' => $aniDbInfo['categories'],
'animeCreators' => $aniDbInfo['creators'],
'animeCharacters' => $aniDbInfo['characters'],
]);
'animeAnidbid' => $aniDbInfo['anidbid'],
'animeTitle' => $aniDbInfo['title'],
'animeType' => $aniDbInfo['type'],
'animePicture' => $aniDbInfo['picture'],
'animeStartDate' => $aniDbInfo['startdate'],
'animeEndDate' => $aniDbInfo['enddate'],
'animeDescription' => $aniDbInfo['description'],
'animeRating' => $aniDbInfo['rating'],
'animeRelated' => $aniDbInfo['related'],
'animeSimilar' => $aniDbInfo['similar'],
'animeCategories' => $aniDbInfo['categories'],
'animeCreators' => $aniDbInfo['creators'],
'animeCharacters' => $aniDbInfo['characters'],
]);
$this->smarty->assign('nodata', '');
$this->title = $aniDbInfo['title'];
$this->meta_title = 'View Anime '.$aniDbInfo['title'];
$this->meta_keywords = 'view,anime,anidb,description,details';
$this->meta_description = 'View '.$aniDbInfo['title'].' Anime';
}
$this->content = $this->smarty->fetch('viewanime.tpl');
$this->pagerender();
} else {
$letter = ($request->has('id') && preg_match('/^(0\-9|[A-Z])$/i', $request->input('id'))) ? $request->input('id') : '0-9';
$animeTitle = ($request->has('title') && ! empty($request->input('title'))) ? $request->input('title') : '';
if ($animeTitle !== '' && ! $request->has('id')) {
$letter = '';
}
$masterserieslist = $aniDB->getAnimeList($letter, $animeTitle);
$title = 'Anime List';
$meta_title = 'View Anime List';
$meta_keywords = 'view,anime,series,description,details';
$meta_description = 'View Anime List';
$animelist = [];
if ($masterserieslist instanceof \Traversable) {
foreach ($masterserieslist as $s) {
if (preg_match('/^[0-9]/', $s['title'])) {
$thisrange = '0-9';
} else {
preg_match('/([A-Z]).*/i', $s['title'], $matches);
$thisrange = strtoupper($matches[1]);
}
$animelist[$thisrange][] = $s;
}
ksort($animelist);
}
$this->smarty->assign('animelist', $animelist);
$this->smarty->assign('animerange', range('A', 'Z'));
$this->smarty->assign('animeletter', $letter);
$this->smarty->assign('animetitle', $animeTitle);
$content = $this->smarty->fetch('viewanimelist.tpl');
$content = $this->smarty->fetch('viewanime.tpl');
$this->smarty->assign(
[
'content' => $content,
@@ -113,4 +91,59 @@ class AnimeController extends BasePageController
$this->pagerender();
}
}
/**
* @param \Illuminate\Http\Request $request
*
* @throws \Exception
*/
public function showList (Request $request)
{
$this->setPrefs();
$letter = ($request->has('id') && preg_match('/^(0\-9|[A-Z])$/i', $request->input('id'))) ? $request->input('id') : '0-9';
$animeTitle = ($request->has('title') && ! empty($request->input('title'))) ? $request->input('title') : '';
if ($animeTitle !== '' && ! $request->has('id')) {
$letter = '';
}
$masterserieslist = $this->aniDb->getAnimeList($letter, $animeTitle);
$title = 'Anime List';
$meta_title = 'View Anime List';
$meta_keywords = 'view,anime,series,description,details';
$meta_description = 'View Anime List';
$animelist = [];
if ($masterserieslist instanceof \Traversable) {
foreach ($masterserieslist as $s) {
if (preg_match('/^[0-9]/', $s['title'])) {
$thisrange = '0-9';
} else {
preg_match('/([A-Z]).*/i', $s['title'], $matches);
$thisrange = strtoupper($matches[1]);
}
$animelist[$thisrange][] = $s;
}
ksort($animelist);
}
$this->smarty->assign('animelist', $animelist);
$this->smarty->assign('animerange', range('A', 'Z'));
$this->smarty->assign('animeletter', $letter);
$this->smarty->assign('animetitle', $animeTitle);
$content = $this->smarty->fetch('viewanimelist.tpl');
$this->smarty->assign(
[
'content' => $content,
'title' => $title,
'meta_title' => $meta_title,
'meta_keywords' => $meta_keywords,
'meta_description' => $meta_description,
]
);
$this->pagerender();
}
}
@@ -12,7 +12,7 @@
<li><a href="{$smarty.const.WWW_TOP}/browse/{$parentcat.title}">TV</a></li>
<hr>
<li><a href="{$smarty.const.WWW_TOP}/series">TV Series</a></li>
<li><a href="{$smarty.const.WWW_TOP}/anime">Anime Series</a></li>
<li><a href="{$smarty.const.WWW_TOP}/animelist">Anime Series</a></li>
<hr>
{foreach $parentcat.subcatlist as $subcat}
<li><a href="{$smarty.const.WWW_TOP}/browse/TV/{$subcat.title}">{$subcat.title}</a></li>
@@ -11,10 +11,10 @@
{$site->adbrowse}
<p><b>Jump to</b>:
&nbsp;&nbsp;[ {if $animeletter == '0-9'}<b><u>{/if}<a
href="{$smarty.const.WWW_TOP}/anime/0-9">0-9</a>{if $animeletter == '0-9'}</u></b>{/if}
href="{$smarty.const.WWW_TOP}/animelist/0-9">0-9</a>{if $animeletter == '0-9'}</u></b>{/if}
{foreach $animerange as $range}
{if $range == $animeletter}<b><u>{/if}<a
href="{$smarty.const.WWW_TOP}/anime?id={$range}">{$range}</a>{if $range == $animeletter}</u></b>{/if}
href="{$smarty.const.WWW_TOP}/animelist?id={$range}">{$range}</a>{if $range == $animeletter}</u></b>{/if}
{/foreach}]
</p>
{$site->adbrowse}
@@ -62,4 +62,4 @@
<strong>Hmm!</strong> No results for this query.
</div>
{/if}
</div>
</div>
+5 -1
View File
@@ -35,7 +35,11 @@ Route::prefix('browse')->group(function () {
Route::get('{parentCategory}/{id?}', 'BrowseController@show');
});
Route::get('anime/{id?}', 'AnimeController@index');
Route::get('anime', 'AnimeController@showAnime');
Route::post('anime', 'AnimeController@showAnime');
Route::get('animelist', 'AnimeController@showList');
Route::post('animelist', 'AnimeController@showList');
Route::get('Books/{id?}', 'BooksController@index');
Route::post('Books/{id?}', 'BooksController@index');