3
* This file implements the "Comment list" widget
5
* @author {@link http://wonderwinds.com/ Ed Bennett}
6
* @author {@link http://astonishme.co.uk/ Yabba (Paul Jones, rest in peace)}
7
* @author {@link http://fplanque.net/ Francois PLANQUE}
8
* @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
9
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
12
if(!defined('QP_MAIN_INIT')) die('fail');
15
* comment_list_Widget class
18
class comment_list_Widget extends ComponentWidget
23
function comment_list_Widget( $db_row = NULL )
25
// Call parent constructor
26
parent::ComponentWidget( $db_row, 'widget', 'comment_list' );
27
$this->widget_name = T_('Comment List');
28
$this->widget_title = T_('Recent comments');
33
* Get widget's short description
37
return T_('List of comments; click goes to comment.');
43
* @todo (3069): rename this to get_title()
45
function get_short_desc()
47
return format_to_output( $this->disp_params['widget_title'] );
52
* Get definitions for editable params
53
* @see Plugin::GetDefaultSettings()
54
* @param local params like 'for_editing' => true
56
function get_param_definitions( $params )
58
$r = array_merge( array(
59
'disp_order' => array(
60
'label' => T_('Order'),
62
'options' => array( 'DESC' => T_('Newest to oldest'), 'ASC' => T_('Oldest to newest'), 'RAND' => T_('Random selection') ),
63
'defaultvalue' => 'DESC',
64
'note' => T_('Order to display items'),
67
'label' => T_('Max items'),
70
'note' => T_('Maximum number of items to display.'),
72
'author_links' => array(
73
'label' => T_('Link to author'),
75
'defaultvalue' => true,
76
'note' => T_('Link the author to their url'),
78
'hover_text' => array(
79
'label' => T_('Hover text'),
81
'defaultvalue' => T_('Read the full comment'),
83
'note' => T_('Text to show when hovering over the link'),
86
'label' => T_('Blog'),
88
'note' => T_('ID of the blog to use, leave empty for the current blog.'),
90
), parent::get_param_definitions( $params ) );
97
* @param array must contain at least the basic display params
99
function display( $params )
103
$this->init_display( $params );
105
$blogCache = get_Cache( 'BlogCache' );
106
$listBlog = ( $this->disp_params['blog_ID'] ? $blogCache->get_by_ID( $this->disp_params['blog_ID'] ) : $Blog );
109
// Note: we pass a widget specific prefix in order to make sure to never interfere with the mainlist
110
$limit = $this->disp_params['limit'];
111
$order = $this->disp_params['disp_order'];
112
$CommentList = new CommentList( $listBlog, "'comment','trackback'", array( 'published' ), '', '', $order, '', $limit );
114
echo $this->disp_params['block_start'];
116
echo $this->disp_params['list_start'];
118
// Loop through comments
119
while( $Comment = & $CommentList->get_next() )
121
// Load comment's Item object:
122
$Comment->get_Item();
123
echo $this->disp_params['item_start'];
124
// display comment author's name
125
$Comment->author( array(
126
'after_visitor' => ' ',
128
'make_link' => $this->disp_params['author_links'],
131
// display a permalink link to the comment
132
$Comment->permanent_link( array(
133
'text' => $Comment->Item->title,
134
'title' => $this->disp_params['hover_text'],
136
echo $this->disp_params['item_end'];
137
} // End of comment loop
138
echo $this->disp_params['list_end'];
139
echo $this->disp_params['block_end'];