This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
82 lines (71 loc) · 1.94 KB
/
index.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
<?php
require 'vendor/autoload.php';
$dev = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'));
// Prepare app
$app = new \Slim\Slim(array(
'templates.path' => 'templates',
'debug' => $dev,
'view' => '\Slim\LayoutView',
'layout' => 'layout.php',
));
if ($dev) {
$dataUrl = '/praguehacks/data/flats-geo.json';
$baseUrl = '/praguehacks';
} else {
$dataUrl = 'http://praguehacks-open-flats-data.mybluemix.net/flats';
$baseUrl = '';
}
$app->get('/', function () use ($app) {
$years = (int) date('Y') - 2000;
$data = json_decode(file_get_contents('data/main.json'));
$app->render('main.php', array(
'years' => $years,
'page' => 'home',
'data' => $data,
));
});
$app->get('/maps', function () use ($app, $baseUrl) {
/*
$client = new Zend\Http\Client();
$client->setUri('http://localhost');
$response = $client->send();
$body = $response->getBody();
echo $body;
die;
*/
$app->render('maps.php', array(
'page' => 'maps',
'data' => array(),
'js' => array(
$baseUrl . '/assets/maps.js',
),
));
});
$app->get('/google', function () use ($app, $baseUrl) {
$app->render('google.php', array(
'page' => 'google',
'data' => array(),
));
});
$app->get('/buildings', function () use ($app, $baseUrl) {
$app->render('buildings.php', array(
'page' => 'buildings',
'title' => 'Budovy Magistrátu hlavního města Prahy',
'js' => array(
$baseUrl . '/assets/maps.js',
$baseUrl . '/assets/proj4.js',
$baseUrl . '/assets/proj4leaflet.js',
),
));
});
$app->get('/detail', function () use ($app) {
$app->render('detail.php', array(
'page' => 'detail',
'data' => array(
'id' => $_GET['id'],
),
));
});
$app->view()->set('dataUrl', $dataUrl);
$app->view()->set('baseUrl', $baseUrl);
$app->run();