Source for file _commentlist.class.php
Documentation is available at _commentlist.class.php
* This file implements the CommentList class.
* This file is part of the Quam Plures project - {@link http://quamplures.net/}.
* See also {@link https://launchpad.net/quam-plures}.
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}.
* Parts of this file are copyright (c)2004-2005 by Daniel HAHLER - {@link http://thequod.de/contact}.
* @license http://quamplures.net/license.html GNU General Public License (GPL)
* {@internal Open Source relicensing agreement:
* Daniel HAHLER grants Francois PLANQUE the right to license
* Daniel HAHLER's contributions to this file and the b2evolution project
* under any OSI approved OSS license (http://www.opensource.org/licenses/).
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author blueyed: Daniel HAHLER.
* @author fplanque: Francois PLANQUE
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class('_core/model/dataobjects/_dataobjectlist.class.php');
* @param Blog can pass NULL if $p is passed
* @param integer Restrict to specific post
* @param string Order ("ASC"/"DESC")
* @param string List of fields to order by (separated by " ")
$comment_types = "'comment'",
$show_statuses = array( 'published' ), // Restrict to these statuses
$p = '', // Restrict to specific post
$author = '', // Not used yet
$order = 'DESC', // ASC or DESC
$orderby = '', // list of fields to order by
$limit = '' // # of comments to display on the page
// Call parent constructor:
parent::DataObjectList( 'T_comments', 'comment_', 'comment_ID', 'Item', NULL, $limit );
$this->sql = 'SELECT DISTINCT T_comments.*
FROM T_comments INNER JOIN T_items__item ON comment_post_ID = post_ID ';
{ // Restrict to comments on selected post
$this->sql .= 'WHERE comment_post_ID = '. $p;
$this->sql .= 'INNER JOIN T_postcats ON post_ID = postcat_post_ID
INNER JOIN T_categories othercats ON postcat_cat_ID = othercats.cat_ID ';
$this->sql .= 'WHERE '. $Blog->get_sql_where_aggregate_coll_IDs('othercats.cat_blog_ID');
$this->sql .= ' AND comment_type IN ('. $comment_types. ') ';
* ----------------------------------------------------
* Restrict to the statuses we want to show:
* ----------------------------------------------------
if( ! empty( $show_statuses ) )
$this->sql .= ' AND comment_status IN (\''. implode( "', '", $show_statuses ). '\')';
// This one restricts to post statuses, but it doesn't work completely right:
// TODO: handle status dependencies with post
$orderby = 'comment_date '. $order. ', comment_ID '. $order;
$orderby_array = explode(' ',$orderby);
$orderby = $orderby_array[0]. ' '. $order;
if (count($orderby_array)> 1)
for($i = 1; $i < (count($orderby_array)); $i++ )
$orderby .= ', comment_'. $orderby_array[$i]. ' '. $order;
if( $order == 'RAND' ) $orderby = 'RAND()';
$this->sql .= "ORDER BY $orderby";
if( !empty( $this->limit ) )
// Prebuild and cache objects:
{ // fplanque>> why this test??
foreach( $this->rows as $row )
$this->Obj[$i] = new Comment( $row ); // COPY (function)
// To avoid potential future waste, cache this object:
// $this->DataObjectCache->add( $this->Obj[$i] );
* T-Tag: Display a message if CommentList is empty
* $params = array_merge( array(
* 'msg_empty' => T_('No comment yet...'),
* @uses Results::display_if_empty()
// Make sure we are not missing any param:
'msg_empty' => T_('No comment yet...'),
return parent::display_if_empty( $params );
|