Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/nparser/ntags.php
Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
$this->AppendCode($o, $code); | $this->AppendCode($o, $code); | ||||
return $o; | return $o; | ||||
} | } | ||||
$this->Single = false; | $this->Single = false; | ||||
$this->OriginalTag = $tag; | $this->OriginalTag = $tag; | ||||
$tag['NP']['name'] = $tag['NP']['design'] . '_' . abs(crc32($tag['file'])) . '_' . $tag['line']; //'__lambda'; | $tag['NP']['name'] = $this->createSafeFunctionName($tag); | ||||
return parent::Open($tag); | return parent::Open($tag); | ||||
} | } | ||||
function RenderDesignCode(&$o, $params) | function RenderDesignCode(&$o, $params) | ||||
{ | { | ||||
$to_pass = $this->Parser->CompileParamsArray($params); | $to_pass = $this->Parser->CompileParamsArray($params); | ||||
$code[] = "echo (\$_parser->ParseBlock(array_merge($to_pass, array('name'=>\"{$params['design']}\",'content'=>\$_parser->ParseBlock($to_pass), 'keep_data_exists'=>1))));"; | $code[] = "echo (\$_parser->ParseBlock(array_merge($to_pass, array('name'=>\"{$params['design']}\",'content'=>\$_parser->ParseBlock($to_pass), 'keep_data_exists'=>1))));"; | ||||
$this->AppendCode($o, $code); | $this->AppendCode($o, $code); | ||||
} | } | ||||
function Close($tag) | function Close($tag) | ||||
{ | { | ||||
if ($this->Single) { | if ($this->Single) { | ||||
return $this->Parser->Buffers[$this->Parser->Level]; | return $this->Parser->Buffers[$this->Parser->Level]; | ||||
} | } | ||||
$o = parent::Close($tag); | $o = parent::Close($tag); | ||||
$this->OriginalTag['NP']['name'] = $this->OriginalTag['NP']['design'] . '_' . abs(crc32($this->OriginalTag['file'])) . '_' . $this->OriginalTag['line']; //'__lambda'; | $this->OriginalTag['NP']['name'] = $this->createSafeFunctionName($this->OriginalTag); | ||||
$this->RenderDesignCode($o, $this->OriginalTag['NP']); | $this->RenderDesignCode($o, $this->OriginalTag['NP']); | ||||
return $o; | return $o; | ||||
} | } | ||||
/** | |||||
* Creates safe function name based on design used in a given tag. | |||||
* | |||||
* @param array $tag Tag. | |||||
* | |||||
* @return string | |||||
*/ | |||||
protected function createSafeFunctionName(array $tag) | |||||
{ | |||||
$safe_design = preg_replace('/[^a-zA-Z0-9_\x7f-\xff]/', '', $tag['NP']['design']); | |||||
return $safe_design . '_' . abs(crc32($tag['file'])) . '_' . $tag['line']; // Former name '__lambda'. | |||||
} | |||||
} | } | ||||
class _Tag_RenderElements extends _BlockTag { | class _Tag_RenderElements extends _BlockTag { | ||||
public function __construct($tag) | public function __construct($tag) | ||||
{ | { | ||||
parent::__construct($tag); | parent::__construct($tag); | ||||
▲ Show 20 Lines • Show All 373 Lines • Show Last 20 Lines |