$loaders[] = new Twig_Loader_Filesystem($template_dir); } $loaders[] = new CustomTwigTemplates(); $loader = new Twig_Loader_Chain($loaders); $twig = new Twig_Environment($loader); call_hooks("twig_init"); }); } function twig_render($template_id, $data) { global $twig; if (!$twig) { trigger_error("Twig library could not be loaded!"); } return $twig->render($template_id, $data); } function twig_render_custom($template, $data) { global $twig; if (!$twig) { trigger_error("Twig library could not be loaded!"); } return $twig->render("custom:" . $template, $data); } register_hook("init", function () { if (file_exists("node_modules/twig/twig.min.js")) { add_html_header("<script src='node_modules/twig/twig.min.js'></script>"); } elseif (file_exists("lib/twig.js/twig.min.js")) { add_html_header("<script src='lib/twig.js/twig.min.js'></script>"); } });
while($r=readdir($dir)) { unset($ext); if(substr($r, 0, 1)!=".") { $ext=substr($r, strrpos($r, ".")+1); } switch($ext) { case "php": require_once "inc/$r"; break; case "js": if(!in_array($r, array("hooks.js", "lang.js"))) add_html_header("<script type='text/javascript' src='inc/$r{$version_string}'></script>"); break; case "css": add_html_header("<link rel='stylesheet' type='text/css' href=\"inc/$r{$version_string}\">"); } } closedir($dir); unset($dir); function html_var_to_js($v) { if(!isset($v)) return "null"; switch(gettype($v)) { case "integer": case "double": $ret=$v; break; case "boolean":
function lang_init() { global $lang_str; global $ui_lang; global $ui_langs; global $data_lang; global $language_list; global $design_hidden; global $lang_genders; global $version_string; lang_load($ui_lang); // Define a language string for every language foreach($language_list as $abbr=>$lang) { $lang_str["lang_native:".$abbr]=$lang; } html_export_var(array("ui_lang"=>$ui_lang, "data_lang"=>$data_lang, "ui_langs"=>$ui_langs, "lang_str"=>$lang_str, "language_list"=>$language_list, "lang_genders"=>$lang_genders)); add_html_header("<meta http-equiv=\"content-language\" content=\"{$ui_lang}\">"); }