From fe03b91b548a46588becfe45accc080bcb0aed06 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 14 May 2009 08:02:56 +0000 Subject: [PATCH] "- 5th option for select-cat: parent category - adding category desciption (if available) as option title" --- etemplate/inc/class.select_widget.inc.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/etemplate/inc/class.select_widget.inc.php b/etemplate/inc/class.select_widget.inc.php index 8113c0a8e1..2ef63fcb07 100644 --- a/etemplate/inc/class.select_widget.inc.php +++ b/etemplate/inc/class.select_widget.inc.php @@ -152,7 +152,7 @@ class select_widget $cell['no_lang'] = True; break; - case 'select-cat': // !$type == globals cats too, $type2: extraStyleMultiselect, $type3: application, if not current-app + case 'select-cat': // !$type == globals cats too, $type2: extraStyleMultiselect, $type3: application, if not current-app, $type4: parent-id if ($readonly) // for readonly we dont need to fetch all cat's, nor do we need to indent them by level { $cell['no_lang'] = True; @@ -175,13 +175,13 @@ class select_widget } if (!$type3 || $type3 === $GLOBALS['egw']->categories->app_name) { - $categories =& $GLOBALS['egw']->categories; + $categories = $GLOBALS['egw']->categories; } else // we need to instanciate a new cat object for the correct application { - $categories =& new categories('',$type3); + $categories = new categories('',$type3); } - foreach((array)$categories->return_sorted_array(0,False,'','','',!$type) as $cat) + foreach((array)$categories->return_sorted_array(0,False,'','','',!$type,$type4) as $cat) { $s = str_repeat(' ',$cat['level']) . stripslashes($cat['name']); @@ -189,14 +189,10 @@ class select_widget { $s .= ' ♦'; } - if (!$tmpl->xslt) - { - $cell['sel_options'][$cat['id']] = $s; // 0.9.14 only - } - else - { - $cell['sel_options'][$cat['cat_id']] = $s; - } + $cell['sel_options'][$cat['id']] = empty($cat['description']) ? $s : array( + 'label' => $s, + 'title' => $cat['description'], + ); } // preserv unavailible cats (eg. private user-cats) if ($value && ($unavailible = array_diff(is_array($value) ? $value : explode(',',$value),array_keys((array)$cell['sel_options']))))