-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.php
More file actions
96 lines (73 loc) · 2.39 KB
/
app.php
File metadata and controls
96 lines (73 loc) · 2.39 KB
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
<?php
use app\models\DBManager;
use app\config\Config;
$f3 = require(__DIR__.'/vendor/fatfree-core/base.php');
require __DIR__.'/vendor/autoload.php';
require_once('config/instances.php');
if(getenv("DEBUG")) {
$f3->set('DEBUG', getenv("DEBUG"));
}
$f3->set('ROOT', __DIR__);
$f3->set('UI', $f3->get('ROOT')."/app/views/");
$f3->set('THEME', implode(DIRECTORY_SEPARATOR, [$f3->get('ROOT'), "themes", Config::getInstance()->get('theme'), '']));
if (is_dir($f3->get('THEME')) === false) {
$f3->set('THEME', implode(DIRECTORY_SEPARATOR, [$f3->get('ROOT'), "themes", 'nutrivin', '']));
}
setlocale(LC_ALL, '');
$f3->language(isset($f3->get('HEADERS')['Accept-Language']) ? $f3->get('HEADERS')['Accept-Language'] : '');
$f3->set('SUPPORTED_LANGUAGES',
[
'bg' => 'Български',
'cs' => 'Čeština',
'da' => 'Dansk',
'de' => 'Deutsch',
'el' => 'Ελληνικά',
'en' => 'English',
'es' => 'Español',
'et' => 'Eesti keel',
'fi' => 'Suomi',
'fr' => 'Français',
'ga' => 'Gaeilge',
'hu' => 'Magyar nyelv',
'it' => 'Italiano',
'lt' => 'Lietuvių kalba',
'lv' => 'Latviešu valoda',
'nl' => 'Nederlands',
'pl' => 'Język polski',
'pt' => 'Português',
'ro' => 'Română',
'ru' => 'Русский',
'sk' => 'Slovenčina',
'sl' => 'Slovenščina',
'sv' => 'Svenska',
]);
if ($f3->get('GET.lang')) {
selectLanguage($f3->get('GET.lang'), $f3);
} else {
selectLanguage($f3->get('LANGUAGE'), $f3);
}
if (!$f3->get('current_language')) {
$f3->set('current_language', 'fr_FR.utf8');
}
$domain = basename(glob($f3->get('ROOT')."/locale/application.pot")[0], '.pot');
bindtextdomain($domain, $f3->get('ROOT')."/locale");
textdomain($domain);
$f3->set('urlbase', Config::getInstance()->getUrlbase());
DBManager::createDB(Config::getInstance()->get('db_pdo'));
include('app/routes.php');
function selectLanguage($lang, $f3) {
$langSupported = null;
foreach(explode(',', $lang) as $l) {
$l = str_replace('-', '_', $l);
if(array_key_exists($l, $f3->get('SUPPORTED_LANGUAGES'))) {
$langSupported = $l;
break;
}
}
if(!$langSupported) {
return null;
}
$f3->set('current_language', $langSupported);
putenv("LANGUAGE=$langSupported");
}
return $f3;