Ejemplo n.º 1
0
    /**
     * 
     * @param WOOOF $wo
     * @param string $sortCriteria = '' -> criteria to sort the movies
     * @param string $targetUserId = '' -> userId to see movies from
     */
    public static function home(WOOOF $wo, $sortCriteria = '', $targetUserId = '')
    {
        $requestedAction = 'viewUncontroled';
        $pageLocation = '3';
        $browserTitle = 'Welcome to MovieRama!';
        $wo = WOOOF::getWOOOF($pageLocation, $requestedAction, $wo);
        if ($wo === FALSE) {
            die('Failed to getWOOOF()');
        }
        //not logged in user
        if ($wo->userData['id'] == '0123456789') {
            $userData = [];
            $requestorUserId = '';
            $isloggedIn = 'false';
        } else {
            $userData = VO_ProfileData::getMainInfo($wo, $wo->app->userId);
            if ($userData === FALSE) {
                $wo->handleShowStopperError('500 Failed to get Profile Data');
            }
            $requestorUserId = $wo->app->userId;
            $isloggedIn = 'true';
        }
        $movies = VO_Movies::getMovies($wo, $requestorUserId, $isloggedIn, $sortCriteria, $targetUserId);
        if ($movies === FALSE) {
            return false;
        }
        $userData = json_encode($userData);
        $movies = json_encode($movies);
        $content = <<<EOH
\t\t<div id='content-main'></div>
\t
\t\t<script>
\t\t\tvar movies = {$movies};
\t\t\tvar isLoggedIn = {$isloggedIn};
\t\t\tvar targetUserId = '{$targetUserId}';
\t\t\t\t\t
\t\t\tReactDOM.render(
\t\t\t\tReact.createElement(
\t\t\t\t\tObjectsList,
\t\t\t\t\t{ data: movies, title: 'MovieRama Movies', isType: 'MOV',
\t\t\t\t\tautocompleteUrl: 'movies', isLoggedIn: isLoggedIn, targetUserId: targetUserId }
\t\t\t\t),
\t\t\t\tdocument.getElementById('content-main')
\t\t\t);
\t\t</script>
EOH;
        $tpl = array('browserTitle' => $browserTitle, 'content' => $content, 'errorMessage' => '', 'message' => '');
        $wo->fetchApplicationFragment('structural/template.php', [], $tpl);
    }
Ejemplo n.º 2
0
 /**
  *
  * @param WOOOF $wo
  * @param string $movieId
  * @return [ 'getCountersOk' => bool, 'errors' => array, 'getCounters' => array ]
  */
 public static function countersInfo(WOOOF $wo, $movieId)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     if ($wo->userData['id'] == '0123456789') {
         $wo->handleShowStopperError('505');
     }
     if (!$wo->hasContent($movieId)) {
         $wo->logError(self::_ECP . "4166 You must provide [movieId] to compute its votes.");
         return false;
     }
     $res = VO_Movies::getCountersInfo($wo, $movieId);
     if ($res === FALSE) {
         $out = ['getCountersOk' => false, 'errors' => $wo->getErrorsAsArrayAndClear()];
         $wo->db->rollback();
     } else {
         $out = ['getCountersOk' => true, 'getCounters' => $res];
         $wo->db->commit();
     }
     return $out;
 }