equal
deleted
inserted
replaced
141 $args[0]['has_children'] = $this->has_children; // Back-compat. |
141 $args[0]['has_children'] = $this->has_children; // Back-compat. |
142 } |
142 } |
143 |
143 |
144 $this->start_el( $output, $element, $depth, ...array_values( $args ) ); |
144 $this->start_el( $output, $element, $depth, ...array_values( $args ) ); |
145 |
145 |
146 // Descend only when the depth is right and there are childrens for this element. |
146 // Descend only when the depth is right and there are children for this element. |
147 if ( ( 0 == $max_depth || $max_depth > $depth + 1 ) && isset( $children_elements[ $id ] ) ) { |
147 if ( ( 0 == $max_depth || $max_depth > $depth + 1 ) && isset( $children_elements[ $id ] ) ) { |
148 |
148 |
149 foreach ( $children_elements[ $id ] as $child ) { |
149 foreach ( $children_elements[ $id ] as $child ) { |
150 |
150 |
151 if ( ! isset( $newlevel ) ) { |
151 if ( ! isset( $newlevel ) ) { |
340 * $children_elements[10][] contains all sub-elements whose parent is 10. |
340 * $children_elements[10][] contains all sub-elements whose parent is 10. |
341 */ |
341 */ |
342 $top_level_elements = array(); |
342 $top_level_elements = array(); |
343 $children_elements = array(); |
343 $children_elements = array(); |
344 foreach ( $elements as $e ) { |
344 foreach ( $elements as $e ) { |
345 if ( 0 == $e->$parent_field ) { |
345 if ( empty( $e->$parent_field ) ) { |
346 $top_level_elements[] = $e; |
346 $top_level_elements[] = $e; |
347 } else { |
347 } else { |
348 $children_elements[ $e->$parent_field ][] = $e; |
348 $children_elements[ $e->$parent_field ][] = $e; |
349 } |
349 } |
350 } |
350 } |
410 public function get_number_of_root_elements( $elements ) { |
410 public function get_number_of_root_elements( $elements ) { |
411 $num = 0; |
411 $num = 0; |
412 $parent_field = $this->db_fields['parent']; |
412 $parent_field = $this->db_fields['parent']; |
413 |
413 |
414 foreach ( $elements as $e ) { |
414 foreach ( $elements as $e ) { |
415 if ( 0 == $e->$parent_field ) { |
415 if ( empty( $e->$parent_field ) ) { |
416 $num++; |
416 $num++; |
417 } |
417 } |
418 } |
418 } |
419 return $num; |
419 return $num; |
420 } |
420 } |