LEPTON CMS 7.0.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
lepton_basics.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25{
26 const SYSTEM_DEFAULT_STR = 'System Default';
33 public static $instance;
34
41 public static function getInstance(): object
42 {
43 if (null === static::$instance)
44 {
45 static::$instance = new static();
46 }
47
48 return static::$instance;
49 }
50
58 static function get_dateformats(): array
59 {
60 global $user_time;
61 global $TEXT;
62
63 // Get the current time (in the users timezone if required)
64 $actual_time = time();
65
66 // Get "System Default"
67 $sSystemDefault = "";
68 if ( isset( $user_time ) && $user_time === true )
69 {
70 $sSystemDefault = date(DEFAULT_DATE_FORMAT, $actual_time).' (';
71 $sSystemDefault .= ($TEXT['SYSTEM_DEFAULT'] ?? self::SYSTEM_DEFAULT_STR).')';
72 }
73
74 // Add values to list
75 $DATE_FORMATS = array(
76 'system_default' => $sSystemDefault,
77 'j.n.Y' => date('j.n.Y', $actual_time).' (j.n.Y)',
78 'm/d/Y' => date('m/d/Y', $actual_time).' (M/D/Y)',
79 'd/m/Y' => date('d/m/Y', $actual_time).' (D/M/Y)',
80 'm.d.Y' => date('m.d.Y', $actual_time).' (M.D.Y)',
81 'd.m.Y' => date('d.m.Y', $actual_time).' (D.M.Y)',
82 'm-d-Y' => date('m-d-Y', $actual_time).' (M-D-Y)',
83 'd-m-Y' => date('d-m-Y', $actual_time).' (D-M-Y)',
84 'D M d, Y' => date( 'D M d, Y', $actual_time ),
85 'M d Y' => date( 'M d Y', $actual_time ),
86 'd M Y' => date( 'd M Y', $actual_time ),
87 'jS F, Y' => date( 'jS F, Y', $actual_time ),
88 'l, jS F, Y' => date( 'l, jS F, Y', $actual_time )
89 );
90
91 $oDateTool = lib_lepton::getToolInstance("datetools", true);
92 $oDateTool->set_core_language( DEFAULT_LANGUAGE );
93
94 $aFormatList = array(
95 'D M d, Y',
96 'M d Y',
97 'd M Y',
98 'jS F, Y',
99 'l, jS F, Y'
100 );
101
102 foreach ($aFormatList as &$format)
103 {
104 $DATE_FORMATS[ $format ] = $oDateTool->formatWithMySQL($format, $actual_time);
105 }
106
107 return $DATE_FORMATS;
108 }
109
116 static function get_timeformats(): array
117 {
118 global $user_time;
119 global $TEXT;
120
121 // Get the current time (in the users timezone if required)
122 $actual_time = time();
123
124 // Get "System Default"
125 $sSystemDefault = "";
126
127 if ((isset($user_time)) && ($user_time === true))
128 {
129 $sSystemDefault = date( DEFAULT_TIME_FORMAT, $actual_time ) . ' (';
130 $sSystemDefault .= ($TEXT['SYSTEM_DEFAULT'] ?? self::SYSTEM_DEFAULT_STR) . ')';
131 }
132
133 return [
134 'system_default' => $sSystemDefault,
135 'H:i' => date('H:i', $actual_time),
136 'H:i:s' => date( 'H:i:s', $actual_time ),
137 'g:i a' => date( 'g:i a', $actual_time ), // Lowercase Ante meridiem and Post meridiem
138 'g:i A' => date( 'g:i A', $actual_time ) // Uppercase Ante meridiem and Post meridiem
139 ];
140 }
141
148 static function get_timezones(): array
149 {
150 return [
151 "Pacific/Kwajalein",
152 "Pacific/Samoa",
153 "Pacific/Honolulu",
154 "America/Anchorage",
155 "America/Los_Angeles",
156 "America/Phoenix",
157 "America/Mexico_City",
158 "America/Lima",
159 "America/Caracas",
160 "America/Halifax",
161 "America/Buenos_Aires",
162 "Atlantic/Reykjavik",
163 "Atlantic/Azores",
164 "Europe/London",
165 "Europe/Berlin",
166 "Europe/Kaliningrad",
167 "Europe/Moscow",
168 "Asia/Tehran",
169 "Asia/Baku",
170 "Asia/Kabul",
171 "Asia/Tashkent",
172 "Asia/Calcutta",
173 "Asia/Colombo",
174 "Asia/Bangkok",
175 "Asia/Hong_Kong",
176 "Asia/Tokyo",
177 "Australia/Adelaide",
178 "Pacific/Guam",
179 "Etc/GMT+10",
180 "Pacific/Fiji"
181 ];
182 }
183
190 static function get_errorlevels(): array
191 {
192 global $TEXT;
193 // Create array
194 $ER_LEVELS = [];
195
196 // Add values to list
197 if (isset($TEXT['SYSTEM_DEFAULT']))
198 {
199 $ER_LEVELS[''] = $TEXT['SYSTEM_DEFAULT'];
200 }
201 else
202 {
203 $ER_LEVELS[''] = self::SYSTEM_DEFAULT_STR;
204 }
205 $ER_LEVELS['6135'] = 'E_ALL^E_NOTICE';
206 $ER_LEVELS['0'] = 'E_NONE'; // standard for productive use
207 $ER_LEVELS['6143'] = 'E_ALL';
208 $ER_LEVELS['-1'] = 'E_EVERYTHING'; // highest level, standard from LEPTON 2.0.0
209
210 return $ER_LEVELS;
211 }
212
222 static function get_backend_translation(string $sKey = ""): string
223 {
224 global $TEXT, $THEME;
225
226 $sLanguagePath_user = THEME_PATH."/languages/".LANGUAGE.".php";
227 $sLanguagePath_default = THEME_PATH."/languages/EN.php";
228
229 if (!isset($THEME))
230 {
234 if (file_exists($sLanguagePath_user))
235 {
236 require_once $sLanguagePath_user;
237 }
238 elseif( file_exists( $sLanguagePath_default ) )
239 {
240 require_once $sLanguagePath_default;
241 }
242 else
243 {
244 // avoid errors and conflicts for non existing $THEME
245 $THEME = [];
246 }
247 }
248
249 if (isset($THEME[$sKey]))
250 {
251 return $THEME[$sKey];
252 }
253 elseif (isset($TEXT[$sKey]))
254 {
255 return $TEXT[$sKey];
256 }
257 else
258 {
259 return "** ".$sKey." (Key not found in Languages!)";
260 }
261 }
262
270 static function getLanguagePath(string $sRootDir = ""): string
271 {
272 $lang = $sRootDir."/languages/".LANGUAGE.".php";
273 return (file_exists($lang))
274 ? $lang
275 : $sRootDir."/languages/EN.php"
276 ;
277 }
278}
static get_timezones()
static getLanguagePath(string $sRootDir="")
static get_timeformats()
static get_errorlevels()
static getInstance()
static get_dateformats()
static get_backend_translation(string $sKey="")
const SYSTEM_DEFAULT_STR
const THEME_PATH