|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\Category; |
|
6
|
|
|
use Blacklight\Movie; |
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
|
|
9
|
|
|
class MovieController extends BasePageController |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @throws \Exception |
|
13
|
|
|
*/ |
|
14
|
|
|
public function showMovies(Request $request, string $id = ''): void |
|
15
|
|
|
{ |
|
16
|
|
|
$this->setPreferences(); |
|
17
|
|
|
$movie = new Movie(['Settings' => $this->settings]); |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
$moviecats = Category::getChildren(Category::MOVIE_ROOT)->map(function ($mcat) { |
|
20
|
|
|
return ['id' => $mcat->id, 'title' => $mcat->title]; |
|
21
|
|
|
}); |
|
22
|
|
|
|
|
23
|
|
|
$category = $request->has('imdb') ? -1 : ($request->input('t', Category::MOVIE_ROOT)); |
|
24
|
|
|
if ($id && $moviecats->pluck('title')->contains($id)) { |
|
25
|
|
|
$cat = Category::where(['title' => $id, 'root_categories_id' => Category::MOVIE_ROOT])->first(['id']); |
|
26
|
|
|
$category = $cat->id ?? Category::MOVIE_ROOT; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
$this->smarty->assign('cpapi', $this->userdata->cp_api); |
|
30
|
|
|
$this->smarty->assign('cpurl', $this->userdata->cp_url); |
|
31
|
|
|
|
|
32
|
|
|
$catarray = $category !== -1 ? [$category] : []; |
|
33
|
|
|
|
|
34
|
|
|
$this->smarty->assign('catlist', $moviecats); |
|
35
|
|
|
$this->smarty->assign('category', $category); |
|
36
|
|
|
$this->smarty->assign('categorytitle', $id); |
|
37
|
|
|
|
|
38
|
|
|
$page = $request->input('page', 1); |
|
39
|
|
|
$offset = ($page - 1) * config('nntmux.items_per_cover_page'); |
|
40
|
|
|
|
|
41
|
|
|
$orderby = $request->input('ob', ''); |
|
42
|
|
|
$ordering = $movie->getMovieOrdering(); |
|
43
|
|
|
if (! in_array($orderby, $ordering, false)) { |
|
44
|
|
|
$orderby = ''; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$rslt = $movie->getMovieRange($page, $catarray, $offset, config('nntmux.items_per_cover_page'), $orderby, -1, $this->userdata->categoryexclusions); |
|
|
|
|
|
|
48
|
|
|
$results = $this->paginate($rslt ?? [], $rslt[0]->_totalcount ?? 0, config('nntmux.items_per_cover_page'), $page, $request->url(), $request->query()); |
|
49
|
|
|
|
|
50
|
|
|
$movies = $results->map(function ($result) { |
|
51
|
|
|
$result->genre = makeFieldLinks($result, 'genre', 'movies'); |
|
52
|
|
|
$result->actors = makeFieldLinks($result, 'actors', 'movies'); |
|
53
|
|
|
$result->director = makeFieldLinks($result, 'director', 'movies'); |
|
54
|
|
|
$result->languages = explode(', ', $result->language); |
|
55
|
|
|
|
|
56
|
|
|
return $result; |
|
57
|
|
|
}); |
|
58
|
|
|
|
|
59
|
|
|
$this->smarty->assign('title', stripslashes($request->input('title', ''))); |
|
60
|
|
|
$this->smarty->assign('actors', stripslashes($request->input('actors', ''))); |
|
61
|
|
|
$this->smarty->assign('director', stripslashes($request->input('director', ''))); |
|
62
|
|
|
$this->smarty->assign('ratings', range(1, 9)); |
|
63
|
|
|
$this->smarty->assign('rating', $request->input('rating', '')); |
|
64
|
|
|
$this->smarty->assign('genres', $movie->getGenres()); |
|
65
|
|
|
$this->smarty->assign('genre', $request->input('genre', '')); |
|
66
|
|
|
$years = range(1903, now()->addYear()->year); |
|
67
|
|
|
rsort($years); |
|
68
|
|
|
$this->smarty->assign('years', $years); |
|
69
|
|
|
$this->smarty->assign('year', $request->input('year', '')); |
|
70
|
|
|
|
|
71
|
|
|
$catname = $category === -1 ? 'All' : Category::find($category) ?? 'All'; |
|
72
|
|
|
$this->smarty->assign('catname', $catname); |
|
73
|
|
|
|
|
74
|
|
|
$this->smarty->assign([ |
|
75
|
|
|
'resultsadd' => $movies, |
|
76
|
|
|
'results' => $results, |
|
77
|
|
|
'covgroup' => 'movies', |
|
78
|
|
|
]); |
|
79
|
|
|
|
|
80
|
|
|
$meta_title = 'Browse Movies'; |
|
81
|
|
|
$meta_keywords = 'browse,nzb,description,details'; |
|
82
|
|
|
$meta_description = 'Browse for Movies'; |
|
83
|
|
|
|
|
84
|
|
|
$content = $request->has('imdb') ? $this->smarty->fetch('viewmoviefull.tpl') : $this->smarty->fetch('movies.tpl'); |
|
85
|
|
|
$this->smarty->assign(compact('content', 'meta_title', 'meta_keywords', 'meta_description')); |
|
86
|
|
|
$this->pagerender(); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return \Illuminate\Http\JsonResponse|void |
|
91
|
|
|
*/ |
|
92
|
|
|
public function showTrailer(Request $request) |
|
93
|
|
|
{ |
|
94
|
|
|
$movie = new Movie; |
|
95
|
|
|
|
|
96
|
|
|
if ($request->has('id') && ctype_digit($request->input('id'))) { |
|
97
|
|
|
$mov = $movie->getMovieInfo($request->input('id')); |
|
98
|
|
|
|
|
99
|
|
|
if (! $mov) { |
|
|
|
|
|
|
100
|
|
|
return response()->json(['message' => 'There is no trailer for this movie.'], 404); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
$this->smarty->assign('movie', $mov); |
|
104
|
|
|
|
|
105
|
|
|
$title = 'Info for '.$mov['title']; |
|
106
|
|
|
$meta_title = ''; |
|
107
|
|
|
$meta_keywords = ''; |
|
108
|
|
|
$meta_description = ''; |
|
109
|
|
|
$this->smarty->registerPlugin('modifier', 'ss', 'stripslashes'); |
|
110
|
|
|
|
|
111
|
|
|
$modal = false; |
|
112
|
|
|
if ($request->has('modal')) { |
|
113
|
|
|
$modal = true; |
|
114
|
|
|
$this->smarty->assign('modal', true); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
$content = $this->smarty->fetch('viewmovietrailer.tpl'); |
|
118
|
|
|
|
|
119
|
|
|
if ($modal) { |
|
120
|
|
|
echo $content; |
|
121
|
|
|
} else { |
|
122
|
|
|
$this->smarty->assign(compact('content', 'title', 'meta_title', 'meta_keywords', 'meta_description')); |
|
123
|
|
|
$this->pagerender(); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|
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.