some etemplate fixes:

- date-widget does no longer set extension-data if readonly (not used and can conflict with other widgets using the same name, as it was the problem in PM)
- select-widget: fix for "can not unselect the last category"
- red error-messages have now a "white-space: nowrap" for nice formatting
- confirm-message did not quote single quotes (') correct, which caused the complete confirm dialog to fail and allways execute the button
- readonly textarea's without column and row specification are rendered now as <pre></pre> to only take space needed
This commit is contained in:
Ralf Becker 2006-08-12 06:15:32 +00:00
parent 0c13c33fd2
commit d1d4bc610e
3 changed files with 34 additions and 20 deletions

View File

@ -97,10 +97,16 @@
}
list($data_format,$options,$options2) = explode(',',$cell['size']);
if ($type == 'date-houronly' && empty($data_format)) $data_format = 'H';
$extension_data = array(
'type' => $type,
'data_format' => $data_format,
);
$readonly = $cell['readonly'] || $readonlys;
if (!$readonly) // dont set extension-data on readonly, it's not needed and can conflict with other widgets
{
$extension_data = array(
'type' => $type,
'data_format' => $data_format,
);
}
if (!$value)
{
$value = array(
@ -145,8 +151,6 @@
}
$time_0h0 = !(int)$value['H'] && !(int)$value['i'];
$readonly = $cell['readonly'] || $readonlys;
$timeformat = array(3 => 'H', 4 => 'i');
if ($this->timeformat == '12' && $readonly && $value['H'] !== '')
{
@ -327,15 +331,18 @@
}
if (!in_array($input_format,array('d','h','dh','m','hm','dhm'))) $input_format = 'dh'; // hours + days
$extension_data = array(
'type' => $cell['type'],
'data_format' => $data_format,
'unit' => ($unit = $input_format == 'd' ? 'd' : 'h'),
'input_format' => $input_format,
'hours_per_day' => $hours_per_day,
'percent_allowed'=> $percent_allowed,
'empty_not_0' => $empty_not_0,
);
if (!$readonly) // dont set extension-data on readonly, it's not needed and can conflict with other widgets
{
$extension_data = array(
'type' => $cell['type'],
'data_format' => $data_format,
'unit' => ($unit = $input_format == 'd' ? 'd' : 'h'),
'input_format' => $input_format,
'hours_per_day' => $hours_per_day,
'percent_allowed'=> $percent_allowed,
'empty_not_0' => $empty_not_0,
);
}
if ($value)
{
switch($data_format)

View File

@ -560,6 +560,6 @@
break;
}
//echo "<p>select_widget::post_process('$name',,'$extension_data',,,'$value_in'): value='$value', is_null(value)=".(int)is_null($value)."</p>\n";
return !is_null($value);
return true;
}
}

View File

@ -953,8 +953,15 @@
}
break;
case 'textarea': // Multiline Text Input, size: [rows][,cols]
$html .= $this->html->textarea($form_name,$value,
$options.$this->html->formatOptions($cell_options,'ROWS,COLS'));
if ($readonly && !$cell_options)
{
$html .= '<pre style="margin-top: 0px;">'.$this->html->htmlspecialchars($value)."</pre>\n";
}
else
{
$html .= $this->html->textarea($form_name,$value,
$options.$this->html->formatOptions($cell_options,'ROWS,COLS'));
}
if (!$readonly)
{
$GLOBALS['egw_info']['etemplate']['to_process'][$form_name] = array(
@ -1065,7 +1072,7 @@
elseif (preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/',$cell['onclick'],$matches))
{
$question = lang($matches[1]).(substr($matches[1],-1) != '?' ? '?' : ''); // add ? if not there, saves extra phrase
$onclick = preg_replace('/confirm\(["\']{1}(.*)["\']{1}\)/','confirm(\''.$question.'\')',$onclick);
$onclick = preg_replace('/confirm\(["\']{1}(.*)["\']{1}\)/','confirm(\''.addslashes($question).'\')',$onclick);
//$onclick = "return confirm('".str_replace('\'','\\\'',$this->html->htmlspecialchars($question))."');";
}
}
@ -1532,7 +1539,7 @@
// if necessary show validation-error behind field
if (isset($GLOBALS['egw_info']['etemplate']['validation_errors'][$form_name]))
{
$html .= ' <font color="red">'.$GLOBALS['egw_info']['etemplate']['validation_errors'][$form_name].'</font>';
$html .= ' <span style="color: red; white-space: nowrap;">'.$GLOBALS['egw_info']['etemplate']['validation_errors'][$form_name].'</span>';
}
// generate an extra div, if we have an onclick handler and NO children or it's an extension
//echo "<p>$this->name($this->onclick_handler:$this->no_onclick:$this->onclick_proxy): $cell[type]/$cell[name]</p>\n";