Index: branches/RC/core/kernel/nparser/nparser.php =================================================================== diff -u -N -r11297 -r11336 --- branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 11297) +++ branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 11336) @@ -84,7 +84,7 @@ function CompileRaw($data, $t_name, $template_name = 'unknown') { $code = "extract (\$_parser->Params);\n"; - $code .= "\$_parser->ElementLocations['{$template_name}'] = Array('file' => '{$t_name}', 'start_pos' => 0, 'end_pos' => " . strlen($data) . ");\n"; + $code .= "\$_parser->ElementLocations['{$template_name}'] = Array('template' => '{$template_name}', 'start_pos' => 0, 'end_pos' => " . strlen($data) . ");\n"; // $code .= "__@@__DefinitionsMarker__@@__\n"; @@ -106,6 +106,7 @@ 'line' => substr_count(substr($data, 0, $tag_data[2][1]), "\n")+1, 'pos' => $tag_data[2][1], 'file' => $t_name, + 'template' => $template_name, ); // the idea is to count number of comment openings and closings before current tag @@ -313,8 +314,16 @@ } return false; } - if (!$pre_parsed || !$pre_parsed['active'] || defined('DBG_NPARSER_FORCE_COMPILE') && DBG_NPARSER_FORCE_COMPILE) { + + $force_compile = defined('DBG_NPARSER_FORCE_COMPILE') && DBG_NPARSER_FORCE_COMPILE; + if (!$pre_parsed || !$pre_parsed['active'] || $force_compile) { $inc_parser = new NParser(); + + if ($force_compile) { + // remove Front-End theme markings during total compilation + $t = preg_replace('/^theme:.*?\//', '', $t); + } + if (!$inc_parser->Compile($pre_parsed, $t)) return false; } return $pre_parsed; @@ -441,14 +450,15 @@ return $ret; } - return defined('DBG_DECORATE_BLOCKS') && DBG_DECORATE_BLOCKS ? $this->DecorateBlock($ret, $params, true) : $ret; + return defined('EDITING_MODE') ? $this->DecorateBlock($ret, $params, true) : $ret; } 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']); + return false; } $m_processor =& $this->GetProcessor('m'); @@ -472,16 +482,71 @@ return $ret; } - return defined('DBG_DECORATE_BLOCKS') && DBG_DECORATE_BLOCKS ? $this->DecorateBlock($ret, $params) : $ret; + return defined('EDITING_MODE') ? $this->DecorateBlock($ret, $params) : $ret; } function DecorateBlock($block_content, $block_params, $is_template = false) { static $used_ids = Array (); + static $edit_insides = null; + + if (!isset($edit_insides)) { + $edit_insides = $this->Application->GetVar('edit_insides'); + } + +// $prepend = '[name: ' . $block_params['name'] . '] [params: ' . implode(', ', array_keys($block_params)) . ']'; + + $decorate = false; + + if ($is_template) { + // content inside pair RenderElement tag +// $prepend = 'CONTENT_OF_DESIGN: ' . $prepend; + + if ($edit_insides && (EDITING_MODE == EDITING_MODE_CMS)) { + $decorate = true; + } + } + else { + if (strpos($block_params['name'], '__capture_') === 0) { + // capture tag (usually inside pair RenderElement) +// $prepend = 'CAPTURE: ' . $prepend; + + if ($edit_insides && (EDITING_MODE == EDITING_MODE_CMS)) { + $decorate = true; + } + } + elseif (array_key_exists('content', $block_params)) { + // pair RenderElement (on template, were it's used) +// $prepend = 'PAIR_RENDER_ELEMENT: ' . $prepend; + + if (EDITING_MODE == EDITING_MODE_DESIGN) { + $decorate = true; + } + } + else { + // non-pair RenderElement +// $prepend = 'SINGLE_RENDER_ELEMENT: ' . $prepend; + + if ($edit_insides && (EDITING_MODE == EDITING_MODE_CMS)) { + $decorate = true; + } + + if (array_key_exists('layout_view', $block_params) && $block_params['layout_view'] && (EDITING_MODE == EDITING_MODE_LAYOUT)) { + $decorate = true; + } + } + } + + if (!$decorate) { + return $block_content; + } + else { + $block_content = /*$prepend .*/ $block_content; + } + $block_name = $block_params['name']; $function_name = $is_template ? $block_name : $this->Elements[$block_name]; - $element_location = $this->ElementLocations[$function_name]; // ensure unique id for every div (used from print lists) $container_num = 1; @@ -494,7 +559,7 @@ $used_ids[] = $container_id; // prepare parameter string - $param_string = "$block_name:$function_name:{$element_location['file']}:{$element_location['start_pos']}:{$element_location['end_pos']}"; + $param_string = $block_name . ':' . $function_name; $block_editor = '
edit
%s