<?php

include __DIR__ . '/../include.php';
try {
    $example = new Raptor\Revision\RestExample('Save Content JSON');
    echo json_encode($example->save());
} catch (Raptor\ClientException $exception) {
    http_response_code(400);
    echo json_encode($exception->getMessage());
} catch (Raptor\ServerException $exception) {
    http_response_code(500);
    echo json_encode($exception->getMessage());
}
Esempio n. 2
0
<?php

include __DIR__ . '/../../include.php';
$example = new Raptor\Revision\RestExample('Save REST');
?>
<!doctype html>
<html>
<head>
    <?php 
echo $example->renderHead();
?>
    <script type="text/javascript">
        init(function($) {
            $('.editable').raptor(extendDefaults({
                plugins: {
                    save: {
                        plugin: 'saveRest'
                    },
                    saveRest: {
                        url: '../../actions/save-content-rest.php',
                        data: function(html) {
                            // Returns an object containing the data to send to the server
                            return {
                                id: this.raptor.getElement().data('id'),
                                content: html
                            };
                        }
                    }
                }
            }));
        });