-
Notifications
You must be signed in to change notification settings - Fork 5
/
common.inc.php
78 lines (72 loc) · 1.44 KB
/
common.inc.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
<?php
/**
*/
function currentPageURL() {
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
{
$u = 'https';
}
else
{
$u = 'http';
}
$u .= '://';
if ($_SERVER['SERVER_PORT'] != '80')
{
$u .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
}
else
{
$u .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
}
return $u;
}
function currentPageURLwithoutQuery()
{
$u = currentPageURL();
if( $p = strpos($u, '?') !== false )
{
$u = substr($u, 0, $p);
}
return $u ;
}
/**
* Language support manager
*/
class LanguageSupport
{
private $lang = "";
public function __construct()
{
$this->lang= substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
/**
* initialise gettext system for PHP strings
*/
public function initGettext()
{
if(array_key_exists($this->lang, Conf::$UI_LANGUAGUES))
{
$lang=Conf::$UI_LANGUAGUES[$this->lang];
$filename = 'default';
putenv("LC_ALL=$lang");
setlocale(LC_ALL, $lang);
bindtextdomain($filename, './locale');
bind_textdomain_codeset($filename, "UTF-8");
textdomain($filename);
}
}
/**
* Include the documentation file in "Documentation" tab
*/
public function printDoc()
{
$lngDir = "default";
if(array_key_exists($this->lang, Conf::$UI_LANGUAGUES) && file_exists("locale/".Conf::$UI_LANGUAGUES[$this->lang]."/doc.php"))
{
$lngDir = Conf::$UI_LANGUAGUES[$this->lang];
}
include("locale/".$lngDir."/doc.php");
}
}
?>