Exemple #1
0
function LoadLibs()
{
    Std::Out();
    Std::Out('[Info] [Libs] Loading');
    $Libs = Config::Get('Libs');
    if (is_array($Libs)) {
        foreach ($Libs as $Lib) {
            LoadLib($Lib);
        }
        Std::Out('[Info] [Libs] Ready!');
    } else {
        Std::Out('[Warning] [Libs] Config file is not an array');
    }
}
Exemple #2
0
 public static function get()
 {
     static $tplh = null;
     if (!isset($tplh)) {
         LoadConfig('TplConfig');
         LoadLib('Twig');
         Twig_Autoloader::register();
         $loader = new Twig_Loader_Filesystem(ROOT_DIR . TplConfig::templates);
         $tplh = new Twig_Environment($loader, array('cache' => DEBUG ? false : ROOT_DIR . TplConfig::cache, 'debug' => DEBUG, 'strict_variables' => true));
         if (DEBUG) {
             $tplh->addExtension(new Twig_Extension_Debug());
         }
         $tplh->addExtension(new TemplateExtension());
     }
     return $tplh;
 }
Exemple #3
0
 public final function Load()
 {
     if (!is_string($this->Extension) || extension_loaded($this->Extension)) {
         if ($this->ModuleManager->KeyExists($this->Key)) {
             $this->Path = "class/Modules/{$this->Key}_{$this->AliasOf}";
             $this->JPath = $this->Path . '.json';
             $this->XPath = $this->Path . '.' . $this->PathExtension;
             if (basename(dirname(realpath($this->JPath))) === 'Modules') {
                 $Json = Json::Decode($this->JPath);
                 if (is_array($Json)) {
                     if (is_readable($this->XPath)) {
                         // Lint
                         $this->Data = $Json;
                         if (isset($this->Data['Libs']) && is_array($this->Data['Libs'])) {
                             foreach ($this->Data['Libs'] as $Lib) {
                                 if (!LoadLib($Lib)) {
                                     Std::Out("[Warning] [Modules] Can't load {$this->Key}::{$this->Name} ({$this->AliasOf}). {$Lib} lib doesn't exists");
                                     $this->Loaded = self::NOT_LOADED;
                                     return $this->Loaded;
                                 }
                             }
                         }
                         $this->Loaded = $this->_Load();
                         return $this->Loaded;
                     } else {
                         Std::Out("[Warning] [Modules] Can't load {$this->Key}::{$this->Name} ({$this->AliasOf}). {$this->PathExtension} file is not readable");
                     }
                 } else {
                     Std::Out("[Warning] [Modules] Can't load {$this->Key}::{$this->Name} ({$this->AliasOf}). Json file is not decodeable");
                 }
             } else {
                 Std::Out("[Warning] [Modules] Can't load {$this->Key}::{$this->Name} ({$this->AliasOf}). It is not in Modules folder");
             }
         } else {
             Std::Out("[Warning] [Modules] Can't load {$this->Key}::{$this->Name} ({$this->AliasOf}). That key doesn't exists");
         }
     } else {
         Std::Out("[Warning] [Modules] Can't load {$this->Key}::{$this->Name} ({$this->AliasOf}). {$this->Extension} extension is not loaded");
     }
     $this->Loaded = self::NOT_LOADED;
     return $this->Loaded;
 }
Exemple #4
0
function LoadLib($Lib, $Test = true, $ShowWarning = true)
{
    if ($Test) {
        $Path = __DIR__ . "/{$Lib}.php";
        if (is_file($Path)) {
            if (is_readable($Path)) {
                // Lint
                return (bool) (require_once $Path);
            } elseif ($ShowWarning) {
                Std::Out("[Warning] [Libs] Can't load {$Lib}. File isn't readable");
            }
        } elseif (strpos(str_replace('\\', '/', $Lib), '/') === false && LoadLib($Lib . '/' . $Lib, $Test, false)) {
            return true;
        } elseif ($ShowWarning) {
            Std::Out("[Warning] [Libs] Can't load {$Lib}. File doesn't exist");
        }
        return false;
    } else {
        return (bool) (require_once __DIR__ . "/{$Lib}.php");
    }
}
Exemple #5
0
 public final function Load()
 {
     if (!is_string($this->Extension) || extension_loaded($this->Extension)) {
         $this->Path = __DIR__ . "/Threads/{$this->Name}";
         $this->JPath = $this->Path . '.json';
         $this->XPath = $this->Path . '.' . $this->PathExtension;
         if (basename(dirname(realpath($this->JPath))) === 'Threads') {
             $Json = Json::Decode($this->JPath);
             if (is_array($Json)) {
                 if (is_readable($this->XPath)) {
                     // Lint
                     $this->Data = $Json;
                     if (isset($this->Data['Libs']) && is_array($this->Data['Libs'])) {
                         foreach ($this->Data['Libs'] as $Lib) {
                             if (!LoadLib($Lib)) {
                                 Std::Out("[Warning] [Threads] Can't load {$this->Name}. {$Lib} lib doesn't exists");
                                 $this->Loaded = self::NOT_LOADED;
                                 return $this->Loaded;
                             }
                         }
                     }
                     $this->Loaded = $this->_Load();
                     return $this->Loaded;
                 } else {
                     Std::Out("[Warning] [Threads] Can't load {$this->Name}. {$this->PathExtension} file is not readable");
                 }
             } else {
                 Std::Out("[Warning] [Threads] Can't load {$this->Name}. Json file is not decodeable");
             }
         } else {
             Std::Out("[Warning] [Threads] Can't load {$this->Name}. It is not in Threads folder");
         }
     } else {
         Std::Out("[Warning] [Threads] Can't load {$this->Name}. {$this->Extension} extension is not loaded");
     }
     $this->Loaded = self::NOT_LOADED;
     return $this->Loaded;
 }
Exemple #6
0
        require $file;
    }
}
function AutoloadView($className)
{
    $file = SITE_ROOT_DIR . 'views' . DIRECTORY_SEPARATOR . strtolower(str_replace('View', '', $className)) . '.php';
    if (is_readable($file)) {
        require $file;
    }
}
function LoadConfig($config)
{
    require_once SITE_ROOT_DIR . 'configs' . DIRECTORY_SEPARATOR . $config . '.php';
}
function LoadLib($lib)
{
    require LIB_DIR . $lib . DIRECTORY_SEPARATOR . $lib . '.php';
}
function ErrorReporting()
{
    ini_set('error_reporting', E_ALL);
    ini_set('display_errors', true);
    ini_set('html_errors', true);
}
LoadLib('Kint');
Kint::enabled(DEBUG);
DEBUG && ErrorReporting();
spl_autoload_register('AutoloadClass');
spl_autoload_register('AutoloadModel');
spl_autoload_register('AutoloadController');
spl_autoload_register('AutoloadView');