Esempio n. 1
0
 public static function builder_call_nested_collection(Database_Query_Builder $builder, Jam_Event_Data $data, $groups = FALSE, $depth = 0)
 {
     $choices = array();
     if ($depth == 0) {
         $builder->root();
     }
     $items = $builder->order_by(':name_key', 'ASC');
     foreach ($items as $item) {
         if ($groups and $depth == 0) {
             $choices[$item->name()] = array();
             if ($item->children->count()) {
                 $choices[$item->name()] = self::builder_call_nested_collection($item->children->collection(), $data, $groups, $depth + 1);
             }
         } else {
             $choices[$item->id()] = str_repeat('   ', $depth) . $item->name();
             if ($item->children->count()) {
                 $choices = Arr::merge($choices, self::builder_call_nested_collection($item->children->collection(), $data, $groups, $depth + 1));
             }
         }
     }
     if ($depth == 0) {
         $data->return = $choices;
     } else {
         return $choices;
     }
 }