[pLog-svn] r4342 - in plog/trunk: class/action templates/standard
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sun Nov 26 22:07:04 GMT 2006
Author: oscar
Date: 2006-11-26 22:07:03 +0000 (Sun, 26 Nov 2006)
New Revision: 4342
Modified:
plog/trunk/class/action/viewarticleaction.class.php
plog/trunk/templates/standard/postandcomments.template
Log:
Added support for a paged comments display. It's working for at least custom URLs and "raw" URLs and needs some more testing with mod_rewrite and "pretty" URLs. It does not require any changes to currently existing templates as long as footer.template has a reference to the pager. However for usability purposes it might be a good thing to have the same pager at the top, near the beginning of the list of comments and I've implemented it like that in the 'standard' template.
Modified: plog/trunk/class/action/viewarticleaction.class.php
===================================================================
--- plog/trunk/class/action/viewarticleaction.class.php 2006-11-26 22:04:00 UTC (rev 4341)
+++ plog/trunk/class/action/viewarticleaction.class.php 2006-11-26 22:07:03 UTC (rev 4342)
@@ -5,6 +5,8 @@
lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
lt_include( PLOG_CLASS_PATH."class/view/errorview.class.php" );
+ define( "DEFAULT_SHOW_COMMENTS_MAX", 10 );
+
/**
* \ingroup Action
* @private
@@ -139,7 +141,8 @@
"categoryName" => $this->_categoryName,
"userId" => $this->_userId,
"userName" => $this->_userName,
- "date" => $this->_date ));
+ "date" => $this->_date,
+ "page" => $this->_page ));
if( $this->_view->isCached()) {
if( $this->_config->getValue( 'update_cached_article_reads', false )) {
@@ -162,7 +165,8 @@
lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
- lt_include( PLOG_CLASS_PATH.'class/data/pager/pager.class.php' );
+ lt_include( PLOG_CLASS_PATH.'class/data/pager/pager.class.php' );
+ lt_include( PLOG_CLASS_PATH.'class/dao/articlecomments.class.php' );
// ---
// if we got a category name or a user name instead of a category
@@ -232,6 +236,24 @@
// if everything's fine, we set up the article object for the view
$this->_view->setArticle( $article );
+ // and the comments
+ $blogSettings = $this->_blogInfo->getSettings();
+ $commentsPerPage = $blogSettings->getValue( "show_comments_max", DEFAULT_SHOW_COMMENTS_MAX );
+ $comments = new ArticleComments();
+ $postComments = $comments->getPostComments( $article->getId(),
+ $order = COMMENT_ORDER_NEWEST_FIRST,
+ COMMENT_STATUS_NONSPAM,
+ $this->_page,
+ $commentsPerPage );
+ $this->_view->setValue( 'comments', $postComments );
+ // build the pager and pass it to the view
+ $url = $this->_blogInfo->getBlogRequestGenerator();
+ $pager = new Pager( $url->postPermalink( $article ).$url->getPageSuffix(),
+ $this->_page, // current page
+ $article->getNumComments(), // total number of articles
+ $commentsPerPage ); // number of comments per page
+ $this->_view->setValue( 'pager', $pager );
+
$this->setCommonData();
// and return everything normal
Modified: plog/trunk/templates/standard/postandcomments.template
===================================================================
--- plog/trunk/templates/standard/postandcomments.template 2006-11-26 22:04:00 UTC (rev 4341)
+++ plog/trunk/templates/standard/postandcomments.template 2006-11-26 22:07:03 UTC (rev 4342)
@@ -8,7 +8,9 @@
<!-- {$url->postTrackbackLink($post)} -->
{include file="$blogtemplate/post.template"}
-{if $blogsettings->getValue("comments_enabled") && $post->getCommentsEnabled()==1 || $comments }<h2 id="comments">{$locale->tr("comments")|capitalize}</h2>{/if}
+{if $blogsettings->getValue("comments_enabled") && $post->getCommentsEnabled()==1 || $comments }<h2 id="comments">{$locale->tr("comments")|capitalize}</h2>
+{/if}
+ {pager style="links"}
{foreach from=$comments item=comment}
<div class="comment">
<h3 class="commentheader">{if $comment->getTopic() != null} {$comment->getTopic()|strip_tags}{else}Re: <em>{$post->getTopic()|strip_tags}</em>{/if}</h3>
More information about the pLog-svn
mailing list