From d1d4bc610efac70ce5d1754f3206852db7b7fb28 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 12 Aug 2006 06:15:32 +0000 Subject: [PATCH] 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
 to only take space needed

---
 etemplate/inc/class.date_widget.inc.php   | 37 ++++++++++++++---------
 etemplate/inc/class.select_widget.inc.php |  2 +-
 etemplate/inc/class.uietemplate.inc.php   | 15 ++++++---
 3 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/etemplate/inc/class.date_widget.inc.php b/etemplate/inc/class.date_widget.inc.php
index d508939006..4a7aab9aca 100644
--- a/etemplate/inc/class.date_widget.inc.php
+++ b/etemplate/inc/class.date_widget.inc.php
@@ -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)
diff --git a/etemplate/inc/class.select_widget.inc.php b/etemplate/inc/class.select_widget.inc.php
index ea4c77dc49..390c1fe891 100644
--- a/etemplate/inc/class.select_widget.inc.php
+++ b/etemplate/inc/class.select_widget.inc.php
@@ -560,6 +560,6 @@
 					break;
 			}
 			//echo "

select_widget::post_process('$name',,'$extension_data',,,'$value_in'): value='$value', is_null(value)=".(int)is_null($value)."

\n"; - return !is_null($value); + return true; } } diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php index 4bd90bd815..3fd1220fec 100644 --- a/etemplate/inc/class.uietemplate.inc.php +++ b/etemplate/inc/class.uietemplate.inc.php @@ -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 .= '
'.$this->html->htmlspecialchars($value)."
\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 .= ' '.$GLOBALS['egw_info']['etemplate']['validation_errors'][$form_name].''; + $html .= ' '.$GLOBALS['egw_info']['etemplate']['validation_errors'][$form_name].''; } // generate an extra div, if we have an onclick handler and NO children or it's an extension //echo "

$this->name($this->onclick_handler:$this->no_onclick:$this->onclick_proxy): $cell[type]/$cell[name]

\n";