-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.php
101 lines (94 loc) · 3.67 KB
/
sample.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
if (!function_exists('array_column')) {
die('Minimum PHP Version: 5.5.0');
}
function call_api($param)
{
$curl = curl_init();
$day = 2;
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://e2fi.eu/s/api'.$param,
));
$data = curl_exec($curl);
curl_close($curl);
$array = json_decode($data, true);
return $array;
}
// init all days to array
$days = [];
for ($i=1; $i <= 5; $i++) {
$days[$i] = call_api('/day/'.$i);
}
// "rotate" the array colums => rows / rows => colums
for ($i=0; $i <= 10; $i++) {
$table_rows[$i] = array_column($days, $i); // need php 5.5 for that (array_column)!
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sample with PHP</title>
<meta name="author" content="gabrielw.de">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/paper/bootstrap.min.css">
<style>
body {padding-top: 20px; padding-bottom: 20px; }
.navbar {margin-bottom: 20px; }
</style>
</head>
<body>
<div class="container">
<!-- Static navbar -->
<div class="navbar navbar-default navbar-inverse" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">E2FI - SP-API</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Version <?= call_api('/')['version'] ?></a></li>
<li><a href="<?= call_api('/')['documentation_url'] ?>">Doku</a></li>
<li><a href="#">Letztes Update: <?= call_api('/')['last_update'] ?></a></li>
</ul>
</div>
</div>
</div>
<h3>Stundenplan</h3>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th class="text-center">Montag</th>
<th class="text-center">Dienstag</th>
<th class="text-center">Mittwoch</th>
<th class="text-center">Donnerstag</th>
<th class="text-center">Freitag</th>
</tr>
</thead>
<tbody>
<?php foreach ($table_rows as $row): ?>
<tr>
<?php foreach ($row as $item): ?>
<?php if (is_array($item)): ?>
<td data-day="<?= $item['day']?>" class="text-center"><?= $item['hour'].'. '.$item['subject'] ?> </td>
<?php endif ?>
<?php endforeach ?>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</body>
</html>