setPaths($config['dir']['template']); $twig = new Twig_Environment($loader, array( 'autoescape' => false, 'cache' => is_writable('templates') && (!is_dir('templates/cache') || is_writable('templates/cache')) ? "{$config['dir']['template']}/cache" : false, 'debug' => $config['debug'] )); $twig->addExtension(new Twig_Extensions_Extension_Tinyboard()); $twig->addExtension(new Twig_Extensions_Extension_I18n()); } function Element($templateFile, array $options) { global $config, $debug, $twig; if (!$twig) load_twig(); if (function_exists('create_pm_header') && ((isset($options['mod']) && $options['mod']) || isset($options['__mod'])) && !preg_match('!^mod/!', $templateFile)) { $options['pm'] = create_pm_header(); } if (isset($options['body']) && $config['debug']) { if (isset($debug['start'])) { $debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms'; $debug['time (initialization)'] = '~' . round(($debug['start_debug'] - $debug['start']) * 1000, 2) . 'ms'; unset($debug['start']); unset($debug['start_debug']); } $debug['included'] = get_included_files(); $debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB'; $options['body'] .= '
' . str_replace("\n", ''; } // Read the template file if (@file_get_contents("{$config['dir']['template']}/${templateFile}")) { $body = $twig->render($templateFile, $options); if ($config['minify_html'] && preg_match('/\.html$/', $templateFile)) { $body = trim(preg_replace("/[\t\r\n]/", '', $body)); } return $body; } else { throw new Exception("Template file '${templateFile}' does not exist or is empty in '{$config['dir']['template']}'!"); } }
', utf8tohtml(print_r($debug, true))) . '