Index: branches/RC/core/units/admin/admin_tag_processor.php =================================================================== diff -u -r11149 -r11214 --- branches/RC/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 11149) +++ branches/RC/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 11214) @@ -802,19 +802,40 @@ function PrintCompileErrors($params) { - $errors = unserialize($this->Application->RecallVar('compile_errors')); - $o = ''; - $class = 'table-color1'; + $block_params = $this->prepareTagParams($params); + $block_params['name'] = $params['render_as']; + + $errors = $this->Application->RecallVar('compile_errors'); + if (!$errors) { + return ; + } + + $ret = ''; + $errors = unserialize($errors); + foreach ($errors as $an_error) { - $f = str_replace(FULL_PATH, '', $an_error['file']); - $o .= ""; - $class = $class == 'table-color1' ? 'table-color2' : 'table-color1'; + $block_params['file'] = str_replace(FULL_PATH, '', $an_error['file']); + $block_params['line'] = $an_error['line']; + $block_params['message'] = $an_error['msg']; + + $ret .= $this->Application->ParseBlock($block_params); } - $o .= '
FileLineMessage
{$f}{$an_error['line']}{$an_error['msg']}
'; + $this->Application->RemoveVar('compile_errors'); - return $o; + + return $ret; } + function CompileErrorCount($params) + { + $errors = $this->Application->RecallVar('compile_errors'); + if (!$errors) { + return 0; + } + + return count( unserialize($errors) ); + } + function ExportData($params) { $export_helper =& $this->Application->recallObject('CSVHelper'); Index: branches/RC/core/kernel/nparser/ntags.php =================================================================== diff -u -r11067 -r11214 --- branches/RC/core/kernel/nparser/ntags.php (.../ntags.php) (revision 11067) +++ branches/RC/core/kernel/nparser/ntags.php (.../ntags.php) (revision 11214) @@ -158,6 +158,11 @@ { $o = parent::Open($tag); + if ($o === false) { + // some required params not passed + return $o; + } + $f_name = $tag['NP']['name'].'_'.abs(crc32($tag['file'])).'_'.$tag['line']; $this->Tag['function_name'] = $f_name; // for later use in closing tag @@ -318,6 +323,11 @@ { $o = parent::Open($tag); + if ($o === false) { + // some required params not passed + return $o; + } + $capture_params = $tag['NP']; $capture_params['name'] = '__capture_' . $tag['NP']['name']; @@ -374,6 +384,12 @@ function Open($tag) { $o = parent::Open($tag); + + if ($o === false) { + // some required params not passed + return $o; + } + $to_pass = $this->Parser->CompileParamsArray($tag['NP']); $code[] = "\$_splited = \$_parser->SplitTag(array('tag'=>\"{$tag['NP']['check']}\", 'file'=>'{$tag['file']}', 'line'=>{$tag['line']}));"; Index: branches/RC/core/kernel/nparser/compiler.php =================================================================== diff -u -r10098 -r11214 --- branches/RC/core/kernel/nparser/compiler.php (.../compiler.php) (revision 10098) +++ branches/RC/core/kernel/nparser/compiler.php (.../compiler.php) (revision 11214) @@ -26,12 +26,13 @@ $save_handler = $this->Application->errorHandlers[0]; $this->Application->errorHandlers[0] = array(&$this, 'SaveError'); - safeDefine('DBG_NPARSER_FORCE_COMPILE',1); + 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']); + + $this->Application->Parser->CheckTemplate($a_template['module'] . '/' . $a_template['path']); $i++; } @@ -57,10 +58,35 @@ function FindTemplates() { - $this->Templates = array(); - foreach ($this->Application->ModuleInfo as $module=>$options) { - $this->FindTemplateFiles('/'.$options['Path'].'admin_templates', $options); + $this->Templates = Array (); + + // find admin templates + foreach ($this->Application->ModuleInfo as $module => $options) { + if ($module == 'In-Portal') { + // don't check In-Portal admin templates, because it doesn't have them + continue; + } + + $template_path = '/' . $options['Path'] . 'admin_templates'; + $options['Path'] = $template_path; + + $this->FindTemplateFiles($template_path, $options); } + + // find Front-End templates + $sql = 'SELECT Name + FROM ' . $this->Application->getUnitOption('theme', 'TableName'); + $themes = $this->Conn->GetCol($sql); + + $options = Array (); + foreach ($themes as $theme_name) { + $template_path = '/themes/' . $theme_name; + $options['Name'] = 'theme:' . $theme_name; + $options['Path'] = $template_path; + + $this->FindTemplateFiles($template_path, $options); + } + return $this->Templates; } @@ -80,7 +106,7 @@ else { $info = pathinfo($full_path); if (isset($info['extension']) && $info['extension'] == 'tpl') { - $this->Templates[] = array('module' => mb_strtolower($options['Name']), 'path' => str_replace(FULL_PATH.'/'.$options['Path'].'admin_templates/', '', preg_replace('/\.tpl$/', '', $full_path))); + $this->Templates[] = array('module' => mb_strtolower($options['Name']), 'path' => str_replace(FULL_PATH . $options['Path'] . '/', '', preg_replace('/\.tpl$/', '', $full_path))); } } } Index: branches/RC/core/admin_templates/tools/compile_complete.tpl =================================================================== diff -u -r10027 -r11214 --- branches/RC/core/admin_templates/tools/compile_complete.tpl (.../compile_complete.tpl) (revision 10027) +++ branches/RC/core/admin_templates/tools/compile_complete.tpl (.../compile_complete.tpl) (revision 11214) @@ -1,13 +1,52 @@ - + + - + + + + + + + +
+ +
- Errors:

+
+ + + + - + + + + + -
Errors ():
FileLineMessage
+ + + + + + + + + +
+ \ No newline at end of file Index: branches/RC/core/kernel/parser/template.php =================================================================== diff -u -r10098 -r11214 --- branches/RC/core/kernel/parser/template.php (.../template.php) (revision 10098) +++ branches/RC/core/kernel/parser/template.php (.../template.php) (revision 11214) @@ -129,6 +129,10 @@ } $path = MODULES_PATH.'/'.mb_strtolower($first_dir).'/admin_templates'; } + elseif (preg_match('/^theme:(.*)/', $first_dir, $regs)) { + // ability to use Front-End templates in admin + $path = FULL_PATH . '/themes/' . $regs[1]; + } else { $path = $this->BasePath; $module_filename = $first_dir.'/'.$module_filename; Index: branches/RC/core/kernel/nparser/nparser.php =================================================================== diff -u -r11107 -r11214 --- branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 11107) +++ branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 11214) @@ -49,14 +49,19 @@ { $data = file_get_contents($pre_parsed['tname']); - $this->CompileRaw($data, $pre_parsed['tname'], $template_name); + if (!$this->CompileRaw($data, $pre_parsed['tname'], $template_name)) { + // compilation failed during errors in template +// trigger_error('Template "' . $template_name . '" not compiled because of errors', E_USER_WARNING); + return false; + } - // saving compiled version + // saving compiled version (only when compilation was successful) $compiled = fopen($pre_parsed['fname'], 'w'); if (!fwrite($compiled, $this->Buffers[0])) { trigger_error('Saving compiled template failed', E_USER_ERROR); } fclose($compiled); + return true; } @@ -130,6 +135,8 @@ $this->Buffers[$this->Level] = preg_replace('//s', '', $this->Buffers[$this->Level]); // remove hidden comments IB#23065 // $this->Buffers[$this->Level] .= 'CacheEnd();\n}\n"." ?".">\n"; // $this->Buffers[$this->Level] = str_replace('__@@__DefinitionsMarker__@@__', $this->Definitions, $this->Buffers[$this->Level]); + + return true; } function SplitParamsStr($params_str) @@ -142,6 +149,7 @@ foreach ($rets AS $key => $val){ $values[$val[1]] = str_replace('\\' . $val[2], $val[2], $val[3]); } + return $values; } @@ -156,13 +164,17 @@ $splited['prefix'] = $parts[2] ? $parts[1] : '__auto__'; $splited['name'] = $parts[2] ? $parts[2] : $parts[1]; $splited['attrs'] = $parts[3]; + return $splited; } function ProcessTag($tag) { $splited = $this->SplitTag($tag); - if ($splited === false) return false; + if ($splited === false) { + return false; + } + $tag = array_merge($tag, $splited); $tag['processed'] = false; $tag['NP'] = $this->SplitParamsStr($tag['attrs']); @@ -179,7 +191,9 @@ $this->Buffers[$this->Level] = ''; $this->Cachable[$this->Level] = true; $open_code = $instance->Open($tag); - if ($open_code === false) return false; + if ($open_code === false) { + return false; + } $o .= $open_code; }