fixed not working default for checkboxes of "No"="0" and displaying sections now with class="th" and colspan="2"

This commit is contained in:
Ralf Becker 2011-03-19 11:23:53 +00:00
parent 07daeda81e
commit 9888fb0c2f
2 changed files with 22 additions and 24 deletions

View File

@ -14,6 +14,10 @@
class uisettings class uisettings
{ {
var $public_functions = array('index' => True); var $public_functions = array('index' => True);
/**
* Instance of Template class
* @var Template
*/
var $t; var $t;
var $list_shown = False; var $list_shown = False;
var $show_help; var $show_help;
@ -104,14 +108,15 @@
$forced = get_var('forced',Array('POST')); $forced = get_var('forced',Array('POST'));
$default = get_var('default',Array('POST')); $default = get_var('default',Array('POST'));
$this->t =& CreateObject('phpgwapi.Template',common::get_tpl_dir('preferences')); $this->t = new Template(common::get_tpl_dir('preferences'));
$this->t->set_file(array( $this->t->set_file(array(
'preferences' => 'preferences.tpl' 'preferences' => 'preferences.tpl'
)); ));
$this->t->set_block('preferences','list','lists'); $this->t->set_block('preferences','list','lists');
$this->t->set_block('preferences','row','rowhandle'); $this->t->set_block('preferences','row','rowhandle');
$this->t->set_block('preferences','help_row','help_rowhandle'); $this->t->set_block('preferences','help_row','help_rowhandle');
$this->t->set_var(array('rowhandle' => '','help_rowhandle' => '','messages' => '')); $this->t->set_block('preferences','section_row','section_rowhandle');
$this->t->set_var(array('rowhandle' => '','help_rowhandle' => '','messages' => '', 'section_rowhandle'));
$this->prefix = get_var('prefix',array('GET'),$this->bo->session_data['appname'] == $_GET['appname'] ? $this->bo->session_data['prefix'] : ''); $this->prefix = get_var('prefix',array('GET'),$this->bo->session_data['appname'] == $_GET['appname'] ? $this->bo->session_data['prefix'] : '');
@ -221,7 +226,7 @@
$this->create_section($valarray['title']); $this->create_section($valarray['title']);
break; break;
case 'subsection': case 'subsection':
$this->create_subsection($valarray['title']); $this->create_section($valarray['title'],'prefSubSection');
break; break;
case 'input': case 'input':
$this->create_input_box( $this->create_input_box(
@ -465,7 +470,7 @@
} }
if(isset($this->bo->prefs[$name])) if(isset($this->bo->prefs[$name]))
{ {
$this->bo->prefs[$name] = (int)(!!$this->bo->prefs[$name]); // to care for '' and 'True' $this->bo->prefs[$name] = (string)(int)(!!$this->bo->prefs[$name]); // to care for '' and 'True'
} }
return $this->create_select_box($label,$name,array( return $this->create_select_box($label,$name,array(
@ -488,24 +493,14 @@
return $s; return $s;
} }
/* for creating different sections with a title */ /**
function create_section($title='') * Create different sections with a title
*/
function create_section($title='',$span_class='prefSection')
{ {
$this->t->set_var('row_value',''); $this->t->set_var('title','<span class="'.$span_class.'">'.lang($title).'</span>');
$this->t->set_var('row_name','<span class="prefSection">'.lang($title).'</span>');
$GLOBALS['egw']->nextmatchs->template_alternate_row_color($this->t);
$this->t->fp('rows',$this->process_help($help) ? 'help_row' : 'row',True); $this->t->fp('rows','section_row',True);
}
/* for creating different sections with a title */
function create_subsection($title='')
{
$this->t->set_var('row_value','');
$this->t->set_var('row_name','<span class="prefSubSection">'.lang($title).'</span>');
$GLOBALS['egw']->nextmatchs->template_alternate_row_color($this->t);
$this->t->fp('rows',$this->process_help($help) ? 'help_row' : 'row',True);
} }
function create_select_box($label,$name,$values,$help='',$default='',$run_lang=True,$multiple=false) function create_select_box($label,$name,$values,$help='',$default='',$run_lang=True,$multiple=false)
@ -546,7 +541,7 @@
$select = html::input_hidden($GLOBALS['type'].'['.$name.']','',false); // causes bosettings not to ignore unsetting all $select = html::input_hidden($GLOBALS['type'].'['.$name.']','',false); // causes bosettings not to ignore unsetting all
$select .= html::checkbox_multiselect($GLOBALS['type'].'['.$name.']',$default,$values,true,'',5); $select .= html::checkbox_multiselect($GLOBALS['type'].'['.$name.']',$default,$values,true,'',5);
} }
if($GLOBALS['type'] == 'user' && $GLOBALS['egw']->preferences->default[$_appname][$name]) if($GLOBALS['type'] == 'user' && (string)$GLOBALS['egw']->preferences->default[$_appname][$name] !== '')
{ {
// flatten values first (some selectbox values are given multi-dimensional) // flatten values first (some selectbox values are given multi-dimensional)
foreach($values as $id => $val) foreach($values as $id => $val)

View File

@ -9,9 +9,6 @@
</tr> </tr>
<!-- BEGIN list --> <!-- BEGIN list -->
<tr class="th">
<td colspan="2"><b>{list_header}</b></td>
</tr>
{rows} {rows}
<!-- END list --> <!-- END list -->
@ -44,3 +41,9 @@
<td colspan="2">{help_value}</td> <td colspan="2">{help_value}</td>
</tr> </tr>
<!-- END help_row --> <!-- END help_row -->
<!-- BEGIN section_row -->
<tr class="th">
<td colspan="2"><b>{title}</b></td>
</tr>
<!-- END section_row -->