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 @@