Files
framework/publiclib.php
T
2022-01-23 18:57:09 +00:00

84 lines
2.2 KiB
PHP
Executable File

<?php
spl_autoload_register(function ($class_name) {
$path = explode('\\', $class_name);
$fileName = $path[sizeof($path)-1];
$path[sizeof($path)-1] = '';
//$path = strtolower(DIR_ROOT. implode(DIRECTORY_SEPARATOR, $path));
$path = DIR_ROOT . strtolower(implode(DIRECTORY_SEPARATOR, $path));
if(is_file($path . $fileName . '.php')){
return include $path . $fileName . '.php';
}
if(is_file(strtolower($path . $fileName . '.php'))){
return include strtolower($path . $fileName . '.php');
}
@include $path . $fileName . '.php';
});
function is_ajax_request() {
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
return true;
} else {
return false;
}
}
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();
}
}
}
}