Make WordPress Core


Ignore:
Timestamp:
09/23/2008 09:11:27 PM (18 years ago)
Author:
ryan
Message:

First cut of comment paging. Add paging and threading settings. see #7769 #7635

File:
1 edited

Legend:

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

    r8939 r8961  
    2727         * @var array
    2828         */
    29         var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term');
     29        var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage');
    3030
    3131        /**
    … …  
    3737         * @var array
    3838         */
    39         var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm');
     39        var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page');
    4040
    4141        /**
    … …  
    732732
    733733        /**
     734         * Max number of pages walked by the paged walker
     735         *
     736         * @since 2.7.0
     737         * @var int
     738         * @access protected
     739         */
     740        var $max_pages = 1;
     741
     742        /**
    734743         * Starts the list before the elements are added.
    735744         *
    … …  
    948957
    949958                /* sanity check */
    950                 if ( empty($elements) || $max_depth < 0 )
     959                if ( empty($elements) || $max_depth < -1 )
    951960                        return '';
    952961
    … …  
    956965                $id_field = $this->db_fields['id'];
    957966                $parent_field = $this->db_fields['parent'];
     967
     968                $count = -1;
     969                if ( -1 == $max_depth )
     970                        $total_top = count( $elements );
     971                if ( $page_num < 1 || $per_page < 0  ) {
     972                        // No paging
     973                        $paging = false;
     974                        $start = 0;
     975                        if ( -1 == $max_depth )
     976                                $end = $total_top;
     977                        $this->max_pages = 1;
     978                } else {
     979                        $paging = true;
     980                        $start = ( (int)$page_num - 1 ) * (int)$per_page;
     981                        $end   = $start + $per_page;
     982                        if ( -1 == $max_depth )
     983                                $this->max_pages = ceil($total_top / $per_page);
     984                }
     985
     986                // flat display
     987                if ( -1 == $max_depth ) {
     988                        $empty_array = array();
     989                        foreach ( $elements as $e ) {
     990                                $count++;
     991                                if ( $count < $start )
     992                                        continue;
     993                                if ( $count >= $end )
     994                                        break;
     995                                $this->display_element( $e, $empty_array, 1, 0, $args, $output );
     996                        }
     997                        return $output;
     998                }
    958999
    9591000                /*
    … …  
    9711012                }
    9721013
    973                 $count = -1;
    9741014                $total_top = count( $top_level_elements );
    975                 if ( $page_num < 1 || $per_page < 0  ) {
    976                         $start = 0;
    977                         $end = $total_top;
    978                 } else {
    979                         $start = ( (int)$page_num - 1 ) * (int)$per_page;
    980                         $end   = $start + $per_page;
    981                 }
     1015
     1016                if ( $paging )
     1017                        $this->max_pages = ceil($total_top / $per_page);
    9821018
    9831019                foreach( $top_level_elements as $e ){
    … …  
    9971033                }
    9981034
    999                 if ( $end >= $total_top && count( $children_elements ) > 0 ){
     1035                if ( $end >= $total_top && count( $children_elements ) > 0 ) {
    10001036                        $empty_array = array();
    10011037                        foreach ( $children_elements as $orphans )
    … …  
    10311067                        $this->unset_children( $child, $children_elements );
    10321068
    1033                 unset( $children_elements[$id] );
     1069                if ( isset($children_elements[$id]) )
     1070                        unset( $children_elements[$id] );
    10341071
    10351072        }
Note: See TracChangeset for help on using the changeset viewer.