Example #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);
    }
 public static function profileEdit(WOOOF $wo)
 {
     $requestedAction = 'viewUncontroled';
     // TODO: should be edit
     $pageLocation = '3';
     $browserTitle = 'MovieRama Edit User Profile';
     $wo = WOOOF::getWOOOF($pageLocation, $requestedAction, $wo);
     if ($wo === FALSE) {
         die('Failed to getWOOOF()');
     }
     if ($wo->userData['id'] == '0123456789') {
         $wo->handleShowStopperError('505');
     }
     $data = VO_ProfileData::getMainInfo($wo, $wo->app->userId);
     if ($data === FALSE) {
         $wo->handleShowStopperError();
     }
     $data = json_encode($data);
     $content = "\n\t\t<div id='content-main'></div>\n\n\t\t<script>\n        \tvar data = {$data};\n        \t\n        \tReactDOM.render(\n        \t\tReact.createElement(\n        \t\t\tProfileEdit, \n        \t\t\t{ data: data }\n        \t\t), \n        \t\tdocument.getElementById('content-main')\n        \t);\n\t\t</script>\n\t\t";
     $tpl = array('browserTitle' => $browserTitle, 'content' => $content, 'errorMessage' => '', 'message' => '');
     $wo->fetchApplicationFragment('structural/template.php', [], $tpl);
 }
Example #3
0
/*******************************************************************/
// Profile
//
// profile/edit
$router->map('GET', '/profile/edit', function () use($wo) {
    VO_CtrlProfile::profileEdit($wo);
}, 'profileEdit');
/******************* API Calls **************************************/
// Profile (MovieRama User)
//
// Gets ==========================================================
// /api/profile/getMainInfo
$router->map('GET', '/api/profile/getMainInfo', function () use($wo) {
    try {
        $res = VO_ProfileData::getMainInfo($wo, $wo->app->userId);
    } catch (Exception $e) {
        $res = false;
        $wo->logError($e->getMessage());
    }
    WOOOF_Util::returnJSON2($wo, $res);
});
// api/profile/changePassword
$router->map('POST', '/api/profile/changePassword', function () use($wo) {
    try {
        $res = VO_CtrlProfile::changePassword($wo, $_POST);
    } catch (Exception $e) {
        $res = false;
        $wo->logError($e->getMessage());
    }
    WOOOF_Util::returnJSON2($wo, $res);
Example #4
0
        <!--<div id="timers">
	        <?php 
///*
$_logLink = '<a href="' . $wo->assetsURL . '../wooof_administration/tailLog.php?session=' . $wo->sid . '" target="_blank">Log</a>';
echo "<pre><code>Timers {$_logLink}<br>";
wooofTimersShow();
echo "</code></pre>";
//*/
?>
        </div>-->
        
        
        <div id="movierama-footer"></div>
        
        <?php 
$userData = json_encode(VO_ProfileData::getMainInfo($wo, $wo->app->userId));
$messages = json_encode(VO_SessionMessages::getMessages($wo));
?>
        
        <script>
        	ReactDOM.render(
            	React.createElement(
            		SiteHeaderBox, 
            		{ userData: <?php 
echo $userData;
?>
 }
            	), 
            	document.getElementById('movierama-header')
            );