From 28428c3aa09f0d8f35d873801357286d66690ba2 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 10 Apr 2013 13:26:04 +0000 Subject: [PATCH] make header_left/right a legacy option for nextmatch widget, allowing to specify it in template and therefore display them in editor --- etemplate/inc/class.nextmatch_widget.inc.php | 15 +++++++-- etemplate/inc/class.xul_io.inc.php | 35 ++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index 67d4a260ab..23f05ff962 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -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')) diff --git a/etemplate/inc/class.xul_io.inc.php b/etemplate/inc/class.xul_io.inc.php index bad1e09872..8f697dbae5 100644 --- a/etemplate/inc/class.xul_io.inc.php +++ b/etemplate/inc/class.xul_io.inc.php @@ -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']); - $embeded = new boetemplate($tpl,$this->load_via); - if ($embeded_too) + $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) { - $this->add_etempl($embeded,$embeded_too); + if (empty($tpl)) continue; + $embeded = new boetemplate($tpl,$this->load_via); + if ($embeded_too) + { + $this->add_etempl($embeded,$embeded_too); + } + $cell['size'][$n] = $embeded->name; + unset($embeded); } - $cell['size'] = $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']);