assign a variable for the template

@access private
@param  string $sContent content
@param  string $sTemplateName tempalte name
@param  boolean $bFirst if you call this for the first time
@return bool
556806
private function _transform($sContent, $sTemplateName, $bFirst = false, $bDoCompilation = true) 
	{
	    if ($this->_bIsLayout === true && self::$_aDisableRenderLevel[1] === true 
	       && self::$_aDisableRenderLevel[2] === true) { 

	        $sContent = '';
	    }
	    else if ($this->_bIsLayout === true && self::$_aDisableRenderLevel[1] === true 
	       && self::$_aDisableRenderLevel[2] === false) { 

	        $sContent = preg_replace('/^(.*)\{include file=\$model\}(.*)$/msi', '$1$2', $sContent);
	    }
	    else if ($this->_bIsLayout === true && self::$_iRenderLevel < 2) { 

	        $sContent = preg_replace('/^.*(\{include file=\$model\}).*$/msi', '$1', $sContent);
	    }
	    else if (self::$_iRenderLevel < 1 || self::$_aDisableRenderLevel[1] === true) { 

	        $sContent = '';
	    }
	    
		//*****************************************************************************************************************************
		// NEW version
		// @deprecated
		//
		// {$foo[section_name]}? http://www.smarty.net/docs/en/language.syntax.variables.tpl
		//*****************************************************************************************************************************

		$sTmpDirectory = self::$_sCachePath;
		$sTmpDirectory = str_replace('\\', '\\\\\\', $sTmpDirectory);

		$sViewDirectory = self::$_sBasePath;

		$_aProtectedVar = $this->_aVar;
		$_aProtectedVar['app']['config'] = array();
		$_aProtectedVar['app']['server'] = $_SERVER;
		$_aProtectedVar['app']['get'] = $_GET;
		$_aProtectedVar['app']['post'] = $_POST;
		$_aProtectedVar['app']['cookies'] = $_COOKIE;
		$_aProtectedVar['app']['env'] = $_ENV;
		
		if (isset($_SESSION)) { $_aProtectedVar['app']['session'] = $_SESSION; }
		else { $_aProtectedVar['app']['session'] = array(); }
		
		$_aProtectedVar['app']['request'] = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV);
		$_aProtectedVar['app']['now'] = time();
		$_aProtectedVar['app']['const'] = get_defined_constants();
		$_aProtectedVar['app']['capture'] = array();					// link to {capture} -> to do it
		$_aProtectedVar['app']['section'] = array();					// link to {section} -> to do it
		$_aProtectedVar['app']['template'] = $this->_sTemplateName;
		$_aProtectedVar['app']['template_object'] = $this;
		$_aProtectedVar['app']['current_dir'] = $sViewDirectory;
		$_aProtectedVar['app']['version'] = self::VERSION;
		$_aProtectedVar['app']['block'] = array();						// link to {block} -> to do it
		$_aProtectedVar['app']['block']['child'] = null;
		$_aProtectedVar['app']['block']['parent'] = null;
		$_aProtectedVar['app']['ldelim'] = $this->_sLeftDelimiter;
		$_aProtectedVar['app']['rdelim'] = $this->_sRightDelimiter;

		//*****************************************************************************************************************************
		// tags: {counter}, {$SCRIPT_NAME}
		//*****************************************************************************************************************************

		$sContent = str_replace('{counter}', '$_aProtectedVar[\'i\']', $sContent);
		$sContent = str_replace('{$SCRIPT_NAME}', '$_aProtectedVar[\'app\'][\'SERVER\'][\'SCRIPT_NAME\']', $sContent);

		//*****************************************************************************************************************************
		// comments: {* this is a comment *}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{\*|', '<?php /*', $sContent);
		$sContent = preg_replace('|\*\}|', '*/ ?>', $sContent);

		//*****************************************************************************************************************************
		// escape: {literal}function bazzy {alert('foobar!');}{/literal}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|'.preg_quote($this->getLeftDelimiter()).'|', "\n".'<?php echo <<<EOF'."\n", $sContent);
		$sContent = preg_replace('|'.preg_quote($this->getRightDelimiter()).'|', "\n".'EOF;'."\n".'?>'."\n", $sContent);

		while (preg_match('|(<<<EOF(?:(?<!EOF;).)+?)\$(.+?EOF;)|msi', $sContent)) {

			$sContent = preg_replace('|(<<<EOF(?:(?<!EOF;).)+?)\$(.+?EOF;)|msi', '$1#DOLLAR#$2', $sContent);
		}


		//*****************************************************************************************************************************
		// variables: {$foo}, {$foo[4]}, {$foo.bar}, {$foo.$bar}, {$foo->bar}, {$foo->bar()}, {$foo.bar.baz}, {$foo.$bar.$baz},
		//				{$foo[4].baz}, {$foo[4].$baz}, {$foo.bar.baz[4]}, {$foo->bar($baz,2,$bar)}, {$app.config.foo},
		//				{$app.server.SERVER_NAME}, {$x+$y}, {$foo[$x+3]}, {$foo={counter}+3}, {$foo="this is message {counter}"},
		//				{$foo=$bar+2}, {$foo = strlen($bar)}, {$foo = myfunct( ($x+$y)*3 )}, {$foo.bar=1}, {$foo.bar.baz=1},
		//				{$foo[]=1}, {$foo.a.b.c}, {$foo.a.$b.c}, {$foo.a.{$b+4}.c}, {$foo.a.{$b.c}}, {$foo['bar']}, {$foo['bar'][1]},
		//				{$foo[$x+$x]}, {$foo[$bar[1]]}, $foo_{$bar}, $foo_{$x+$y}, $foo_{$bar}_buh_{$blar}, {$foo_{$x}}, {time()}
		//				{$foo+1}, {$foo*$bar}, {$app.get.page}, {$app.post.page}, {$app.cookies.page}, , {$app.anv.path},
		//				{$app.session.page}, {$app.request.page}, {$app.now}, {$app.const.page}, {$smarty.capture}, {$smarty.section},
		//				{$smarty.template}, {$smarty.current_dir}, {$smarty.version}, {$smarty.template_object}, {$smarty.block.child},
		//				{$smarty.block.parent}, {$app.ldelim}, {$app.rdelim}
		// particulier ;
		// version 1 forbiden : {$app['security']}, {$app['user']}, {$app['environment']}, {$app['debug']}
		//*****************************************************************************************************************************

		while (preg_match('|\{(.*?)\$([^_\(][a-z0-9_\[\]\->\(\)\+/*\']+)\.([a-z0-9_]+)(.*?)\}|msi', $sContent, $ret)) {

			$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_\[\]\->\(\)\+/*\']+)\.([a-z0-9_]+)(.*?)\}|msi',
							'{'.'$1'.'$'.'$2[\'$3\']'.'$4'.'}', $sContent);
		}



		// {$foo.$bar.baz}

		$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_]*)([a-z0-9_\[\].\->\(\)\+/*\']*)\.\$([^_][a-z0-9_]*)([a-z0-9_\[\]\->\(\)\+/*\']*)(.*?)\}|msi',
			'{'.'$1'.'$_aProtectedVar[\'$2\']$3[$_aProtectedVar[\'$4\']$5]'.'$6'.'}', $sContent);

		// {$foo.a.{$b.c}}

		$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_]*)([a-z0-9_\[\].\->\(\)\+/*\']*)\.\{\$([^_][a-z0-9_]*)([a-z0-9_\[\]\->.\(\)\+/*\']*)\}(.*?)\}|msi',
						'{'.'$1'.'$_aProtectedVar[\'$2\']$3[$_aProtectedVar[\'$4\']$5]'.'$6'.'}', $sContent);

		// $foo_{$bar}, $foo_{$x+$y}, $foo_{$bar}_buh_{$blar}, {$foo_{$x}}

		$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_]*?)_\{([a-z0-9_\+/*\->\$\(\)\[\]]*)([a-z0-9_\[\]\->\(\)\+/*\']*)\}(.*?)\}|msi',
						'{'.'$1'.'$_aProtectedVar[\'$2\'.($3)]'.'$5'.'}', $sContent);

		while (preg_match('|\{(.*?)\$([^_\(][a-z0-9_]*)([a-z0-9_\[\].\->\(\)\+/*\']*)(.*?)\}|msi', $sContent)) {

			$sContent = preg_replace('|\{(.*?)\$([^_\(][a-z0-9_]*)([a-z0-9_\[\].\->\(\)\+/*\']*)(.*?)\}|msi',
							'{'.'$1'.'$_aProtectedVar[\'$2\']$3'.'$4'.'}', $sContent);
		}

		//*****************************************************************************************************************************
		// var modifiers : {$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}
		//*****************************************************************************************************************************

		preg_match_all('#\{(\$_aProtectedVar[a-z0-9_\[\].\->\(\)\+/*\']*)\|([^:\}]+)([^\}]*)\}#msi', $sContent, $aMatchs, PREG_SET_ORDER);

		foreach ($aMatchs as $aOne) {

			$sName = ucfirst($aOne[2]);

			$sName = preg_replace('|_([a-z])|e', 'strtoupper("$1")', $sName);
			// replace the name of modifier which are a key name of php
			$sName = str_replace(array('Default'), array('StringDefault'), $sName);

			if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'Modifiers'.DIRECTORY_SEPARATOR.$sName.'.php')) {

				$sClassName = '\Apollina\Template\Modifiers\\'.$sName;
				$oFunction = new $sClassName;
				$aAttributes = explode(' ', $aOne[3]);
				preg_match_all('#:([^:]+)#msi', $aOne[3], $aMatchs2, PREG_SET_ORDER);
				$aParams = [];
				$aParams[] = $aOne[1];
				$iIndex = 1;

				foreach ($aMatchs2 as $sOne2) {

					if (!isset($aParams[$iIndex])) { $aParams[$iIndex] = $sOne2[1]; }
					else { $aParams[$iIndex] .= $sOne2[1]; }

					if (substr($aParams[$iIndex], -1) == "'" && substr($aParams[$iIndex], 0, 1) == "'") { $iIndex++; }
					else if (substr($aParams[$iIndex], -1) == '"' && substr($aParams[$iIndex], 0, 1) == '"') { $iIndex++; }
					else if (substr($aParams[$iIndex], 0, 1) != '"' && substr($aParams[$iIndex], 0, 1) != "'") { $iIndex++; }
					else { $aParams[$iIndex] .= ":"; }
				}

				$oFunction->run($aParams);
				$sContent = str_replace($aOne[0], call_user_func_array(array($oFunction, 'replaceBy') , $aParams), $sContent);
			}
		}

		//*****************************************************************************************************************************
		// transformation all : {$ssdsd} in <php echo ; >
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{(\$[a-z0-9_\[\].\->\(\)\$\+/*\'=+]+)\}|msi', '<?php echo $1; ?>', $sContent);
		$sContent = preg_replace('|\{([a-z0-9_\(\),.]+\(\$[a-z0-9_\[\].\->\(\)\$\+/*\'"]+[ a-z0-9_\(\),".]+)\}|msi', '<?php echo $1; ?>', $sContent);
		$sContent = preg_replace('|\{([a-z0-9_\(\),.]+\([^\}]+\))\}|msi', '<?php echo $1; ?>', $sContent);

		$sContent = preg_replace('|echo echo|', 'echo', $sContent);

		//*****************************************************************************************************************************
		// escape: {ldelim}function{/rdelim}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|<?php echo ldelim; ?>|', '{', $sContent);
		$sContent = preg_replace('|<?php echo rdelim; ?>|', '}', $sContent);

		//*****************************************************************************************************************************
		// variables: {#foo#}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{#([a-z0-9_]+)#\}|msi', '<?php echo $_aProtectedVar[\'app\'][\'config\'][\'$1\']; ?>', $sContent);

		//*****************************************************************************************************************************
		// variables: {"foo"}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{"([^"]+)"\}|msi', '<?php echo "$1"; ?>', $sContent);

		//*****************************************************************************************************************************
		// {$nale='dsds'}
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{(\$_aProtectedVar[^= }]+=[\'"][^\'"}]+[\'"])\}|msi', '<?php $1'.'; ?>', $sContent);

		//*****************************************************************************************************************************
		// variables: {funcname attr1="val1" attr2="val2"}
		//				{assign var=foo value={counter}}
		//				{html_select_date display_days=true}
		//				{mailto address="smarty@example.com"}
		//				{html_options options=$companies selected=$company_id}
		//				{include file="subdir/$tpl_name.tpl"} => exception : class ToInclude
		//				{cycle values="one,two,`$smarty.config.myval`"}
		//				{config_load file='foo.conf'}
		//				{url alias='home' ...}
		//*****************************************************************************************************************************

		preg_match_all('|\{([a-z0-9_]+) +([a-z]+=[^\}]+)\}|msi', $sContent, $aMatchs, PREG_SET_ORDER);

		foreach ($aMatchs as $aOne) {

			$sName = ucfirst($aOne[1]);

			$sName = preg_replace_callback('|_([a-z])|', function ($aMatches) {
				return strtoupper($aMatches[1]);
			}, $sName);

			if ($sName == 'Include') { $sName = 'ToInclude'; }
			if ($sName == 'Foreach') { $sName = 'ToForeach'; }

			if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'Functions'.DIRECTORY_SEPARATOR.$sName.'.php')) {

				$sClassName = 'Apollina\Template\Functions\\'.$sName;
				$oFunction = new $sClassName;
				$aAttributes = explode(' ', $aOne[2]);

				$aParams = [];

				foreach ($aAttributes as $sOne2) {

					$aSplitParams = explode('=', $sOne2);
					$aParams[$aSplitParams[0]] = $aSplitParams[1];
				}

				if ($sName == 'ToInclude') {

					if (preg_match('/_aProtectedVar/', $aParams['file'])) {

						$sModelToCall = str_replace(array("\$_aProtectedVar['", "']", "'", '"'), array('', '' , '', ''), $aParams['file']);
						$aParams['real_name'] = $_aProtectedVar[$sModelToCall];
					}
					else {

						$aParams['real_name'] = str_replace(array("'", '"'), array('', ''), $aParams['file']);
					}
				}

				$sContent = str_replace($aOne[0], $oFunction->replaceBy($aParams), $sContent);
			}
			
			foreach ($this->_aFunctionsPath as $sOnePath) {

			    if (file_exists($sOnePath['files'].DIRECTORY_SEPARATOR.$sName.'.php')) {
			    
			        $sClassName = $sOnePath['namespace'].$sName;
			        $oFunction = new $sClassName;
			        $aAttributes = explode(' ', $aOne[2]);
			    
			        $aParams = [];
			    
			        foreach ($aAttributes as $sOne2) {
			    
			            $aSplitParams = explode('=', $sOne2);
			            $aParams[$aSplitParams[0]] = $aSplitParams[1];
			        }

			        $sContent = str_replace($aOne[0], $oFunction->replaceBy($aParams), $sContent);
			    }
			}
		}

		//*****************************************************************************************************************************
		// variables: {include model}
		//*****************************************************************************************************************************

		if (preg_match('|\{include model\}|', $sContent)) {

			if ($this->_bIsMobile && file_exists(self::$_sBasePath.str_replace('.tpl', 'Mobile.tpl', $_aProtectedVar['model']))) {

				$this->_transform(file_get_contents(self::$_sBasePath.str_replace('.tpl', 'Mobile.tpl', $_aProtectedVar['model'])), str_replace('.tpl', 'Mobile.tpl', $_aProtectedVar['model']));
			}
			else {

				$this->_transform(file_get_contents(self::$_sBasePath.$sModelname), $sModelname);
			}
		}

		//*****************************************************************************************************************************
		// variables: {if $foo > 3}{elseif $foo > 3}{else}{/if}
		//				{foreachelse} execute program if the array of foreach is empty
		//				{/foreach} to close foreach
		//*****************************************************************************************************************************

		$sContent = preg_replace('|\{if ([^\}]+)\}|', '<?php if ($1) { ?>', $sContent);
		$sContent = preg_replace('|\{elseif ([^\}]+)\}|', '<?php } else if ($1) { ?>', $sContent);
		$sContent = str_replace(array('{else}', '{foreachelse}'), '<?php } else { ?>', $sContent);
		$sContent = str_replace('{/foreach}', '<?php }} ?>', $sContent);
		$sContent = str_replace(array('{/if}', '{/section}'), '<?php } ?>', $sContent);

		//*****************************************************************************************************************************
		// finition
		//*****************************************************************************************************************************

		//$sContent = preg_replace('|\{|msi', '<?php ', $sContent);
		//$sContent = preg_replace('|\}|msi', ' ? >', $sContent);

		while (preg_match('|(<<<EOF(?:(?<!EOF;).)+?)#DOLLAR#(.+?EOF;)|msi', $sContent)) {

			$sContent = preg_replace('|(<<<EOF(?:(?<!EOF;).)+?)#DOLLAR#(.+?EOF;)|msi', '$1'.'\\\$'.'$2', $sContent);
		}

		$sContent .= "\n".'<?php /* '.print_r(str_replace('\\\\\\', '/', $sTmpDirectory).$this->_getEncodeTemplateName($sTemplateName).'.cac.php', true).' */ ?>';
		$sContent .= "\n".'<?php /* template : '.$sTemplateName.' */ ?>';
		$sContent .= "\n".'<?php /* '.print_r(file_put_contents(str_replace('\\\\\\', '/', $sTmpDirectory).$this->_getEncodeTemplateName($sTemplateName).'.cac.php', $sContent), true).' */ ?>';
		$sContent .= "\n".'<?php /* '.str_replace('\\\\\\', '/', $sTmpDirectory).' = '.$sTemplateName.' = '.md5($sTemplateName).' */ ?>';
	
		if ($bFirst === true) {

			include(str_replace('\\\\\\', '/', $sTmpDirectory).$this->_getEncodeTemplateName($sTemplateName).'.cac.php');
		}
	}
354580
public function setRepeaters($contentKey, $className, $inputData = null)
    {
        $standalone = false;

        if ($inputData === null && !isset($this->contenttypes[$contentKey])) {
            return null;
        }

        if ($inputData === null) {
            $inputData = $this->contenttypes[$contentKey]['fields'];
        } else {
            $standalone = true;
        }

        foreach ($inputData as $key => $data) {
            $mapping = [
                'fieldname'        => $key,
                'attribute'        => $this->camelize($key),
                'type'             => 'null',
                'fieldtype'        => $this->typemap['repeater'],
                'tables'           => [
                    'field'        => $this->schemaManager->getTableName('field'),
                    'field_value'  => $this->schemaManager->getTableName('field_value'),
                ],
            ];

            if (in_array($data['type'], ['repeater', 'block'])) {
                if ($data['type'] === 'repeater') {
                    $this->normalizeFieldTypes($data['fields']);
                }
                if ($data['type'] === 'block') {
                    foreach ($data['fields'] as $block => &$fields) {
                        $this->normalizeFieldTypes($fields['fields']);
                    }
                    $mapping['fieldtype'] = $this->typemap['block'];
                }

                if ($standalone) {
                    return $data;
                }

                $this->metadata[$className]['fields'][$key] = $mapping;
                foreach ((array) $data['fields'] as &$field) {
                    $this->postProcessField($field);
                }

                $this->metadata[$className]['fields'][$key]['data'] = $data;
            }
        }

        return null;
    }
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;
    }
71333
function variableEndPos( $tpl, $relatedTemplateName, &$text, $startPosition, $textLength,
                             &$namespace, &$name, &$scope )
    {
        $currentPosition = $startPosition;
        $namespaces = array();
        $variableName = false;
        $lastPosition = false;
        $scopeType = eZTemplate::NAMESPACE_SCOPE_LOCAL;
        $scopeRead = false;
        while ( $currentPosition < $textLength )
        {
            if ( $lastPosition !== false and
                 $lastPosition == $currentPosition )
            {
                $tpl->error( "ElementParser::variableEndPos", "parser error @ $relatedTemplateName\[" . $currentPosition . "]\n" .
                             "Parser position did not move, this is most likely a bug in the template parser." );
                break;
            }
            $lastPosition = $currentPosition;
            if ( $text[$currentPosition] == '#' )
            {
                if ( $scopeRead )
                {
                    $tpl->error( "ElementParser::variableEndPos", "parser error @ $relatedTemplateName\[" . $currentPosition . "]\n" .
                                 "Namespace scope already declared, cannot set to global." );
                }
                else
                {
                    $scopeType = eZTemplate::NAMESPACE_SCOPE_GLOBAL;
                }
                $scopeRead = true;
                ++$currentPosition;
            }
            else if ( $text[$currentPosition] == ':' )
            {
                if ( $scopeRead )
                {
                    $tpl->error( "ElementParser::variableEndPos", "parser error @ $relatedTemplateName\[" . $currentPosition . "]\n" .
                                 "Namespace scope already declared, cannot set to relative." );
                }
                else
                {
                    $scopeType = eZTemplate::NAMESPACE_SCOPE_RELATIVE;
                }
                $scopeRead = true;
                ++$currentPosition;
            }
            else
            {
                $identifierEndPosition = $this->identifierEndPosition( $tpl, $text, $currentPosition, $textLength );
                if ( $identifierEndPosition > $currentPosition )
                {
                    $identifier = substr( $text, $currentPosition, $identifierEndPosition - $currentPosition );
                    $currentPosition = $identifierEndPosition;
                    if ( $identifierEndPosition < $textLength and
                         $text[$identifierEndPosition] == ':' )
                    {
                        $namespaces[] = $identifier;
                        ++$currentPosition;
                    }
                    else
                        $variableName = $identifier;
                }
                else if ( $identifierEndPosition < $textLength and
                          ( $text[$identifierEndPosition] != ":" and
                            $text[$identifierEndPosition] != "#" ) )
                {
                    if ( $variableName === false )
                    {
                        $tpl->error( "ElementParser::variableEndPos", "parser error @ $relatedTemplateName\[" . $currentPosition . "]\n" .
                                     "No variable name found, this is most likely a bug in the template parser." );
                        return $startPosition;
                    }
                    break;
                }
                else
                {
                    $tpl->error( "ElementParser::variableEndPos", "parser error @ $relatedTemplateName\[" . $currentPosition . "]\n" .
                                 "Missing identifier for variable name or namespace, this is most likely a bug in the template parser." );
                    return $startPosition;
                }
            }
        }
        $scope = $scopeType;
        $namespace = implode( ':', $namespaces );
        $name = $variableName;
        return $currentPosition;
    }
107924
public function set(
        callable $inputDataFunction,
        $tHashKeys,
        $tRedisTags,
        int $iCache = null
    ): self {
        try {
            if ($tHashKeys === [] || $tHashKeys === null || (\is_string($tHashKeys) && trim($tHashKeys) === '')) {
                throw new InvalidArgumentException('HashKey is required!', 1);
            }

            $tRedisTags = (array)$tRedisTags;
            $tHashKeys  = (array)$tHashKeys;
            $iCache     = $iCache ?? $this->defaultTtl;

            $hashKey = $this->genHash($tHashKeys);

            if ($this->isEnabled === false) {
                $this->logger->debug(sprintf('CACHE [%s]: cache omitted [not enabled]', $hashKey));
                $this->userData = $inputDataFunction();
            } elseif ($iCache > 0) {
                $oCachedItem = $this->oCache->getItem($hashKey);
                //do każdego zapytania dajemy TAG związany z projektem
                $tRedisTags = array_unique(array_merge([$this->projectHash], $tRedisTags));

                if (!$oCachedItem->isHit() || $oCachedItem->get() === null) {
                    $this->logger->debug(sprintf('CACHE [%s]: old or NULL, reset [ttl=%s]', $hashKey, $iCache));
                    $this->userData = $inputDataFunction();
                    $oCachedItem
                        ->set($this->userData)
                        ->setTags($tRedisTags)
                        ->expiresAfter($iCache)
                    ;
                    $this->oCache->save($oCachedItem);
                } else {
                    $this->logger->debug(sprintf('CACHE [%s]: getting from cache', $hashKey));
                    $this->userData = $oCachedItem->get();
                }
            } else {
                $this->logger->debug(sprintf('CACHE [%s]: cache omitted [ttl=0]', $hashKey));
                $this->userData = $inputDataFunction();
            }

            return $this;
        } catch (\Exception $e) {
            $this->logger->warning(sprintf('CACHE Error: %s. Using fallback function.', $e->getMessage()));
            $this->userData = $inputDataFunction();

            return $this;
        }
    }
728775
private function AssignFrom( $src )
	{
		$this->elementIndex = $src->elementIndex;
		$this->index = $src->index;
		$this->itemSet = $src->itemSet;
		$this->lastNode = $src->lastNode;
	}
1185957
private function strContainsFromCharset($sStr, $sCharset)
    {
        if (empty($this->aCharset[$sCharset])) {
            return true;
        }

        return preg_match('/[' . preg_quote($this->aCharset[$sCharset], '/') . ']/', $sStr);
    }
160910
function assign( $blockName, $varName, &$variable )
    {
        if ( isset( $this->BlockValues[$blockName][$varName] ) )
            $variable = $this->BlockValues[$blockName][$varName];
        else
            return false;
        return true;
    }
200649
protected function copyTemplate($template, $dest)
    {
        $source = __DIR__.'/../../templates/'.$template;
        if (file_exists($source)) {
            return file_put_contents($dest, file_get_contents($source));
        }
    }
999561
public function sendToBrowser($strFilename = '', $strDest = 'I')
    {
        $strFilename = $strFilename ?: $this->buildFilename();

        $this->objPdf->Output($strFilename, $strDest);
    }
1189122
public boolean assignParsedElement(Concept parsedConcept, String syntaxElementName, ISyntaxElement syntaxElement) throws ModelException
    {
        if (syntaxElementName.equalsIgnoreCase(XMLSyntax.URI()) && syntaxElement instanceof SemanticIdentifier)
        {
            parsedConcept.setSemanticIdentifier((SemanticIdentifier) syntaxElement);
            return true;
        }
        if (syntaxElementName.equalsIgnoreCase(XMLSyntax.ONTOLOGY()))
        {
            if (syntaxElement instanceof SemanticIdentifier)
            {
                parsedConcept.setOntology(bsdlRegistry, (SemanticIdentifier) syntaxElement);
            }
            return true;
        }
        if (syntaxElementName.equalsIgnoreCase(XMLSyntax.SUPERCONCEPT()))
        {
            if (syntaxElement instanceof SemanticIdentifier)
            {
                parsedConcept.superconcepts().add(
                        new ReferenceToSemanticAxiom<Concept>(
                                bsdlRegistry, 
                                (SemanticIdentifier) syntaxElement,
                                Concept.class
                        ));
                return true;
            }
            if (syntaxElement instanceof Concept)
            {
                parsedConcept.superconcepts().add(
                        new ReferenceToSemanticAxiom<Concept>((Concept) syntaxElement));
                return true;
            }
        }
        if (syntaxElementName.equalsIgnoreCase(XMLSyntax.PROPERTY()))
        {
            parsedConcept.addProperty(((Property) syntaxElement));
            return true;
        }
        return false;
    }
893756
public function replaceBy($sContent, $sFormat = '"%b %e, %Y"') 
	{
		$aTransformFormat = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
		$aTransformFormatFinal = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');

		if (strpos($sFormat, '%e') !== false) {

			$aTransformFormat[] = '%e';
			$aTransformFormatFinal[] = sprintf('%\' 2d', date('j', $sContent));
		}

		if (strpos($sFormat, '%l') !== false) {

			$aTransformFormat[] = '%l';
			$aTransformFormatFinal[] = sprintf('%\' 2d', date('h', $sContent));
		}

		$sFormat = str_replace($aTransformFormat, $aTransformFormatFinal, $sFormat);

		return '{strftime('.$sFormat.', '.$sContent.')}';
	}
1276372
protected function AssignFrom( $src )
	{
		$context = $this->context;
		$node = $this->node;
		$dataPool = $this->dataPool;
		$baseIter = $this->baseIter;
		$iter = $this->iter->CloneInstance();
		$sequentialPosition = $this->sequentialPosition;

	}
885620
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        switch ( $functionName )
        {
            case $this->BlockName:
            {
                // Check for disabled cache.
                $ini = eZINI::instance();
                if ( $ini->variable( 'TemplateSettings', 'TemplateCache' ) != 'enabled' )
                {
                    $text = eZTemplateCacheFunction::processUncached( $tpl, $functionChildren,
                                                                      $rootNamespace, $currentNamespace );
                    $textElements[] = $text;
                    return;
                }
                else
                {
                    $text = eZTemplateCacheFunction::processCachedPreprocess( $tpl,  $functionChildren,
                                                                              $functionParameters, $functionPlacement,
                                                                              $rootNamespace, $currentNamespace );
                    $textElements[] = $text;
                }
            } break;
        }
    }
167379
public function extendBackendTemplate($strContent, $strTemplate)
    {
        if ($strTemplate == 'be_main')
        {
            $strScript = "<script>var advancedClassesSet = '".$GLOBALS['TL_CONFIG']['advancedClassesSet']."';var defaultColumnWidth = '".$GLOBALS['TL_CONFIG']['ac_defaultColumnWidth']."';</script>\n\r</body>";
            return str_replace('</body>', $strScript, $strContent);
        }
        return $strContent;
    }
918220
private function setBasicData(FrontendTemplate $template, array $data)
    {
        foreach ($data as $k => $v) {
            if (0 === strpos($k, 'cookiebar_')) {
                $template->{substr($k, 10)} = $v;
            }
        }

        $template->raw = $data;
    }
846849
public function display($sName = null, \Apollina\Template $oTemplate = null) 
	{
		if ($oTemplate !== null) {

			if ($this->_oTemplateLink !== null) {

				$aVar = $this->getAllAssign();
				$aVar = array_merge($aVar, $this->_oTemplateLink->getAllAssign());
				$this->assignAll($aVar);
			}
		}

		$sTemplate = $this->fetch($sName);

		echo $sTemplate;
	}