1 <?php |
1 <?php |
2 |
2 |
3 require_once("utilsFunctions.php"); |
3 require_once("constants.php"); |
4 require_once("dbFunctions.php"); |
4 require_once("utilsFunctions.php"); |
|
5 require_once("dbFunctions.php"); |
5 |
6 |
6 function getRenkan($renkanId) { |
7 function getRenkan($renkanId) { |
7 |
8 |
8 $resRenkan = selectProject($renkanId); |
9 $resRenkan = selectProject($renkanId); |
9 |
10 |
10 header('Content-Type: application/json'); |
11 header('Content-Type: application/json'); |
11 echo($resRenkan[0]['renkan']); |
12 echo($resRenkan[0]['renkan']); |
12 die(); |
13 die(); |
13 |
14 |
|
15 } |
|
16 |
|
17 function saveRenkan($renkanId, $renkanStr) { |
|
18 |
|
19 $renkanJson = json_decode($renkanStr, true); |
|
20 if(array_key_exists("title", $renkanJson)) { |
|
21 $title = $renkanJson["title"]; |
|
22 } |
|
23 else { |
|
24 $title = ""; |
14 } |
25 } |
15 |
26 |
16 function saveRenkan($renkanId, $renkanStr) { |
27 $res = updateProject($renkanId, $title, $renkanStr); |
17 |
|
18 $renkanJson = json_decode($renkanStr, true); |
|
19 if(array_key_exists("title", $renkanJson)) { |
|
20 $title = $renkanJson["title"]; |
|
21 } |
|
22 else { |
|
23 $title = ""; |
|
24 } |
|
25 |
|
26 $res = updateProject($renkanId, $title, $renkanStr); |
|
27 |
28 |
28 |
29 |
29 //TODO: return error when fail. |
30 //TODO: return error when fail. |
30 http_response_code(200); |
31 http_response_code(200); |
31 echo("RES:"); |
32 echo("RES:"); |
32 print_r($res); |
33 print_r($res); |
33 die(); |
34 die(); |
34 |
35 |
|
36 } |
|
37 |
|
38 function emptyRenkan($title, $description, $renkanId = NULL) { |
|
39 if(is_null($renkanId) || trim($renkanId) === '' ) { |
|
40 $renkanId = genUuid4(); |
35 } |
41 } |
36 |
42 |
37 function emptyRenkan($title, $description, $renkanId = NULL) { |
43 $now = new DateTime('NOW'); |
38 if(is_null($renkanId) || trim($renkanId) === '' ) { |
|
39 $renkanId = genUuid4(); |
|
40 } |
|
41 |
44 |
42 $now = new DateTime('NOW'); |
45 $renkan_array = [ |
|
46 'id' => $renkanId, |
|
47 'title' => $title, |
|
48 'description' => $description, |
|
49 'uri' => NULL, |
|
50 'color' => NULL, |
|
51 'created' => $now->format("c"), |
|
52 'updated' => $now->format("c"), |
|
53 'schema_version' => RENKAN_SCHEMA_VERSION, |
|
54 'nodes' => [], |
|
55 'edges' => [], |
|
56 'users' => [], |
|
57 'views' => [] |
|
58 ]; |
43 |
59 |
44 $renkan_array = [ |
60 return json_encode($renkan_array); |
45 'id' => $renkanId, |
|
46 'title' => $title, |
|
47 'description' => $description, |
|
48 'uri' => NULL, |
|
49 'color' => NULL, |
|
50 'created' => $now->format("c"), |
|
51 'updated' => $now->format("c"), |
|
52 'nodes' => [], |
|
53 'edges' => [], |
|
54 'users' => [], |
|
55 'views' => [] |
|
56 ]; |
|
57 |
61 |
58 return json_encode($renkan_array); |
62 } |
59 |
|
60 } |
|