fixed not working autorepeated rows with , added id's to (content of) labels and images

This commit is contained in:
Ralf Becker 2007-09-06 12:00:02 +00:00
parent 47994931b8
commit 9735285636
2 changed files with 15 additions and 12 deletions

View File

@ -194,11 +194,11 @@
* @param boolean $check_col to check for col- or row-autorepeat * @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 * @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' ]; $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,','))) if (!($komma = strpos($idx,',')))
{ {
$idx_cname = $idx; $idx_cname = $idx;
@ -222,7 +222,7 @@
else else
{ {
$Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' || $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) if ($this->name && $this->name == $this->debug)

View File

@ -664,9 +664,9 @@ foreach($sess as $key => $val)
{ {
if (!(list($r_key) = each($data))) // no further row if (!(list($r_key) = each($data))) // no further row
{ {
if (!(($this->autorepeat_idx($cols['A'],0,$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) && $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) && $idx_cname)) || ($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname,false,$content) && $idx_cname)) ||
!$this->isset_array($content,$idx_cname)) !$this->isset_array($content,$idx_cname))
{ {
break; // no auto-row-repeat 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 // otherwise the rows have a differen number of cells and it saved a lot checks
if ($c >= $max_cols) 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)) !$this->isset_array($content,$idx))
{ {
break; // no auto-col-repeat break; // no auto-col-repeat
@ -1015,7 +1015,8 @@ foreach($sess as $key => $val)
if ($activate_links) $value = $this->html->activate_links($value); 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,'b')!==false) $value = $this->html->bold($value);
if ($value != '' && $style && strpos($style,'i')!==false) $value = $this->html->italic($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 ? '<span id="'.$name.'">' : '').$value.($name ? '</span>' : '');
if ($help) if ($help)
{ {
$class = array( $class = array(
@ -1039,6 +1040,7 @@ foreach($sess as $key => $val)
} }
if (($type == 'float' || !is_numeric($pre)) && $value && $pre) if (($type == 'float' || !is_numeric($pre)) && $value && $pre)
{ {
$value = str_replace(array(' ',','),array('','.'),$value);
$value = is_numeric($pre) ? round($value,$pre) : sprintf($pre,$value); $value = is_numeric($pre) ? round($value,$pre) : sprintf($pre,$value);
} }
$cell_options .= ',,'.($cell['type'] == 'int' ? '/^-?[0-9]*$/' : '/^-?[0-9]*[,.]?[0-9]*$/'); $cell_options .= ',,'.($cell['type'] == 'int' ? '/^-?[0-9]*$/' : '/^-?[0-9]*[,.]?[0-9]*$/');
@ -1279,7 +1281,7 @@ foreach($sess as $key => $val)
{ {
echo "<p>show_cell::template(tpl=$this->name,name=$cell[name]): $obj_read, readonly=$readonly</p>\n"; echo "<p>show_cell::template(tpl=$this->name,name=$cell[name]): $obj_read, readonly=$readonly</p>\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'])) if ($span == '' && isset($content[$idx]['span']))
{ // this allows a colspan in autorepeated cells like the editor { // this allows a colspan in autorepeated cells like the editor
@ -1429,7 +1431,7 @@ foreach($sess as $key => $val)
} }
} }
break; break;
case 'image': // size: [link],[link_target],[imagemap],[link_popup] case 'image': // size: [link],[link_target],[imagemap],[link_popup],[id]
$image = $value != '' ? $value : $name; $image = $value != '' ? $value : $name;
list($app,$img) = explode('/',$image,2); list($app,$img) = explode('/',$image,2);
if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false) if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false)
@ -1439,10 +1441,11 @@ foreach($sess as $key => $val)
} }
if (!$readonly) 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, $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; $extra_label = False;
break; break;
case 'file': // size: size of the filename field case 'file': // size: size of the filename field