|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\Category; |
|
6
|
|
|
use Blacklight\Console; |
|
7
|
|
|
use Blacklight\Genres; |
|
8
|
|
|
use Illuminate\Http\Request; |
|
9
|
|
|
use Illuminate\Support\Arr; |
|
10
|
|
|
|
|
11
|
|
|
class ConsoleController extends BasePageController |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @throws \Exception |
|
15
|
|
|
*/ |
|
16
|
|
|
public function show(Request $request, string $id = '') |
|
17
|
|
|
{ |
|
18
|
|
|
if ($id === 'WiiVare') { |
|
19
|
|
|
$id = 'WiiVareVC'; |
|
20
|
|
|
} |
|
21
|
|
|
$console = new Console; |
|
22
|
|
|
$gen = new Genres; |
|
23
|
|
|
|
|
24
|
|
|
$concats = Category::getChildren(Category::GAME_ROOT); |
|
25
|
|
|
$ctmp = []; |
|
26
|
|
|
foreach ($concats as $ccat) { |
|
27
|
|
|
$ctmp[] = |
|
28
|
|
|
[ |
|
29
|
|
|
'id' => $ccat->id, |
|
30
|
|
|
'title' => $ccat->title, |
|
31
|
|
|
]; |
|
32
|
|
|
} |
|
33
|
|
|
$category = $request->has('t') ? $request->input('t') : Category::GAME_ROOT; |
|
34
|
|
|
if ($id && \in_array($id, Arr::pluck($ctmp, 'title'), false)) { |
|
35
|
|
|
$cat = Category::query() |
|
36
|
|
|
->where('title', $id) |
|
37
|
|
|
->where('root_categories_id', '=', Category::GAME_ROOT) |
|
38
|
|
|
->first(['id']); |
|
39
|
|
|
$category = $cat !== null ? $cat['id'] : Category::GAME_ROOT; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$catarray = []; |
|
43
|
|
|
$catarray[] = $category; |
|
44
|
|
|
|
|
45
|
|
|
$ordering = $console->getConsoleOrdering(); |
|
46
|
|
|
$orderby = $request->has('ob') && \in_array($request->input('ob'), $ordering, false) ? $request->input('ob') : ''; |
|
47
|
|
|
$page = $request->has('page') && is_numeric($request->input('page')) ? $request->input('page') : 1; |
|
48
|
|
|
$offset = ($page - 1) * config('nntmux.items_per_cover_page'); |
|
49
|
|
|
|
|
50
|
|
|
$consoles = []; |
|
51
|
|
|
$rslt = $console->getConsoleRange($page, $catarray, $offset, config('nntmux.items_per_cover_page'), $orderby, $this->userdata->categoryexclusions); |
|
|
|
|
|
|
52
|
|
|
$results = $this->paginate($rslt ?? [], $rslt[0]->_totalcount ?? 0, config('nntmux.items_per_cover_page'), $page, $request->url(), $request->query()); |
|
53
|
|
|
|
|
54
|
|
|
$maxwords = 50; |
|
55
|
|
|
foreach ($results as $result) { |
|
56
|
|
|
if (! empty($result->review)) { |
|
57
|
|
|
$words = explode(' ', $result->review); |
|
58
|
|
|
if (\count($words) > $maxwords) { |
|
59
|
|
|
$newwords = \array_slice($words, 0, $maxwords); |
|
60
|
|
|
$result->review = implode(' ', $newwords).'...'; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
$consoles[] = $result; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
$platform = ($request->has('platform') && ! empty($request->input('platform'))) ? stripslashes($request->input('platform')) : ''; |
|
67
|
|
|
$title = ($request->has('title') && ! empty($request->input('title'))) ? stripslashes($request->input('title')) : ''; |
|
68
|
|
|
|
|
69
|
|
|
$genres = $gen->getGenres(Genres::CONSOLE_TYPE, true); |
|
70
|
|
|
$tmpgnr = []; |
|
71
|
|
|
foreach ($genres as $gn) { |
|
72
|
|
|
$tmpgnr[$gn->id] = $gn->title; |
|
73
|
|
|
} |
|
74
|
|
|
$genre = ($request->has('genre') && array_key_exists($request->input('genre'), $tmpgnr)) ? $request->input('genre') : ''; |
|
75
|
|
|
|
|
76
|
|
|
if ((int) $category === -1) { |
|
77
|
|
|
$catname = 'All'; |
|
78
|
|
|
} else { |
|
79
|
|
|
$cdata = Category::find($category); |
|
80
|
|
|
if ($cdata !== null) { |
|
81
|
|
|
$catname = $cdata; |
|
82
|
|
|
} else { |
|
83
|
|
|
$catname = 'All'; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
$this->viewData = array_merge($this->viewData, [ |
|
88
|
|
|
'catlist' => $ctmp, |
|
89
|
|
|
'category' => $category, |
|
90
|
|
|
'categorytitle' => $id, |
|
91
|
|
|
'platform' => $platform, |
|
92
|
|
|
'title' => $title, |
|
93
|
|
|
'genres' => $genres, |
|
94
|
|
|
'genre' => $genre, |
|
95
|
|
|
'catname' => $catname, |
|
96
|
|
|
'resultsadd' => $consoles, |
|
97
|
|
|
'results' => $results, |
|
98
|
|
|
'covgroup' => 'console', |
|
99
|
|
|
'meta_title' => 'Browse Console', |
|
100
|
|
|
'meta_keywords' => 'browse,nzb,console,games,description,details', |
|
101
|
|
|
'meta_description' => 'Browse for Console Games', |
|
102
|
|
|
]); |
|
103
|
|
|
|
|
104
|
|
|
return view('console.index', $this->viewData); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|