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 "

No results found

"; - } - else - { + } else { $ourmovieimdbs = array(); - if (count($imdbids) > 0) - { - $m = new Movie(); + if (count($imdbids) > 0) { + $m = new Film(['Settings' => $page->settings, 'TMDb' => $tmdb]); $allmovies = $m->getMovieInfoMultiImdb($imdbids); - foreach ($allmovies as $ourmovie) - if ($ourmovie["relimdb"] != "") - $ourmovieimdbs[$ourmovie["imdbID"]] = $ourmovie["imdbID"]; + foreach ($allmovies as $ourmovie) { + if ($ourmovie['relimdb'] != '') { + $ourmovieimdbs[$ourmovie['imdbid']] = $ourmovie['imdbid']; + } + } } $userimdbs = array(); $usermovies = $um->getMovies($page->users->currentUserId()); - foreach ($usermovies as $umovie) - $userimdbs[$umovie["imdbID"]] = $umovie["imdbID"]; + foreach ($usermovies as $umovie) { + $userimdbs[$umovie['imdbid']] = $umovie['imdbid']; + } - $page->smarty->assign('data', $res); + $page->smarty->assign('data', $obj); $page->smarty->assign('ourmovies', $ourmovieimdbs); $page->smarty->assign('userimdbs', $userimdbs); diff --git a/www/pages/mymoviesedit.php b/www/pages/mymoviesedit.php index ac940a301..2d2c30a6d 100644 --- a/www/pages/mymoviesedit.php +++ b/www/pages/mymoviesedit.php @@ -1,44 +1,39 @@ users->isLoggedIn()) +if (!$page->users->isLoggedIn()) { $page->show403(); +} -$um = new UserMovies(); - -if (isset($_REQUEST["del"])) -{ +$um = new UserMovies(['Settings' => $page->settings]); +if (isset($_REQUEST["del"])) { $um->delMovie($page->users->currentUserId(), $_REQUEST["del"]); } -$cat = new Category; -$tmpcats = $cat->getChildren(Category::CAT_PARENT_MOVIE, true, $page->userdata["categoryexclusions"]); +$cat = new Category(['Settings' => $page->settings]); +$tmpcats = $cat->getChildren(Category::CAT_PARENT_MOVIE); $categories = array(); -foreach($tmpcats as $c) - $categories[$c['ID']] = $c['title']; +foreach ($tmpcats as $c) { + $categories[$c['id']] = $c['title']; +} $movies = $um->getMovies($page->users->currentUserId()); $results = array(); -foreach ($movies as $mov=>$m) -{ - $movcats = explode('|', $m['categoryID']); - if (is_array($movcats) && sizeof($movcats) > 0) - { +foreach ($movies as $mov => $m) { + $movcats = explode('|', $m['categoryid']); + if (is_array($movcats) && sizeof($movcats) > 0) { $catarr = array(); - foreach ($movcats as $movcat) - { - if (!empty($movcat)) + foreach ($movcats as $movcat) { + if (!empty($movcat)) { $catarr[] = $categories[$movcat]; + } } $m['categoryNames'] = implode(', ', $catarr); - } - else - { + } else { $m['categoryNames'] = ''; - } - $results[$mov] = $m; + $results[$mov] = $m; } $page->smarty->assign('movies', $results); @@ -48,6 +43,4 @@ $page->meta_keywords = "couch,potato,movie,add"; $page->meta_description = "Manage Your Movies"; $page->content = $page->smarty->fetch('mymoviesedit.tpl'); -$page->render(); - - +$page->render(); \ No newline at end of file diff --git a/www/templates/nntmux/views/frontend/mymoviesedit.tpl b/www/templates/nntmux/views/frontend/mymoviesedit.tpl index b4b67697e..6292778c6 100644 --- a/www/templates/nntmux/views/frontend/mymoviesedit.tpl +++ b/www/templates/nntmux/views/frontend/mymoviesedit.tpl @@ -1,51 +1,51 @@

{$page->title}

-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} - - +
+ - - - - - - - - {foreach from=$movies item=movie} - - - - - - - - - + + + + + - {/foreach} -
namecategoryaddedoptions
- -
- {$movie.title|escape: -
- 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}Removenamecategoryaddedoptions
+ {foreach from=$movies item=movie} + + + + +
+ {$movie.title|escape: +
+ 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 + + {/foreach} + + {else} -{/if} +{/if} \ No newline at end of file