Пример #1
0
//
$router->map('GET', '/movies/[a:userId]/sort/[a:sortCriteria]', function ($userId, $sortCriteria) use($wo) {
    switch ($sortCriteria) {
        case "noOfLikes":
            $criteria = "MUM_noOfLikes";
            break;
        case "noOfHates":
            $criteria = "MUM_noOfHates";
            break;
        case "publishDateTime":
            $criteria = "MUM_publishDateTime";
            break;
        default:
            $wo->handleShowStopperError('505 Unknown sort criteria');
    }
    VO_CtrlSite::home($wo, $criteria, $userId);
}, 'userMoviesSorted');
/******************* API Calls **************************************/
// api/movie/create
$router->map('POST', '/api/movie/create', function () use($wo) {
    try {
        $res = VO_CtrlMovie::createMovie($wo, $_POST);
    } catch (Exception $e) {
        $res = false;
        $wo->logError($e->getMessage());
    }
    WOOOF_Util::returnJSON2($wo, $res);
});
// /api/movie/like/[a:movieId]
$router->map('POST', '/api/movie/like/[a:movieId]', function ($movieId) use($wo) {
    try {
Пример #2
0
<?php

// index.php
$executionTimers['wooof_1'][0] = microtime(true);
require_once '../setup.inc.php';
$wo = new WOOOF(true, null, null, false);
if (!$wo->constructedOk) {
    $wo->handleShowStopperError("1000 Failed to init WOOOF.");
}
wooofTimerStop('wooof_1');
$router = new AltoRouter();
$router->setBasePath(substr($wo->getConfigurationFor('siteBaseURL') . $wo->getConfigurationFor('publicSite'), 0, -1));
/*******************************************************************/
// the start/home
//
$router->map('GET', '/', function () use($wo) {
    VO_CtrlSite::home($wo);
}, 'home');
require_once 'routes/movies.php';
require_once 'routes/profile.php';
require_once 'routes/registration.php';
require_once 'routes/evaluations.php';
/*
==========================================================================
*/
// Find and follow route based on URL
// Handling of no matches, etc. inside the 'run' function.
$router->run($wo);
/* End of file index.php */