Index: trunk/core/kernel/processors/main_processor.php =================================================================== diff -u -N -r8178 -r8358 --- trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 8178) +++ trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 8358) @@ -42,6 +42,15 @@ } else { $path = substr(THEMES_PATH, 1); + $module = isset($params['module']) ? $params['module'] : 'core'; + + if (strtolower($module) == 'in-portal') { + $module_folder = 'platform'; + } + else { + $module_folder = $this->Application->findModule('Name', $module, 'TemplatePath'); + } + $path .= '/'.trim($module_folder, '/').'/'; } return $this->Application->BaseURL().$path; } @@ -547,6 +556,8 @@ function MyInclude($params) { $BlockParser =& $this->Application->makeClass('TemplateParser'); + /* @var $BlockParser TemplateParser */ + // $BlockParser->SetParams($params); $parser =& $this->Application->Parser; $this->Application->Parser =& $BlockParser; @@ -563,21 +574,38 @@ trigger_error('Template name not specified in <inp2:m_include .../> tag', E_USER_ERROR); } - $res = $BlockParser->ParseTemplate( $t, 1, $params, isset($params['is_silent']) ? 1 : 0 ); - + if (isset($this->Application->PreParsedBlocks[$t]) ) { + $params['name'] = $t; + $res = $this->Application->ParseBlock($params); + } + else { + $res = $BlockParser->ParseTemplate($t, 1, $params, isset($params['is_silent']) ? 1 : 0 ); + } + if ( !$BlockParser->DataExists && (isset($params['data_exists']) || isset($params['block_no_data'])) ) { if ($block_no_data = getArrayValue($params, 'block_no_data')) { - $res = $BlockParser->Parse( - $this->Application->TemplatesCache->GetTemplateBody($block_no_data, getArrayValue($params, 'is_silent') ), - $t - ); + if (isset($this->Application->PreParsedBlocks[$block_no_data]) ) { + // block_no_data is another block name + $res = $this->Application->ParseBlock(Array('name' => $block_no_data)); + } + else { + // block_no_data is template name (only looks through real templates) + $res = $BlockParser->ParseTemplate($block_no_data, 1, Array(), getArrayValue($params, 'is_silent')); + } } else { $res = ''; } } + $this->Application->Parser =& $parser; $this->Application->Parser->DataExists = $this->Application->Parser->DataExists || $BlockParser->DataExists; + + if (isset($params['return_params']) && $params['return_params']) { + $new_params = array_merge($this->Application->Parser->Params, $BlockParser->ParamsStack[0]); + $this->Application->Parser->SetParams($new_params, false); + } + return $res; } @@ -591,10 +619,10 @@ $module_key = strtolower($module_name); if ($module_name == 'In-Portal') { - $module_prefix = $this->Application->IsAdmin() ? 'in-portal/' : ''; + $module_prefix = $this->Application->IsAdmin() ? 'in-portal/' : $module_data['TemplatePath']; } else { - $module_prefix = $this->Application->IsAdmin() ? $module_key.'/' : $module_data['TemplatePath'].'/'; + $module_prefix = $this->Application->IsAdmin() ? $module_key.'/' : rtrim($module_data['TemplatePath'], '/').'/'; } $block_params['t'] = $module_prefix.$this->SelectParam($params, $module_key.'_template,'.$module_key.'_t,template,t'); @@ -689,15 +717,35 @@ function RenderElement($params) { + if (isset($params['design']) && $params['design']) { + $block_name = $params['name']; + if ($block_name != '__this__') { + $block_params['name'] = $block_name; + $block_params['content'] = $this->MyInclude( Array('template' => $params['name'], 'return_params' => 1, 'strip_nl' => 2) ); + + if ( !$this->Application->Parser->DataExists && (isset($params['data_exists']) || isset($params['block_no_data'])) ) { + if ($block_no_data = getArrayValue($params, 'block_no_data')) { + $block_params['content'] = $this->MyInclude(Array('template' => $block_no_data)); + } + else { + return ''; + } + } + } + + $block_params['name'] = $params['design']; + return $this->Application->ParseBlock($block_params, 1); + } + return $this->ParseBlock($params); } function RenderElements($params) { if (!isset($params['elements']) || !$params['elements']) return; - $elements = explode(',',$params['elements']); + $elements = explode(',', $params['elements']); if (isset($params['skip']) && $params['skip']) { - $tmp_skip = explode(',',$params['skip']); + $tmp_skip = explode(',', $params['skip']); foreach ($tmp_skip as $elem) { $skip[] = trim($elem); } @@ -710,10 +758,10 @@ foreach ($elements as $an_element) { $cur = trim($an_element); - if (in_array($cur,$skip)) continue; + if (in_array($cur,$skip) || !$cur) continue; $pass_params = $params; $pass_params['name'] = $cur; - $o .= $this->ParseBlock($pass_params); + $o .= $this->RenderElement($pass_params); } return $o;