1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
4
|
|
|
|
5
|
|
|
use Blacklight\Movie; |
6
|
|
|
use App\Models\Release; |
7
|
|
|
use App\Models\MovieInfo; |
8
|
|
|
use Illuminate\Http\Request; |
9
|
|
|
use Blacklight\utility\Utility; |
10
|
|
|
use App\Http\Controllers\BasePageController; |
11
|
|
|
|
12
|
|
|
class MovieController extends BasePageController |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @throws \Exception |
16
|
|
|
*/ |
17
|
|
|
public function index() |
18
|
|
|
{ |
19
|
|
|
$this->setAdminPrefs(); |
20
|
|
|
|
21
|
|
|
$meta_title = $title = 'Movie List'; |
22
|
|
|
|
23
|
|
|
$movieList = Utility::getRange('movieinfo'); |
24
|
|
|
$this->smarty->assign('movielist', $movieList); |
|
|
|
|
25
|
|
|
|
26
|
|
|
$content = $this->smarty->fetch('movie-list.tpl'); |
|
|
|
|
27
|
|
|
|
28
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content')); |
29
|
|
|
|
30
|
|
|
$this->adminrender(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param \Illuminate\Http\Request $request |
35
|
|
|
* |
36
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |
37
|
|
|
* @throws \Exception |
38
|
|
|
*/ |
39
|
|
|
public function create(Request $request) |
40
|
|
|
{ |
41
|
|
|
if (! \defined('STDOUT')) { |
42
|
|
|
\define('STDOUT', fopen('php://stdout', 'wb')); |
43
|
|
|
} |
44
|
|
|
$this->setAdminPrefs(); |
45
|
|
|
$movie = new Movie(['Settings' => null]); |
46
|
|
|
|
47
|
|
|
$meta_title = $title = 'Movie Add'; |
48
|
|
|
|
49
|
|
|
$id = $request->input('id'); |
50
|
|
|
|
51
|
|
|
if ($request->has('id') && is_numeric($request->input('id'))) { |
52
|
|
|
$movCheck = $movie->getMovieInfo($id); |
53
|
|
|
$movieInfo = $movie->updateMovieInfo($id); |
54
|
|
|
if ($movieInfo && ($movCheck === null || ($request->has('update') && (int) $request->input('update') === 1))) { |
55
|
|
|
$forUpdate = Release::query()->where('imdbid', $id)->get(['id']); |
56
|
|
|
if ($forUpdate !== null) { |
57
|
|
|
$movieInfoId = MovieInfo::query()->where('imdbid', $id)->first(['id']); |
58
|
|
|
if ($movieInfoId !== null) { |
59
|
|
|
foreach ($forUpdate as $movie) { |
60
|
|
|
Release::query()->where('id', $movie->id)->update(['movieinfo_id' => $movieInfoId->id]); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
if (($request->has('update') && (int) $request->input('update') === 1)) { |
65
|
|
|
return back()->withInput(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return redirect('/admin/movie-list'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return redirect('/admin/movie-list'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
$content = $this->smarty->fetch('movie-add.tpl'); |
75
|
|
|
|
76
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content')); |
77
|
|
|
|
78
|
|
|
$this->adminrender(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param \Illuminate\Http\Request $request |
83
|
|
|
* |
84
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |
85
|
|
|
* @throws \Exception |
86
|
|
|
*/ |
87
|
|
|
public function edit(Request $request) |
88
|
|
|
{ |
89
|
|
|
$this->setAdminPrefs(); |
90
|
|
|
|
91
|
|
|
$movie = new Movie(); |
92
|
|
|
$meta_title = $title = 'Add Movie'; |
93
|
|
|
|
94
|
|
|
// set the current action |
95
|
|
|
$action = $request->input('action') ?? 'view'; |
96
|
|
|
|
97
|
|
|
if ($request->has('id')) { |
98
|
|
|
$id = $request->input('id'); |
99
|
|
|
$mov = $movie->getMovieInfo($id); |
100
|
|
|
|
101
|
|
|
if ($mov === null) { |
102
|
|
|
abort(404, 'Movie you requested does not exist in database'); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
switch ($action) { |
106
|
|
|
case 'submit': |
107
|
|
|
$coverLoc = resource_path().'/covers/movies/'.$id.'-cover.jpg'; |
108
|
|
|
$backdropLoc = resource_path().'covers/movies/'.$id.'-backdrop.jpg'; |
109
|
|
|
|
110
|
|
|
if ($_FILES['cover']['size'] > 0) { |
111
|
|
|
$tmpName = $_FILES['cover']['tmp_name']; |
112
|
|
|
$file_info = getimagesize($tmpName); |
113
|
|
|
if (! empty($file_info)) { |
114
|
|
|
move_uploaded_file($_FILES['cover']['tmp_name'], $coverLoc); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
if ($_FILES['backdrop']['size'] > 0) { |
119
|
|
|
$tmpName = $_FILES['backdrop']['tmp_name']; |
120
|
|
|
$file_info = getimagesize($tmpName); |
121
|
|
|
if (! empty($file_info)) { |
122
|
|
|
move_uploaded_file($_FILES['backdrop']['tmp_name'], $backdropLoc); |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
$request->merge(['cover' => file_exists($coverLoc) ? 1 : 0]); |
127
|
|
|
$request->merge(['backdrop' => file_exists($backdropLoc) ? 1 : 0]); |
128
|
|
|
|
129
|
|
|
$movie->update([ |
130
|
|
|
'actors' => $request->input('actors'), |
131
|
|
|
'backdrop' => $request->input('backdrop'), |
132
|
|
|
'cover' => $request->input('cover'), |
133
|
|
|
'director' => $request->input('director'), |
134
|
|
|
'genre' => $request->input('genre'), |
135
|
|
|
'imdbid' => $id, |
136
|
|
|
'language' => $request->input('language'), |
137
|
|
|
'plot' => $request->input('plot'), |
138
|
|
|
'rating' => $request->input('rating'), |
139
|
|
|
'tagline' => $request->input('tagline'), |
140
|
|
|
'title' => $request->input('title'), |
141
|
|
|
'year' => $request->input('year'), |
142
|
|
|
]); |
143
|
|
|
|
144
|
|
|
$movieInfo = MovieInfo::query()->where('imdbid', $id)->first(['id']); |
145
|
|
|
if ($movieInfo !== null) { |
146
|
|
|
Release::query()->where('imdbid', $id)->update(['movieinfo_id' => $movieInfo->id]); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
return redirect('admin/movie-list'); |
150
|
|
|
break; |
|
|
|
|
151
|
|
|
case 'view': |
152
|
|
|
default: |
153
|
|
|
$meta_title = $title = 'Movie Edit'; |
154
|
|
|
$this->smarty->assign('movie', $mov); |
155
|
|
|
break; |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
$content = $this->smarty->fetch('movie-edit.tpl'); |
160
|
|
|
|
161
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content')); |
162
|
|
|
|
163
|
|
|
$this->adminrender(); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.