1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Models\Category; |
6
|
|
|
use Blacklight\Games; |
7
|
|
|
use Blacklight\Genres; |
8
|
|
|
use Illuminate\Http\Request; |
9
|
|
|
|
10
|
|
|
class GamesController extends BasePageController |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @throws \Exception |
14
|
|
|
*/ |
15
|
|
|
public function show(Request $request) |
16
|
|
|
{ |
17
|
|
|
$games = new Games(['Settings' => $this->settings]); |
|
|
|
|
18
|
|
|
$gen = new Genres(['Settings' => $this->settings]); |
|
|
|
|
19
|
|
|
|
20
|
|
|
$concats = Category::getChildren(Category::PC_ROOT); |
21
|
|
|
$ctmp = []; |
22
|
|
|
foreach ($concats as $ccat) { |
23
|
|
|
$ctmp[$ccat['id']] = $ccat; |
24
|
|
|
} |
25
|
|
|
$category = Category::PC_GAMES; |
26
|
|
|
if ($request->has('t') && array_key_exists($request->input('t'), $ctmp)) { |
27
|
|
|
$category = $request->input('t') + 0; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
$catarray = []; |
31
|
|
|
$catarray[] = $category; |
32
|
|
|
|
33
|
|
|
$page = $request->has('page') && is_numeric($request->input('page')) ? $request->input('page') : 1; |
34
|
|
|
$ordering = $games->getGamesOrdering(); |
35
|
|
|
$orderby = $request->has('ob') && \in_array($request->input('ob'), $ordering, false) ? $request->input('ob') : ''; |
36
|
|
|
$offset = ($page - 1) * config('nntmux.items_per_cover_page'); |
37
|
|
|
$rslt = $games->getGamesRange($page, $catarray, $offset, config('nntmux.items_per_cover_page'), $orderby, '', $this->userdata->categoryexclusions); |
|
|
|
|
38
|
|
|
$results = $this->paginate($rslt ?? [], $rslt[0]->_totalcount ?? 0, config('nntmux.items_per_cover_page'), $page, $request->url(), $request->query()); |
39
|
|
|
|
40
|
|
|
$title = ($request->has('title') && ! empty($request->input('title'))) ? stripslashes($request->input('title')) : ''; |
41
|
|
|
|
42
|
|
|
$genres = $gen->getGenres(Genres::GAME_TYPE, true); |
43
|
|
|
$tmpgnr = []; |
44
|
|
|
foreach ($genres as $gn) { |
45
|
|
|
$tmpgnr[$gn->id] = $gn->title; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$years = range(1903, date('Y') + 1); |
49
|
|
|
rsort($years); |
50
|
|
|
$year = ($request->has('year') && \in_array($request->input('year'), $years, false)) ? $request->input('year') : ''; |
51
|
|
|
|
52
|
|
|
$genre = ($request->has('genre') && array_key_exists($request->input('genre'), $tmpgnr)) ? $request->input('genre') : ''; |
53
|
|
|
|
54
|
|
|
if ((int) $category === -1) { |
55
|
|
|
$catname = 'All'; |
56
|
|
|
} else { |
57
|
|
|
$cdata = Category::find($category); |
58
|
|
|
if ($cdata !== null) { |
59
|
|
|
$catname = $cdata->title; |
60
|
|
|
} else { |
61
|
|
|
$catname = 'All'; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
// Build order by URLs |
66
|
|
|
$orderByUrls = []; |
67
|
|
|
foreach ($ordering as $orderType) { |
68
|
|
|
$orderByUrls['orderby'.$orderType] = url('Games?ob='.$orderType); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$this->viewData = array_merge($this->viewData, [ |
72
|
|
|
'catlist' => $ctmp, |
73
|
|
|
'category' => $category, |
74
|
|
|
'catname' => $catname, |
75
|
|
|
'title' => $title, |
76
|
|
|
'genres' => $genres, |
77
|
|
|
'genre' => $genre, |
78
|
|
|
'years' => $years, |
79
|
|
|
'year' => $year, |
80
|
|
|
'results' => $results, |
81
|
|
|
'covgroup' => 'games', |
82
|
|
|
'meta_title' => 'Browse Games', |
83
|
|
|
'meta_keywords' => 'browse,nzb,games,description,details', |
84
|
|
|
'meta_description' => 'Browse for Games', |
85
|
|
|
], $orderByUrls); |
86
|
|
|
|
87
|
|
|
return view('games.index', $this->viewData); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.