server/php/basic/resources/library/renkanFunctions.php
author ymh <ymh.work@gmail.com>
Fri, 22 May 2015 17:48:14 +0200
changeset 442 adb907bba956
child 444 19f0b7803aed
permissions -rw-r--r--
add server php example

<?php

    require_once("utilsFunctions.php");
    require_once("dbFunctions.php");

    function getRenkan($renkanId) {

        $resRenkan = selectProject($renkanId);

        header('Content-Type: application/json');
        echo($resRenkan[0]['renkan']);
        die();

    }

    function saveRenkan($renkanId, $renkanStr) {

        $renkanJson = json_decode($renkanStr, true);
        $title = $renkanJson["title"];

        $res = updateProject($renkanId, $title, $renkanStr);


        //TODO: return error when fail.
        http_response_code(200);
        echo("RES:");
        print_r($res);
        die();

    }

    function emptyRenkan($title, $description, $renkanId = NULL) {
        if(is_null($renkanId) || trim($renkanId) === '' ) {
            $renkanId = genUuid4();
        }

        $now = new DateTime('NOW');

        $renkan_array = [
            'id' => $renkanId,
            'title' => $title,
            'description' => $description,
            'uri' => NULL,
            'color' => NULL,
            'created' => $now->format("c"),
            'updated' => $now->format("c"),
            'nodes' => [],
            'edges' => [],
            'users' => [],
            'views' => []
        ];

        return json_encode($renkan_array);

    }