-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
158 lines (127 loc) · 6.12 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
require_once 'initialize.php';
require_once 'HtmlBuilder.php';
global $VERSION;
global $database;
global $user;
$uri = urldecode($_SERVER['REQUEST_URI']);
if (str_starts_with($uri, '/last_changed')) $pageType = PageType::lastChanged;
else if (str_starts_with($uri, '/decorrespondent')) $pageType = PageType::deCorrespondent;
else if (str_starts_with($uri, '/map')) $pageType = PageType::map;
else if (str_starts_with($uri, '/moderations')) $pageType = PageType::moderations;
else if (str_starts_with($uri, '/mosaic')) $pageType = PageType::mosaic;
else if (str_starts_with($uri, '/child_victims')) $pageType = PageType::childVictims;
else if (str_starts_with($uri, '/statistics/general')) $pageType = PageType::statisticsGeneral;
else if (str_starts_with($uri, '/statistics/media_humanization')) $pageType = PageType::statisticsHumanizationTest;
else if (str_starts_with($uri, '/statistics/counterparty')) $pageType = PageType::statisticsCrashPartners;
else if (str_starts_with($uri, '/statistics/transportation_modes')) $pageType = PageType::statisticsTransportationModes;
else if (str_starts_with($uri, '/statistics')) $pageType = PageType::statisticsGeneral;
else if (str_starts_with($uri, '/export')) $pageType = PageType::export;
else $pageType = PageType::recent;
$showFullHeaderTitle = true;
$addSearchBar = false;
$showButtonAdd = false;
$head = "<script src='/js/main.js?v=$VERSION'></script>";
if ($pageType === PageType::statisticsCrashPartners) {
$head .= "<script src='/scripts/d3.v7.js?v=$VERSION'></script>
<script src='/js/d3CirclePlot.js?v=$VERSION'></script>";
} elseif (in_array($pageType, [PageType::recent, PageType::statisticsHumanizationTest])) {
$head .= "<script src='/scripts/d3.v7.js?v=$VERSION'></script>
<script src='/scripts/plot.js?v=$VERSION'></script>";
}
// Open streetmap
//<link rel='stylesheet' href='https://unpkg.com/leaflet@1.3.1/dist/leaflet.css' integrity='sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==' crossorigin=''/>
//<script src='https://unpkg.com/leaflet@1.3.1/dist/leaflet.js' integrity='sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==' crossorigin=''></script>
// Maptiler using mapbox
// <script src="https://cdn.maptiler.com/ol/v5.3.0/ol.js"></script>
// <script src="https://cdn.maptiler.com/ol-mapbox-style/v4.3.1/olms.js"></script>
// <link rel="stylesheet" href="https://cdn.maptiler.com/ol/v5.3.0/ol.css">
// Mapbox tiles
//<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.1/mapbox-gl.css' rel='stylesheet'>
//<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.1/mapbox-gl.js'></script>
if (pageWithMap($pageType)) {
$mapbox_js = MAPBOX_GL_JS;
$mapbox_css = MAPBOX_GL_CSS;
$head .= <<<HTML
<script src="$mapbox_js"></script>
<link href="$mapbox_css" type="text/css" rel="stylesheet">
HTML;
}
if (pageWithEditMap($pageType)) {
$mapbox_geocoder_js = MAPBOX_GEOCODER_JS;
$mapbox_geocoder_css = MAPBOX_GEOCODER_CSS;
$head .= <<<HTML
<script src="$mapbox_geocoder_js"></script>
<link href="$mapbox_geocoder_css" type="text/css" rel="stylesheet">
HTML;
}
if ($pageType === PageType::statisticsGeneral) {
$texts = translateArray(['Statistics', 'General']);
$mainHTML = <<<HTML
<div id="pageMain">
<div class="pageInner pageInnerScroll">
<div class="pageSubTitle">{$texts['Statistics']} - {$texts['General']}</div>
<div class="panelTableOverflow">
<table id="tableStatistics" class="dataTable"></table>
<div id="spinnerLoad"><img src="/images/spinner.svg" alt="spinner"></div>
</div>
</div>
</div>
HTML;
} else if ($pageType === PageType::childVictims) {
$showButtonAdd = true;
$mainHTML = HtmlBuilder::pageChildVictims();
} else if ($pageType === PageType::map) {
$showButtonAdd = true;
$addSearchBar = true;
$mainHTML = '<div id="mapMain"></div>';
} else if ($pageType === PageType::mosaic) {
$showButtonAdd = true;
$addSearchBar = true;
$mainHTML = HtmlBuilder::pageMosaic();
} else if ($pageType === PageType::statisticsHumanizationTest) {
$mainHTML = HtmlBuilder::pageHumanizationTest();
} else if ($pageType === PageType::statisticsCrashPartners) {
$mainHTML = HtmlBuilder::pageStatsCrashPartners();
} else if ($pageType === PageType::statisticsTransportationModes) {
$mainHTML = HtmlBuilder::pageStatsTransportationModes();
} else if ($pageType === PageType::export) {
$mainHTML = HtmlBuilder::pageExport();
} else {
$addSearchBar = true;
$showButtonAdd = true;
$showFullHeaderTitle = false;
$websiteInfo = translateLongText('website_info');
$title = '';
switch ($pageType){
case PageType::lastChanged: $title = translate('Last_modified_crashes'); break;
case PageType::deCorrespondent: $title = translate('The_correspondent_week') . '<br>14-20 jan. 2019'; break;
case PageType::moderations: $title = translate('Moderations'); break;
case PageType::recent: $title = translate('Recent_crashes') . '<span id="countryName"></span>'; break;
}
$pageTitle = WEBSITE_NAME;
$introText = "<div id='pageSubTitle' class='pageSubTitle'>$title</div>";
if (isset($websiteInfo) && in_array($pageType, [PageType::recent, PageType::lastChanged, PageType::deCorrespondent, PageType::crash])) {
$readMore = translate('Read_more');
$introText .= "<div id='sectionIntro' class='sectionIntro sectionCollapsed'>$websiteInfo</div>" .
"<div id='introReadMore' class='readMore' onclick='showFullIntro();'>$readMore</div>";
}
$mainHTML = <<<HTML
<div id="pageMain">
<div class="pageInner">
<a id="largeTitle" href="/">$pageTitle</a>
$introText
<div id="featuredGraph"></div>
<div id="cards"></div>
<div id="spinnerLoad"><img src="/images/spinner.svg"></div>
</div>
</div>
HTML;
$head .= '<script src="/scripts/mark.es6.js"></script>';
}
$html =
HtmlBuilder::getHTMLBeginMain('', $head, 'initMain', $addSearchBar,
$showButtonAdd, $showFullHeaderTitle) .
$mainHTML .
HtmlBuilder::getHTMLEnd();
echo $html;