Last change
on this file since 1462 was
307,
checked in by sven, 11 years ago
|
- Fehlerseite (404) mit besserem Text (mehrsprachig) bestückt
- t29Client PHP-Klasse hinzugefügt (noch keine große Verwendung)
- Kleines Design für Tablet-Computer und schmale Bildschirme geschrieben
- Fixes in robots.txt (piwik-Logging-Mountpoint nicht erschliessen)
- template.php: Klassendurchreichen einer Information ueber leere Footer
|
File size:
1.0 KB
|
Line | |
---|
1 | <?php |
---|
2 | /** |
---|
3 | * Optional client information |
---|
4 | * |
---|
5 | * |
---|
6 | * |
---|
7 | **/ |
---|
8 | |
---|
9 | class t29Client { |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | // HTTP Language detection/negotiation |
---|
14 | // http://www.dyeager.org/ BSD |
---|
15 | static function getLanguage() { |
---|
16 | if(isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) |
---|
17 | return self::parseDefaultLanguage($_SERVER["HTTP_ACCEPT_LANGUAGE"]); |
---|
18 | else |
---|
19 | return self::parseDefaultLanguage(NULL); |
---|
20 | } |
---|
21 | |
---|
22 | static function parseDefaultLanguage($http_accept, $deflang = "en") { |
---|
23 | if(isset($http_accept) && strlen($http_accept) > 1) { |
---|
24 | # Split possible languages into array |
---|
25 | $x = explode(",",$http_accept); |
---|
26 | foreach ($x as $val) { |
---|
27 | #check for q-value and create associative array. No q-value means 1 by rule |
---|
28 | if(preg_match("/(.*);q=([0-1]{0,1}\.\d{0,4})/i",$val,$matches)) |
---|
29 | $lang[$matches[1]] = (float)$matches[2]; |
---|
30 | else |
---|
31 | $lang[$val] = 1.0; |
---|
32 | } |
---|
33 | |
---|
34 | #return default language (highest q-value) |
---|
35 | $qval = 0.0; |
---|
36 | foreach ($lang as $key => $value) { |
---|
37 | if ($value > $qval) { |
---|
38 | $qval = (float)$value; |
---|
39 | $deflang = $key; |
---|
40 | } |
---|
41 | } |
---|
42 | } |
---|
43 | return strtolower($deflang); |
---|
44 | } |
---|
45 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.