Index: trunk/kernel/units/configuration/configuration_tag_processor.php =================================================================== diff -u -N -r1566 -r4043 --- trunk/kernel/units/configuration/configuration_tag_processor.php (.../configuration_tag_processor.php) (revision 1566) +++ trunk/kernel/units/configuration/configuration_tag_processor.php (.../configuration_tag_processor.php) (revision 4043) @@ -2,63 +2,58 @@ class ConfigurationTagProcessor extends kDBTagProcessor { + + /** + * Prints list content using block specified + * + * @param Array $params + * @return string + * @access public + */ function PrintList($params) { - $params['per_page'] = -1; - $list =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List',$params); + $list =& $this->GetList($params); $id_field = $this->Application->getUnitOption($this->Prefix,'IDField'); - - if ( !($list->OriginalParams == $params) ) { - $this->Application->removeObject($this->getPrefixSpecial()); - $list =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix.'_List',$params); - } - - - $list->PerPage = -1; - + $list->Query(); $o = ''; $list->GoFirst(); - + $block_params=$this->prepareTagParams($params); - $block_params['name']=$params['block']; - $block_params['pass_params']='true'; - $block_params['IdField'] = $id_field; +// $block_params['name'] = $this->SelectParam($params, 'render_as,block'); + $block_params['pass_params'] = 'true'; + $block_params['IdField'] = $list->IDField; - $next_block=$params['full_block']; + $prev_heading = ''; + $next_block = $params['full_block']; + $this->groupRecords($list->Records, 'heading'); - $prev_title=""; - - while (!$list->EOL()) + while (!$list->EOL()) { - $nextItemPrompt=$list->Records[$list->CurrentIndex+1]['prompt']; - $thisItemPrompt=$list->Records[$list->CurrentIndex]['prompt']; - - $this_title=$list->Records[$list->CurrentIndex]['heading']; - - if ($this_title!=$prev_title){ - $prev_title=$this_title; - $section_header_params=array(); - $section_header_params['name']='config_section_header'; - $section_header_params['title']=$this->Application->Phrase($this_title); - $o.= $this->Application->ParseBlock($section_header_params, 1); + $this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET + + // using 2 blocks for drawing o row in case if current & next record titles match + $next_item_prompt = $list->Records[$list->CurrentIndex + 1]['prompt']; + $this_item_prompt = $list->GetDBField('prompt'); + + if ($next_item_prompt == $this_item_prompt) { + $curr_block = $params['half_block1']; + $next_block = $params['half_block2']; + } else { + $curr_block = $next_block; + $next_block = $params['full_block']; } - - if ($nextItemPrompt==$thisItemPrompt){ - $curr_block=$params['half_block1']; - $next_block=$params['half_block2']; - }else{ - $curr_block=$next_block; - $next_block=$params['full_block']; - } - $block_params['name']=$curr_block; + + $block_params['name'] = $curr_block; - $this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); + $block_params['show_heading'] = ($prev_heading != $list->GetDBField('heading') ) ? 1 : 0; $o.= $this->Application->ParseBlock($block_params, 1); - + $prev_heading = $list->GetDBField('heading'); $list->GoNext(); } - return $o; + + $this->Application->SetVar( $this->getPrefixSpecial().'_id', ''); + return $o; } function PrintConfList($params){ @@ -70,57 +65,29 @@ $o = ''; $list->GoFirst(); - $tmp_row=array(); + $tmp_row = Array(); - while (!$list->EOL()) - { + while (!$list->EOL()) { $rec = $list->getCurrentRecord(); - $tmp_row[0][$rec['VariableName']]=$rec['VariableValue']; - $tmp_row[0]['prompt']=$rec['prompt']; + $tmp_row[0][$rec['VariableName']] = $rec['VariableValue']; + $tmp_row[0][$rec['VariableName'].'_prompt'] = $rec['prompt']; $list->GoNext(); } $list->Records = $tmp_row; - $block_params=$this->prepareTagParams($params); - $block_params['name']=$params['block']; + $block_params = $this->prepareTagParams($params); + $block_params['name'] = $params['block']; $list->GoFirst(); return $this->Application->ParseBlock($block_params, 1); } - - function GetToEnv($params){ - - $vars = explode(',', $params['vars']); - - foreach ($vars as $key => $var){ - $val=$this->Application->GetVar($var); - if ($val) { - $this->Application->SetVar("conf_".$var, $this->myUrlEncode($val)); - } - - } - } - - function myUrlDecode($str){ - $str=str_replace(';',':', $str); - $str=str_replace('!','-', $str); - return $str; - } - - function myUrlEncode($str){ - $str=str_replace('-', '!', $str); - $str=str_replace(':', ';', $str); - return $str; - } - - function ConfigValue($params){ - + function ConfigValue($params) + { return $this->Application->ConfigValue($params['name']); - } function Error($params) @@ -131,7 +98,7 @@ $errors = $this->Application->GetVar('errormsgs'); $errors = $errors[$this->getPrefixSpecial()]; - if (isset($errors[$field])){ + if (isset($errors[$field])) { $msg = $this->Application->Phrase($errors[$field]); } else {