public function naturalNext( $className=null, $root=0, $afterNode=null ) {
        // If this node is not the node we are searching from, then we can possibly return this
        // node as a solution
        if($afterNode && $afterNode->ID != $this->owner->ID) {
            if(!$className || ($className && $this->owner->class == $className)) {
                return $this->owner;
            }
        }
            
        $nextNode=null;
        $baseClass=ClassInfo::baseDataClass($this->owner->class);
        
        $children=DataObject::get(ClassInfo::baseDataClass($this->owner->class), "\"$baseClass\".\"LanguageID\"={$this->owner->ID}" . ( ( $afterNode ) ? " AND \"Sort\" > " . sprintf( '%d', $afterNode->Sort ) : "" ), '"Sort" ASC');
        
        // Try all the siblings of this node after the given node
        /*if( $siblings=DataObject::get( ClassInfo::baseDataClass($this->owner->class), "\"LanguageID\"={$this->owner->LanguageID}" . ( $afterNode ) ? "\"Sort\" > {$afterNode->Sort}" : "" , '\"Sort\" ASC' ) )
            $searchNodes->merge( $siblings );*/
        
        if($children) {
            foreach($children as $node) {
                if($nextNode=$node->naturalNext($className, $node->ID, $this->owner)) {
                    break;
                }
            }
            
            if($nextNode) {
                return $nextNode;
            }
        }
        
        // if this is not an instance of the root class or has the root id, search the parent
        if(!(is_numeric($root) && $root == $this->owner->ID || $root == $this->owner->class) && ($parent=$this->owner->Language())) {
            return $parent->naturalNext( $className, $root, $this->owner );
        }
        
        return null;
    }
public function naturalNext( $className=null, $root=0, $afterNode=null ) {
        // If this node is not the node we are searching from, then we can possibly return this
        // node as a solution
        if($afterNode && $afterNode->ID != $this->owner->ID) {
            if(!$className || ($className && $this->owner->class == $className)) {
                return $this->owner;
            }
        }
            
        $nextNode=null;
        $baseClass=ClassInfo::baseDataClass($this->owner->class);
        
        $children=DataObject::get(ClassInfo::baseDataClass($this->owner->class), "\"$baseClass\".\"LanguageID\"={$this->owner->ID}" . ( ( $afterNode ) ? " AND \"Sort\" > " . sprintf( '%d', $afterNode->Sort ) : "" ), '"Sort" ASC');
        
        // Try all the siblings of this node after the given node
        /*if( $siblings=DataObject::get( ClassInfo::baseDataClass($this->owner->class), "\"LanguageID\"={$this->owner->LanguageID}" . ( $afterNode ) ? "\"Sort\" > {$afterNode->Sort}" : "" , '\"Sort\" ASC' ) )
            $searchNodes->merge( $siblings );*/
        
        if($children) {
            foreach($children as $node) {
                if($nextNode=$node->naturalNext($className, $node->ID, $this->owner)) {
                    break;
                }
            }
            
            if($nextNode) {
                return $nextNode;
            }
        }
        
        // if this is not an instance of the root class or has the root id, search the parent
        if(!(is_numeric($root) && $root == $this->owner->ID || $root == $this->owner->class) && ($parent=$this->owner->Language())) {
            return $parent->naturalNext( $className, $root, $this->owner );
        }
        
        return null;
    }
public function naturalNext ( $ className = null , $ root = 0 , $ afterNode = null ) { // If this node is not the node we are searching from, then we can possibly return this // node as a solution if ( $ afterNode && $ afterNode -> ID != $ this -> owner -> ID ) { if ( ! $ className || ( $ className && $ this -> owner -> class == $ className ) ) { return $ this -> owner ; } } $ nextNode = null ; $ baseClass = ClassInfo :: baseDataClass ( $ this -> owner -> class ) ; $ children = DataObject :: get ( ClassInfo :: baseDataClass ( $ this -> owner -> class ) , "\"$baseClass\".\"LanguageID\"={$this->owner->ID}" . ( ( $ afterNode ) ? " AND \"Sort\" > " . sprintf ( '%d' , $ afterNode -> Sort ) : "" ) , '"Sort" ASC' ) ; // Try all the siblings of this node after the given node /*if( $siblings=DataObject::get( ClassInfo::baseDataClass($this->owner->class), "\"LanguageID\"={$this->owner->LanguageID}" . ( $afterNode ) ? "\"Sort\" > {$afterNode->Sort}" : "" , '\"Sort\" ASC' ) )
            $searchNodes->merge( $siblings );*/ if ( $ children ) { foreach ( $ children as $ node ) { if ( $ nextNode = $ node -> naturalNext ( $ className , $ node -> ID , $ this -> owner ) ) { break ; } } if ( $ nextNode ) { return $ nextNode ; } } // if this is not an instance of the root class or has the root id, search the parent if ( ! ( is_numeric ( $ root ) && $ root == $ this -> owner -> ID || $ root == $ this -> owner -> class ) && ( $ parent = $ this -> owner -> Language ( ) ) ) { return $ parent -> naturalNext ( $ className , $ root , $ this -> owner ) ; } return null ; }
Get the next node in the tree of the type. If there is no instance of the className descended from this node,
then search the parents.
@param string $className Class name of the node to find.
@param string|int $root ID/ClassName of the node to limit the search to
@param DataObject afterNode Used for recursive calls to this function
@return DataObject
Get the next node in the tree of the type . If there is no instance of the className descended from this node then search the parents .