function _compile_file($tpl_file, $template_source, &$template_compiled) { global $Lens_SmartyVars; $rez = parent::_compile_file($tpl_file, $template_source, &$template_compiled); $Lens_SmartyVars = $this->_vars; return $rez; }
/** * @param string $template_path template file. (full path) * @return CompiledTemplate */ public function compile($template_path) { $compiler = new \Smarty_Compiler(); if ($this->plugins_dir) { $compiler->plugins_dir[] = $this->plugins_dir; } $compiler->caching = 1; $source_content = file_get_contents($template_path); $compiled_content = ''; $compiler->_compile_file($template_path, $source_content, $compiled_content); $smarty_file_name = $compiler->_get_auto_filename($this->template_dir, $template_path); return new CompiledTemplate($template_path, $this->template_dir, $smarty_file_name, $compiled_content); }
function _compile_file($resource_name, $source_content, &$compiled_content) { $this->current_resource_name = $resource_name; return parent::_compile_file($resource_name, $source_content, $compiled_content); }
/** * compile the given source * * @param string $resource_name * @param string $source_content * @param string $compiled_content * @return boolean */ function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path = null) { if (file_exists(SMARTY_DIR . $this->compiler_file)) { require_once SMARTY_DIR . $this->compiler_file; } else { // use include_path require_once $this->compiler_file; } $smarty_compiler = new Smarty_Compiler(); $smarty_compiler->template_dir = $this->template_dir; $smarty_compiler->compile_dir = $this->compile_dir; $smarty_compiler->plugins_dir = $this->plugins_dir; $smarty_compiler->config_dir = $this->config_dir; $smarty_compiler->force_compile = $this->force_compile; $smarty_compiler->caching = $this->caching; $smarty_compiler->php_handling = $this->php_handling; $smarty_compiler->left_delimiter = $this->left_delimiter; $smarty_compiler->right_delimiter = $this->right_delimiter; $smarty_compiler->_version = $this->_version; $smarty_compiler->security = $this->security; $smarty_compiler->secure_dir = $this->secure_dir; $smarty_compiler->security_settings = $this->security_settings; $smarty_compiler->trusted_dir = $this->trusted_dir; $smarty_compiler->use_sub_dirs = $this->use_sub_dirs; $smarty_compiler->_reg_objects =& $this->_reg_objects; $smarty_compiler->_plugins =& $this->_plugins; $smarty_compiler->_tpl_vars =& $this->_tpl_vars; $smarty_compiler->default_modifiers = $this->default_modifiers; $smarty_compiler->compile_id = $this->_compile_id; $smarty_compiler->_config = $this->_config; $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals; if (isset($cache_include_path) && isset($this->_cache_serials[$cache_include_path])) { $smarty_compiler->_cache_serial = $this->_cache_serials[$cache_include_path]; } $smarty_compiler->_cache_include = $cache_include_path; $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content); if ($smarty_compiler->_cache_serial) { $this->_cache_include_info = array('cache_serial' => $smarty_compiler->_cache_serial, 'plugins_code' => $smarty_compiler->_plugins_code, 'include_file_path' => $cache_include_path); } else { $this->_cache_include_info = null; } return $_results; }
function _compile_file($resource_name, $source_content, &$compiled_content) { $this->resourceName = $resource_name; if (substr($resource_name, -6) == '.xotpl') { $this->tplLangFiles = $this->tplWidgets = array(); if (strpos(substr($source_content, 0, 256), '<XoopsTemplate') !== false) { $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $source_content, $values, $tags); xml_parser_free($parser); if (isset($tags['Object'])) { $objects =& $tags['Object']; for ($n = 0; $n != count($objects); $n += 2) { $start = $objects[$n] + 1; $this->parseObject($values[$objects[$n]], array_slice($values, $start, $objects[$n + 1] - $start)); } } foreach ($tags['TemplateData'] as $tag) { $tagInfo =& $values[$tag]; if ($tagInfo['attributes']['contentType'] == $this->template_engine->currentTheme->contentType) { $source_content = $tagInfo['value']; break; } elseif (isset($tagInfo['attributes']['default'])) { $source_content = $tagInfo['value']; } } } $mods = $this->default_modifiers; $this->default_modifiers = array('@htmlspecialchars:' . ENT_QUOTES); parent::_compile_file($resource_name, $source_content, $compiled_content); $this->default_modifiers = $mods; $prelude = ''; if (!empty($this->tplWidgets)) { $prelude = "<?php\n"; foreach ($this->tplWidgets as $widgetDef) { $prelude .= $this->insertWidget($widgetDef); } $prelude .= "\n?>"; } $compiled_content = $prelude . $compiled_content; return true; } return parent::_compile_file($resource_name, $source_content, $compiled_content); }
function _compile_file($resource_name, $source_content, &$compiled_content) { if (parent::_compile_file($resource_name, $source_content, $compiled_content)) { $open_tag_replace_to = "\nEOT;\n"; $close_tag_replace_to = "echo <<<EOT\n"; $content = preg_replace("/\?>/si", $close_tag_replace_to, preg_replace("/<\?(php)?/si", $open_tag_replace_to, trim($compiled_content), -1, $c_open), -1, $c_close)."\n"; if ($c_open == $c_close) $content .= "\nEOT;\n"; $compiled_content = $content; return true; } }