Example #1
0
 public static function Step2()
 {
     if (!isset($_GET['q'])) {
         return AddMovie::Step1('invalid-searchterm');
     }
     if (preg_match("/^\\d{7}\$/", $_GET['q'])) {
         $_GET['id'] = $_GET['q'];
         return AddMovie::Step3($GLOBALS['modernLanguagesFlipped']);
         // GLOBALS?!
     }
     $results = imdb\imdb()->find($_GET['q']);
     if (isset($_REQUEST['content-type']) && $_REQUEST['content-type'] == 'application/json') {
         header('Content-Type: application/json');
         echo json_encode(array_map(function ($movie) {
             return array('id' => $movie->id(), 'title' => $movie->title(), 'year' => $movie->year(), 'image' => $movie->image() ? $movie->image()->url : null);
         }, $results));
     } else {
         $tpl = new Template(DOCUMENT_ROOT . '_templates/add-movie.tpl');
         $content = new Template(DOCUMENT_ROOT . '_templates/step-2.tpl');
         $content->set('results', $results);
         $tpl->set('content', $content);
         echo $tpl->fetch();
     }
 }
Example #2
0
require_once '_includes/imdbphp/imdb.class.php';
require_once '_includes/imdbphp/imdbsearch.class.php';
if (!LOGGEDIN) {
    header('Location: login.php?requestURI=' . urlencode($_SERVER["REQUEST_URI"]));
    exit;
}
switch (STEP) {
    case 1:
    default:
        AddMovie::Step1();
        break;
    case 2:
        AddMovie::Step2();
        break;
    case 3:
        AddMovie::Step3($modernLanguagesFlipped);
        break;
    case 4:
        AddMovie::Step4($modernLanguagesFlipped);
        break;
}
class AddMovie
{
    /*
      Display the searchbox and ID inputbox.
    */
    public function Step1($message = false)
    {
        $tpl = new Template(DOCUMENT_ROOT . '_templates/add-movie.tpl');
        $content = new Template(DOCUMENT_ROOT . '_templates/step-1.tpl');
        if ($message) {