SmartTemplate Constructor

@access public
@param string $template_filename Template Filename
976012
function SmartTemplate ( $template_filename = '' )
		{
			global $_CONFIG;

			if (!empty($_CONFIG['smarttemplate_compiled']))
			{
				$this->temp_dir  =  $_CONFIG['smarttemplate_compiled'];
			}
			if (!empty($_CONFIG['smarttemplate_cache']))
			{
				$this->cache_dir  =  $_CONFIG['smarttemplate_cache'];
			}
			if (is_numeric($_CONFIG['cache_lifetime']))
			{
				$this->cache_lifetime  =  $_CONFIG['cache_lifetime'];
			}
			if (!empty($_CONFIG['template_dir'])  &&  is_file($_CONFIG['template_dir'] . '/' . $template_filename))
			{
				$this->template_dir  =  $_CONFIG['template_dir'];
			}
			$this->tpl_file  =  $template_filename;
		}
596134
function display($template_file) {
        $template = $this->twig->load($template_file);
        echo $template->render($this->twig_vars);
    }
1098523
public function onLoadTemplate(ITemplateFactory $templateFactory, $templateFile, $presenterName)
	{
		if (!$this->activeTheme) {
			return;
		}
		$templateFactory->addTemplate(
			$this->formatTemplateFilePath($this->activeTheme, $templateFile, $presenterName)
		);
		$templateFactory->addTemplate(
			$this->formatTemplateFilePath($this->activeTheme, $templateFile)
		);

		$parent = $this->activeTheme->getParent();
		if (!$parent) {
			return;
		}
		$parentTheme = $this->getTheme($parent);
		$templateFactory->addTemplate(
			$this->formatTemplateFilePath($parentTheme, $templateFile, $presenterName)
		);
		$templateFactory->addTemplate(
			$this->formatTemplateFilePath($parentTheme, $templateFile)
		);
	}
1139091
public function setTemplate($templateName)
    {
    	if($templateName instanceof MailTemplate)
    	{
    		$this->template = $templateName;
    	}
    	elseif (!$this->template = $this->mailerManager->getRepository()->findOneBy(array('name' => $templateName)))
    	{
    		$this->template =  $this->mailerManager->createDefault($templateName);
    	}
    
    	return $this;
    }
599784
protected function doCompile($_content, $isTemplateSource = false)
    {
        /* here is where the compiling takes place. Smarty
          tags in the templates are replaces with PHP code,
          then written to compiled files. */
        // init the lexer/parser to compile the template
        $this->parser =
            new $this->parser_class(new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $_content), $this),
                                    $this);
        if ($isTemplateSource && $this->template->caching) {
            $this->parser->insertPhpCode("<?php\n\$_smarty_tpl->compiled->nocache_hash = '{$this->nocache_hash}';\n?>\n");
        }
        if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
            $mbEncoding = mb_internal_encoding();
            mb_internal_encoding('ASCII');
        } else {
            $mbEncoding = null;
        }

        if ($this->smarty->_parserdebug) {
            $this->parser->PrintTrace();
            $this->parser->lex->PrintTrace();
        }
        // get tokens from lexer and parse them
        while ($this->parser->lex->yylex()) {
            if ($this->smarty->_parserdebug) {
                echo "<pre>Line {$this->parser->lex->line} Parsing  {$this->parser->yyTokenName[$this->parser->lex->token]} Token " .
                    htmlentities($this->parser->lex->value) . "</pre>";
            }
            $this->parser->doParse($this->parser->lex->token, $this->parser->lex->value);
        }

        // finish parsing process
        $this->parser->doParse(0, 0);
        if ($mbEncoding) {
            mb_internal_encoding($mbEncoding);
        }
        // check for unclosed tags
        if (count($this->_tag_stack) > 0) {
            // get stacked info
            list($openTag, $_data) = array_pop($this->_tag_stack);
            $this->trigger_template_error("unclosed {$this->smarty->left_delimiter}" . $openTag .
                                          "{$this->smarty->right_delimiter} tag");
        }
        // call post compile callbacks
        foreach ($this->postCompileCallbacks as $cb) {
            $parameter = $cb;
            $parameter[0] = $this;
            call_user_func_array($cb[0], $parameter);
        }
        // return compiled code
        return $this->prefixCompiledCode . $this->parser->retvalue . $this->postfixCompiledCode;
    }
180329
public function setName($template_name , $path = null)
    {
        parent::setName($template_name);
        $this->directory = $path;
    }
1172255
static function filename_format($template, $values) {
		static $constants = false;
		if ($constants === false) {
			// Fixme: How to invalidate this cache?
			$constants = get_defined_constants();
		}

		$args = func_get_args();
		array_splice($args, 2, 0, array(null, $constants));

		//return template_format($template, $values, null, $constants);
		return call_user_func_array(__NAMESPACE__ . '\Utils::template_format', $args);
	}
1347740
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
    {
        /** @var Smarty_Internal_Template $_smarty_tpl
         * used in included file
         */
        $_smarty_tpl = $_template;

        return @include $_template->cached->filepath;
    }
1346688
private function loadCompiledTemplate(Smarty_Internal_Template $_template)
    {
        if (function_exists('opcache_invalidate')) {
            opcache_invalidate($_template->compiled->filepath);
        }
        $_smarty_tpl = $_template;
        if (defined('HHVM_VERSION')) {
            $_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->compiled->filepath);
        } else {
            include($_template->compiled->filepath);
        }
    }
625503
public function getRenderedTemplateCode(Smarty_Internal_Template $_template, $unifunc = null)
    {
        $unifunc = isset($unifunc) ? $unifunc : $this->unifunc;
        $level = ob_get_level();
        try {
            if (empty($unifunc) || !is_callable($unifunc)) {
                throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'");
            }
            if (isset($_template->smarty->security_policy)) {
                $_template->smarty->security_policy->startTemplate($_template);
            }
            //
            // render compiled or saved template code
            //
            if (!isset($_template->_cache['capture_stack'])) {
                $_template->_cache['capture_stack'] = array();
            }
            $_saved_capture_level = count($_template->_cache['capture_stack']);
            $unifunc($_template);
            // any unclosed {capture} tags ?
            if ($_saved_capture_level != count($_template->_cache['capture_stack'])) {
                $_template->capture_error();
            }
            if (isset($_template->smarty->security_policy)) {
                $_template->smarty->security_policy->exitTemplate();
            }
            return null;
        }
        catch (Exception $e) {
            while (ob_get_level() > $level) {
                ob_end_clean();
            }
             if (isset($_template->smarty->security_policy)) {
                $_template->smarty->security_policy->exitTemplate();
            }
            throw $e;
        }
    }
443047
protected function load_template( string $template_file ) {
		global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
		if ( 0 !== validate_file( $template_file ) ) {
			return;
		}
		require $template_file;
	}
25146
public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
    {
        $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
        $_filepath = $compiled->source->uid;
        // if use_sub_dirs, break file into directories
        if ($_template->smarty->use_sub_dirs) {
            $_filepath = substr($_filepath, 0, 2) . DS
             . substr($_filepath, 2, 2) . DS
             . substr($_filepath, 4, 2) . DS
             . $_filepath;
        }
        $_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
        if (isset($_compile_id)) {
            $_filepath = $_compile_id . $_compile_dir_sep . $_filepath;
        }
        // caching token
        if ($_template->caching) {
            $_cache = '.cache';
        } else {
            $_cache = '';
        }
        $_compile_dir = $_template->smarty->getCompileDir();
        // set basename if not specified
        $_basename = $this->getBasename($compiled->source);
        if ($_basename === null) {
            $_basename = basename( preg_replace('![^\w\/]+!', '_', $compiled->source->name) );
        }
        // separate (optional) basename by dot
        if ($_basename) {
            $_basename = '.' . $_basename;
        }

        $compiled->filepath = $_compile_dir . $_filepath . '.' . $compiled->source->type . $_basename . $_cache . '.php';
    }
1256928
protected function generateFromTemplate($template, $fileName, $path)
    {
        $file = $this->loadTemplate($template);
        $content = $this->replaceValues( $file );
        $this->createFile( $fileName, $path, $content );

        return true;
    }
826467
static function compileParentBlock($compiler, $_name = null)
    {
        // if called by {$smarty.block.parent} we must search the name of enclosing {block}
        if ($_name == null) {
            $stack_count = count($compiler->_tag_stack);
            while (--$stack_count >= 0) {
                if ($compiler->_tag_stack[$stack_count][0] == 'block') {
                    $_name = trim($compiler->_tag_stack[$stack_count][1][0]['name'], "\"'");
                    break;
                }
            }
        }
        if ($_name == null) {
            $compiler->trigger_template_error(' tag {$smarty.block.parent} used outside {block} tags ', $compiler->lex->taglineno);
        }
        if (empty(Smarty_Internal_Compile_Block::$nested_block_names)) {
            $compiler->trigger_template_error(' illegal {$smarty.block.parent} in parent template ', $compiler->lex->taglineno);
        }
        Smarty_Internal_Compile_Block::$block_data[Smarty_Internal_Compile_Block::$nested_block_names[0]]['source'] .= Smarty_Internal_Compile_Block::parent;
        $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK);
        $compiler->has_code = false;
        return;
    }
1045220
public function addTemplate($name, $filename)
    {
        if (!is_string($name) || !is_string($filename) || empty($name) || empty($filename)) {
            throw new \InvalidArgumentException('Template name and filename must be a not empty string');
        }

        $this->templateMap[$name] = $filename;
    }
171738
public function prepare(Template $template): void
    {
        $formLayout = $this->layoutManager->getDefaultLayout();

        if ($formLayout instanceof HorizontalFormLayout) {
            $template->labelColClass  = $formLayout->getLabelColumnClass();
            $template->colClass       = $formLayout->getColumnClass();
            $template->colOffsetClass = $formLayout->getColumnClass(true);
            $template->rowClass       = $formLayout->getRowClass();
            $template->isHorizontal   = true;
        } else {
            $template->labelColClass  = null;
            $template->colClass       = null;
            $template->colOffsetClass = null;
            $template->rowClass       = null;
            $template->isHorizontal   = false;
        }

        $template->formLayout  = $formLayout;
        $template->buttonClass = $this->getButtonClass();
    }
1329983
public function compileTemplate(Smarty_Internal_Template $template)
    {
        if (empty($template->properties['nocache_hash'])) {
            $template->properties['nocache_hash'] = $this->nocache_hash;
        } else {
            $this->nocache_hash = $template->properties['nocache_hash'];
        }
        // flag for nochache sections
        $this->nocache = false;
        $this->tag_nocache = false;
        // save template object in compiler class
        $this->template = $template;
        // reset has noche code flag
        $this->template->has_nocache_code = false;
        $this->smarty->_current_file = $saved_filepath = $this->template->source->filepath;
        // template header code
        $template_header = '';
        if (!$this->suppressHeader) {
            $template_header .= "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
            $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
        }

        do {
            // flag for aborting current and start recompile
            $this->abort_and_recompile = false;
            // get template source
            $_content = $template->source->content;
            // run prefilter if required
            if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) {
                $template->source->content = $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
            }
            // on empty template just return header
            if ($_content == '') {
                if ($this->suppressTemplatePropertyHeader) {
                    $code = '';
                } else {
                    $code = $template_header . $template->createTemplateCodeFrame();
                }
                return $code;
            }
            // call compiler
            $_compiled_code = $this->doCompile($_content);
        } while ($this->abort_and_recompile);
        $this->template->source->filepath = $saved_filepath;
        // free memory
        unset($this->parser->root_buffer, $this->parser->current_buffer, $this->parser, $this->lex, $this->template);
        self::$_tag_objects = array();
        // return compiled code to template object
        $merged_code = '';
        if (!$this->suppressMergedTemplates) {
            foreach ($this->merged_templates as $code) {
                $merged_code .= $code;
            }
        }
        if ($this->suppressTemplatePropertyHeader) {
            $code = $_compiled_code . $merged_code;
        } else {
            $code = $template_header . $template->createTemplateCodeFrame($_compiled_code) . $merged_code;
        }
        // run postfilter if required
        if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
            $code = Smarty_Internal_Filter_Handler::runFilter('post', $code, $template);
        }
        return $code;
    }