/**
  * Singleton class, the constructor is private
  */
 private function __construct()
 {
     $loader = new Twig_Loader_Filesystem();
     $this->twig = new Twig_Environment($loader, array('cache' => _files_ . '/tmp', 'debug' => Get::cfg('twig_debug', false)));
     $this->twig->addFunction('translate', new Twig_Function_Function(function ($key, $module = false, $substitution = array(), $lang_code = false, $default = false) {
         return Lang::t($key, $module, $substitution, $lang_code, $default);
     }));
     $this->twig->addFunction('pluginUrl', new Twig_Function_Function(function ($resource) {
         $plugin_files = PluginManager::find_files();
         return '/' . _folder_plugins_ . '/' . $plugin_files[$resource] . '/' . $resource;
     }));
 }
Exemple #2
0
 /**
  * Return an object that describe the system languages
  * @return DoceboLangManager
  */
 public static function inc_all($file, $function = 'include')
 {
     include $file;
     if (!Get::cfg('enable_plugins', false)) {
         return;
     }
     $file = str_replace(_base_ . '/', '', $file);
     $plugin_files = PluginManager::find_files();
     if (isset($plugin_files[$file])) {
         // let's include the plugin file
         include _plugins_ . '/' . $plugin_files[$file] . '/' . $file;
     }
 }