From a615cada898e321038ca3de00613af0f01e5a933 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 20 Mar 2006 21:51:55 +0000 Subject: [PATCH] added ability to specify some extra styles for the multiselectbox with checkboxes --- etemplate/inc/class.select_widget.inc.php | 6 ++++-- etemplate/inc/class.uietemplate.inc.php | 6 +++--- phpgwapi/inc/class.html.inc.php | 9 +++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/etemplate/inc/class.select_widget.inc.php b/etemplate/inc/class.select_widget.inc.php index 7cbdd85ae1..67f34294a5 100644 --- a/etemplate/inc/class.select_widget.inc.php +++ b/etemplate/inc/class.select_widget.inc.php @@ -221,7 +221,7 @@ $cell['no_lang'] = True; break; - case 'select-cat': // !$type == globals cats too + case 'select-cat': // !$type == globals cats too, $type2: extraStyleMultiselect if (!is_object($GLOBALS['egw']->categories)) { $GLOBALS['egw']->categories =& CreateObject('phpgwapi.categories'); @@ -243,6 +243,7 @@ $cell['sel_options'][$cat['cat_id']] = $s; } } + $cell['size'] = $rows.($type2 ? ','.$type2 : ''); $cell['no_lang'] = True; break; @@ -321,7 +322,7 @@ $value = intval($value); break; - case 'select-dow': // options: rows[,0=summaries befor days, 1=summaries after days, 2=no summaries + case 'select-dow': // options: rows[,0=summaries befor days, 1=summaries after days, 2=no summaries[,extraStyleMultiselect]] if (!defined('MCAL_M_SUNDAY')) { define('MCAL_M_SUNDAY',1); @@ -386,6 +387,7 @@ { $GLOBALS['egw_info']['etemplate']['to_process'][$name] = 'ext-select-dow'; } + $cell['size'] = $rows.($type2 ? ','.$type2 : ''); break; case 'select-day': diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php index dbf7d0e3c4..8a28751c76 100644 --- a/etemplate/inc/class.uietemplate.inc.php +++ b/etemplate/inc/class.uietemplate.inc.php @@ -1162,9 +1162,9 @@ if ($set_readonlys_all) unset($readonlys['__ALL__']); break; - case 'select': // size:[linesOnMultiselect|emptyLabel] + case 'select': // size:[linesOnMultiselect|emptyLabel,extraStyleMulitselect] $sels = array(); - list($multiple) = explode(',',$cell_options); + list($multiple,$extraStyleMultiselect) = explode(',',$cell_options,2); if (!empty($multiple) && 0+$multiple <= 0) { $sels[''] = $multiple < 0 ? 'all' : $multiple; @@ -1257,7 +1257,7 @@ if ($multiple && is_numeric($multiple)) // eg. "3+" would give a regular multiselectbox { $html .= $this->html->checkbox_multiselect($form_name.($multiple > 1 ? '[]' : ''),$value,$sels, - $cell['no_lang'],$options,$multiple); + $cell['no_lang'],$options,$multiple,true,$extraStyleMultiselect); } else { diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 9779bc3682..f6bf11e1eb 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -260,10 +260,12 @@ class html * @param string $options additional options (e.g. 'width') * @param int $multiple number of lines for a multiselect, default 3 * @param boolean $selected_first show the selected items before the not selected ones, default true + * @param string $style='' extra style settings like "width: 100%", default '' none * @return string to set for a template or to echo into html page */ - function checkbox_multiselect($name, $key, $arr=0,$no_lang=false,$options='',$multiple=3,$selected_first=true) + function checkbox_multiselect($name, $key, $arr=0,$no_lang=false,$options='',$multiple=3,$selected_first=true,$style='') { + //echo "

checkbox_multiselect('$name',".print_r($key,true).",".print_r($arr,true).",$no_lang,'$options',$multiple,$selected_first,'$style')

\n"; if (!is_array($arr)) { $arr = array('no','yes'); @@ -320,7 +322,10 @@ class html ' id="'.$base_name.'['.$val.']'.'" '.($title ? 'title="'.$this->htmlspecialchars($title).'" ':'')). $this->htmlspecialchars($label),$base_name.'['.$val.']')."
\n"; } - $style = 'height: '.(1.7*$multiple).'em; width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.55)).'em; background-color: white; overflow: auto; border: lightgray 2px inset;'; + if ($style && substr($style,-1) != ';') $style .= '; '; + if (!strstr($style,'height')) $style .= 'height: '.(1.7*$multiple).'em; '; + if (!strstr($style,'width')) $style .= 'width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.55)).'em; '; + $style .= 'background-color: white; overflow: auto; border: lightgray 2px inset;'; return $this->div($html,$options,'',$style); }