prefix = $prefix; $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $conn; } } function is_ajax_request() { if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { return true; } else { return false; } } function last_class() { $class = get_declared_classes()[sizeof(get_declared_classes()) - 1]; return new $class; } global $_LANG; $_LANG = Array(); class Lang { public static function getStrings($module = '', $lang = null){ global $_LANG; if($lang == null){ $lang = APP_LANG; } if (isset($_LANG[$lang][$module])) { return $_LANG[$lang][$module]; } return $module; } public static function getString($string = '', $module = null, $lang = null) { global $_LANG; if($lang == null){ $lang = APP_LANG; } if (isset($_LANG[$lang][$string]) && is_string($_LANG[$lang][$string])) { return $_LANG[$lang][$string]; } if (isset($_LANG[$lang][$module][$string])) { return $_LANG[$lang][$module][$string]; } return $string; } public static function buildStrings() { global $_LANG; if (isset($_SESSION['cache']['strings']) && CACHE_LANG) { $_LANG = $_SESSION['cache']['strings']; return; } $rdi = new RecursiveDirectoryIterator(DIR_APP); foreach (new RecursiveIteratorIterator($rdi) as $file) { if (preg_match("/lang\/.*\.php$/", $file)) { $included_lang = explode('/', $file); $included_lang = end($included_lang); $included_lang = str_replace('.php', '', $included_lang); $lang = Array(); include_once $file; $_LANG[$included_lang] = $lang; $lang = Array(); } } } } abstract class Controller { }