Index: branches/RC/kernel/admin_templates/groups/groups_edit_permissions.tpl =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/kernel/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 8929) +++ branches/RC/kernel/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 8953) @@ -63,7 +63,7 @@ - + [][]" name="[][]" value=""> [][]" name="_cb_[][]" checked onchange="update_checkbox(this, document.getElementById('[][]'));" onclick=""> Index: branches/RC/core/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 8929) +++ branches/RC/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 8953) @@ -847,6 +847,19 @@ return ''; } - } + function PrintCompileErrors($params) + { + $errors = unserialize($this->Application->RecallVar('compile_errors')); + $o = ''; + foreach ($errors as $an_error) { + $f = str_replace(FULL_PATH, '', $an_error['file']); + $o .= ""; + } + $o .= '
FileLineMessage
{$f}{$an_error['line']}{$an_error['msg']}
'; + $this->Application->RemoveVar('compile_errors'); + return $o; + } + + } ?> \ No newline at end of file Index: branches/RC/core/kernel/nparser/ntags.php =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/core/kernel/nparser/ntags.php (.../ntags.php) (revision 8929) +++ branches/RC/core/kernel/nparser/ntags.php (.../ntags.php) (revision 8953) @@ -181,6 +181,7 @@ 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']); + return false; } $code[] = "\$_splited = \$_parser->SplitTag(array('tag'=>\"{$tag['NP']['check']}\", 'file'=>'{$tag['file']}', 'line'=>{$tag['line']}));"; @@ -203,6 +204,9 @@ $this->AppendCode($o, '} else {'); $tag['processed'] = true; } + if ($tag['name'] == 'elseif') { + $tag['processed'] = true; // !!! TEMPORARY !!! + } return $o; } Index: branches/RC/admin/install/upgrades/changelog_4_2_0.txt =================================================================== diff -u -N -r8949 -r8953 --- branches/RC/admin/install/upgrades/changelog_4_2_0.txt (.../changelog_4_2_0.txt) (revision 8949) +++ branches/RC/admin/install/upgrades/changelog_4_2_0.txt (.../changelog_4_2_0.txt) (revision 8953) @@ -3,7 +3,7 @@ File in-portal/admin/install/inportal_data.sql changed File in-portal/admin/install/inportal_schema.sql changed File in-portal/admin/install/upgrades/changelog_.txt is removed; release_4_1_0 revision 1.1 -File in-portal/admin/install/upgrades/changelog_4_2_0.txt is new; release_4_2_0 revision 1.1.2.1 +File in-portal/admin/install/upgrades/changelog_4_2_0.txt is new; release_4_2_0 revision 1.1.2.2 File in-portal/admin/install/upgrades/inportal_upgrade_v4.2.0.sql is new; release_4_2_0 revision 1.1 File in-portal/admin/install/upgrades/readme_4_2_0.txt is new; release_4_2_0 revision 1.1 File in-portal/kernel/action.php changed @@ -155,6 +155,8 @@ File kernel.X/core/admin_templates/themes/themes_edit_files.tpl changed File kernel.X/core/admin_templates/themes/themes_edit_tabs.tpl changed File kernel.X/core/admin_templates/themes/themes_list.tpl changed +File kernel.X/core/admin_templates/tools/compile_complete.tpl is new; release_4_2_0 revision 1.1.2.1 +File kernel.X/core/admin_templates/tools/compile_templates.tpl is new; release_4_2_0 revision 1.1.2.1 File kernel.X/core/admin_templates/tools/skins.tpl is removed; release_4_1_0 revision 1.1.2.1 File kernel.X/core/admin_templates/tools/system_tools.tpl changed File kernel.X/core/install/english.lang changed @@ -163,6 +165,7 @@ File kernel.X/core/install/upgrades.sql changed File kernel.X/core/install/utf.php is new; release_4_2_0 revision 1.2 File kernel.X/core/install/step_templates/db_config.tpl changed +File kernel.X/core/units/admin/admin_events_handler.php changed File kernel.X/core/units/admin/admin_tag_processor.php changed File kernel.X/core/units/categories/cache_updater.php changed File kernel.X/core/units/categories/categories_config.php changed @@ -206,8 +209,10 @@ File kernel4_dev/kernel4/db/dbitem.php changed File kernel4_dev/kernel4/db/dblist.php changed File kernel4_dev/kernel4/languages/phrases_cache.php changed -File kernel4_dev/kernel4/nparser/nparser.php is new; release_4_2_0 revision 1.1 -File kernel4_dev/kernel4/nparser/ntags.php is new; release_4_2_0 revision 1.1 +File kernel4_dev/kernel4/nparser/compiler.php is new; release_4_2_0 revision 1.1.2.1 +File kernel4_dev/kernel4/nparser/nparser.php is new; release_4_2_0 revision 1.1.2.1 +File kernel4_dev/kernel4/nparser/nparser_config.php is new; release_4_2_0 revision 1.1.2.1 +File kernel4_dev/kernel4/nparser/ntags.php is new; release_4_2_0 revision 1.1.2.1 File kernel4_dev/kernel4/parser/construct_tags.php changed File kernel4_dev/kernel4/parser/tags.php changed File kernel4_dev/kernel4/parser/template.php changed @@ -309,7 +314,9 @@ File theme_portal2007/in-commerce/my_account/affiliate/affiliate_thankyou.tpl is new; release_4_2_0 revision 1.1 File theme_portal2007/in-commerce/product/details.tpl is new; release_4_2_0 revision 1.19 File theme_portal2007/in-commerce/product/readme.1st is new; release_4_2_0 revision 1.1 -File theme_portal2007/in-commerce/products/add_review.tpl is new; release_4_2_0 revision 1.4 +File theme_portal2007/in-commerce/products/add_review.tpl is new; release_4_2_0 revision 1.4.2.1 +File theme_portal2007/in-commerce/products/add_review_confirm.tpl is new; release_4_2_0 revision 1.1.2.1 +File theme_portal2007/in-commerce/products/add_review_pending_confirm.tpl is new; release_4_2_0 revision 1.1.2.1 File theme_portal2007/in-commerce/products/featured_products.tpl is new; release_4_2_0 revision 1.8 File theme_portal2007/in-commerce/products/form_options.tpl is new; release_4_2_0 revision 1.4 File theme_portal2007/in-commerce/products/manufacturer_products.tpl is new; release_4_2_0 revision 1.5 Index: branches/RC/core/units/admin/admin_events_handler.php =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 8929) +++ branches/RC/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 8953) @@ -32,6 +32,14 @@ $this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files" OR VarName = "configs_parsed" OR VarName = "sections_parsed"'); } + function OnCompileTemplates(&$event) + { + $compiler =& $this->Application->recallObject('NParserCompiler'); + /* @var $compiler NParserCompiler */ + $compiler->CompileTemplatesStep(); + $event->status = erSTOP; + } + /** * Generates sturcture for specified table * @@ -47,25 +55,25 @@ 'double' => 'double', 'numeric' => 'decimal', ); - + $table_name = $this->Application->GetVar('table_name'); if (!$table_name) { echo 'error: no table name specified'; return ; } - + if (TABLE_PREFIX && !preg_match('/^'.preg_quote(TABLE_PREFIX, '/').'(.*)/', $table_name)) { // table name without prefix, then add it $table_name = TABLE_PREFIX.$table_name; } - + if (!$this->Conn->TableFound($table_name)) { // table with prefix doesn't exist, assume that just config prefix passed -> resolve table name from it $table_name = $this->Application->getUnitOption(substr($table_name, strlen(TABLE_PREFIX)), 'TableName'); } - + $table_info = $this->Conn->Query('DESCRIBE '.$table_name); - + // 1. prepare config keys $id_field = ''; $fields = Array(); @@ -75,17 +83,17 @@ // don't put multilingual fields in config continue; } - + $field_options = Array (); - + // 1. get php field type by mysql field type foreach ($types_hash as $php_type => $db_types) { if (preg_match('/'.$db_types.'/', $field_info['Type'])) { $field_options['type'] = $php_type; break; } } - + $default_value = $field_info['Default']; if (in_array($php_type, $float_types)) { // this is float number @@ -100,36 +108,36 @@ $default_value = (float)$default_value; } } - + if (preg_match('/varchar\(([\d]+)\)/i', $field_info['Type'], $regs)) { $field_options['max_len'] = (int)$regs[1]; } - + if ($field_info['Null'] != 'YES') { $field_options['not_null'] = 1; } - + if ($field_info['Key'] == 'PRI') { $default_value = 0; $id_field = $field_info['Field']; } - + if ($php_type == 'int' && ($field_info['Null'] != 'YES' || is_numeric($default_value))) { // is integer field AND not null $field_options['default'] = (int)$default_value; } else { $field_options['default'] = $default_value; } - + $fields[ $field_info['Field'] ] = $this->transformDump($field_options); } - + $ret = stripslashes(var_export($fields, true)); $ret = preg_replace("/'(.*?)' => 'Array \((.*?), \)',/", "'\\1' => Array (\\2),", $ret); $ret = preg_replace("/\n '/", "\n\t'", $ret); $ret = "'IDField' => '".$id_field."',\n'Fields' => A".substr($ret, 1).','; - + ob_start(); ?> @@ -139,27 +147,27 @@ Close Window
highlightString($ret); ?> -
Close Window
+
Close Window
status = erSTOP; } - + function transformDump($dump) { if (is_array($dump)) { $dump = var_export($dump, true); } - + $dump = preg_replace("/,\n[ ]*/", ', ', $dump); $dump = preg_replace("/array \(\n[ ]*/", 'Array (', $dump); // replace array start $dump = preg_replace("/,\n[ ]*\),/", "),", $dump); // replace array end - + return $dump; } - + /** * Refreshes ThemeFiles & Theme tables by actual content on HDD * @@ -204,7 +212,7 @@ */ function OnStartup(&$event) { - + } /** Index: branches/RC/core/kernel/nparser/compiler.php =================================================================== diff -u -N --- branches/RC/core/kernel/nparser/compiler.php (revision 0) +++ branches/RC/core/kernel/nparser/compiler.php (revision 8953) @@ -0,0 +1,89 @@ +Application->RecallVar('templates_to_compile'); + if (!$templates) { + // build $templates + $templates = $this->FindTemplates(); + } + else { + $templates = unserialize($templates); + } + $total = count($templates); + $current = $this->Application->RecallVar('current_template_to_compile'); + if (!$current) $current = 0; + + if ($errors = $this->Application->RecallVar('compile_errors')) { + $this->Errors = unserialize($errors); + } + + $save_handler = $this->Application->errorHandlers[0]; + $this->Application->errorHandlers[0] = array(&$this, 'SaveError'); + + safeDefine('DBG_NPARSER_FORCE_COMPILE',1); + $i = $current; + $this->Application->InitParser(); + while ($i < $total && $i < ($current + 20)) { + $a_template = $templates[$i]; + $this->Application->Parser->CheckTemplate($a_template['module'].'/'.$a_template['path']); + $i++; + } + + $this->Application->errorHandlers[0] = $save_handler; + + $this->Application->StoreVar('current_template_to_compile', $i); + $this->Application->StoreVar('templates_to_compile', serialize($templates)); + $this->Application->StoreVar('compile_errors', serialize($this->Errors)); + $res = floor(($current / $total) * 100); + if ($res == 100 || $current >= $total) { + $this->Application->RemoveVar('templates_to_compile'); + $this->Application->RemoveVar('current_template_to_compile'); + $this->Application->Redirect($this->Application->GetVar('finish_template')); + } + echo $res; + } + + function SaveError($errno, $errstr, $errfile, $errline, $errcontext) + { + $this->Errors[] = array('msg'=>$errstr, 'file'=>$errfile, 'line'=>$errline); + } + + function FindTemplates() + { + $this->Templates = array(); + foreach ($this->Application->ModuleInfo as $module=>$options) { + $this->FindTemplateFiles('/'.$options['Path'].'admin_templates', $options); + } + return $this->Templates; + } + + function FindTemplateFiles($folderPath, $options) + { + // if FULL_PATH = "/" ensure, that all "/" in $folderPath are not deleted + $reg_exp = '/^'.preg_quote(FULL_PATH, '/').'/'; + $folderPath = preg_replace($reg_exp, '', $folderPath, 1); // this make sense, since $folderPath may NOT contain FULL_PATH + + $fh = opendir(FULL_PATH.$folderPath); + while (($sub_folder = readdir($fh))) { + $full_path = FULL_PATH.$folderPath.'/'.$sub_folder; + $base_name = basename($full_path); + if (is_dir($full_path) && $base_name != '.' && $base_name != '..') { + $this->FindTemplateFiles($full_path, $options); + } + else { + $info = pathinfo($full_path); + if (isset($info['extension']) && $info['extension'] == 'tpl') { + $this->Templates[] = array('module' => strtolower($options['Name']), 'path' => str_replace(FULL_PATH.'/'.$options['Path'].'admin_templates/', '', preg_replace('/\.tpl$/', '', $full_path))); + } + } + } + } + + +} \ No newline at end of file Index: branches/RC/kernel/admin_templates/incs/image_blocks.tpl =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/kernel/admin_templates/incs/image_blocks.tpl (.../image_blocks.tpl) (revision 8929) +++ branches/RC/kernel/admin_templates/incs/image_blocks.tpl (.../image_blocks.tpl) (revision 8953) @@ -133,7 +133,7 @@ " id=""> img/itemicons/"> - +
Index: branches/RC/core/admin_templates/tools/compile_complete.tpl =================================================================== diff -u -N --- branches/RC/core/admin_templates/tools/compile_complete.tpl (revision 0) +++ branches/RC/core/admin_templates/tools/compile_complete.tpl (revision 8953) @@ -0,0 +1,20 @@ + + + + + + + Errors:

+ + + + + + "> + + +
+ " class="button" onclick="window.close();"/> +
+ + \ No newline at end of file Index: branches/RC/core/admin_templates/incs/image_blocks.tpl =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/core/admin_templates/incs/image_blocks.tpl (.../image_blocks.tpl) (revision 8929) +++ branches/RC/core/admin_templates/incs/image_blocks.tpl (.../image_blocks.tpl) (revision 8953) @@ -133,7 +133,7 @@ " id=""> img/itemicons/"> - + Index: branches/RC/core/kernel/nparser/nparser.php =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 8929) +++ branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 8953) @@ -52,7 +52,9 @@ // appending any text/html data found before tag $this->Buffers[$this->Level] .= $tag_data[1][0]; if (!$this->InsideComment) { - $this->ProcessTag($tag); + if ($this->ProcessTag($tag) === false) { + return false; + } } else { $this->Buffers[$this->Level] .= $tag_data[2][0].$tag_data[3][0].$tag_data[4][0]; @@ -61,6 +63,7 @@ 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']); + return false; } // appending text data after last tag (after its closing pos), @@ -73,6 +76,7 @@ trigger_error('Saving compiled template failed', E_USER_ERROR); } fclose($compiled); + return true; } function SplitParamsStr($params_str) @@ -93,6 +97,7 @@ 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']); + return false; } $splited['prefix'] = $parts[2] ? $parts[1] : '__auto__'; @@ -103,7 +108,9 @@ function ProcessTag($tag) { - $tag = array_merge($tag, $this->SplitTag($tag)); + $splited = $this->SplitTag($tag); + if ($splited === false) return false; + $tag = array_merge($tag, $splited); $tag['processed'] = false; $tag['NP'] = $this->SplitParamsStr($tag['attrs']); @@ -117,7 +124,9 @@ /* @var $instance _BlockTag */ $this->Stack[++$this->Level] =& $instance; $this->Buffers[$this->Level] = ''; - $o .= $instance->Open($tag); + $open_code = $instance->Open($tag); + if ($open_code === false) return false; + $o .= $open_code; } if ($tag['is_closing']) { // not ELSE here, because tag may be and still has a handler-class @@ -127,14 +136,16 @@ $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']); + $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']); + return false; } 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']); + return false; } $o .= $this->Stack[$this->Level]->Close($tag); // DO NOT use $this->Level-- here because it's used inside Close $this->Level--; @@ -143,14 +154,18 @@ 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']); + return false; } if ($this->Level > 0) $o .= $this->Stack[$this->Level]->PassThrough($tag); if (!$tag['processed']) { - $o .= 'CompileTag($tag)." ?>\n"; + $compiled = $this->CompileTag($tag); + if ($compiled === false) return false; + $o .= '\n"; } } $this->Buffers[$this->Level] .= $o; + return true; } function TagInfo($tag, $with_params=false) @@ -191,6 +206,7 @@ $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 false; } } return $code; @@ -208,7 +224,7 @@ } if (!$pre_parsed || !$pre_parsed['active'] || defined('DBG_NPARSER_FORCE_COMPILE') && DBG_NPARSER_FORCE_COMPILE) { $inc_parser =& new NParser(); - $inc_parser->Compile($pre_parsed); + if (!$inc_parser->Compile($pre_parsed)) return false; } return $pre_parsed; } Index: branches/RC/core/kernel/nparser/nparser_config.php =================================================================== diff -u -N --- branches/RC/core/kernel/nparser/nparser_config.php (revision 0) +++ branches/RC/core/kernel/nparser/nparser_config.php (revision 8953) @@ -0,0 +1,11 @@ + 'nparser', + + 'EventHandlerClass' => Array('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'), + + 'RegisterClasses' => Array( + Array('pseudo'=>'NParserCompiler','class'=>'NParserCompiler','file'=>'compiler.php','build_event'=>'','require_classes'=>'kHelper'), + ), + ); Index: branches/RC/core/admin_templates/tools/compile_templates.tpl =================================================================== diff -u -N --- branches/RC/core/admin_templates/tools/compile_templates.tpl (revision 0) +++ branches/RC/core/admin_templates/tools/compile_templates.tpl (revision 8953) @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file Index: branches/RC/core/admin_templates/groups/groups_edit_permissions.tpl =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/core/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 8929) +++ branches/RC/core/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 8953) @@ -63,7 +63,7 @@ - + [][]" name="[][]" value=""> [][]" name="_cb_[][]" checked onchange="update_checkbox(this, document.getElementById('[][]'));" onclick=""> Index: branches/RC/core/admin_templates/tools/system_tools.tpl =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/core/admin_templates/tools/system_tools.tpl (.../system_tools.tpl) (revision 8929) +++ branches/RC/core/admin_templates/tools/system_tools.tpl (.../system_tools.tpl) (revision 8953) @@ -12,6 +12,11 @@ submit_event($prefix, $event); set_hidden_field('events[adm]', ''); } + + function compile_templates() + { + openwin('', 'compile', 800, 575); + } @@ -34,6 +39,15 @@ + "> + + + Compile Templates (with NParser): + + + + + "> Index: branches/RC/core/kernel/application.php =================================================================== diff -u -N -r8929 -r8953 --- branches/RC/core/kernel/application.php (.../application.php) (revision 8929) +++ branches/RC/core/kernel/application.php (.../application.php) (revision 8953) @@ -706,7 +706,7 @@ // $this->LinkVar('return_m'); // main env part to restore after popup will be closed (from finalizePopup) } - if ($this->GetVar('ajax') == 'yes') { + if ($this->GetVar('ajax') == 'yes' && !$this->GetVar('debug_ajax')) { // hide debug output from ajax requests automatically define('DBG_SKIP_REPORTING', 1); }