forked from JohanGriesel/Stratusolve-Exercise
-
Notifications
You must be signed in to change notification settings - Fork 35
/
list_tasks.php
31 lines (31 loc) · 1.18 KB
/
list_tasks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
* Created by PhpStorm.
* User: johangriesel
* Date: 15122016
* Time: 15:14
* @package ${NAMESPACE}
* @subpackage ${NAME}
* @author johangriesel <[email protected]>
* Task_Data.txt is expected to be a json encoded string, e.g: [{"TaskId":1,"TaskName":"Test","TaskDescription":"Test"},{"TaskId":"2","TaskName":"Test2","TaskDescription":"Test2"}]
*/
$taskData = file_get_contents('Task_Data.txt');
$html = '<a id="newTask" href="#" class="list-group-item" data-toggle="modal" data-target="#myModal">
<h4 class="list-group-item-heading">No Tasks Available</h4>
<p class="list-group-item-text">Click here to create one</p>
</a>';
if (strlen($taskData) < 1) {
die($html);
}
$taskArray = json_decode($taskData);
if (sizeof($taskArray) > 0) {
$html = '';
foreach ($taskArray as $task) {
$html .= '<a id="'.$task->TaskId.'" href="#" class="list-group-item" data-toggle="modal" data-target="#myModal">
<h4 class="list-group-item-heading">'.$task->TaskName.'</h4>
<p class="list-group-item-text">'.$task->TaskDescription.'</p>
</a>';
}
}
die($html);
?>