Exemplo n.º 1
0
 public function loadLib($libName, $options = [])
 {
     $className = 'Libs\\' . ucfirst($libName);
     if (class_exists($className)) {
         if (!empty($className::$composerPacks)) {
             foreach ($className::$composerPacks as $packageName => $version) {
                 ComposerCmd::requirePackage($packageName, $version);
             }
         }
         if (!empty($className::$requiredLibs)) {
             foreach ($className::$requiredLibs as $rLib) {
                 $this->loadLib($rLib);
             }
         }
         if (!empty($className::$files['css']) && (!isset($options['loadCss']) || $options['loadCss'])) {
             foreach ($className::$files['css'] as $file) {
                 if (strpos($file, '/') === 0 || strpos($file, 'http') === 0) {
                     App::$cur->view->customAsset('css', $file, $libName);
                 } else {
                     App::$cur->view->customAsset('css', '/static/libs/vendor/' . ucfirst($libName) . '/' . $file, $libName);
                 }
             }
         }
         if (!empty($className::$files['js'])) {
             foreach ($className::$files['js'] as $file) {
                 if (strpos($file, '/') === 0 || strpos($file, 'http') === 0) {
                     App::$cur->view->customAsset('js', $file, $libName);
                 } else {
                     App::$cur->view->customAsset('js', '/static/libs/vendor/' . ucfirst($libName) . '/' . $file, $libName);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public static function requirePackage($packageName, $version = '', $path = '')
 {
     if (!$path) {
         $path = App::$primary->path . '/';
     }
     if (file_exists($path . 'composer.lock')) {
         $lockFile = json_decode(file_get_contents($path . 'composer.lock'), true);
     }
     if (!empty($lockFile['packages'])) {
         foreach ($lockFile['packages'] as $package) {
             if ($package['name'] == $packageName) {
                 return true;
             }
         }
     }
     ComposerCmd::command('require ' . $packageName . ($version ? ':' . $version : ''), false, $path);
     return true;
 }
Exemplo n.º 3
0
        return $event['eventObject'];
    });
}
Inji::$inst->listen('Config-change-app-' . App::$cur->name, 'curAppConfig', function ($event) {
    App::$cur->config = $event['eventObject'];
    return $event['eventObject'];
});
$shareConfig = Config::share();
if (empty($shareConfig['installed']) && App::$cur->name != 'setup' && (empty(App::$cur->params[0]) || App::$cur->params[0] != 'static')) {
    Tools::redirect('/setup');
}
putenv('COMPOSER_HOME=' . getcwd());
putenv('COMPOSER_CACHE_DIR=' . getcwd() . DIRECTORY_SEPARATOR . 'composerCache');
ComposerCmd::check();
if (!function_exists('idn_to_utf8')) {
    ComposerCmd::requirePackage("mabrahamde/idna-converter", "dev-master", './');
    function idn_to_utf8($domain)
    {
        if (empty(Inji::$storage['IdnaConvert'])) {
            Inji::$storage['IdnaConvert'] = new \idna_convert(array('idn_version' => 2008));
        }
        return Inji::$storage['IdnaConvert']->decode($domain);
    }
}
if (file_exists('vendor/autoload.php')) {
    include_once 'vendor/autoload.php';
}
if (file_exists(App::$primary->path . '/vendor/autoload.php')) {
    include_once App::$primary->path . '/vendor/autoload.php';
}
Module::$cur = Module::resolveModule(App::$cur);