~quam-plures-core/quam-plures/mass_file_upload

« back to all changes in this revision

Viewing changes to qp_plugins/comment_list_widget/_comment_list.widget.php

  • Committer: EdB
  • Date: 2013-03-04 08:19:59 UTC
  • mfrom: (7612.2.45 quam-plures)
  • Revision ID: 1912webworks@gmail.com-20130304081959-r7ka022xkhhryu9a
matching current core

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * This file implements the Comment list Widget class.
4
 
 *
5
 
 * This file is part of Quam Plures - {@link http://quamplures.net/}
6
 
 * See also {@link https://launchpad.net/quam-plures}.
7
 
 *
8
 
 * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
9
 
 * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
10
 
 *
11
 
 * {@internal License choice
12
 
 * - If you have received this file as part of a package, please find the license.txt file in
13
 
 *   the same folder or the closest folder above for complete license terms.
14
 
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
15
 
 *   then you must choose one of the following licenses before using the file:
16
 
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
17
 
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
18
 
 * }}
19
 
 *
20
 
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
21
 
 * @author fplanque: Francois PLANQUE.
22
 
 * @author Yabba        - {@link http://www.astonishme.co.uk/}
23
 
 *
24
 
 * @package widgets
25
 
 */
26
 
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
27
 
 
28
 
load_class( 'widgets/model/_widget.class.php' );
29
 
 
30
 
 
31
 
/**
32
 
 * @package widgets
33
 
 */
34
 
class comment_list_Widget extends ComponentWidget
35
 
{
36
 
        /**
37
 
         * Constructor
38
 
         */
39
 
        function comment_list_Widget( $db_row = NULL )
40
 
        {
41
 
                // Call parent constructor:
42
 
                parent::ComponentWidget( $db_row, 'widget', 'comment_list' );
43
 
 
44
 
                $this->widget_name = $this->T_('Comment list');
45
 
                $this->widget_title = $this->T_('Recent comments');
46
 
        }
47
 
 
48
 
 
49
 
  /**
50
 
   * Get definitions for editable params
51
 
   *
52
 
         * @see Plugin::GetDefaultSettings()
53
 
         * @param local params like 'for_editing' => true
54
 
         */
55
 
        function get_param_definitions( $params )
56
 
        {
57
 
                $r = array_merge( array(
58
 
                        'disp_order' => array(
59
 
                                'label' => $this->T_('Order'),
60
 
                                'note' => $this->T_('Order to display items'),
61
 
                                'type' => 'select',
62
 
                                'options' => array( 'DESC' => $this->T_('Newest to oldest'), 'ASC' => $this->T_('Oldest to newest'), 'RAND' => $this->T_('Random selection') ),
63
 
                                'defaultvalue' => 'DESC',
64
 
                        ),
65
 
                        'limit' => array(
66
 
                                'label' => $this->T_('Max items'),
67
 
                                'note' => $this->T_('Maximum number of items to display.'),
68
 
                                'size' => 4,
69
 
                                'defaultvalue' => 20,
70
 
                        ),
71
 
                        'author_links' => array(
72
 
                                'label' => $this->T_('Link to author'),
73
 
                                'note' => $this->T_('Link the author to their url'),
74
 
                                'defaultvalue' => true,
75
 
                                'type' => 'checkbox',
76
 
                        ),
77
 
                        'hover_text' => array(
78
 
                                'label' => $this->T_('Hover text'),
79
 
                                'note' => $this->T_('Text to show when hovering over the link'),
80
 
                                'size' => 40,
81
 
                                'defaultvalue' => $this->T_('Read the full comment'),
82
 
                                'type' => 'text',
83
 
                        ),
84
 
                        'blog_ID' => array(
85
 
                                'label' => $this->T_('Blog'),
86
 
                                'note' => $this->T_('ID of the blog to use, leave empty for the current blog.'),
87
 
                                'size' => 4,
88
 
                        ),
89
 
                ), parent::get_param_definitions( $params )     );
90
 
 
91
 
                return $r;
92
 
        }
93
 
 
94
 
 
95
 
        /**
96
 
         * Get a very short desc. Used in the widget list.
97
 
         */
98
 
        function get_short_desc()
99
 
        {
100
 
                return format_to_output($this->disp_params['widget_title']);
101
 
        }
102
 
 
103
 
 
104
 
  /**
105
 
         * Get short description
106
 
         */
107
 
        function get_desc()
108
 
        {
109
 
                return $this->T_('List of comments; click goes to comment.');
110
 
        }
111
 
 
112
 
 
113
 
        /**
114
 
         * Display the widget!
115
 
         *
116
 
         * @param array MUST contain at least the basic display params
117
 
         */
118
 
        function display( $params )
119
 
        {
120
 
                $this->init_display( $params );
121
 
 
122
 
                global $Blog;
123
 
 
124
 
                $blogCache = get_Cache( 'BlogCache' );
125
 
                $listBlog = ( $this->disp_params[ 'blog_ID' ] ? $blogCache->get_by_ID( $this->disp_params[ 'blog_ID' ] ) : $Blog );
126
 
 
127
 
                // Create ItemList
128
 
                // Note: we pass a widget specific prefix in order to make sure to never interfere with the mainlist
129
 
                $limit = $this->disp_params[ 'limit' ];
130
 
                $order = $this->disp_params[ 'disp_order' ];
131
 
 
132
 
                $CommentList = new CommentList( $listBlog, "'comment','trackback'", array('published'), '',     '',     $order, '',     $limit );
133
 
 
134
 
                echo $this->disp_params[ 'block_start'];
135
 
 
136
 
                // Display title if requested
137
 
                $this->disp_title();
138
 
 
139
 
                echo $this->disp_params[ 'list_start' ];
140
 
 
141
 
    /**
142
 
                 * @var Comment
143
 
                 */
144
 
                while( $Comment = & $CommentList->get_next() )
145
 
                { // Loop through comments:
146
 
                        // Load comment's Item object:
147
 
                        $Comment->get_Item();
148
 
                        echo $this->disp_params[ 'item_start' ];
149
 
                        // display comment author's name
150
 
                        $Comment->author( array(
151
 
                                'after_visitor' => ' ',
152
 
                                'after_user' => ' ',
153
 
                                'make_link' => $this->disp_params[ 'author_links' ],
154
 
                        ) );
155
 
                        echo $this->T_('on').' ';
156
 
                        // display a permalink link to the comment
157
 
                        $Comment->permanent_link( array(
158
 
                                'text'  => $Comment->Item->title,
159
 
                                'title' => $this->disp_params[ 'hover_text' ],
160
 
                        ) );
161
 
                        echo $this->disp_params[ 'item_end' ];
162
 
                }       // End of comment loop.
163
 
                echo $this->disp_params[ 'list_end' ];
164
 
                echo $this->disp_params[ 'block_end' ];
165
 
 
166
 
                return true;
167
 
        }
168
 
}
169
 
 
170
 
 
171
 
?>
 
 
b'\\ No newline at end of file'