Index: trunk/core/kernel/nparser/ntags.php
===================================================================
diff -u -N
--- trunk/core/kernel/nparser/ntags.php (revision 8860)
+++ trunk/core/kernel/nparser/ntags.php (revision 0)
@@ -1,228 +0,0 @@
-Tag = $tag;
- }
-
- function Open($tag)
- {
-
- }
-
- /**
- * All tags inside block tag are passed through to this method
- * Any returned result is appened to current level's buffer
- * This can be used to implement special handling of such tags as
- *
- * @param unknown_type $tag
- * @return unknown
- */
- function PassThrough(&$tag)
- {
- return '';
- }
-
- function Close($tag)
- {
- return $this->Parser->Buffers[$this->Parser->Level];
- }
-
- function AppendCode(&$o, $code)
- {
- $o .= ''."php\n" . ( is_array($code) ? implode("\n", $code)."\n" : $code) .'?>';
- }
-}
-
-class _Tag_Comment extends _BlockTag {
- function PassThrough(&$tag)
- {
- $tag['processed'] = true;
- }
-
- function Close($tag)
- {
- return '';
- }
-}
-
-class _Tag_DefineElement extends _BlockTag {
-
- function Open($tag)
- {
- $o = '';
-
- $f_name = $tag['NP']['name'].'_'.abs(crc32($tag['file'])).'_'.$tag['line'];
-
- $code[] = "\$_parser->Elements['{$tag['NP']['name']}'] = '$f_name';";
-
- // function_exists is required here, because a template may be included more than once
- // leading to Cannot redeclare error
- $code[] = "if (!function_exists('{$f_name}')) {";
- $code[] = "function $f_name(&\$_parser, \$params) {";
- $code[] = "global \$application;";
-
- $defaults = $this->Parser->CompileParamsArray($tag['NP']);
-
- $code[] = "\$params = array_merge($defaults, \$params);";
- $code[] = "if (!isset(\$params['PrefixSpecial']) && isset(\$params['prefix'])) {\$params['PrefixSpecial'] = \$params['prefix'];};";
- $code[] = "extract(\$params);";
- $code[] = "\$_parser->SetParams(\$params);";
- $code[] = 'ob_start();';
- $this->AppendCode($o, $code);
- return $o;
- }
-
- function Close($tag)
- {
- $o = $this->Parser->Buffers[$this->Parser->Level];
- $code[] = '$_output = ob_get_contents();';
- $code[] = 'ob_end_clean();';
- $code[] = 'return $_output;';
- $code[] = '}}';
- $this->AppendCode($o, $code);
- return $o;
- }
-}
-
-class _Tag_Capture extends _Tag_DefineElement {
- function Open($tag)
- {
- $tag['NP']['name'] = '__capture_'.$tag['NP']['to_var'];
-
- $o = '';
- $this->AppendCode($o, "\$_parser->Captures['{$tag['NP']['to_var']}'] = 1;");
- $o .= parent::Open($tag);
- return $o;
- }
-}
-
-class _Tag_RenderElement extends _Tag_DefineElement {
- var $Single = true;
- var $OriginalTag;
-
- function Open($tag)
- {
- $o = '';
- if ($tag['is_closing']) {
- if (isset($tag['NP']['design'])) {
- $this->RenderDesignCode($o, $tag['NP']);
- return $o;
- }
- $to_pass = $this->Parser->CompileParamsArray($tag['NP']);
- $this->AppendCode($o, "echo (\$_parser->ParseBlock($to_pass));");
- return $o;
- }
- $this->Single = false;
- $this->OriginalTag = $tag;
- $tag['NP']['name'] = '__lambda';
- return parent::Open($tag);
- }
-
- function RenderDesignCode(&$o, $params)
- {
- $to_pass = $this->Parser->CompileParamsArray($params);
- $code[] = "echo (\$_parser->ParseBlock(array_merge($to_pass, array('name'=>'{$params['design']}','content'=>\$_parser->ParseBlock($to_pass)))));";
- $this->AppendCode($o, $code);
- }
-
- function Close($tag)
- {
- if ($this->Single) {
- return $this->Parser->Buffers[$this->Parser->Level];
- }
- $o = parent::Close($tag);
- $this->OriginalTag['NP']['name'] = '__lambda';
- $this->RenderDesignCode($o, $this->OriginalTag['NP']);
- return $o;
- }
-}
-
-class _Tag_Param extends _BlockTag {
- function Open($tag)
- {
- $o = '';
- $code[] = "if (isset(\$_parser->Captures['{$tag['NP']['name']}'])) {";
- $code[] = "\${$tag['NP']['name']} = \$_parser->ParseBlock(array('name' => '__capture_{$tag['NP']['name']}'));";
- $code[] = "\$params['{$tag['NP']['name']}'] = \${$tag['NP']['name']};";
- $code[] = "}";
- $code[] = "echo (\${$tag['NP']['name']});";
- $this->AppendCode($o, $code);
- return $o;
- }
-}
-
-class _Tag_Include extends _BlockTag {
- function Open($tag)
- {
- $o = '';
- $to_pass = $this->Parser->CompileParamsArray($tag['NP']);
- $this->AppendCode($o, "echo (\$_parser->IncludeTemplate($to_pass))");
- return $o;
- }
-}
-
-class _Tag_If extends _BlockTag {
- function Open($tag)
- {
- $o = '';
- $to_pass = $this->Parser->CompileParamsArray($tag['NP']);
-
- if (!isset($tag['NP']['check'])) {
- $this->Application->handleError(E_USER_ERROR, 'Tag '.$this->Parser->TagInfo($tag, true).' called without required check attribute', $tag['file'], $tag['line']);
- }
-
- $code[] = "\$_splited = \$_parser->SplitTag(array('tag'=>\"{$tag['NP']['check']}\", 'file'=>'{$tag['file']}', 'line'=>{$tag['line']}));";
- $code[] = 'if ($_splited[\'prefix\'] == \'__auto__\') {$_splited[\'prefix\'] = $PrefixSpecial;}';
- $code[] = '$_p_ =& $_parser->GetProcessor($_splited[\'prefix\']);';
- if (isset($tag['NP']['inverse'])) {
- $code[] = "if (!\$_p_->ProcessParsedTag(\$_splited['name'], $to_pass, \$_splited['prefix'], '{$tag['file']}', {$tag['line']})) {";
- }
- else {
- $code[] = "if (\$_p_->ProcessParsedTag(\$_splited['name'], $to_pass, \$_splited['prefix'], '{$tag['file']}', {$tag['line']})) {";
- }
- $this->AppendCode($o, $code);
- return $o;
- }
-
- function PassThrough(&$tag)
- {
- $o = '';
- if ($tag['name'] == 'else') {
- $this->AppendCode($o, '} else {');
- $tag['processed'] = true;
- }
- return $o;
- }
-
- function Close($tag)
- {
- $o = $this->Parser->Buffers[$this->Parser->Level];
- $this->AppendCode($o, "}\n");
- return $o;
- }
-}
-
-class _Tag_DefaultParam extends _BlockTag {
- function Open($tag)
- {
- $o = '';
- foreach ($tag['NP'] as $key => $val) {
- $code[] = 'if (!isset($'.$key.')) $params[\''.$key.'\'] = \''.$val.'\';';
- $code[] = '$'.$key.' = isset($'.$key.') ? $'.$key.' : \''.$val.'\';';
- }
- $this->AppendCode($o, $code);
- return $o;
- }
-}