예제 #1
0
파일: api.php 프로젝트: andrelotto/Cosmo
            $message = array('error' => "This method is not allowed. You probably used the wrong verb (GET, POST, PUT, or DELETE) or you included/omitted an id parameter.");
            break;
    }
    return $message;
}
switch ($segments[0]) {
    ##################################################
    #                   Blocks                       #
    ##################################################
    case 'blocks':
        switch ($method) {
            case 'GET':
                $url = isset($_GET['url']) ? $_GET['url'] : '';
                $type = isset($_GET['type']) ? $_GET['type'] : '';
                if (isset($segments[2]) && $segments[2] === 'requirements') {
                    $response = $Cosmo->blocksRequirementsRead($segments[1]);
                } else {
                    if (isset($segments[1])) {
                        $response['html'] = $Cosmo->blocksRead($segments[1]);
                    } else {
                        if ($type || $url) {
                            $response = $Cosmo->blocksRead(NULL, $type, $url);
                        } else {
                            $response = $Cosmo->blocksRead();
                        }
                    }
                }
                break;
            case 'POST':
                if ($role === 'admin') {
                    $type = isset($_POST['type']) ? $_POST['type'] : '';