Changeset 6858

Show
Ignore:
Timestamp:
02/15/08 07:34:52 (7 months ago)
Author:
ryan
Message:

Walker markup fixes from hailin. fixes #5844

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/classes.php

    r6839 r6858  
    410410            return $output; 
    411411 
    412         if ( $max_depth != 0 ) { 
    413             if ($depth >= $max_depth) 
    414                 return $output; 
    415         } 
    416  
    417412        $id_field = $this->db_fields['id']; 
    418413        $parent_field = $this->db_fields['parent']; 
    419  
    420         if ($depth > 0) { 
    421             //start the child delimiter 
    422             $cb_args = array_merge( array($output, $depth), $args); 
    423             $output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args); 
    424         } 
    425414 
    426415        //display this element 
     
    428417        $output = call_user_func_array(array(&$this, 'start_el'), $cb_args); 
    429418 
    430         for ( $i = 0; $i < sizeof( $children_elements ); $i++ ) { 
    431  
    432             $child = $children_elements[$i]; 
    433             if ( $child->$parent_field == $element->$id_field ) { 
    434  
    435                 array_splice( $children_elements, $i, 1 ); 
    436                 $output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); 
    437                 $i = -1; 
     419        if ( $max_depth == 0 ||  
     420             ($max_depth != 0 &&  $max_depth > $depth+1 )) { //whether to descend 
     421         
     422            for ( $i = 0; $i < sizeof( $children_elements ); $i++ ) { 
     423                 
     424                $child = $children_elements[$i]; 
     425                if ( $child->$parent_field == $element->$id_field ) { 
     426 
     427                    if ( !isset($newlevel) ) { 
     428                        $newlevel = true;  
     429                        //start the child delimiter 
     430                        $cb_args = array_merge( array($output, $depth), $args); 
     431                        $output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args); 
     432                    } 
     433                 
     434                    array_splice( $children_elements, $i, 1 ); 
     435                    $output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); 
     436                    $i = -1; 
     437                } 
    438438            } 
    439439        } 
    440  
     440         
     441        if ( isset($newlevel) && $newlevel ){ 
     442            //end the child delimiter 
     443            $cb_args = array_merge( array($output, $depth), $args); 
     444            $output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args); 
     445        } 
     446         
    441447        //end this element 
    442448        $cb_args = array_merge( array($output, $element, $depth), $args); 
    443449        $output = call_user_func_array(array(&$this, 'end_el'), $cb_args); 
    444  
    445         if ($depth > 0) { 
    446             //end the child delimiter 
    447             $cb_args = array_merge( array($output, $depth), $args); 
    448             $output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args); 
    449         } 
    450450 
    451451        return $output;