function _read_file($filename, $start = null, $lines = null) { global $_SMARTY_INTERNAL_FILES; if (!isset($_SMARTY_INTERNAL_FILES[$filename])) { return parent::_read_file($filename, $start, $lines); } $contents = $_SMARTY_INTERNAL_FILES[$filename]; if ($start == null && $lines == null) { return $contents; } $arr = split("\n", $contents); if ($start > 1) { $arr = array_slice($arr, $start - 1); } if ($lines != null) { $arr = array_slice($arr, 0, $lines); } return join("\n", $contents); }
function new_smarty() { global $config; static $has_templates_c; $tc = ROOT_DIR . '/templates_c/'; if (!isset($has_templates_c)) { $has_templates_c = is_dir($tc) && is_writable($tc) && file_exists("{$tc}/.htaccess"); } require_once $config['root_dir'] . '/smarty/Smarty.class.php'; if (!$has_templates_c) { require_once $config['root_dir'] . '/smarty/SmartyNoWrite.class.php'; $t = new _SmartyNoWrite(); $t->force_compile = 1; $t->compile_check = 1; } else { $t = new _Smarty(); $t->compile_check = 1; } $t->register_prefilter('smarty_prefilter_literal_script'); $t->register_prefilter('smarty_prefilter_literal_style'); require_once $t->_get_plugin_filepath('shared', 'make_timestamp'); $t->register_modifier('amember_date_format', 'smarty_modifier_amember_date_format'); $t->register_outputfilter('smarty_outputfilter_put_config'); $t->register_outputfilter('smarty_outputfilter_put_lang'); $t->register_outputfilter('smarty_outputfilter_literal_cleanup'); $t->register_outputfilter('amember_filter_output'); $t->register_function('country_options', 'smarty_function_country_options'); $t->register_function('state_options', 'smarty_function_state_options'); $t->register_function('lookup_country', 'smarty_function_lookup_country'); $t->register_function('lookup_state', 'smarty_function_lookup_state'); $t->register_function('root_url', 'smarty_function_root_url'); $t->template_dir = ROOT_DIR . "/templates"; $t->compile_dir = ROOT_DIR . "/templates_c"; $t->register_resource("memory", array("memory_get_template", "memory_get_timestamp", "memory_get_secure", "memory_get_trusted")); $t->assign('config', $config); return $t; }