Esempio n. 1
0
    case 'delete_GET':
        $model = Exercise::Get($_REQUEST['Exercise_id']);
        $view = "exercise/delete.php";
        break;
    case 'delete_POST':
        $errors = Exercise::Delete($_REQUEST['Exercise_id']);
        if ($errors) {
            $model = Exercise::Get($_REQUEST['Exercise_id']);
            $view = "exercise/delete.php";
        } else {
            header("Location: ?sub_action={$sub_action}&id={$_REQUEST['Exercise_id']}");
            die;
        }
        break;
    case 'search_GET':
        $model = Exercise::Search($_REQUEST['q']);
        $view = 'exercise/index.php';
        break;
    case 'index_GET':
    default:
        $model = Exercise::Get();
        $view = 'exercise/index.php';
        break;
}
switch ($format) {
    case 'json':
        echo json_encode($model);
        break;
    case 'plain':
        include __DIR__ . "/../Views/{$view}";
        break;
Esempio n. 2
0
    case 'delete_GET':
        $exercises = Exercise::Get($_REQUEST['id']);
        $view = "exercises/delete.php";
        break;
    case 'delete_POST':
        $errors = Exercise::Delete($_REQUEST['id']);
        if ($errors) {
            $exercises = Exercise::Get($_REQUEST['id']);
            $view = "exercises/delete.php";
        } else {
            header("Location: ?sub_action={$sub_action}&id={$_REQUEST['id']}");
            die;
        }
        break;
    case 'search_GET':
        $exercises = Exercise::Search($_REQUEST['q']);
        $view = 'exercises/meal.php';
        break;
    case 'meal_GET':
    case 'view_GET':
        $exercises = Exercise::Get($_REQUEST['id']);
        $view = "exercises/view.php";
        break;
    default:
        $exercises = Exercise::Get();
        $view = 'exercises/exercise.php';
        break;
}
switch ($format) {
    case 'json':
        echo json_encode($exercises);