make header_left/right a legacy option for nextmatch widget, allowing to specify it in template and therefore display them in editor

This commit is contained in:
Ralf Becker 2013-04-10 13:26:04 +00:00
parent b171acf19a
commit 28428c3aa0
2 changed files with 42 additions and 8 deletions

View File

@ -17,6 +17,12 @@
* This widget replaces the old nextmatch-class. It is independent of the UI,
* as it only uses etemplate-widgets and has therefor no render-function
*
* Following options can be set comma-separated in $cell['size']:
* 1. template
* 2. hide_header
* 3. header_left
* 4. header_right
*
* $content[$id] = array( // I = value set by the app, 0 = value on return / output
* 'get_rows' => // I method/callback to request the data for the rows eg. 'notes.bo.get_rows'
* 'filter_label' => // I label for filter (optional)
@ -66,6 +72,7 @@
* 'selected' => // O array with selected id's
* 'checkboxes' => // O array with checkbox id as key and boolean checked value
* 'select_all' => // O boolean value of select_all checkbox, reference to above value for key 'select_all'
* 'hide_header' => // I do NOT show header row
* );
*/
class nextmatch_widget
@ -329,7 +336,11 @@ class nextmatch_widget
$value['rows'] =& $rows;
unset($rows);
list($template,$options) = explode(',',$cell['size']);
list($template,$hide_header,$header_left,$header_right) = explode(',',$cell['size']);
if ($header_left) $value['header_left'] = $header_left;
if ($header_right) $value['header_right'] = $header_right;
if ((string)$hide_header !== '') $value['hide_header'] = $hide_header;
if (!$value['template'] && $template) // template name can be supplied either in $value['template'] or the options-field
{
$value['template'] = $template;
@ -352,7 +363,7 @@ class nextmatch_widget
{
$value['template']->data[0]['h'.$value['template']->rows] .= ',1'; // disable the last data row
}
if (!$value['never_hide'] && $total <= $max && $options && $value['search'] == '' &&
if (!$value['never_hide'] && $total <= $max && $value['hide_header'] && $value['search'] == '' &&
($value['no_cat'] || !$value['cat_id']) &&
($value['no_filter'] || !$value['filter'] || $value['filter'] == 'none') &&
($value['no_filter2'] || !$value['filter2'] || $value['filter2'] == 'none'))

View File

@ -108,6 +108,9 @@ class xul_io
'htmlarea' => array(
'size' => 'mode,height,width,toolbar,base_href',
),
'nextmatch' => array(
'size' => 'template,hide_header,header_left,header_right',
),
);
/**
* translate xul-widget names to our internal ones, not set ones are identical
@ -212,14 +215,20 @@ class xul_io
switch ($type)
{
case 'nextmatch':
list($tpl) = explode(',',$cell['size']);
$tpls = $cell['size'] = explode(',', $cell['size']); // template,hide_header,header_left,header_right
unset($tpls[1]); // hide_header is no template
foreach($tpls as $n => $tpl)
{
if (empty($tpl)) continue;
$embeded = new boetemplate($tpl,$this->load_via);
if ($embeded_too)
{
$this->add_etempl($embeded,$embeded_too);
}
$cell['size'] = $embeded->name;
$cell['size'][$n] = $embeded->name;
unset($embeded);
}
$cell['size'] = implode(',', $cell['size']);
break;
case 'tabbox':
$labels = explode('|',$cell['label']); unset($cell['label']);
@ -745,6 +754,20 @@ class xul_io
unset($attr['image']); unset($attr['ro_image']);
}
break;
case 'nextmatch':
// re-assemble legacy options in "size" attribute
if (empty($attr['size']) && $this->widget2xul[$tag]['size'])
{
foreach(explode(',', $this->widget2xul[$tag]['size']) as $l_attr)
{
$attr['size'] .= ($attr['size'] ? ',' : '').$attr[$l_attr];
unset($attr[$l_attr]);
}
while(substr($attr['size'], -1) == ',')
{
$attr['size'] = substr($attr['size'], 0, -1);
}
}
}
$attr['help'] = $attr['statustext']; unset($attr['statustext']);
$attr['span'] .= $attr['class'] ? ','.$attr['class'] : ''; unset($attr['class']);