Index: trunk/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r8679 -r8860 --- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 8679) +++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 8860) @@ -1873,7 +1873,8 @@ $params['pass'] = 'm'; $params[$object->getPrefixSpecial().'_id'] = $object->GetID(); - return $this->Application->ProcessParsedTag('m', 't', $params); + $m =& $this->Application->recallObject('m_TagProcessor'); + return $m->t($params); } function PresetFormFields($params) Index: trunk/themes/default2007/platform/elements/pagination.tpl =================================================================== diff -u -N -r8811 -r8860 --- trunk/themes/default2007/platform/elements/pagination.tpl (.../pagination.tpl) (revision 8811) +++ trunk/themes/default2007/platform/elements/pagination.tpl (.../pagination.tpl) (revision 8860) @@ -28,7 +28,7 @@ :  - @@ -39,12 +39,12 @@ :
- "> + + + - " value="" /> + " value="" /> Index: trunk/themes/default2007/platform/elements/subcats.xml.tpl =================================================================== diff -u -N -r8539 -r8860 --- trunk/themes/default2007/platform/elements/subcats.xml.tpl (.../subcats.xml.tpl) (revision 8539) +++ trunk/themes/default2007/platform/elements/subcats.xml.tpl (.../subcats.xml.tpl) (revision 8860) @@ -1,9 +1,10 @@ - + + " orient="V" showicon="true" showsubicon="true" stlprf="" @@ -17,7 +18,7 @@ suburl="" + rand="$rand" serial="$serial"/>" >]]> Index: trunk/themes/default2007/platform/elements/menu.tpl =================================================================== diff -u -N -r8809 -r8860 --- trunk/themes/default2007/platform/elements/menu.tpl (.../menu.tpl) (revision 8809) +++ trunk/themes/default2007/platform/elements/menu.tpl (.../menu.tpl) (revision 8860) @@ -10,13 +10,14 @@ -
Loading menu...
+
Index: trunk/themes/default2007/platform/designs/content_boxes.tpl =================================================================== diff -u -N -r8845 -r8860 --- trunk/themes/default2007/platform/designs/content_boxes.tpl (.../content_boxes.tpl) (revision 8845) +++ trunk/themes/default2007/platform/designs/content_boxes.tpl (.../content_boxes.tpl) (revision 8860) @@ -35,7 +35,7 @@ - "> + "> "> Index: trunk/core/kernel/nparser/ntags.php =================================================================== diff -u -N --- trunk/core/kernel/nparser/ntags.php (revision 0) +++ trunk/core/kernel/nparser/ntags.php (revision 8860) @@ -0,0 +1,228 @@ +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 .= ''; + } +} + +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; + } +} Index: trunk/themes/default2007/platform/designs/default_design.tpl =================================================================== diff -u -N -r8797 -r8860 --- trunk/themes/default2007/platform/designs/default_design.tpl (.../default_design.tpl) (revision 8797) +++ trunk/themes/default2007/platform/designs/default_design.tpl (.../default_design.tpl) (revision 8860) @@ -31,16 +31,22 @@ + + + + + +
img/s.gif" width="3" height="1" alt=""/>

Index: trunk/themes/default2007/platform/elements/forms.tpl =================================================================== diff -u -N -r8833 -r8860 --- trunk/themes/default2007/platform/elements/forms.tpl (.../forms.tpl) (revision 8833) +++ trunk/themes/default2007/platform/elements/forms.tpl (.../forms.tpl) (revision 8860) @@ -51,7 +51,7 @@ - - " value="" /> + " value="" /> "> -
+
- " id="" value="" tabindex="" size="" style="" datepickerIcon="img/calendar_icon.gif"> () + " id="" value="" tabindex="" size="" style="" datepickerIcon="img/calendar_icon.gif"> () - " id="" value="" /> + " id="" value="" /> @@ -181,12 +181,12 @@ -
+
- " id="" value="" tabindex="" size="" style="">  - () + " id="" value="" tabindex="" size="" style="">  + () - " id="" value="" /> + " id="" value="" /> @@ -197,14 +197,14 @@ -
+
- " id="" value="" tabindex="" size="" style="" datepickerIcon="core/admin_templates/img/calendar_icon.gif"> - () + " id="" value="" tabindex="" size="" style="" datepickerIcon="core/admin_templates/img/calendar_icon.gif"> + () -  " id="" value="" tabindex="" size="" style=""> () +  " id="" value="" tabindex="" size="" style=""> () @@ -215,9 +215,9 @@ -
+
- + @@ -236,39 +236,39 @@ -
+
- " name="" style=""> + + - - + +
- " style="" name="" id="_" value="">  + " style="" name="" id="_" value="">  - " style="" name="" id="_" value="">  + " style="" name="" id="_" value="">  "> -
+
- + - + @@ -280,10 +280,10 @@ -
+
- " name="" value="" /> - " type="checkbox" id="_cb_" name="_cb_" style="" onchange="update_checkbox(this, document.getElementById(''));"> + " name="" value="" /> + " type="checkbox" id="_cb_" name="_cb_" style="" onchange="update_checkbox(this, document.getElementById(''));"> Index: trunk/core/kernel/parser/template.php =================================================================== diff -u -N -r8793 -r8860 --- trunk/core/kernel/parser/template.php (.../template.php) (revision 8793) +++ trunk/core/kernel/parser/template.php (.../template.php) (revision 8860) @@ -210,6 +210,8 @@ $fname = str_replace(FULL_PATH, defined('WRITEABLE') ? WRITEABLE.'/cache' : FULL_PATH.'/kernel/cache', $fname); $tname = $real_name.'.tpl'; + if (!file_exists($tname)) return false; + if (defined('SAFE_MODE') && SAFE_MODE) { $conn =& $this->Application->GetADODBConnection(); $cached = $conn->GetRow('SELECT * FROM '.TABLE_PREFIX.'Cache WHERE VarName = "'.$fname.'"'); @@ -226,7 +228,7 @@ $this->CheckDir(dirname($fname), defined('WRITEABLE') ? WRITEABLE.'/cache' : FULL_PATH.'/kernel/cache'); } } - return array('active' => 0, 'fname' => $fname, 'tname' => $tname); + return array('active' => 0, 'fname' => $fname, 'tname' => $tname, 'mode'=>'file'); } /** Index: trunk/core/units/categories/cache_updater.php =================================================================== diff -u -N -r8815 -r8860 --- trunk/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 8815) +++ trunk/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 8860) @@ -293,6 +293,7 @@ $this->Conn->Query('DROP TABLE IF EXISTS '.$this->progressTable); $this->Conn->Query('DROP TABLE IF EXISTS '.$this->permCacheTable); $this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = \'ForcePermCacheUpdate\''); + $this->Conn->Query('UPDATE '.TABLE_PREFIX.'ConfigurationValues SET VariableValue = VariableValue+1 WHERE VariableName = \'CategoriesRebuildSerial\''); } function DoTheJob() Index: trunk/themes/default2007/platform/inc/nlsmenuext_xml.js =================================================================== diff -u -N -r8591 -r8860 --- trunk/themes/default2007/platform/inc/nlsmenuext_xml.js (.../nlsmenuext_xml.js) (revision 8591) +++ trunk/themes/default2007/platform/inc/nlsmenuext_xml.js (.../nlsmenuext_xml.js) (revision 8860) @@ -3,7 +3,7 @@ * Copyright 2005-2007, addobject.com. All Rights Reserved * Author Jack Hermanto, www.addobject.com */ -var $nls_ieXML=["MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument", "Microsoft.XmlDom"]; +var $nls_ieXML=["MSXML2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument", "Microsoft.XmlDom"]; function NlsMenuUtil() {} var NLSMNUTIL=NlsMenuUtil.prototype; @@ -18,10 +18,10 @@ mgr.defaultEffect=$aonevl(rt.getAttribute("defaulteffect"), null); mgr.icPath=$aonvl(rt.getAttribute("icpath"), ""); mgr.memorizeSel=$aonevl(rt.getAttribute("memorizesel"), false); - + var dm=rt.getElementsByTagName("menubar")[0]; NlsMenuUtil.createMenu(dm, mgr); - + var mns=rt.getElementsByTagName("menus")[0]; if(mns){ for (var i=0;iBuffers[0] = '\n"; + + // finding all the tags + $reg = '(.*?)(<[\\/]?)inp2:([^>]*?)([\\/]?>(\r\n){0,1})'; + preg_match_all('/'.$reg.'/s', $data, $results, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); + + $this->InsideComment = false; + foreach ($results as $tag_data) { + $tag = array( + 'opening' => $tag_data[2][0], + 'tag' => $tag_data[3][0], + 'closing' => $tag_data[4][0], + 'line' => substr_count(substr($data, 0, $tag_data[2][1]), "\n")+1, + 'file' => $pre_parsed['tname'], + ); + + // the idea is to count number of comment openings and closings before current tag + // if the numbers do not match we inverse the status of InsideComment + if (substr_count($tag_data[1][0], '')) { + $this->InsideComment = !$this->InsideComment; + } + + // appending any text/html data found before tag + $this->Buffers[$this->Level] .= $tag_data[1][0]; + if (!$this->InsideComment) { + $this->ProcessTag($tag); + } + else { + $this->Buffers[$this->Level] .= $tag_data[2][0].$tag_data[3][0].$tag_data[4][0]; + } + } + + if ($this->Level > 0) { + $this->Application->handleError(E_USER_ERROR, 'Unclosed tag opened by '.$this->TagInfo($this->Stack[$this->Level]->Tag), $this->Stack[$this->Level]->Tag['file'], $this->Stack[$this->Level]->Tag['line']); + } + + // appending text data after last tag (after its closing pos), + // if no tag was found at all ($tag_data is not set) - append the whole $data + $this->Buffers[$this->Level] .= isset($tag_data) ? substr($data, $tag_data[4][1]+strlen($tag_data[4][0])) : $data; + + // saving compiled version + $compiled = fopen($pre_parsed['fname'], 'w'); + if (!fwrite($compiled, $this->Buffers[0])) { + trigger_error('Saving compiled template failed', E_USER_ERROR); + } + fclose($compiled); + } + + function SplitParamsStr($params_str) + { + preg_match_all('/([\${}a-zA-Z0-9_.\\-\\\\#\\[\\]]+)=(["\']{1,1})(.*?)(? $val){ + $values[$val[1]] = str_replace('\\' . $val[2], $val[2], $val[3]); + } + return $values; + } + + function SplitTag($tag) + { + if (!preg_match('/([^_ \t\n]*)[_]?([^ \t\n]*)[ \t\n]*(.*)$$/s', $tag['tag'], $parts)) { + // this is virtually impossible, but just in case + $this->Application->handleError(E_USER_ERROR, 'Incorrect tag format: '.$tag['tag'], $tag['file'], $tag['line']); + } + + $splited['prefix'] = $parts[2] ? $parts[1] : '__auto__'; + $splited['name'] = $parts[2] ? $parts[2] : $parts[1]; + $splited['attrs'] = $parts[3]; + return $splited; + } + + function ProcessTag($tag) + { + $tag = array_merge($tag, $this->SplitTag($tag)); + $tag['processed'] = false; + $tag['NP'] = $this->SplitParamsStr($tag['attrs']); + + $o = ''; + $tag['is_closing'] = $tag['opening'] == ''; + if (class_exists('_Tag_'.$tag['name'])) { // block tags should have special handling class + if ($tag['opening'] == '<') { + $class = '_Tag_'.$tag['name']; + $instance = new $class($tag); + $instance->Parser =& $this; + /* @var $instance _BlockTag */ + $this->Stack[++$this->Level] =& $instance; + $this->Buffers[$this->Level] = ''; + $o .= $instance->Open($tag); + } + + if ($tag['is_closing']) { // not ELSE here, because tag may be and still has a handler-class + if ($this->Level == 0) { + $dump = array(); + foreach ($this->Stack as $instance) { + $dump[] = $instance->Tag; + } + print_pre($dump); + $this->Application->handleError(E_USER_ERROR, 'Closing tag without an opening: '.$this->TagInfo($tag).' - probably opening tag was removed or nested tags error', $tag['file'], $tag['line']); + } + if ($this->Stack[$this->Level]->Tag['name'] != $tag['name']) { + $opening_tag = $this->Stack[$this->Level]->Tag; + $this->Application->handleError(E_USER_ERROR, + 'Closing tag '.$this->TagInfo($tag).' does not match + opening tag at current nesting level ('.$this->TagInfo($opening_tag).' + opened at line '.$opening_tag['line'].')', $tag['file'], $tag['line']); + } + $o .= $this->Stack[$this->Level]->Close($tag); // DO NOT use $this->Level-- here because it's used inside Close + $this->Level--; + } + } + else { // regular tags - just compile + if (!$tag['is_closing']) { + $this->Application->handleError(E_USER_ERROR, 'Tag without a handler: '.$this->TagInfo($tag).' - probably missing <empty /> tag closing', $tag['file'], $tag['line']); + } + + if ($this->Level > 0) $o .= $this->Stack[$this->Level]->PassThrough($tag); + if (!$tag['processed']) { + $o .= 'CompileTag($tag)." ?>\n"; + } + } + $this->Buffers[$this->Level] .= $o; + } + + function TagInfo($tag, $with_params=false) + { + return "{$tag['prefix']}_{$tag['name']}".($with_params ? ' '.$tag['attrs'] : '').""; + } + + function CompileParamsArray($arr) + { + $to_pass = 'Array('; + foreach ($arr as $name => $val) { + $to_pass .= '"'.$name.'" => "'.str_replace('"', '\"', $val).'",'; + } + $to_pass .= ')'; + return $to_pass; + } + + function CompileTag($tag) + { + $to_pass = $this->CompileParamsArray($tag['NP']); + + $code = ''; + if ($tag['prefix'] == '__auto__') { + $prefix = $this->GetParam('PrefixSpecial'); + $code .= '$_p_ =& $_parser->GetProcessor($PrefixSpecial);'."\n"; + $code .= 'echo $_p_->ProcessParsedTag(\''.$tag['name'].'\', '.$to_pass.', "$PrefixSpecial", \''.$tag['file'].'\', '.$tag['line'].');'."\n"; + } + else { + $prefix = $tag['prefix']; + $code .= '$_p_ =& $_parser->GetProcessor("'.$tag['prefix'].'");'."\n"; + $code .= 'echo $_p_->ProcessParsedTag(\''.$tag['name'].'\', '.$to_pass.', "'.$tag['prefix'].'", \''.$tag['file'].'\', '.$tag['line'].');'."\n"; + } + if (isset($tag['NP']['result_to_var'])) { + $code .= "\$params['{$tag['NP']['result_to_var']}'] = \$_parser->GetParam('{$tag['NP']['result_to_var']}');\n"; + $code .= "\${$tag['NP']['result_to_var']} = \$params['{$tag['NP']['result_to_var']}'];\n"; + } + if ($prefix && strpos($prefix, '$') === false) { + $p =& $this->GetProcessor($prefix); + if (!$p->CheckTag($tag['name'], $tag['prefix'])) { + $this->Application->handleError(E_USER_ERROR, 'Unknown tag: '.$this->TagInfo($tag).' - incorrect tag name or prefix ', $tag['file'], $tag['line']); + } + } + return $code; + } + + function CheckTemplate($t, $silent=null) + { + $pre_parsed = $this->Application->TemplatesCache->GetPreParsed($t); + if (!$pre_parsed) { + if (!$silent) { + if ($this->Application->isDebugMode()) $this->Application->Debugger->appendTrace(); + trigger_error("Cannot include $t - file does not exist", E_USER_ERROR); + } + return false; + } + if (!$pre_parsed || !$pre_parsed['active'] || defined('DBG_NPARSER_FORCE_COMPILE') && DBG_NPARSER_FORCE_COMPILE) { + $inc_parser =& new NParser(); + $inc_parser->Compile($pre_parsed); + } + return $pre_parsed; + } + + function Run($t, $silent=null) + { + $pre_parsed = $this->CheckTemplate($t, $silent); + if (!$pre_parsed) return false; + + ob_start(); + $_parser =& $this; + if ($pre_parsed['mode'] == 'file') { + include($pre_parsed['fname']); + } + else { + eval('?'.'>'.$pre_parsed['content']); + } + $output = ob_get_contents(); + ob_end_clean(); + + return $output; + } + + function &GetProcessor($prefix) + { + static $Processors = array(); + if (!isset($Processors[$prefix])) { + $Processors[$prefix] = $this->Application->recallObject($prefix.'_TagProcessor'); + } + + return $Processors[$prefix]; + } + + function SelectParam($params, $possible_names) + { + if (!is_array($params)) return; + if (!is_array($possible_names)) + + $possible_names = explode(',', $possible_names); + foreach ($possible_names as $name) + { + if( isset($params[$name]) ) return $params[$name]; + } + return false; + } + + function SetParams($params) + { + $this->Params = $params; + $keys = array_keys($this->Params); + } + + function GetParam($name) + { + return isset($this->Params[$name]) ? $this->Params[$name] : false; + } + + function SetParam($name, $value) + { + $this->Params[$name] = $value; + } + + function PushParams($params) + { + $this->ParamsStack[$this->ParamsLevel++] = $this->Params; + $this->Params = $params; + } + + function PopParams() + { + $this->Params = $this->ParamsStack[--$this->ParamsLevel]; + } + + function ParseBlock($params, $pass_params=false) + { + if ($pass_params || isset($params['pass_params'])) $params = array_merge($this->Params, $params); + $this->PushParams($params); + + if (!isset($this->Elements[$params['name']])) { + $pre_parsed = $this->Application->TemplatesCache->GetPreParsed($params['name']); + if ($pre_parsed) { + return $this->IncludeTemplate($params); + } + + if ($this->Application->isDebugMode()) { + $this->Application->Debugger->appendTrace(); + } + $trace_results = debug_backtrace(); + $this->Application->handleError(E_USER_ERROR, 'Rendering of undefined element '.$params['name'].'', $trace_results[0]['file'], $trace_results[0]['line']); + } + + $m_processor =& $this->GetProcessor('m'); + $flag_values = $m_processor->PreparePostProcess($params); + + $f_name = $this->Elements[$params['name']]; + $ret = $f_name($this, $params); + + $ret = $m_processor->PostProcess($ret, $flag_values); + + $this->PopParams(); + return $ret; + } + + function IncludeTemplate($params, $silent=null) + { + $t = is_array($params) ? $this->SelectParam($params, 't,template,block,name') : $params; + $t = eregi_replace("\.tpl$", '', $t); + + $this->PushParams($params); + $ret = $this->Run($t, $silent); + $this->PopParams(); + + return $ret; + } +} \ No newline at end of file Index: trunk/themes/default2007/platform/elements/navigation_bar.tpl =================================================================== diff -u -N -r8797 -r8860 --- trunk/themes/default2007/platform/elements/navigation_bar.tpl (.../navigation_bar.tpl) (revision 8797) +++ trunk/themes/default2007/platform/elements/navigation_bar.tpl (.../navigation_bar.tpl) (revision 8860) @@ -20,7 +20,7 @@ - "> + "> Index: trunk/core/kernel/processors/tag_processor.php =================================================================== diff -u -N -r8686 -r8860 --- trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 8686) +++ trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 8860) @@ -40,11 +40,30 @@ }*/ } - function ProcessParsedTag($tag, $params, $prefix) + function CheckTag($tag, $prefix) { $Method = $tag; if(method_exists($this, $Method)) { + return true; + } + else { + if ($this->Application->hasObject('TagsAggregator')) { + $aggregator =& $this->Application->recallObject('TagsAggregator'); + $tmp = $this->Application->processPrefix($prefix); + $tag_mapping = $aggregator->GetArrayValue($tmp['prefix'], $Method); + if ($tag_mapping) { + return true; + } + } + } + } + + function ProcessParsedTag($tag, $params, $prefix, $file='unknown', $line=0) + { + $Method = $tag; + if(method_exists($this, $Method)) + { if ($this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS')) { $this->Application->Debugger->appendHTML('Processing PreParsed Tag '.$Method.' in '.$this->Prefix); } @@ -118,14 +137,50 @@ if ($this->Application->isDebugMode()) { $this->Application->Debugger->appendTrace(); } - trigger_error('Tag '.$Method.' Undefined in '.get_class($this).'[Agregated Tag]:
'.$tag.'', E_USER_WARNING); + $this->Application->handleError(E_USER_ERROR, 'Tag '.$Method.' Undefined in '.get_class($this).'[Agregated Tag]:
'.$tag.'', $file, $line); } - trigger_error('Tag Undefined:
'.$prefix.':'.$tag.'',E_USER_WARNING); + $this->Application->handleError(E_USER_ERROR, 'Tag Undefined:
'.$prefix.':'.$tag.'', $file, $line); return false; } } + function PreparePostProcess(&$params) + { + $flags = Array('js_escape', 'result_to_var', 'pass_params', 'html_escape', 'strip_nl'); + $flag_values = Array(); + foreach ($flags as $flag_name) { + $flag_values[$flag_name] = false; + if (isset($params[$flag_name])) { + $flag_values[$flag_name] = $params[$flag_name]; + unset($params[$flag_name]); + } + } + return $flag_values; + } + + function PostProcess($ret, $flag_values) + { + if ($flag_values['js_escape']) { + $ret = addslashes($ret); + $ret = str_replace(Array("\r", "\n"), Array('\r', '\n'), $ret); + $ret = str_replace('', "", $ret); + } + if ($flag_values['html_escape']) { + $ret = htmlspecialchars($ret); + } + if ($flag_values['strip_nl']) { + // 1 - strip \r,\n; 2 - strip tabs too + $ret = preg_replace($flag_values['strip_nl'] == 2 ? "/[\r\n\t]/" : "/[\r\n]/", '', $ret); + } + if ($flag_values['result_to_var']) { + $this->Application->Parser->SetParam($flag_values['result_to_var'], $ret); + $ret = ''; + } + return $ret; + } + + /** * Not tag, method for parameter * selection from list in this TagProcessor Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r8751 -r8860 --- trunk/core/kernel/application.php (.../application.php) (revision 8751) +++ trunk/core/kernel/application.php (.../application.php) (revision 8860) @@ -29,7 +29,15 @@ */ var $Parser; + /** + * New Parser (Experimental) + * + * @var NParser + */ + var $NParser; + + /** * Holds parser output buffer * @access private * @var string @@ -507,10 +515,14 @@ $this->registerClass('kMainTagProcessor', KERNEL_PATH.'/processors/main_processor.php','m_TagProcessor', 'kTagProcessor'); $this->registerClass('kDBTagProcessor', KERNEL_PATH.'/db/db_tag_processor.php', null, 'kTagProcessor'); - $this->registerClass('TemplatesCache', KERNEL_PATH.'/parser/template.php'); + $this->registerClass('TemplatesCache', KERNEL_PATH.'/parser/template.php',null, 'kDBTagProcessor'); $this->registerClass('Template', KERNEL_PATH.'/parser/template.php'); $this->registerClass('TemplateParser', KERNEL_PATH.'/parser/template_parser.php',null, 'kDBTagProcessor'); + if (defined('NPARSER') && 'NPARSER') { + $this->registerClass('NParser', KERNEL_PATH.'/nparser/nparser.php'); + } + $this->registerClass('kEmailSendingHelper', KERNEL_PATH.'/utility/email_send.php', 'EmailSender', Array('kHelper')); $this->registerClass('kSocket', KERNEL_PATH.'/utility/socket.php', 'Socket'); @@ -727,7 +739,12 @@ $this->Debugger->appendMemoryUsage('Application before Parsing:'); } - $this->HTML = $this->Parser->ParseTemplate( $t ); + if (defined('NPARSER') && 'NPARSER') { + $this->HTML = $this->NParser->Run( $t ); + } + else { + $this->HTML = $this->Parser->ParseTemplate( $t ); + } if ($this->isDebugMode() && constOn('DBG_PROFILE_MEMORY')) { $this->Debugger->appendMemoryUsage('Application after Parsing:'); @@ -736,10 +753,22 @@ function InitParser() { - if( !is_object($this->Parser) ) { - $this->Parser =& $this->recallObject('TemplateParser'); - $this->TemplatesCache =& $this->recallObject('TemplatesCache'); + if (defined('NPARSER') && 'NPARSER') { + if( !is_object($this->NParser) ) { + $this->NParser =& $this->recallObject('NParser'); + $this->TemplatesCache =& $this->recallObject('TemplatesCache'); + + // can be removed in future +// $this->Parser =& $this->recallObject('TemplateParser'); + $this->Parser =& $this->NParser; + } } + else { + if( !is_object($this->Parser) ) { + $this->Parser =& $this->recallObject('TemplateParser'); + $this->TemplatesCache =& $this->recallObject('TemplatesCache'); + } + } } /** @@ -1017,6 +1046,10 @@ function ProcessParsedTag($prefix, $tag, $params) { + if (defined('NPARSER') && NPARSER) { + $p = $this->Parser->GetProcessor($prefix); + return $p->ProcessParsedTag($tag, $params, $prefix); + } $a_tag = new Tag('',$this->Parser); $a_tag->Tag = $tag; @@ -2113,7 +2146,17 @@ fclose($fp); } - if( !$this->errorHandlers ) return true; + if( !$this->errorHandlers ) { + if ($errno == E_USER_ERROR) { + header('HTTP/1.0 500 Script Fatal Error'); + echo ('
+ Fatal Error: + '."$errstr in $errfile on line $errline".' +
'); + exit; + } + return true; + } $i = 0; // while (not foreach) because it is array of references in some cases $eh_count = count($this->errorHandlers); Index: trunk/core/kernel/globals.php =================================================================== diff -u -N -r8605 -r8860 --- trunk/core/kernel/globals.php (.../globals.php) (revision 8605) +++ trunk/core/kernel/globals.php (.../globals.php) (revision 8860) @@ -551,4 +551,28 @@ return ($ip >= $from && $ip <= $to); } } + + function request_headers() + { + if(function_exists("apache_request_headers")) // If apache_request_headers() exists... + { + if($headers = apache_request_headers()) // And works... + { + return $headers; // Use it + } + } + + $headers = array(); + + foreach(array_keys($_SERVER) as $skey) + { + if(substr($skey, 0, 5) == "HTTP_") + { + $headername = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($skey, 0, 5))))); + $headers[$headername] = $_SERVER[$skey]; + } + } + + return $headers; + } ?> \ No newline at end of file Index: trunk/core/kernel/utility/debugger.php =================================================================== diff -u -N -r8605 -r8860 --- trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 8605) +++ trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 8860) @@ -1041,8 +1041,11 @@ $dbg_path = str_replace(FULL_PATH, '', $this->tempFolder); ob_start(); + // the