Changeset 746

Show
Ignore:
Timestamp:
12/07/06 17:22:32 (2 years ago)
Author:
sven
Message:

paging of comments on a post, so as not to try to render 148935739457398454674 comments at once.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/htaccess-dist

    r707 r746  
    7373RewriteRule ^([A-Za-z0-9]+)\/weblog\/rssnot\/(.+)\/?$ _weblog/rss2.php?weblog_name=$1&tag=$2&modifier=not 
    7474RewriteRule ^[A-Za-z0-9]+\/weblog\/([0-9]+)\.html$ _weblog/view_post.php?post=$1 
     75RewriteRule ^[A-Za-z0-9]+\/weblog\/([0-9]+)\.html.([0-9]+)$ _weblog/view_post.php?post=$1&commentpage=$2 
    7576 
    7677RewriteRule ^tag\/(.+)\/?$ search/all.php?tag=$1 
  • devel/units/weblogs/default_template.php

    r690 r746  
    5151        'description' => __gettext("A placeholder for weblog comments."), 
    5252        'glossary' => array( 
    53             '{{comments}}' => __gettext('The list of comments themselves') 
     53            '{{comments}}' => __gettext('The list of comments themselves'), 
     54            '{{paging}}' => __gettext('The list of page links when there are lots of comments') 
    5455        ) 
    5556    ); 
     
    6263<div id="comments"><!-- start comments div --> 
    6364    <h4>$comments</h4> 
     65    <div>{{paging}}</div> 
    6466    <ol> 
    6567        {{comments}} 
    6668    </ol> 
     69    <div>{{paging}}</div> 
    6770</div><!-- end comments div --> 
    6871END; 
  • devel/units/weblogs/weblogs_posts_view.php

    r703 r746  
    141141            // if post exists and is visible 
    142142             
     143            //which page of comments to display (page numbers are 0-based) 
     144            $page = optional_param('commentpage', 0, PARAM_INT); 
     145            $perpage = 20; // set to 0/false to disable paging 
     146            $offset = $page * $perpage; 
     147            $thispageurl = $CFG->wwwroot . $username . "/weblog/" . $post->ident . ".html"; 
     148             
    143149            if ($comments = get_records('weblog_comments','post_id',$post->ident,'posted ASC')) { 
     150                $numcomments = count($comments); 
     151                if (!empty($perpage) && $numcomments > $perpage) { 
     152                    $comments = array_slice($comments, $offset, $perpage); 
     153                    $numpages = ceil($numcomments / $perpage); 
     154                    $pagelinks = __gettext("Page: "); 
     155                    for ($i = 1; $i <= $numpages; $i++) { 
     156                        $pagenum = $i - 1; 
     157                        if ($pagenum != $page) { 
     158                            $pageurl = $thispageurl . (($pagenum) ? '.' . $pagenum : ''); 
     159                            $pagelinks .= ' <a href="' . $pageurl . '">' . $i . '</a>' ; 
     160                        } else { 
     161                            $pagelinks .= ' ' . $i . ' '; 
     162                        } 
     163                         
     164                    } 
     165                    $thispageurl .= '.' . $page; 
     166                } 
     167                 
    144168                foreach($comments as $comment) { 
    145169                    $commentmenu = ""; 
     
    175199                                                          'posted' => strftime("%A, %e %B %Y, %R %Z",$comment->posted), 
    176200                                                          'usericon' => $comment->icon, 
    177                                                           'permalink' => $CFG->wwwroot . $username . "/weblog/{$post->ident}.html#cmt" . $comment->ident 
     201                                                          'permalink' => $thispageurl . "#cmt" . $comment->ident 
    178202                                                          ) 
    179203                                                    ); 
     
    182206                $commentsbody = templates_draw(array( 
    183207                                                     'context' => 'weblogcomments', 
     208                                                     'paging' => $pagelinks, 
    184209                                                     'comments' => $commentsbody 
    185210                                                     )