require_once 'config.php';
require_once $CFG->root . 'lib/utils.inc.php';
+ function createHeader($data) {
+ $out = '<th>Id</th>';
+ foreach ($data as $head => $value) {
+ $out .= "<th>$head</th>";
+ }
+
+ return $out;
+ }
+
+ function parseResponse($raw) {
+ if (count($raw) < 1) {
+ return '';
+ }
+ $headers = createHeader($raw[0]);
+ $r = "<table><tr>$headers</tr>";
+ $i = 1;
+ foreach ($raw as $obj) {
+ $r .= "<tr><td>$i</td>";
+ foreach ($obj as $value) {
+ $r .= "<td>$value</td>";
+ }
+ $r .= '</tr>';
+ }
+ $r .= '</table>';
+
+ return $r;
+ }
+
$util = new Utils;
if ($util->isLoggedIn()) {
$subfunction = isset($_GET['s']) ? $_GET['s'] : null;
if (($function && $function == 'show' && !$subfunction) ||
($function && $function == 'add' && $subfunction) ||
- ($function && $function == 'del' && $subfunction) {
+ ($function && $function == 'del' && $subfunction)) {
header('Location: index.php');
} else if($function == 'show') {
if ($subfunction == 'all') {
$list = $util->makeRestCall('/show');
if ($list) {
- $out = var_export($list, true);
+ $out = parseResponse($list);
} else {
$out = '<p>Connection to REST service failed</p>';
}