From 55d331283110e78aa5ae4a092e393a3ff0e18104 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 20 Apr 2018 14:58:58 +0200 Subject: [PATCH] Fix numerous category browsing issues --- Changelog | 1 + app/Http/Controllers/BooksController.php | 18 +++++++++++--- app/Http/Controllers/ConsoleController.php | 24 +++++++++++++++---- app/Http/Controllers/MovieController.php | 18 ++++++++++---- app/Http/Controllers/MusicController.php | 19 +++++++++++---- resources/views/themes/Charisma/console.tpl | 2 +- .../views/themes/Charisma/headermenu.tpl | 2 +- resources/views/themes/Charisma/movies.tpl | 2 +- resources/views/themes/Charisma/music.tpl | 2 +- resources/views/themes/Gamma/books.tpl | 2 +- resources/views/themes/Gamma/console.tpl | 2 +- resources/views/themes/Gamma/headermenu.tpl | 2 +- resources/views/themes/Gamma/movies.tpl | 2 +- resources/views/themes/Gamma/music.tpl | 2 +- resources/views/themes/Gentele/books.tpl | 2 +- resources/views/themes/Gentele/console.tpl | 2 +- resources/views/themes/Gentele/headermenu.tpl | 2 +- resources/views/themes/Gentele/movies.tpl | 2 +- resources/views/themes/Gentele/music.tpl | 2 +- resources/views/themes/Omicron/books.tpl | 2 +- resources/views/themes/Omicron/console.tpl | 2 +- resources/views/themes/Omicron/headermenu.tpl | 2 +- resources/views/themes/Omicron/movies.tpl | 2 +- resources/views/themes/Omicron/music.tpl | 2 +- routes/web.php | 13 ++++++---- 25 files changed, 91 insertions(+), 40 deletions(-) diff --git a/Changelog b/Changelog index 3ea58bbb6..ce288369f 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-04-20 DariusIII + * Fix: Fix numerous category browsing issues * Chg: Update browsing per category * Chg: Update anime page links in all the themes * Chg: Fix myshows/browse page diff --git a/app/Http/Controllers/BooksController.php b/app/Http/Controllers/BooksController.php index 271fd8095..064203832 100644 --- a/app/Http/Controllers/BooksController.php +++ b/app/Http/Controllers/BooksController.php @@ -13,7 +13,7 @@ class BooksController extends BasePageController * * @throws \Exception */ - public function index(Request $request) + public function index(Request $request, $id = '') { $this->setPrefs(); $book = new Books(['Settings' => $this->settings]); @@ -22,15 +22,27 @@ class BooksController extends BasePageController $btmp = []; foreach ($boocats as $bcat) { - $btmp[$bcat['id']] = $bcat; + $btmp[] = + [ + 'id' => $bcat->id, + 'title' => $bcat->title, + ]; } $category = Category::BOOKS_ROOT; + if ($id && \in_array($id, array_pluck($btmp, 'title'), false)) { + $cat = Category::query() + ->where('title', $id) + ->where('parentid', '=', Category::BOOKS_ROOT) + ->first(['id']); + $category = $cat !== null ? $cat['id'] : Category::BOOKS_ROOT; + } $catarray = []; $catarray[] = $category; $this->smarty->assign('catlist', $btmp); $this->smarty->assign('category', $category); + $this->smarty->assign('categorytitle', $id); $ordering = $book->getBookOrdering(); $orderby = $request->has('ob') && \in_array($request->input('ob'), $ordering, false) ? $request->input('ob') : ''; @@ -64,7 +76,7 @@ class BooksController extends BasePageController } else { $cdata = Category::find($category); if ($cdata !== null) { - $this->smarty->assign('catname', $cdata->parent !== null ? $cdata->parent->title.' > '.$cdata->title : $cdata->title); + $this->smarty->assign('catname', $cdata->parentid !== null ? $cdata->parent->title.' > '.$cdata->title : $cdata->title); } else { $this->show404(); } diff --git a/app/Http/Controllers/ConsoleController.php b/app/Http/Controllers/ConsoleController.php index f602c268a..d88745364 100644 --- a/app/Http/Controllers/ConsoleController.php +++ b/app/Http/Controllers/ConsoleController.php @@ -11,9 +11,11 @@ class ConsoleController extends BasePageController { /** * @param \Illuminate\Http\Request $request + * @param string $id + * * @throws \Exception */ - public function show(Request $request) + public function show(Request $request, $id = '') { $this->setPrefs(); $console = new Console(['Settings' => $this->settings]); @@ -22,15 +24,27 @@ class ConsoleController extends BasePageController $concats = Category::getChildren(Category::GAME_ROOT); $ctmp = []; foreach ($concats as $ccat) { - $ctmp[$ccat['id']] = $ccat; + $ctmp[] = + [ + 'id' => $ccat->id, + 'title' => $ccat->title, + ]; + } + $category = Category::GAME_ROOT; + if ($id && \in_array($id, array_pluck($ctmp, 'title'), false)) { + $cat = Category::query() + ->where('title', $id) + ->where('parentid', '=', Category::GAME_ROOT) + ->first(['id']); + $category = $cat !== null ? $cat['id'] : Category::MUSIC_ROOT; } - $category = Category::query()->where('id', '=', Category::GAME_ROOT)->first(); $catarray = []; $catarray[] = $category; $this->smarty->assign('catlist', $ctmp); - $this->smarty->assign('category', $category->title); + $this->smarty->assign('category', $category); + $this->smarty->assign('categorytitle', $id); $page = $request->has('page') ? $request->input('page') : 1; @@ -69,7 +83,7 @@ class ConsoleController extends BasePageController } else { $cdata = Category::find($category); if ($cdata) { - $this->smarty->assign('catname', array_first($cdata)->parent !== null ? array_first($cdata)->parent->title.' > '.array_first($cdata)->title : array_first($cdata)->title); + $this->smarty->assign('catname', $cdata->parentid !== null ? $cdata->parent->title.' > '.$cdata->title : $cdata->title); } else { $this->show404(); } diff --git a/app/Http/Controllers/MovieController.php b/app/Http/Controllers/MovieController.php index c50b61d19..6dad87b49 100644 --- a/app/Http/Controllers/MovieController.php +++ b/app/Http/Controllers/MovieController.php @@ -60,10 +60,11 @@ class MovieController extends BasePageController /** * @param \Illuminate\Http\Request $request + * @param string $id * * @throws \Exception */ - public function showMovies(Request $request) + public function showMovies(Request $request, $id = '') { $this->setPrefs(); $movie = new Movie(['Settings' => $this->settings]); @@ -71,12 +72,20 @@ class MovieController extends BasePageController $moviecats = Category::getChildren(Category::MOVIE_ROOT); $mtmp = []; foreach ($moviecats as $mcat) { - $mtmp[$mcat['id']] = $mcat; + $mtmp[] = + [ + 'id' => $mcat->id, + 'title' => $mcat->title, + ]; } $category = $request->has('imdb') ? -1 : Category::MOVIE_ROOT; - if ($request->has('t') && array_key_exists($request->input('t'), $mtmp)) { - $category = $request->input('t') + 0; + if ($id && \in_array($id, array_pluck($mtmp, 'title'), false)) { + $cat = Category::query() + ->where('title', $id) + ->where('parentid', '=', Category::MOVIE_ROOT) + ->first(['id']); + $category = $cat !== null ? $cat['id'] : Category::MOVIE_ROOT; } $user = User::find(Auth::id()); @@ -92,6 +101,7 @@ class MovieController extends BasePageController $this->smarty->assign('catlist', $mtmp); $this->smarty->assign('category', $category); + $this->smarty->assign('categorytitle', $id); $page = $request->has('page') ? $request->input('page') : 1; diff --git a/app/Http/Controllers/MusicController.php b/app/Http/Controllers/MusicController.php index 2729398ec..97f64d167 100644 --- a/app/Http/Controllers/MusicController.php +++ b/app/Http/Controllers/MusicController.php @@ -11,10 +11,11 @@ class MusicController extends BasePageController { /** * @param \Illuminate\Http\Request $request + * @param string $id * * @throws \Exception */ - public function show(Request $request) + public function show(Request $request, $id = '') { $this->setPrefs(); $music = new Music(['Settings' => $this->settings]); @@ -23,11 +24,20 @@ class MusicController extends BasePageController $musiccats = Category::getChildren(Category::MUSIC_ROOT); $mtmp = []; foreach ($musiccats as $mcat) { - $mtmp[$mcat['id']] = $mcat; + $mtmp[] = + [ + 'id' => $mcat->id, + 'title' => $mcat->title, + ]; } + $category = Category::MUSIC_ROOT; - if ($request->has('t') && array_key_exists($request->input('t'), $mtmp)) { - $category = $request->input('t') + 0; + if ($id && \in_array($id, array_pluck($mtmp, 'title'), false)) { + $cat = Category::query() + ->where('title', $id) + ->where('parentid', '=', Category::MUSIC_ROOT) + ->first(['id']); + $category = $cat !== null ? $cat['id'] : Category::MUSIC_ROOT; } $catarray = []; @@ -35,6 +45,7 @@ class MusicController extends BasePageController $this->smarty->assign('catlist', $mtmp); $this->smarty->assign('category', $category); + $this->smarty->assign('categorytitle', $id); $page = $request->has('page') ? $request->input('page') : 1; diff --git a/resources/views/themes/Charisma/console.tpl b/resources/views/themes/Charisma/console.tpl index 4d50b00f7..565a82167 100755 --- a/resources/views/themes/Charisma/console.tpl +++ b/resources/views/themes/Charisma/console.tpl @@ -19,7 +19,7 @@
View: Covers | List
+ href="{$smarty.const.WWW_TOP}/browse/console/{$categorytitle}">List
Check all:
With Selected:
diff --git a/resources/views/themes/Charisma/headermenu.tpl b/resources/views/themes/Charisma/headermenu.tpl index e879430a6..762e12766 100755 --- a/resources/views/themes/Charisma/headermenu.tpl +++ b/resources/views/themes/Charisma/headermenu.tpl @@ -144,7 +144,7 @@ {/if}
{foreach $parentcat.subcatlist as $subcat} -
  • {$subcat.title}
  • +
  • {$subcat.title}
  • {/foreach} diff --git a/resources/views/themes/Charisma/movies.tpl b/resources/views/themes/Charisma/movies.tpl index 9047a9e70..bc53c2e8e 100755 --- a/resources/views/themes/Charisma/movies.tpl +++ b/resources/views/themes/Charisma/movies.tpl @@ -20,7 +20,7 @@
    View: Covers | List
    + href="{$smarty.const.WWW_TOP}/browse/movies/{$categorytitle}">List
    Check all:
    With Selected:
    diff --git a/resources/views/themes/Charisma/music.tpl b/resources/views/themes/Charisma/music.tpl index 8e19215af..d42dccaa8 100755 --- a/resources/views/themes/Charisma/music.tpl +++ b/resources/views/themes/Charisma/music.tpl @@ -19,7 +19,7 @@
    View: Covers | List
    + href="{$smarty.const.WWW_TOP}/browse/audio/{$categorytitle}">List
    Check all:
    With Selected:
    diff --git a/resources/views/themes/Gamma/books.tpl b/resources/views/themes/Gamma/books.tpl index c5b24eaaf..1cfa2ec40 100755 --- a/resources/views/themes/Gamma/books.tpl +++ b/resources/views/themes/Gamma/books.tpl @@ -24,7 +24,7 @@ {if isset($sabintegrated) && $sabintegrated !=""}{/if}
    View: Covers | List
    + href="{$smarty.const.WWW_TOP}/browse/books/{$categorytitle}">List
    diff --git a/resources/views/themes/Gamma/console.tpl b/resources/views/themes/Gamma/console.tpl index e835674ca..6383c2a3d 100755 --- a/resources/views/themes/Gamma/console.tpl +++ b/resources/views/themes/Gamma/console.tpl @@ -26,7 +26,7 @@

    View: Covers | List + href="{$smarty.const.WWW_TOP}/browse/console/{$categorytitle}">List
    diff --git a/resources/views/themes/Gamma/headermenu.tpl b/resources/views/themes/Gamma/headermenu.tpl index 314541c1e..9b04d4d70 100755 --- a/resources/views/themes/Gamma/headermenu.tpl +++ b/resources/views/themes/Gamma/headermenu.tpl @@ -149,7 +149,7 @@ {/if}
    {foreach $parentcat.subcatlist as $subcat} -
  • {$subcat.title}
  • +
  • {$subcat.title}
  • {/foreach} diff --git a/resources/views/themes/Gamma/movies.tpl b/resources/views/themes/Gamma/movies.tpl index 726e2867b..1b0f68060 100755 --- a/resources/views/themes/Gamma/movies.tpl +++ b/resources/views/themes/Gamma/movies.tpl @@ -23,7 +23,7 @@ {if isset($sabintegrated) && $sabintegrated !=""}{/if}
    View: Covers | List
    + href="{$smarty.const.WWW_TOP}/browse/movies/{$categorytitle}">List
    diff --git a/resources/views/themes/Gamma/music.tpl b/resources/views/themes/Gamma/music.tpl index 67f53fb3d..465ba4c92 100755 --- a/resources/views/themes/Gamma/music.tpl +++ b/resources/views/themes/Gamma/music.tpl @@ -23,7 +23,7 @@ {if isset($sabintegrated) && $sabintegrated !=""}{/if}
    View: Covers | List
    + href="{$smarty.const.WWW_TOP}/browse/audio/{$categorytitle}">List
    diff --git a/resources/views/themes/Gentele/books.tpl b/resources/views/themes/Gentele/books.tpl index 96b0e68da..51b7dd40c 100755 --- a/resources/views/themes/Gentele/books.tpl +++ b/resources/views/themes/Gentele/books.tpl @@ -21,7 +21,7 @@
    View: Covers | List
    + href="{$smarty.const.WWW_TOP}/browse/books/{$categorytitle}">List
    With Selected: