"- 5th option for select-cat: parent category

- adding category desciption (if available) as option title"
This commit is contained in:
Ralf Becker 2009-05-14 08:02:56 +00:00
parent c133b4b106
commit fe03b91b54

View File

@ -152,7 +152,7 @@ class select_widget
$cell['no_lang'] = True; $cell['no_lang'] = True;
break; 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 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; $cell['no_lang'] = True;
@ -175,13 +175,13 @@ class select_widget
} }
if (!$type3 || $type3 === $GLOBALS['egw']->categories->app_name) 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 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']); $s = str_repeat(' ',$cat['level']) . stripslashes($cat['name']);
@ -189,14 +189,10 @@ class select_widget
{ {
$s .= ' ♦'; $s .= ' ♦';
} }
if (!$tmpl->xslt) $cell['sel_options'][$cat['id']] = empty($cat['description']) ? $s : array(
{ 'label' => $s,
$cell['sel_options'][$cat['id']] = $s; // 0.9.14 only 'title' => $cat['description'],
} );
else
{
$cell['sel_options'][$cat['cat_id']] = $s;
}
} }
// preserv unavailible cats (eg. private user-cats) // preserv unavailible cats (eg. private user-cats)
if ($value && ($unavailible = array_diff(is_array($value) ? $value : explode(',',$value),array_keys((array)$cell['sel_options'])))) if ($value && ($unavailible = array_diff(is_array($value) ? $value : explode(',',$value),array_keys((array)$cell['sel_options']))))