Index: branches/5.0.x/core/kernel/processors/main_processor.php =================================================================== diff -u -r12299 -r12323 --- branches/5.0.x/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 12299) +++ branches/5.0.x/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 12323) @@ -1,6 +1,6 @@ Tag=='include') $tag->Tag='MyInclude'; - return parent::ProcessTag($tag); - } - - /** * Base folder for all template includes * * @param Array $params @@ -219,54 +206,34 @@ } /** - * Returns block parameter by name + * Returns block parameter by name (used only as "check" parameter value for "m_if" tag !) * * @param Array $params * @return stirng * @access public */ function Param($params) { - //$parser =& $this->Application->recallObject('TemplateParser'); $name = $params['name']; - if (isset($this->Application->LateParsed[$name])) { + + /*if (isset($this->Application->LateParsed[$name])) { $f = $this->Application->PreParsedBlocks['capture_'.$name.$this->Application->LateParsed[$name]]; $this->Application->Parser->SetParam($name, $f(array())); - } + }*/ $res = $this->Application->Parser->GetParam($params['name']); - if ($res === false) $res = ''; - if (isset($params['plus'])) + if ($res === false) { + $res = ''; + } + + if (isset($params['plus'])) { $res += $params['plus']; + } + return $res; } - function DefaultParam($params) - { - foreach ($params as $key => $val) { - if ($this->Application->Parser->GetParam($key) === false) { - $this->Application->Parser->SetParam($key, $val); - } - } - } - /** - * Gets value of specified field from specified prefix_special and set it as parser param - * - * @param Array $params - */ - /*function SetParam($params) - { - // - list($prefix_special, $field_name) = explode(':', $params['src']); - - $object =& $this->Application->recallObject($prefix_special); - $name = $this->SelectParam($params, 'param,name,var'); - - $this->Application->Parser->SetParam($name, $object->GetField($field_name) ); - }*/ - - /** * Compares block parameter with value specified * * @param Array $params @@ -275,9 +242,9 @@ */ function ParamEquals($params) { - //$parser =& $this->Application->recallObject('TemplateParser'); $name = $this->SelectParam($params, 'name,var,param'); $value = $params['value']; + return ($this->Application->Parser->GetParam($name) == $value); } @@ -381,7 +348,9 @@ */ function GetConst($params) { - return defined($this->SelectParam($params, 'name,const')) ? constant($this->SelectParam($params, 'name,const,param')) : ''; + $constant_name = $this->SelectParam($params, 'name,const'); + + return defined($constant_name) ? constant($constant_name) : ''; } /** @@ -599,75 +568,6 @@ } } - /** - * Includes template - * and returns it's - * parsed version - * - * @param Array $params - * @return string - * @access public - */ - function MyInclude($params) - { - if (defined('NPARSER') && NPARSER) { - return $this->Application->Parser->IncludeTemplate($params, isset($params['is_silent']) ? 1 : 0); - } - - $BlockParser =& $this->Application->makeClass('TemplateParser'); - /* @var $BlockParser TemplateParser */ - -// $BlockParser->SetParams($params); - $parser =& $this->Application->Parser; - $this->Application->Parser =& $BlockParser; - - // this is for the parser to know the master template in case an error occurs, - // ParseTemplate will reset it anyway, but this will allow error handler to display the tempalte - // which tries to include missing template for example - $this->Application->Parser->TemplateName = $parser->TemplateName; - - $t = $this->SelectParam($params, 't,template,block,name'); - $t = eregi_replace("\.tpl$", '', $t); - - if (!$t) { - trigger_error('Template name not specified in <inp2:m_include .../> tag', E_USER_ERROR); - } - - 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']) && $params['data_exists']) || isset($params['block_no_data']))) { - if ($block_no_data = getArrayValue($params, 'block_no_data')) { - 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; - } - function ModuleInclude($params) { $ret = ''; @@ -710,7 +610,8 @@ if ($no_data) { $block_params['block_no_data'] = $module_prefix.'/'.$no_data; } - $ret .= $this->MyInclude($block_params); + + $ret .= $this->Application->Parser->IncludeTemplate($block_params, isset($block_params['is_silent']) ? 1 : 0); } return $ret; @@ -721,67 +622,7 @@ return $this->Application->isModuleEnabled( $params['module'] ); } - /*function Kernel_Scripts($params) - { - return ''; - }*/ - - - /*function GetUserPermission($params) - { - // echo"GetUserPermission $params[name]"; - if ($this->Application->RecallVar('user_type') == 1) - return 1; - else { - $perm_name = $params[name]; - $aPermissions = unserialize($this->Application->RecallVar('user_permissions')); - if ($aPermissions) - return $aPermissions[$perm_name]; - } - }*/ - - /** - * Set's parser block param value - * - * @param Array $params - * @access public - */ - function AddParam($params) - { - $parser =& $this->Application->Parser; // recallObject('TemplateParser'); - foreach ($params as $param => $value) { - $this->Application->SetVar($param, $value); - $parser->SetParam($param, $value); - $parser->AddParam('/\$'.$param.'/', $value); - } - } - - /*function ParseToVar($params) - { - $var = $params['var']; - $tagdata = $params['tag']; - $parser =& $this->Application->Parser; //recallObject('TemplateParser'); - $res = $this->Application->ProcessTag($tagdata); - - $parser->SetParam($var, $res); - $parser->AddParam('/\$'.$var.'/', $res); - return ''; - }*/ - - /*function TagNotEmpty($params) - { - $tagdata = $params['tag']; - $res = $this->Application->ProcessTag($tagdata); - return $res != ''; - }*/ - - /*function TagEmpty($params) - { - return !$this->TagNotEmpty($params); - }*/ - - /** * Checks if debug mode is on * * @param Array $params @@ -790,10 +631,10 @@ */ function IsDebugMode($params) { - return $this->Application->isDebugMode(); + return defined('DEBUG_MODE') && $this->Application->isDebugMode(); } - function MassParse($params) + /*function MassParse($params) { $qty = $params['qty']; $block = $params['block']; @@ -833,7 +674,7 @@ $o.= $this->Application->ParseBlock($block_params, 1); } return $o; - } + }*/ function LoggedIn($params) {