From 97352856365926445f034732fc0049d446e46a3d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 6 Sep 2007 12:00:02 +0000 Subject: [PATCH] fixed not working autorepeated rows with , added id's to (content of) labels and images --- etemplate/inc/class.boetemplate.inc.php | 6 +++--- etemplate/inc/class.uietemplate.inc.php | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/etemplate/inc/class.boetemplate.inc.php b/etemplate/inc/class.boetemplate.inc.php index 3411ec8a28..e1e4be9d8b 100644 --- a/etemplate/inc/class.boetemplate.inc.php +++ b/etemplate/inc/class.boetemplate.inc.php @@ -194,11 +194,11 @@ * @param boolean $check_col to check for col- or row-autorepeat * @return boolean true if cell is autorepeat (has index with vars / '$') or false otherwise */ - function autorepeat_idx($cell,$c,$r,&$idx,&$idx_cname,$check_col=False) + function autorepeat_idx($cell,$c,$r,&$idx,&$idx_cname,$check_col=False,$cont=null) { $org_idx = $idx = $cell[ $cell['type'] == 'template' ? 'size' : 'name' ]; - $idx = $this->expand_name($idx,$c,$r); + $idx = $this->expand_name($idx,$c,$r,'','',$cont); if (!($komma = strpos($idx,','))) { $idx_cname = $idx; @@ -222,7 +222,7 @@ else { $Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' || - substr($pat,0,4) == 'row_' && substr($pat,0,8) != 'row_cont'); + substr($pat,0,4) == 'row_'); } } if ($this->name && $this->name == $this->debug) diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php index 21067e6e6e..8326e2397b 100644 --- a/etemplate/inc/class.uietemplate.inc.php +++ b/etemplate/inc/class.uietemplate.inc.php @@ -664,9 +664,9 @@ foreach($sess as $key => $val) { if (!(list($r_key) = each($data))) // no further row { - if (!(($this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname) && $idx_cname) || - (substr($cols['A']['type'],1) == 'box' && $this->autorepeat_idx($cols['A'][1],0,$r,$idx,$idx_cname) && $idx_cname) || - ($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname) && $idx_cname)) || + if (!(($this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname,false,$content) && $idx_cname) || + (substr($cols['A']['type'],1) == 'box' && $this->autorepeat_idx($cols['A'][1],0,$r,$idx,$idx_cname,false,$content) && $idx_cname) || + ($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname,false,$content) && $idx_cname)) || !$this->isset_array($content,$idx_cname)) { break; // no auto-row-repeat @@ -706,7 +706,7 @@ foreach($sess as $key => $val) // otherwise the rows have a differen number of cells and it saved a lot checks if ($c >= $max_cols) { - if (!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True) || + if (!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True,$content) || !$this->isset_array($content,$idx)) { break; // no auto-col-repeat @@ -1015,7 +1015,8 @@ foreach($sess as $key => $val) if ($activate_links) $value = $this->html->activate_links($value); if ($value != '' && $style && strpos($style,'b')!==false) $value = $this->html->bold($value); if ($value != '' && $style && strpos($style,'i')!==false) $value = $this->html->italic($value); - $html .= $value; + // if the label has a name, use it as id in a span, to allow addressing it via javascript + $html .= ($name ? '' : '').$value.($name ? '' : ''); if ($help) { $class = array( @@ -1039,6 +1040,7 @@ foreach($sess as $key => $val) } if (($type == 'float' || !is_numeric($pre)) && $value && $pre) { + $value = str_replace(array(' ',','),array('','.'),$value); $value = is_numeric($pre) ? round($value,$pre) : sprintf($pre,$value); } $cell_options .= ',,'.($cell['type'] == 'int' ? '/^-?[0-9]*$/' : '/^-?[0-9]*[,.]?[0-9]*$/'); @@ -1279,7 +1281,7 @@ foreach($sess as $key => $val) { echo "

show_cell::template(tpl=$this->name,name=$cell[name]): $obj_read, readonly=$readonly

\n"; } - if ($this->autorepeat_idx($cell,$show_c,$show_row,$idx,$idx_cname) || $cell_options != '') + if ($this->autorepeat_idx($cell,$show_c,$show_row,$idx,$idx_cname,false,$content) || $cell_options != '') { if ($span == '' && isset($content[$idx]['span'])) { // this allows a colspan in autorepeated cells like the editor @@ -1429,7 +1431,7 @@ foreach($sess as $key => $val) } } break; - case 'image': // size: [link],[link_target],[imagemap],[link_popup] + case 'image': // size: [link],[link_target],[imagemap],[link_popup],[id] $image = $value != '' ? $value : $name; list($app,$img) = explode('/',$image,2); if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false) @@ -1439,10 +1441,11 @@ foreach($sess as $key => $val) } if (!$readonly) { - list($extra_link,$extra_link_target,$imagemap,$extra_link_popup) = explode(',',$cell['size']); + list($extra_link,$extra_link_target,$imagemap,$extra_link_popup,$id) = explode(',',$cell['size']); } $html .= $this->html->image($app,$img,strlen($label) > 1 && !$cell['no_lang'] ? lang($label) : $label, - 'border="0"'.($imagemap?' usemap="'.$this->html->htmlspecialchars($imagemap).'"':'')); + 'border="0"'.($imagemap?' usemap="'.$this->html->htmlspecialchars($imagemap).'"':''). + ($id || $value ? ' id="'.($id ? $id : $name).'"' : '')); $extra_label = False; break; case 'file': // size: size of the filename field