diff --git a/www/pages/ajax_mymovies.php b/www/pages/ajax_mymovies.php index 1c162a6ea..be4bcb74e 100644 --- a/www/pages/ajax_mymovies.php +++ b/www/pages/ajax_mymovies.php @@ -1,86 +1,90 @@ users->isLoggedIn()) + +if (!$page->users->isLoggedIn()) { $page->show403(); - -$um = new UserMovies(); - - -if (isset($_REQUEST["del"])) -{ - $usermovies = $um->delMovie($page->users->currentUserId(), $_REQUEST["del"]); } -elseif (isset($_REQUEST["add"])) -{ - // - // derive cats from user preferences - // + +$um = new UserMovies(['Settings' => $page->settings]); + +if (isset($_REQUEST['del'])) { + $usermovies = $um->delMovie($page->users->currentUserId(), $_REQUEST['del']); +} else if (isset($_REQUEST['add'])) { + // Derive cats from user preferences. $cats = array(); - $cats[] = "2030"; - $cats[] = "2040"; + $cats[] = '2030'; + $cats[] = '2040'; - $m = new Movie(false); - $mi = $m->getMovieInfo($_REQUEST["add"]); - if (!$mi) - $m->updateMovieInfo($_REQUEST["add"]); + $m = new Film(['Settings' => $page->settings]); + $mi = $m->getMovieInfo($_REQUEST['add']); + if (!$mi) { + $m->updateMovieInfo($_REQUEST['add']); + } - $usermovies = $um->addMovie($page->users->currentUserId(), $_REQUEST["add"], $cats); -} -else -{ - if (!isset($_REQUEST["id"])) + $usermovies = $um->addMovie($page->users->currentUserId(), $_REQUEST['add'], $cats); +} else { + if (!isset($_REQUEST['id'])) { $page->show404(); - - $m = new Movie(false); - - if (is_numeric($_REQUEST["id"])) - { - $prop = $m->fetchTmdbProperties($_REQUEST["id"]); - if ($prop !== false) - $res = array($prop); - } - else - { - $res = $m->searchTmdb($_REQUEST["id"]); } + $tmdb = new TMDb($page->settings->getSetting('tmdbkey'), $page->settings->getSetting('imdblanguage')); + $m = new Film(['Settings' => $page->settings, 'TMDb' => $tmdb]); + + if (is_numeric($_REQUEST['id'])) { + $movie = $m->fetchTMDBProperties($_REQUEST['id']); + if ($movie !== false) { + $obj = array($movie); + } + } else { + $searchm = $tmdb->searchMovie($_REQUEST['id']); + if ($searchm !== false) { + if (isset($searchm['results'])) { + $obj = array(); + $limit = 0; + foreach ($searchm['results'] as $movie) { + $limit++; + $movieinfo = $m->fetchTMDBProperties($movie['id'], true); + if ($movieinfo !== false) { + $obj[] = $movieinfo; + } + if ($limit > 4) { + break; + } + } + } + } + } $imdbids = array(); - if ($res) - { - foreach ($res as $movie) - { - if (isset($movie['title']) && isset($movie['imdb_id'])) - { - $imdbids[] = str_replace("tt", "", $movie['imdb_id']); - } - else - { - // no results + + if (isset($obj) && count($obj) > 0) { + foreach ($obj as $movie) { + if (isset($movie['title']) && isset($movie['imdb_id'])) { + $imdbids[] = str_replace('tt', '', $movie['imdb_id']); } } - if (count($imdbids) == 0) - { + if (count($imdbids) == 0) { print "
-Use this page to manage movies added to your personal list. If the movie becomes available it will be added to an Rss Feed you can use to automatically download. To add more movies use the My Movies search feature. + Use this page to manage movies added to your personal list. If the movie becomes available it will be added to an Rss Feed you can use to automatically download. To add more movies use the My Movies search feature.
{if $movies|@count > 0} -| - | name | -category | -added | -options | -|||||
|---|---|---|---|---|---|---|---|---|---|
|
-
-
-
-
-
- Imdb
-
- |
-
-
-
- {$movie.title|escape:"htmlall"} ({$movie.year})- {if $movie.tagline != ''}{$movie.tagline}{/if} - {if $movie.plot != ''}{$movie.plot} {/if} - {if $movie.genre != ''}Genre: {$movie.genre} {/if} - {if $movie.director != ''}Director: {$movie.director} {/if} - {if $movie.actors != ''}Starring: {$movie.actors} {/if} - |
- {if $movie.categoryNames != ''}{$movie.categoryNames|escape:"htmlall"}{else}All{/if} | -{$movie.createddate|date_format} | -Remove | ++ | name | +category | +added | +options |
+