-
Notifications
You must be signed in to change notification settings - Fork 3
/
LMPHP.php
137 lines (137 loc) · 2.42 KB
/
LMPHP.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
<?php
/**
*
* @Name : LMPHP.php
* @Version : 1.1
* @Programmer : Max
* @Date : 2018-12-01 - 2019-01-22
* @Released under : https://github.com/BaseMax/LMPHP/blob/master/LICENSE
* @Repository : https://github.com/BaseMax/LMPHP
*
**/
class LMPHP
{
public $languages = [];
public $language = null;
public $language_default = null;
public $words = [];
public $word = null;
function language($filter=null)
{
if($filter == null)
{
return $this->languages;
}
else
{
if(language_exists($filter))
{
return $this->words[$filter];
}
else{}//#soon #error
}
return false;
}
function language_exists($key)
{
return isset($this->languages[$key]) ? true : false;
}
function language_current()
{
return $this->language;
}
function language_default($key)
{
if($this->language_exists($key))
{
$this->language_default = $key;
return true;
}
else{}//#soon #error
return false;
}
function language_active($key)
{
if($this->language_exists($key))
{
$this->language = $key;
return true;
}
else{}//#soon #error
return false;
}
function language_remove($key)
{
if($this->language_exists($key))
{
unset($this->languages[$key]);
return true;
}
else{}//#soon #error
return false;
}
function language_add($key,$name=null)
{
if($name == null)
{
$name = $key;
}
if(! $this->language_exists($key))
{
$this->languages[$key]=$name;
$this->language_active($key);
$this->words[$key]=[];
return true;
}
else{}//#soon #error
return false;
}
///////////////////////////////////////////////
function word_add_to($lang,$name,$value=null)
{
if($value == null)
{
$value = $name;
}
if(isset($this->words[$lang]))
{
$this->words[$lang][$name]=$value;
return true;
}
else{}//#soon #error
return false;
}
function word_add($name,$value=null)
{
if($this->language_current() != null)
{
return $this->word_add_to($this->language_current(),$name,$value);
}
else{}//#soon #error
return false;
}
function word_get($name)
{
if($this->language_current() != null)
{
if(isset($this->words[ $this->language_current() ][$name]))
{
return $this->words[ $this->language_current() ][$name];
}
else
{
//Only check language_default? or all?
foreach($this->words as $lang)
{
if(isset($lang[$name]))
{
return $lang[$name];
}
}
return false;
}
}
else{}//#soon #error
return false;
}
}