~quam-plures-core/quam-plures/fix-auto_p_plugin

« back to all changes in this revision

Viewing changes to qp_inc/comments/model/_comment.class.php

  • Committer: EdB
  • Date: 2013-03-18 19:30:14 UTC
  • mfrom: (7602.1.58 quam-plures)
  • Revision ID: 1912webworks@gmail.com-20130318193014-qogr0c0lwd5ix8lj
quam-plures/qp5_colls-blogs_chaps-cats

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
/**
3
 
 * This file implements the Comment class.
4
 
 *
5
 
 * This file is part of the Quam Plures project - {@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
 
 * Parts of this file are copyright (c)2004-2005 by Daniel HAHLER - {@link http://thequod.de/contact}.
11
 
 *
12
 
 * @license http://quamplures.net/license.html GNU General Public License (GPL)
13
 
 *
14
 
 * {@internal Open Source relicensing agreement:
15
 
 * Daniel HAHLER grants Francois PLANQUE the right to license
16
 
 * Daniel HAHLER's contributions to this file and the b2evolution project
17
 
 * under any OSI approved OSS license (http://www.opensource.org/licenses/).
18
 
 * }}
19
 
 *
20
 
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
21
 
 * @author blueyed: Daniel HAHLER.
22
 
 * @author fplanque: Francois PLANQUE
23
 
 *
24
 
 * @package pond
 
3
 * This file implements the Comment class
 
4
 *
 
5
 * @todo (1111) vars type 'foo' need useful/valid descriptions
 
6
 * @author {@link http://wonderwinds.com/ Ed Bennett}
 
7
 * @author {@link http://daniel.hahler.de/ Daniel HAHLER}
 
8
 * @author {@link http://fplanque.net/ Francois PLANQUE}
 
9
 * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
 
10
 * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
 
11
 * @package comments
25
12
 */
26
 
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
27
 
 
28
 
load_class('_core/model/dataobjects/_dataobject.class.php');
 
13
if(!defined('QP_MAIN_INIT')) die('fail');
29
14
 
30
15
/**
31
 
 * Comment Class
 
16
 * Comment class
32
17
 *
33
 
 * @package pond
 
18
 * @package comments
34
19
 */
35
20
class Comment extends DataObject
36
21
{
37
22
        /**
38
 
         * The item (parent) of this Comment (lazy-filled).
39
 
         * @access protected
 
23
         * The item (parent) of this Comment (lazy-filled)
40
24
         * @see Comment::get_Item()
41
25
         * @see Comment::set_Item()
42
 
         * @var Item
 
26
         * @var object|Item
43
27
         */
44
28
        var $Item;
45
29
        /**
46
 
         * The comment's user, this is NULL for (anonymous) visitors (lazy-filled).
 
30
         * The comment's user, this is NULL for (anonymous) visitors (lazy-filled)
47
31
         * @see Comment::get_author_User()
48
32
         * @see Comment::set_author_User()
49
 
         * @access protected
50
 
         * @var User
 
33
         * @var object|User
51
34
         */
52
35
        var $author_User;
53
 
 
 
36
        /**
 
37
         * Item ID
 
38
         * @var foo
 
39
         */
54
40
        var $item_ID;
 
41
        /**
 
42
         * Author User ID
 
43
         * @var foo
 
44
         */
55
45
        var $author_user_ID;
 
46
        /**
 
47
         * Type
 
48
         * @var foo
 
49
         */
56
50
        var $type;
 
51
        /**
 
52
         * Status
 
53
         * @var foo
 
54
         */
57
55
        var $status;
 
56
        /**
 
57
         * Author
 
58
         * @var foo
 
59
         */
58
60
        var $author;
 
61
        /**
 
62
         * Author Email
 
63
         * @var foo
 
64
         */
59
65
        var $author_email;
 
66
        /**
 
67
         * Author URL
 
68
         * @var foo
 
69
         */
60
70
        var $author_url;
 
71
        /**
 
72
         * Author IP
 
73
         * @var foo
 
74
         */
61
75
        var $author_IP;
 
76
        /**
 
77
         * Date
 
78
         * @var foo
 
79
         */
62
80
        var $date;
 
81
        /**
 
82
         * Content
 
83
         * @var foo
 
84
         */
63
85
        var $content;
 
86
        /**
 
87
         * Spam Karma
 
88
         * @var foo
 
89
         */
64
90
        var $spam_karma;
 
91
        /**
 
92
         * Allow Message Form
 
93
         * @var foo
 
94
         */
65
95
        var $allow_msgform;
 
96
        /**
 
97
         * No Follow
 
98
         * @var foo
 
99
         */
66
100
        var $nofollow;
67
101
 
68
102
        /**
70
104
         */
71
105
        function Comment( $db_row = NULL )
72
106
        {
73
 
                // Call parent constructor:
 
107
                // Call parent constructor
74
108
                parent::DataObject( 'T_comments', 'comment_', 'comment_ID' );
75
 
 
76
109
                if( $db_row == NULL )
77
110
                {
78
111
                        $this->rating = NULL;
83
116
                {
84
117
                        $this->ID = $db_row['comment_ID'];
85
118
                        $this->item_ID = $db_row['comment_post_ID'];
86
 
                        if( ! empty($db_row['comment_author_ID']) )
 
119
                        if( ! empty( $db_row['comment_author_ID'] ) )
87
120
                        {
88
121
                                $this->author_user_ID = $db_row['comment_author_ID'];
89
122
                        }
92
125
                        $this->author = $db_row['comment_author'];
93
126
                        $this->author_email = $db_row['comment_author_email'];
94
127
                        $url = trim( $db_row['comment_author_url'] );
95
 
                        if( ! empty($url) && ! preg_match( '~^\w+://~', $url ) )
96
 
                        { // URL given and does not start with a protocol:
 
128
                        if( ! empty( $url ) && ! preg_match( '~^\w+://~', $url ) )
 
129
                        {
 
130
                                // URL given and does not start with a protocol
97
131
                                $url = 'http://'.$url;
98
132
                        }
99
133
                        $this->author_url = $url;
110
144
 
111
145
 
112
146
        /**
113
 
         * Get the author User of the comment. This is NULL for anonymous visitors.
 
147
         * Get the author User of the comment
 
148
         *
 
149
         * This is NULL for anonymous visitors.
114
150
         *
115
151
         * @return User
116
152
         */
117
153
        function & get_author_User()
118
154
        {
119
 
                if( isset($this->author_user_ID) && ! isset($this->author_User) )
 
155
                if( isset( $this->author_user_ID ) && ! isset( $this->author_User ) )
120
156
                {
121
157
                        $UserCache = & get_Cache( 'UserCache' );
122
158
                        $this->author_User = & $UserCache->get_by_ID( $this->author_user_ID );
123
159
                }
124
 
 
125
160
                return $this->author_User;
126
161
        }
127
162
 
133
168
         */
134
169
        function & get_Item()
135
170
        {
136
 
                if( ! isset($this->Item) )
 
171
                if( ! isset( $this->Item ) )
137
172
                {
138
173
                        $ItemCache = & get_Cache( 'ItemCache' );
139
174
                        $this->Item = & $ItemCache->get_by_ID( $this->item_ID );
140
175
                }
141
 
 
142
176
                return $this->Item;
143
177
        }
144
178
 
158
192
         * T-Tag: Displays author of comment
159
193
         *
160
194
         * @uses Comment::get_author()
 
195
         * @param array Associative array of parameters
161
196
         */
162
197
        function author( $params = array() )
163
198
        {
164
 
                echo $this->get_author($params);
 
199
                echo $this->get_author( $params );
165
200
        }
166
201
 
167
202
 
170
205
         *
171
206
         * <code>
172
207
         * $params = array_merge( array(
173
 
         *   'before'    => '',
174
 
         *   'after'     => '',
175
 
         *   'text'      => '',
 
208
         *   'before' => '',
 
209
         *   'after' => '',
 
210
         *   'text' => '',
176
211
         *   'make_link' => true,
177
212
         * ), $params );
178
213
         * </code>
 
214
         *
 
215
         * @todo (3069) EdB> 'text' should have a special case of # to get an email icon {@see Comment::delete_link()}
 
216
         * @uses Comment::get_author_email()
 
217
         * @param array Associative array of parameters
179
218
         */
180
219
        function author_email( $params = array() )
181
220
        {
182
221
                $email = $this->get_author_email();
183
222
 
 
223
                // If email exists
184
224
                if( strlen( $email ) > 5 )
185
 
                { // If email exists:
186
 
                        // Make sure we are not missing any param:
 
225
                {
 
226
                        // make sure we aren't missing any required params
187
227
                        $params = array_merge( array(
188
 
                                        'before'    => '',
189
 
                                        'after'     => '',
190
 
                                        'text'      => '',
191
 
                                        'make_link' => true,
192
 
                                ), $params );
 
228
                                'before' => '',
 
229
                                'after' => '',
 
230
                                'text' => '',
 
231
                                'make_link' => true,
 
232
                        ), $params );
193
233
 
194
234
                        echo $params['before'];
195
235
                        if( $params['make_link'] )
196
236
                        {
197
237
                                echo '<a href="mailto:'.$email.'">';
198
238
                        }
199
 
                        echo ($params['text'] != '') ? $params['text'] : $email;
 
239
                        echo ( $params['text'] != '' ) ? $params['text'] : $email;
200
240
                        if( $params['make_link'] )
201
241
                        {
202
242
                                echo '</a>';
212
252
         * <code>
213
253
         * $params = array_merge( array(
214
254
         *   'before' => '',
215
 
         *   'after'  => '',
 
255
         *   'after' => '',
216
256
         * ), $params );
217
257
         * </code>
 
258
         *
 
259
         * @uses Plugins::get_trigger_event() FilterIpAddress
 
260
         * @param array Associative array of parameters
218
261
         */
219
262
        function author_ip( $params = array() )
220
263
        {
221
 
                if( !empty( $this->author_IP ) )
 
264
                if( ! empty( $this->author_IP ) )
222
265
                {
223
266
                        global $Plugins;
224
267
 
225
 
                // Make sure we are not missing any param:
226
 
                $params = array_merge( array(
 
268
                        // make sure we aren't missing any required params
 
269
                        $params = array_merge( array(
227
270
                                'before' => '',
228
 
                                'after'  => '',
 
271
                                'after' => '',
229
272
                        ), $params );
230
273
 
231
274
                        echo $params['before'];
232
 
                        // Filter the IP by plugins for display, allowing e.g. the DNSBL plugin to add a link that displays info about the IP:
 
275
                        // Filter the IP by plugins for display, allowing e.g. the DNSBL plugin
 
276
                        // to add a link that displays info about the IP
233
277
                        echo $Plugins->get_trigger_event( 'FilterIpAddress', array(
234
 
                                        'format'=>'htmlbody',
235
 
                                        'data' => $this->author_IP ),
236
 
                                'data' );
 
278
                                'format' => 'htmlbody',
 
279
                                'data' => $this->author_IP
 
280
                        ), 'data' );
237
281
                        echo $params['after'];
238
282
                }
239
283
        }
243
287
         * T-Tag: Display a link to the comment author's provided URL
244
288
         *
245
289
         * @uses Comment::get_author_url_link()
 
290
         * @param array Associative array of parameters
246
291
         * @return boolean true if URL has been displayed
247
292
         */
248
293
        function author_url( $params = array() )
249
294
        {
250
295
                $r = $this->get_author_url_link( $params );
251
 
                if( !empty( $r ) )
 
296
                if( ! empty( $r ) )
252
297
                {
253
298
                        echo $r;
254
299
                        return true;
260
305
        /**
261
306
         * T-Tag: Display the contents of a comment
262
307
         *
263
 
         * @param string Output format, see {@link format_to_output()}
264
308
         * @uses Comment::get_content()
 
309
         * @param string Output format (see {@link format_to_output()})
265
310
         */
266
311
        function content( $format = 'htmlbody' )
267
312
        {
275
320
         * <code>
276
321
         * $params = array_merge( array(
277
322
         *   'before' => '',
278
 
         *   'after'  => '',
 
323
         *   'after' => '',
279
324
         *   'format' => locale_datefmt(),
280
 
         *   'useGM'  => false,
 
325
         *   'useGM' => false,
281
326
         * ), $params );
282
327
         * </code>
 
328
         *
 
329
         * @uses mysql2date()
 
330
         * @param array Associative array of parameters
283
331
         */
284
332
        function date( $params = array() )
285
333
        {
286
 
                // Make sure we are not missing any param:
 
334
                // make sure we aren't missing any required params
287
335
                $params = array_merge( array(
288
 
                                'before' => '',
289
 
                                'after'  => '',
290
 
                                'format' => locale_datefmt(),
291
 
                                'useGM'  => false,
292
 
                        ), $params );
 
336
                        'before' => '',
 
337
                        'after' => '',
 
338
                        'format' => locale_datefmt(),
 
339
                        'useGM' => false,
 
340
                ), $params );
293
341
 
294
342
                echo $params['before'];
295
343
                echo mysql2date( $params['format'], $this->date, $params['useGM'] );
298
346
 
299
347
 
300
348
        /**
301
 
         * Trigger event AfterCommentDelete after calling parent method.
 
349
         * Trigger event AfterCommentDelete after calling parent method
302
350
         *
 
351
         * @uses Plugins::trigger_event() AfterCommentDelete
303
352
         * @return boolean true on success
304
353
         */
305
354
        function dbdelete()
313
362
                {
314
363
                        // re-set the ID for the Plugin event
315
364
                        $this->ID = $old_ID;
316
 
 
317
 
                        $Plugins->trigger_event( 'AfterCommentDelete', $params = array( 'Comment' => & $this ) );
318
 
 
 
365
                        $Plugins->trigger_event( 'AfterCommentDelete', $params = array(
 
366
                                'Comment' => & $this
 
367
                        ) );
319
368
                        $this->ID = 0;
320
369
                }
321
370
 
326
375
        /**
327
376
         * Get karma and set it before adding the Comment to DB.
328
377
         *
 
378
         * @uses Plugins::trigger_event() AfterCommentInsert
329
379
         * @return boolean true on success, false if it did not get inserted
330
380
         */
331
381
        function dbinsert()
332
382
        {
333
 
                /**
334
 
                 * @var Plugins
335
 
                 */
336
383
                global $Plugins;
337
384
                global $Settings;
338
385
 
341
388
 
342
389
                $this->set_spam_karma( $spam_karma );
343
390
 
344
 
                // Change status accordingly:
345
 
                if( ! is_null($spam_karma) )
 
391
                // Change status accordingly
 
392
                if( ! is_null( $spam_karma ) )
346
393
                {
347
 
                        if( $spam_karma < $Settings->get('antispam_threshold_publish') )
348
 
                        { // Publish:
349
 
                                $this->set( 'status', 'published' );
 
394
                        if( $spam_karma < $Settings->get( 'antispam_threshold_publish' ) )
 
395
                        {
 
396
                                $this->set( 'status', 'published' ); // Publish
350
397
                        }
351
 
                        elseif( $spam_karma > $Settings->get('antispam_threshold_delete') )
352
 
                        { // Delete/No insert:
353
 
                                return false;
 
398
                        elseif( $spam_karma > $Settings->get( 'antispam_threshold_delete' ) )
 
399
                        {
 
400
                                return false; // Delete/No insert
354
401
                        }
355
402
                }
356
403
 
358
405
 
359
406
                if( $r = parent::dbinsert() )
360
407
                {
361
 
                        $Plugins->trigger_event( 'AfterCommentInsert', $params = array( 'Comment' => & $this, 'dbchanges' => $dbchanges ) );
 
408
                        $Plugins->trigger_event( 'AfterCommentInsert', $params = array(
 
409
                                'Comment' => & $this,
 
410
                                'dbchanges' => $dbchanges
 
411
                        ) );
362
412
                }
363
413
 
364
414
                return $r;
368
418
        /**
369
419
         * Trigger event AfterCommentUpdate after calling parent method.
370
420
         *
 
421
         * @uses Plugins::trigger_event() AfterCommentUpdate
371
422
         * @return boolean true on success
372
423
         */
373
424
        function dbupdate()
378
429
 
379
430
                if( ( $r = parent::dbupdate() ) !== false )
380
431
                {
381
 
                        $Plugins->trigger_event( 'AfterCommentUpdate', $params = array( 'Comment' => & $this, 'dbchanges' => $dbchanges ) );
 
432
                        $Plugins->trigger_event( 'AfterCommentUpdate', $params = array(
 
433
                                'Comment' => & $this,
 
434
                                'dbchanges' => $dbchanges
 
435
                        ) );
382
436
                }
383
437
 
384
438
                return $r;
390
444
         *
391
445
         * <code>
392
446
         * $params = array_merge( array(
393
 
         *   'before'       => '',
394
 
         *   'after'        => ' ',
395
 
         *   'text'         => '#', // '#' = get_icon( 'delete', 'imgtag' ).' '.T_('Delete!')
396
 
         *   'title'        => T_('Delete this comment'),
397
 
         *   'class'        => '',
398
 
         *   'button'       => false,
399
 
         *   'glue'         => '&amp;',
 
447
         *   'before' => '',
 
448
         *   'after' => ' ',
 
449
         *   'text' => '#', // '#' = get_icon( 'delete', 'imgtag' ).' '.T_('Delete!')
 
450
         *   'title' => T_('Delete this comment'),
 
451
         *   'class' => '',
 
452
         *   'button' => false,
 
453
         *   'glue' => '&amp;',
400
454
         *   'save_context' => true,
401
455
         * ), $params );
402
456
         * </code>
 
457
         *
 
458
         * @todo (1111) defaults should be empty not space
 
459
         * @uses Comment::get_Item()
 
460
         * @uses User::check_perm()
 
461
         * @uses Item::get_blog_ID()
 
462
         * @uses regenerate_url()
 
463
         * @param array Associative array of parameters
403
464
         */
404
465
        function delete_link( $params = array() )
405
466
        {
406
 
                global $current_User, $admin_url;
407
 
 
408
 
                if( ! is_logged_in() ) return false;
409
 
 
410
 
                if( empty($this->ID) )
411
 
                { // Happens in Preview
 
467
                global $admin_url;
 
468
                global $current_User;
 
469
 
 
470
                if( ! is_logged_in() )
 
471
                {
412
472
                        return false;
413
473
                }
414
474
 
 
475
                if( empty( $this->ID ) )
 
476
                {
 
477
                        return false; // Happens in Preview
 
478
                }
 
479
 
415
480
                $this->get_Item();
416
481
 
417
482
                if( ! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get_blog_ID() ) )
418
 
                { // If User has no permission to edit comments:
419
 
                        return false;
 
483
                {
 
484
                        return false; // User has no permission to edit comments
420
485
                }
421
486
 
422
 
                // Make sure we are not missing any param:
 
487
                // make sure we aren't missing any required params
423
488
                $params = array_merge( array(
424
 
                                'before'       => '',
425
 
                                'after'        => ' ',
426
 
                                'text'         => '#',
427
 
                                'title'        => T_('Delete this comment'),
428
 
                                'class'        => '',
429
 
                                'button'       => false,
430
 
                                'glue'         => '&amp;',
431
 
                                'save_context' => true,
432
 
                        ), $params );
 
489
                        'before' => '',
 
490
                        'after' => ' ',
 
491
                        'text' => '#',
 
492
                        'title' => T_('Delete this comment'),
 
493
                        'class' => '',
 
494
                        'button' => false,
 
495
                        'glue' => '&amp;',
 
496
                        'save_context' => true,
 
497
                ), $params );
433
498
 
434
499
                if( $params['text'] == '#' )
435
 
                { // Use icon+text as default, if not displayed as button (otherwise just the text)
 
500
                {
 
501
                        // Use icon+text as default, if not displayed as button (otherwise just the text)
436
502
                        if( ! $params['button'] )
437
503
                        {
438
504
                                $params['text'] = get_icon( 'delete', 'imgtag' ).' '.T_('Delete!');
451
517
 
452
518
                echo $params['before'];
453
519
                if( $params['button'] )
454
 
                { // Display as button
 
520
                {
 
521
                        // Display as button
455
522
                        echo '<input type="button"';
456
 
                        echo ' value="'.$params['text'].'" title="'.$params['title'].'" onclick="if ( confirm(\'';
 
523
                        echo ' value="'.$params['text'].'" title="'.$params['title'].'" onclick="if( confirm(\'';
457
524
                        echo TS_('You are about to delete this comment!\\nThis cannot be undone!');
458
525
                        echo '\') ) { document.location.href=\''.$url.'\' }"';
459
 
                        if( !empty( $params['class'] ) ) echo ' class="'.$params['class'].'"';
 
526
                        if( ! empty( $params['class'] ) ) echo ' class="'.$params['class'].'"';
460
527
                        echo '/>';
461
528
                }
462
529
                else
463
 
                { // Display as link
 
530
                {
 
531
                        // Display as link
464
532
                        echo '<a href="'.$url.'" title="'.$params['title'].'" onclick="return confirm(\'';
465
533
                        echo TS_('You are about to delete this comment!\\nThis cannot be undone!');
466
534
                        echo '\')"';
467
 
                        if( !empty( $params['class'] ) ) echo ' class="'.$params['class'].'"';
 
535
                        if( ! empty( $params['class'] ) ) echo ' class="'.$params['class'].'"';
468
536
                        echo '>'.$params['text'].'</a>';
469
537
                }
470
538
                echo $params['after'];
489
557
         *
490
558
         * <code>
491
559
         * $params = array_merge( array(
492
 
         *   'before'       => '',
493
 
         *   'after'        => ' ',
494
 
         *   'text'         => get_icon( 'edit' ).' '.T_('Edit...'),
495
 
         *   'title'        => T_('Edit this comment'),
496
 
         *   'class'        => '',
497
 
         *   'glue'         => '&amp;',
 
560
         *   'before' => '',
 
561
         *   'after' => ' ',
 
562
         *   'text' => get_icon( 'edit' ).' '.T_('Edit...'),
 
563
         *   'title' => T_('Edit this comment'),
 
564
         *   'class' => '',
 
565
         *   'glue' => '&amp;',
498
566
         *   'save_context' => true,
499
567
         * ), $params );
500
568
         * </code>
 
569
         *
 
570
         * @todo (1111) defaults should be empty not space
 
571
         * @todo (3069) EdB> how come 'text' isn't # like {@see Comment::delete_link()}?
 
572
         * @uses Comment::get_Item()
 
573
         * @uses User::check_perm()
 
574
         * @uses Item::get_blog_ID()
 
575
         * @uses get_icon()
 
576
         * @uses regenerate_url()
 
577
         * @param array Associative array of parameters
501
578
         */
502
579
        function edit_link( $params = array() )
503
580
        {
504
 
                global $current_User, $admin_url;
505
 
 
506
 
                if( ! is_logged_in() ) return false;
507
 
 
508
 
                if( empty($this->ID) )
509
 
                { // Happens in Preview
 
581
                global $admin_url;
 
582
                global $current_User;
 
583
 
 
584
                if( ! is_logged_in() )
 
585
                {
510
586
                        return false;
511
587
                }
512
588
 
 
589
                if( empty( $this->ID ) )
 
590
                {
 
591
                        return false; // Happens in Preview
 
592
                }
 
593
 
513
594
                $this->get_Item();
514
595
 
515
596
                if( ! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get_blog_ID() ) )
516
 
                { // If User has no permission to edit comments:
517
 
                        return false;
 
597
                {
 
598
                        return false; // User has no permission to edit comments
518
599
                }
519
600
 
520
 
                // Make sure we are not missing any param:
 
601
                // make sure we aren't missing any required params
521
602
                $params = array_merge( array(
522
 
                                'before'       => '',
523
 
                                'after'        => ' ',
524
 
                                'text'         => get_icon( 'edit' ).' '.T_('Edit...'),
525
 
                                'title'        => T_('Edit this comment'),
526
 
                                'class'        => '',
527
 
                                'glue'         => '&amp;',
528
 
                                'save_context' => true,
529
 
                        ), $params );
 
603
                        'before' => '',
 
604
                        'after' => ' ',
 
605
                        'text' => get_icon( 'edit' ).' '.T_('Edit...'),
 
606
                        'title' => T_('Edit this comment'),
 
607
                        'class' => '',
 
608
                        'glue' => '&amp;',
 
609
                        'save_context' => true,
 
610
                ), $params );
530
611
 
531
612
                echo $params['before'];
532
613
                echo '<a href="'.$admin_url.'?ctrl=comments&amp;action=edit&amp;comment_ID='.$this->ID;
535
616
                        echo $params['glue'].'redirect_to='.rawurlencode( regenerate_url( '', '', '', '&' ) );
536
617
                }
537
618
                echo '" title="'.$params['title'].'"';
538
 
                if( !empty( $params['class'] ) )
 
619
                if( ! empty( $params['class'] ) )
539
620
                {
540
621
                        echo ' class="'.$params['class'].'"';
541
622
                }
568
649
 
569
650
 
570
651
        /**
571
 
         * T-Tag: Return the comment's ID for an anchor
 
652
         * Return the comment's ID for an anchor
572
653
         *
573
654
         * @return string
574
655
         */
579
660
 
580
661
 
581
662
        /**
582
 
         * T-Tag: Return the author of comment
 
663
         * Return the author of comment
583
664
         *
584
665
         * <code>
585
666
         * $params = array_merge( array(
586
667
         *   'before_visitor' => '',
587
 
         *   'after_visitor'  => ' ['.T_('Visitor').']',
588
 
         *   'before_user'    => '',
589
 
         *   'after_user'     => ' ['.T_('Member').']',
590
 
         *   'format'         => 'htmlbody',
 
668
         *   'after_visitor' => ' ['.T_('Visitor').']',
 
669
         *   'before_user' => '',
 
670
         *   'after_user' => ' ['.T_('Member').']',
 
671
         *   'format' => 'htmlbody',
591
672
         *   'make_link' => false,
592
673
         * ), $params );
593
674
         * </code>
594
675
         *
 
676
         * @uses Comment::get_author_User()
 
677
         * @uses format_to_output()
 
678
         * @uses User::get_preferred_name()
 
679
         * @uses DataObject::dget()
 
680
         * @uses Comment::get_author_url_link()
 
681
         * @uses Plugins::trigger_event() FilterCommentAuthor
 
682
         * @param array Associative array of parameters
595
683
         * @return string
596
684
         */
597
685
        function get_author( $params = array() )
598
686
        {
599
687
                global $Plugins;
600
688
 
601
 
                // Make sure we are not missing any param:
 
689
                // make sure we aren't missing any required params
602
690
                $params = array_merge( array(
603
 
                                'before_visitor' => '',
604
 
                                'after_visitor'  => ' ['.T_('Visitor').']',
605
 
                                'before_user'    => '',
606
 
                                'after_user'     => ' ['.T_('Member').']',
607
 
                                'format'         => 'htmlbody',
608
 
                                'make_link'      => false,
609
 
                        ), $params );
 
691
                        'before_visitor' => '',
 
692
                        'after_visitor' => ' ['.T_('Visitor').']',
 
693
                        'before_user' => '',
 
694
                        'after_user' => ' ['.T_('Member').']',
 
695
                        'format' => 'htmlbody',
 
696
                        'make_link' => false,
 
697
                ), $params );
610
698
 
611
699
                if( $this->get_author_User() )
612
 
                { // Author is a user
 
700
                {
 
701
                        // Author is a user
613
702
                        if( strlen( $this->author_User->url ) <= 10 )
614
703
                        {
615
704
                                $params['make_link'] = false;
622
711
 
623
712
                }
624
713
                else
625
 
                { // Display info recorded at edit time:
 
714
                {
 
715
                        // Display info recorded at edit time
626
716
                        if( strlen( $this->author_url ) <= 10 )
627
717
                        {
628
718
                                $params['make_link'] = false;
632
722
                }
633
723
 
634
724
                if( $params['make_link'] )
635
 
                { // Make a link:
 
725
                {
 
726
                        // Make a link
636
727
                        $r = $this->get_author_url_link( array(
637
 
                                        'before' => $params['before_visitor'],
638
 
                                        'after' => $params['after_visitor'],
639
 
                                        'text' => $author_name,
640
 
                                ) );
 
728
                                'before' => $params['before_visitor'],
 
729
                                'after' => $params['after_visitor'],
 
730
                                'text' => $author_name,
 
731
                        ) );
641
732
                }
642
733
                else
643
 
                { // Display the name: (NOTE: get_author_url_link( with nolink option ) would NOT handle this correctly when url is empty
 
734
                {
 
735
                        // Display the name: (NOTE: get_author_url_link( with nolink option )
 
736
                        // would NOT handle this correctly when url is empty
644
737
                        $r = $params['before_visitor'].$author_name.$params['after_visitor'];
645
738
                }
646
739
 
647
 
                $Plugins->trigger_event( 'FilterCommentAuthor', array( 'data' => & $r, 'makelink' => $params['make_link'], 'Comment' => & $this ) );
 
740
                $Plugins->trigger_event( 'FilterCommentAuthor', array(
 
741
                        'data' => & $r,
 
742
                        'makelink' => $params['make_link'],
 
743
                        'Comment' => & $this
 
744
                ) );
648
745
 
649
746
                return $r;
650
747
        }
651
748
 
652
749
 
653
750
        /**
654
 
         * Get the EMail of the comment's author.
 
751
         * Get the email of the comment's author
655
752
         *
656
753
         * @return string
657
754
         */
658
755
        function get_author_email()
659
756
        {
660
757
                if( $this->get_author_User() )
661
 
                { // Author is a user
662
 
                        return $this->author_User->get('email');
 
758
                {
 
759
                        return $this->author_User->get( 'email' ); // Author is a user
663
760
                }
664
761
                else
665
762
                {
669
766
 
670
767
 
671
768
        /**
672
 
         * Get the comment author's name.
 
769
         * Get the comment author's name
673
770
         *
674
771
         * @return string
675
772
         */
687
784
 
688
785
 
689
786
        /**
690
 
         * Get the URL of the comment's author.
 
787
         * Get the URL of the comment's author
691
788
         *
 
789
         * @uses Comment::get_author_User()
692
790
         * @return string
693
791
         */
694
792
        function get_author_url()
695
793
        {
696
794
                if( $this->get_author_User() )
697
 
                { // Author is a user
698
 
                        return $this->author_User->get('url');
 
795
                {
 
796
                        return $this->author_User->get( 'url' ); // Author is a user
699
797
                }
700
798
                else
701
799
                {
705
803
 
706
804
 
707
805
        /**
708
 
         * T-Tag: Return a link to comment author's provided URL
 
806
         * Return a link to comment author's provided URL
709
807
         *
710
808
         * <code>
711
809
         * $params = array_merge( array(
712
 
         *   'before'    => '',
713
 
         *   'after'     => '',
714
 
         *   'text'      => '',
 
810
         *   'before' => '',
 
811
         *   'after' => '',
 
812
         *   'text' => '',
715
813
         *   'make_link' => true,
716
814
         * ), $params );
717
815
         * </code>
 
816
         *
 
817
         * @todo (3069) EdB> 'text' should have a special case of # to get a www icon {@see Comment::delete_link()}
 
818
         * @uses Comment::get_author_url()
 
819
         * @uses Plugins::trigger_event() FilterCommentAuthorUrl
 
820
         * @param array Associative array of parameters
718
821
         */
719
822
        function get_author_url_link( $params = array() )
720
823
        {
727
830
                        return false;
728
831
                }
729
832
 
730
 
                // Make sure we are not missing any param:
 
833
                // make sure we aren't missing any required params
731
834
                $params = array_merge( array(
732
 
                                'before'    => '',
733
 
                                'after'     => '',
734
 
                                'text'      => '',
735
 
                                'make_link' => true,
736
 
                        ), $params );
 
835
                        'before' => '',
 
836
                        'after' => '',
 
837
                        'text' => '',
 
838
                        'make_link' => true,
 
839
                ), $params );
737
840
 
738
 
                // If URL exists:
 
841
                // If URL exists
739
842
                $r = $params['before'];
740
843
                if( $params['make_link'] )
741
844
                {
746
849
                        }
747
850
                        $r .= 'href="'.$url.'">';
748
851
                }
749
 
                $r .= ( empty($params['text']) ? $url : $params['text'] );
 
852
                $r .= ( empty( $params['text'] ) ? $url : $params['text'] );
750
853
                if( $params['make_link'] ) $r .= '</a>';
751
854
                $r .= $params['after'];
752
855
 
753
 
                $Plugins->trigger_event( 'FilterCommentAuthorUrl', array( 'data' => & $r, 'makelink' => $params['make_link'], 'Comment' => & $this ) );
 
856
                $Plugins->trigger_event( 'FilterCommentAuthorUrl', array(
 
857
                        'data' => & $r,
 
858
                        'makelink' => $params['make_link'],
 
859
                        'Comment' => & $this
 
860
                ) );
754
861
 
755
862
                return $r;
756
863
        }
757
864
 
758
865
 
759
866
        /**
760
 
         * T-Tag: Return the contents of a comment
 
867
         * Return the contents of a comment
761
868
         *
762
 
         * @param string Output format, see {@link format_to_output()}
 
869
         * @uses Plugins::trigger_event() FilterCommentContent
 
870
         * @uses format_to_output() 
 
871
         * @param string Output format (see {@link format_to_output()})
 
872
         * @param Output format
763
873
         * @return string
764
874
         */
765
875
        function get_content( $format = 'htmlbody' )
767
877
                global $Plugins;
768
878
 
769
879
                $comment = $this->content;
770
 
                $Plugins->trigger_event( 'FilterCommentContent', array( 'data' => & $comment, 'Comment' => $this ) );
 
880
                $Plugins->trigger_event( 'FilterCommentContent', array(
 
881
                        'data' => & $comment,
 
882
                        'Comment' => $this
 
883
                ) );
771
884
                $comment = format_to_output( $comment, $format );
772
 
 
773
885
                return $comment;
774
886
        }
775
887
 
776
888
 
777
889
        /**
778
 
         * T-Tag: Return a link to deprecate a comment if user has edit rights
 
890
         * Return a link to deprecate a comment if user has edit rights
779
891
         *
780
892
         * <code>
781
893
         * $params = array_merge( array(
782
 
         *   'before'       => '',
783
 
         *   'after'        => ' ',
784
 
         *   'text'         => get_icon( 'deprecate', 'imgtag' ).' '.T_('Deprecate!'),
785
 
         *   'title'        => T_('Deprecate this comment!'),
786
 
         *   'class'        => '',
787
 
         *   'glue'         => '&amp;',
 
894
         *   'before' => '',
 
895
         *   'after' => ' ',
 
896
         *   'text' => get_icon( 'deprecate', 'imgtag' ).' '.T_('Deprecate!'),
 
897
         *   'title' => T_('Deprecate this comment!'),
 
898
         *   'class' => '',
 
899
         *   'glue' => '&amp;',
788
900
         *   'save_context' => true,
789
901
         * ), $params );
790
902
         * </code>
 
903
         *
 
904
         * @todo (3069) EdB> how come 'text' isn't # like {@see Comment::delete_link()}?
 
905
         * @todo (1111) defaults should be empty not space
 
906
         * @uses Comment::get_Item()
 
907
         * @uses User::check_perm()
 
908
         * @uses Item::get_blog_ID()
 
909
         * @uses regenerate_url()
 
910
         * @param array Associative array of parameters
791
911
         */
792
912
        function get_deprecate_link( $params = array() )
793
913
        {
794
 
                global $current_User, $admin_url;
 
914
                global $admin_url;
 
915
                global $current_User;
795
916
 
796
 
                if( ! is_logged_in() ) return false;
 
917
                if( ! is_logged_in() )
 
918
                {
 
919
                        return false;
 
920
                }
797
921
 
798
922
                $this->get_Item();
799
923
 
800
 
                if( ($this->status == 'deprecated') // Already deprecateded!
 
924
                if( ( $this->status == 'deprecated' ) // Already deprecated!
801
925
                        || ! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get_blog_ID() ) )
802
 
                { // If User has no permission to edit comments:
803
 
                        return false;
 
926
                {
 
927
                        return false; // User has no permission to edit comments
804
928
                }
805
929
 
806
 
                // Make sure we are not missing any param:
 
930
                // make sure we aren't missing any required params
807
931
                $params = array_merge( array(
808
 
                                'before'       => '',
809
 
                                'after'        => ' ',
810
 
                                'text'         => get_icon( 'deprecate', 'imgtag' ).' '.T_('Deprecate!'),
811
 
                                'title'        => T_('Deprecate this comment!'),
812
 
                                'class'        => '',
813
 
                                'glue'         => '&amp;',
814
 
                                'save_context' => true,
815
 
                        ), $params );
 
932
                        'before' => '',
 
933
                        'after' => ' ',
 
934
                        'text' => get_icon( 'deprecate', 'imgtag' ).' '.T_('Deprecate!'),
 
935
                        'title' => T_('Deprecate this comment!'),
 
936
                        'class' => '',
 
937
                        'glue' => '&amp;',
 
938
                        'save_context' => true,
 
939
                ), $params );
816
940
 
817
941
                $r = $params['before'];
818
942
                $r .= '<a href="';
822
946
                        $r .= $params['glue'].'redirect_to='.rawurlencode( regenerate_url( '', '', '', '&' ) );
823
947
                }
824
948
                $r .= '" title="'.$params['title'].'"';
825
 
                if( !empty( $params['class'] ) ) $r .= ' class="'.$params['class'].'"';
 
949
                if( ! empty( $params['class'] ) ) $r .= ' class="'.$params['class'].'"';
826
950
                $r .= '>'.$params['text'].'</a>';
827
951
                $r .= $params['after'];
828
952
 
831
955
 
832
956
 
833
957
        /**
834
 
         * T-tag: Returns a permalink link to the Comment
 
958
         * Returns a permalink link to the Comment
835
959
         *
836
960
         * Note: If you only want the permalink URL, use Comment::get_permanent_url()
837
961
         *
838
962
         * <code>
839
963
         * $params = array_merge( array(
840
 
         *   'text'     => '#', // '#' = see below
841
 
         *   'title'    => T_('Permanent link to this comment'),
842
 
         *   'class'    => '',
 
964
         *   'text' => '#', // '#' = see below
 
965
         *   'title' => T_('Permanent link to this comment'),
 
966
         *   'class' => '',
843
967
         *   'nofollow' => true,
844
968
         * ), $params );
845
969
         * </code>
847
971
         * 'text' => '#' = get_icon( 'permalink' ).T_('Permalink')<br />
848
972
         * 'text' => '#icon#' = get_icon( 'permalink' )<br />
849
973
         * 'text' => '#text#' = T_('Permalink')
 
974
         *
 
975
         * @uses get_icon()
 
976
         * @uses Comment::get_permanent_url()
 
977
         * @param array Associative array of parameters
850
978
         */
851
979
        function get_permanent_link( $params = array() )
852
980
        {
853
 
                global $current_User, $app_baseurl;
 
981
                global $app_baseurl;
 
982
                global $current_User;
854
983
 
855
 
                // Make sure we are not missing any param:
 
984
                // make sure we aren't missing any required params
856
985
                $params = array_merge( array(
857
 
                                'text'     => '#',
858
 
                                'title'    => T_('Permanent link to this comment'),
859
 
                                'class'    => '',
860
 
                                'nofollow' => false,
861
 
                        ), $params );
 
986
                        'text' => '#',
 
987
                        'title' => T_('Permanent link to this comment'),
 
988
                        'class' => '',
 
989
                        'nofollow' => false,
 
990
                ), $params );
862
991
 
863
992
                switch( $params['text'] )
864
993
                {
865
994
                        case '#':
866
 
                                $params['text'] = get_icon( 'permalink' ).T_('Permalink');
867
 
                                break;
 
995
                        $params['text'] = get_icon( 'permalink' ).T_('Permalink');
 
996
                        break;
868
997
 
869
998
                        case '#icon#':
870
 
                                $params['text'] = get_icon( 'permalink' );
871
 
                                break;
 
999
                        $params['text'] = get_icon( 'permalink' );
 
1000
                        break;
872
1001
 
873
1002
                        case '#text#':
874
 
                                $params['text'] = T_('Permalink');
875
 
                                break;
 
1003
                        $params['text'] = T_('Permalink');
 
1004
                        break;
876
1005
                }
877
1006
 
878
1007
                $url = $this->get_permanent_url();
879
1008
 
880
1009
                // Display as link
881
1010
                $r = '<a href="'.$url.'" title="'.$params['title'].'"';
882
 
                if( !empty( $params['class'] ) )
 
1011
                if( ! empty( $params['class'] ) )
883
1012
                {
884
1013
                        $r .= ' class="'.$params['class'].'"';
885
1014
                }
886
 
                if( !empty( $params['nofollow'] ) )
 
1015
                if( ! empty( $params['nofollow'] ) )
887
1016
                {
888
1017
                        $r .= ' rel="nofollow"';
889
1018
                }
894
1023
 
895
1024
 
896
1025
        /**
897
 
         * Generate permalink to this comment.
 
1026
         * Generate permalink to this comment
898
1027
         *
899
1028
         * Note: This actually only returns the URL, to get a real link, use Comment::get_permanent_link()
900
1029
         */
909
1038
 
910
1039
 
911
1040
        /**
912
 
         * T-Tag: Provide a link to publish a comment if user has edit rights
 
1041
         * Provide a link to publish a comment if user has edit rights
913
1042
         *
914
1043
         * <code>
915
1044
         * $params = array_merge( array(
916
 
         *   'before'       => '',
917
 
         *   'after'        => ' ',
918
 
         *   'text'         => get_icon( 'publish', 'imgtag' ).' '.T_('Publish!'),
919
 
         *   'title'        => T_('Publish this comment!'),
920
 
         *   'class'        => '',
921
 
         *   'glue'         => '&amp;',
 
1045
         *   'before' => '',
 
1046
         *   'after' => ' ',
 
1047
         *   'text' => get_icon( 'publish', 'imgtag' ).' '.T_('Publish!'),
 
1048
         *   'title' => T_('Publish this comment!'),
 
1049
         *   'class' => '',
 
1050
         *   'glue' => '&amp;',
922
1051
         *   'save_context' => true,
923
1052
         * ), $params );
924
1053
         * </code>
 
1054
         *
 
1055
         * @todo (1111) defaults should be empty not space
 
1056
         * @todo (3069) EdB> how come 'text' isn't # like {@see Comment::delete_link()}?
 
1057
         * @uses Comment::get_Item()
 
1058
         * @uses User::check_perm()
 
1059
         * @uses Item::get_blog_ID()
 
1060
         * @uses regenerate_url()
 
1061
         * @param array Associative array of parameters
925
1062
         */
926
1063
        function get_publish_link( $params = array() )
927
1064
        {
928
 
                global $current_User, $admin_url;
 
1065
                global $admin_url;
 
1066
                global $current_User;
929
1067
 
930
 
                if( ! is_logged_in() ) return false;
 
1068
                if( ! is_logged_in() )
 
1069
                {
 
1070
                        return false;
 
1071
                }
931
1072
 
932
1073
                $this->get_Item();
933
1074
 
934
 
                if( ($this->status == 'published') // Already published!
 
1075
                if( ( $this->status == 'published' ) // Already published!
935
1076
                        || ! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get_blog_ID() ) )
936
 
                { // If User has no permission to edit comments:
 
1077
                {
 
1078
                        // If User has no permission to edit comments
937
1079
                        return false;
938
1080
                }
939
1081
 
940
 
                // Make sure we are not missing any param:
 
1082
                // make sure we aren't missing any required params
941
1083
                $params = array_merge( array(
942
 
                                'before'       => '',
943
 
                                'after'        => ' ',
944
 
                                'text'         => get_icon( 'publish', 'imgtag' ).' '.T_('Publish!'),
945
 
                                'title'        => T_('Publish this comment!'),
946
 
                                'class'        => '',
947
 
                                'glue'         => '&amp;',
948
 
                                'save_context' => true,
949
 
                        ), $params );
 
1084
                        'before' => '',
 
1085
                        'after' => ' ',
 
1086
                        'text' => get_icon( 'publish', 'imgtag' ).' '.T_('Publish!'),
 
1087
                        'title' => T_('Publish this comment!'),
 
1088
                        'class' => '',
 
1089
                        'glue' => '&amp;',
 
1090
                        'save_context' => true,
 
1091
                ), $params );
950
1092
 
951
1093
                $r = $params['before'];
952
1094
                $r .= '<a href="';
956
1098
                        $r .= $params['glue'].'redirect_to='.rawurlencode( regenerate_url( '', '', '', '&' ) );
957
1099
                }
958
1100
                $r .= '" title="'.$params['title'].'"';
959
 
                if( !empty( $params['class'] ) )
 
1101
                if( ! empty( $params['class'] ) )
960
1102
                {
961
1103
                        $r .= ' class="'.$params['class'].'"';
962
1104
                }
971
1113
         * Get title of comment, e.g. "Comment from: Foo Bar"
972
1114
         *
973
1115
         * @param array Params
974
 
         *   'author_format': Formatting of the author (%s gets replaced with
975
 
         *                    the author string)
 
1116
         * - 'author_format': Formatting of the author (%s gets replaced with the author string)
976
1117
         * @return string
977
1118
         */
978
 
        function get_title($params = array())
 
1119
        function get_title( $params = array() )
979
1120
        {
980
 
                if( empty($params['author_format']) )
 
1121
                if( empty( $params['author_format'] ) )
981
1122
                {
982
1123
                        $params['author_format'] = '%s';
983
1124
                }
984
 
                $author = sprintf($params['author_format'], $this->get_author());
 
1125
                $author = sprintf( $params['author_format'], $this->get_author() );
985
1126
 
986
1127
                switch( $this->get( 'type' ) )
987
1128
                {
988
 
                        case 'comment': // Display a comment:
989
 
                                $s = T_('Comment from %s');
990
 
                                break;
 
1129
                        case 'comment': // Display a comment
 
1130
                        $s = T_('Comment from %s');
 
1131
                        break;
991
1132
 
992
 
                        case 'trackback': // Display a trackback:
993
 
                                $s = T_('Trackback from %s');
994
 
                                break;
 
1133
                        case 'trackback': // Display a trackback
 
1134
                        $s = T_('Trackback from %s');
 
1135
                        break;
995
1136
                }
996
 
                return sprintf($s, $author);
 
1137
                return sprintf( $s, $author );
997
1138
        }
998
1139
 
999
1140
 
1003
1144
         * <code>
1004
1145
         * $params = array_merge( array(
1005
1146
         *   'before' => '',
1006
 
         *   'after'  => ' ',
1007
 
         *   'text'   => '#', // '#' = get_icon( 'email', 'imgtag', array( 'class' => 'middle', 'title' => $params['title'] ) )
1008
 
         *   'title'  => T_('Send email to comment author'),
1009
 
         *   'class'  => '',
 
1147
         *   'after' => ' ',
 
1148
         *   'text' => '#',
 
1149
         *   'title' => T_('Send email to comment author'),
 
1150
         *   'class' => '',
1010
1151
         * ), $params );
1011
1152
         * </code>
1012
1153
         *
 
1154
         * @todo (0000) have an SEO setting for nofollow, default to nofollow
 
1155
         * @todo (1111) defaults should be empty not space
 
1156
         * @uses Comment::get_author_User()
 
1157
         * @uses url_add_param()
1013
1158
         * @param string url of the message form
 
1159
         * @param array Associative array of parameters
1014
1160
         */
1015
1161
        function msgform_link( $form_url, $params = array() )
1016
1162
        {
1017
1163
                if( $this->get_author_User() )
1018
 
                { // This comment is from a registered user:
1019
 
                        if( empty($this->author_User->email) )
1020
 
                        { // We have no email for this Author :(
 
1164
                {
 
1165
                        // This comment is from a registered user
 
1166
                        if( empty( $this->author_User->email ) )
 
1167
                        {
 
1168
                                // We have no email for this Author :(
1021
1169
                                return false;
1022
1170
                        }
1023
 
                        elseif( empty($this->author_User->allow_msgform) )
1024
 
                        { // User does not allow message form
 
1171
                        elseif( empty( $this->author_User->allow_msgform ) )
 
1172
                        {
 
1173
                                // User does not allow message form
1025
1174
                                return false;
1026
1175
                        }
1027
1176
                        $form_url = url_add_param( $form_url, 'recipient_id='.$this->author_User->ID );
1028
1177
                }
1029
1178
                else
1030
 
                { // This comment is from a visitor:
1031
 
                        if( empty($this->author_email) )
1032
 
                        { // We have no email for this comment :(
 
1179
                {
 
1180
                        // This comment is from a visitor:
 
1181
                        if( empty( $this->author_email ) )
 
1182
                        {
 
1183
                                // We have no email for this comment :(
1033
1184
                                return false;
1034
1185
                        }
1035
 
                        elseif( empty($this->allow_msgform) )
1036
 
                        { // Anonymous commentator does not allow message form (for this comment)
 
1186
                        elseif( empty( $this->allow_msgform ) )
 
1187
                        {
 
1188
                                // Anonymous commentator does not allow message form (for this comment)
1037
1189
                                return false;
1038
1190
                        }
1039
1191
                }
1040
1192
 
1041
1193
                $form_url = url_add_param( $form_url, 'comment_id='.$this->ID.'&amp;post_id='.$this->item_ID
1042
 
                                .'&amp;redirect_to='.rawurlencode(url_rel_to_same_host(regenerate_url('','','','&'), $form_url)) );
 
1194
                                .'&amp;redirect_to='.rawurlencode( url_rel_to_same_host( regenerate_url( '','','','&' ), $form_url ) ) );
1043
1195
 
1044
 
                // Make sure we are not missing any param:
 
1196
                // make sure we aren't missing any required params
1045
1197
                $params = array_merge( array(
1046
 
                                'before' => '',
1047
 
                                'after'  => ' ',
1048
 
                                'text'   => '#',
1049
 
                                'title'  => T_('Send email to comment author'),
1050
 
                                'class'  => '',
1051
 
                        ), $params );
 
1198
                        'before' => '',
 
1199
                        'after' => ' ',
 
1200
                        'text' => '#',
 
1201
                        'title' => T_('Send email to comment author'),
 
1202
                        'class' => '',
 
1203
                ), $params );
1052
1204
 
1053
1205
                // gotta be done this way due to you can't use $params when array_merging $params
1054
1206
                if( $params['text'] == '#' ) $params['text'] = get_icon( 'email', 'imgtag', array( 'class' => 'middle', 'title' => $params['title'] ) );
1055
1207
 
1056
1208
                echo $params['before'];
1057
1209
                echo '<a href="'.$form_url.'" title="'.$params['title'].'"';
1058
 
                if( !empty( $params['class'] ) )
 
1210
                if( ! empty( $params['class'] ) )
1059
1211
                {
1060
1212
                        echo ' class="'.$params['class'].'"';
1061
1213
                }
1062
 
                // TODO: have an SEO setting for nofollow here, default to nofollow
1063
1214
                echo ' rel="nofollow"';
1064
1215
                echo '>'.$params['text'].'</a>';
1065
1216
                echo $params['after'];
1069
1220
 
1070
1221
 
1071
1222
        /**
1072
 
         * T-tag: Displays a permalink link to the Comment
 
1223
         * T-Tag: Displays a permalink link to the Comment
1073
1224
         *
1074
 
         * Note: If you only want the permalink URL, use Comment::permanent_url()
 
1225
         * If you only want the permalink URL, use Comment::permanent_url()
1075
1226
         *
1076
1227
         * <code>
1077
1228
         * $params = array_merge( array(
1078
 
         *   'before'   => '',
1079
 
         *   'after'    => ' ',
1080
 
         *   'text'     => '#', // '#' = see below
1081
 
         *   'title'    => T_('Permanent link to this comment'),
1082
 
         *   'class'    => '',
 
1229
         *   'before' => '',
 
1230
         *   'after' => ' ',
 
1231
         *   'text' => '#', // '#' = see below
 
1232
         *   'title' => T_('Permanent link to this comment'),
 
1233
         *   'class' => '',
1083
1234
         *   'nofollow' => true,
1084
1235
         * ), $params );
1085
1236
         * </code>
1088
1239
         * 'text' => '#icon#' = get_icon( 'permalink' )<br />
1089
1240
         * 'text' => '#text#' = T_('Permalink')
1090
1241
         *
 
1242
         * @todo (1111) defaults should be empty not space
1091
1243
         * @uses Comment::get_permanent_link()
 
1244
         * @param array Associative array of parameters
1092
1245
         */
1093
1246
        function permanent_link( $params = array() )
1094
1247
        {
1095
 
                // Make sure we are not missing any param:
 
1248
                // make sure we aren't missing any required params
1096
1249
                $params = array_merge( array(
1097
 
                                'before'   => '',
1098
 
                                'after'    => ' ',
1099
 
                                'text'     => '#',
1100
 
                                'title'    => T_('Permanent link to this comment'),
1101
 
                                'class'    => '',
1102
 
                                'nofollow' => false,
1103
 
                        ), $params );
 
1250
                        'before' => '',
 
1251
                        'after' => ' ',
 
1252
                        'text' => '#',
 
1253
                        'title' => T_('Permanent link to this comment'),
 
1254
                        'class' => '',
 
1255
                        'nofollow' => false,
 
1256
                ), $params );
1104
1257
 
1105
1258
                echo $params['before'];
1106
1259
                echo $this->get_permanent_link( $params );
1109
1262
 
1110
1263
 
1111
1264
        /**
1112
 
         * Template function: display permalink to this comment
 
1265
         * T-Tag: display permalink to this comment
1113
1266
         *
1114
 
         * Note: This actually only returns the URL, to get a real link, use Comment::permanent_link()
 
1267
         * Note: This only displays the URL; to get a real link use Comment::permanent_link()
1115
1268
         *
1116
1269
         * @param string 'urltitle', 'pid', 'archive#id' or 'archive#title'
1117
1270
         * @param string url to use
1126
1279
         * T-Tag: Display a link to publish a comment if user has edit rights
1127
1280
         *
1128
1281
         * @uses Comment::get_publish_link()
 
1282
         * @param array Associative array of parameters
1129
1283
         */
1130
1284
        function publish_link( $params = array())
1131
1285
        {
1138
1292
         *
1139
1293
         * <code>
1140
1294
         * $params = array_merge( array(
1141
 
         *   'before'     => '<div class="comment_rating">',
1142
 
         *   'after'      => '</div>',
 
1295
         *   'before' => '<div class="comment_rating">',
 
1296
         *   'after' => '</div>',
1143
1297
         *   'star_class' => 'middle',
1144
1298
         * ), $params );
1145
1299
         * </code>
 
1300
         *
 
1301
         * @uses star_rating()
 
1302
         * @param array Associative array of parameters
1146
1303
         */
1147
1304
        function rating( $params = array() )
1148
1305
        {
1151
1308
                        return false;
1152
1309
                }
1153
1310
 
1154
 
                // Make sure we are not missing any param:
 
1311
                // make sure we aren't missing any required params
1155
1312
                $params = array_merge( array(
1156
 
                                'before'     => '<div class="comment_rating">',
1157
 
                                'after'      => '</div>',
1158
 
                                'star_class' => 'middle',
1159
 
                        ), $params );
 
1313
                        'before' => '<div class="comment_rating">',
 
1314
                        'after' => '</div>',
 
1315
                        'star_class' => 'middle',
 
1316
                ), $params );
1160
1317
 
1161
1318
                echo $params['before'];
1162
1319
                star_rating( $this->rating, $params['star_class'] );
1169
1326
         *
1170
1327
         * <code>
1171
1328
         * $params = array_merge( array(
1172
 
         *   'before'     => '',
1173
 
         *   'after'      => '',
1174
 
         *   'label_low'  => T_('Poor'),
 
1329
         *   'before' => '',
 
1330
         *   'after' => '',
 
1331
         *   'label_low' => T_('Poor'),
1175
1332
         *   'label_high' => T_('Excellent'),
1176
1333
         * ), $params );
1177
1334
         * </code>
 
1335
         *
 
1336
         * @param array Associative array of parameters
1178
1337
         */
1179
1338
        function rating_input( $params = array() )
1180
1339
        {
1181
 
                // Make sure we are not missing any param:
 
1340
                // make sure we aren't missing any required params
1182
1341
                $params = array_merge( array(
1183
 
                                'before'     => '',
1184
 
                                'after'      => '',
1185
 
                                'label_low'  => T_('Poor'),
1186
 
                                'label_high' => T_('Excellent'),
1187
 
                        ), $params );
 
1342
                        'before' => '',
 
1343
                        'after' => '',
 
1344
                        'label_low' => T_('Poor'),
 
1345
                        'label_high' => T_('Excellent'),
 
1346
                ), $params );
1188
1347
 
1189
1348
                echo $params['before'];
1190
1349
                echo $params['label_low'];
1210
1369
         * <code>
1211
1370
         * $params = array_merge( array(
1212
1371
         *   'before' => '',
1213
 
         *   'after'  => '',
1214
 
         *   'label'  => T_('No rating'),
 
1372
         *   'after' => '',
 
1373
         *   'label' => T_('No rating'),
1215
1374
         * ), $params );
1216
1375
         * </code>
 
1376
         *
 
1377
         * @param array Associative array of parameters
1217
1378
         */
1218
1379
        function rating_none_input( $params = array() )
1219
1380
        {
1220
 
                // Make sure we are not missing any param:
 
1381
                // make sure we aren't missing any required params
1221
1382
                $params = array_merge( array(
1222
 
                                'before' => '',
1223
 
                                'after'  => '',
1224
 
                                'label'  => T_('No rating'),
1225
 
                        ), $params );
 
1383
                        'before' => '',
 
1384
                        'after' => '',
 
1385
                        'label' => T_('No rating'),
 
1386
                ), $params );
1226
1387
 
1227
1388
                echo $params['before'];
1228
1389
                echo '<label><input type="radio" class="radio" name="comment_rating" value="0"';
1229
 
                if( empty($this->rating) )
 
1390
                if( empty( $this->rating ) )
1230
1391
                {
1231
1392
                        echo ' checked="checked"';
1232
1393
                }
1237
1398
 
1238
1399
 
1239
1400
        /**
1240
 
         * Send email notifications to subscribed users:
 
1401
         * Send email notifications to subscribed users
1241
1402
         *
1242
 
         * @todo fp> SEPARATE MODERATION notifications from SUBSCRIPTION notifications
1243
 
         * @todo shall we notify suscribers of blog were this is in extra-cat?
1244
 
         * @todo cache message by locale like {@link Item::send_email_notifications()}
1245
 
         * @todo dh> Indicator in url to see where the user came from (&from=subnote ["subscription notification"]) - Problem: too long urls.
1246
 
         * @todo dh> "Beautify" like {@link Item::send_email_notifications()} ? fp > sure
1247
 
         * @todo Should include "visibility status" in the mail to the Item's Author
 
1403
         * So far you get notifications for everything. We'll need a setting to decide
 
1404
         * if you want to received unmoderated (aka unpublished) comments or not. Note:
 
1405
         * users receive comments on their own posts. This is done on purpose. Otherwise
 
1406
         * they think it's broken when they test the app.
1248
1407
         */
1249
1408
        function send_email_notifications()
1250
1409
        {
1251
 
                global $DB, $admin_url, $debug, $Debuglog;
 
1410
                global $admin_url;
 
1411
                global $DB;
 
1412
                global $debug;
1252
1413
 
1253
1414
                $edited_Item = & $this->get_Item();
1254
1415
                $edited_Blog = & $edited_Item->get_Blog();
1256
1417
                $notify_array = array();
1257
1418
 
1258
1419
                if( $edited_Blog->get_setting( 'allow_subscriptions' ) )
1259
 
                { // Get list of users who want to be notfied:
1260
 
                        // TODO: also use extra cats/blogs??
1261
 
                        // So far you get notifications for everything. We'll need a setting to decide if you want to received unmoderated (aka unpublished) comments or not.
1262
 
                        // Note: users receive comments on their own posts. This is done on purpose. Otherwise they think it's broken when they test the app.
 
1420
                {
 
1421
                        // Get list of users who want to be notified
1263
1422
                        $sql = 'SELECT DISTINCT user_email, user_locale
1264
 
                                                                FROM T_subscriptions INNER JOIN T_users ON sub_user_ID = user_ID
1265
 
                                                         WHERE sub_coll_ID = '.$this->Item->get_blog_ID().'
1266
 
                                                                 AND sub_comments <> 0
1267
 
                                                                 AND LENGTH(TRIM(user_email)) > 0';
 
1423
                                FROM T_subscriptions INNER JOIN T_users ON sub_user_ID = user_ID
 
1424
                                WHERE sub_blog_ID = '.$this->Item->get_blog_ID().'
 
1425
                                AND sub_comments <> 0
 
1426
                                AND LENGTH(TRIM(user_email)) > 0';
1268
1427
                        $notify_list = $DB->get_results( $sql );
1269
1428
 
1270
 
                        // Preprocess list:
 
1429
                        // Preprocess list
1271
1430
                        foreach( $notify_list as $notification )
1272
1431
                        {
1273
1432
                                $notify_array[$notification->user_email] = $notification->user_locale;
1274
1433
                        }
1275
1434
                }
1276
1435
 
1277
 
                // Check if we need to include the author:
 
1436
                // Check if we need to include the author
1278
1437
                $item_author_User = & $edited_Item->get_creator_User();
1279
1438
                if( $item_author_User->notify
1280
1439
                                && ( ! empty( $item_author_User->email ) ) )
1281
 
                { // Author wants to be notified...
1282
 
                        if( ! ($this->get_author_User() // comment is from registered user
1283
 
                                && $item_author_User->login == $this->author_User->login) ) // comment is from same user as post
1284
 
                                { // Author is not commenting on his own post...
 
1440
                {
 
1441
                        // Author wants to be notified
 
1442
                        if( ! ( $this->get_author_User() // comment is from registered user
 
1443
                                && $item_author_User->login == $this->author_User->login ) ) // comment is from same user as post
 
1444
                                {
 
1445
                                        // Author is not commenting on his own post...
1285
1446
                                        $notify_array[$item_author_User->email] = $item_author_User->locale;
1286
1447
                                }
1287
1448
                }
1288
1449
 
1289
 
                if( ! count($notify_array) )
1290
 
                { // No-one to notify:
1291
 
                        return false;
 
1450
                if( ! count( $notify_array ) )
 
1451
                {
 
1452
                        return false; // No-one to notify
1292
1453
                }
1293
1454
 
1294
 
                /*
1295
 
                 * We have a list of email addresses to notify:
1296
 
                 */
1297
 
                // TODO: dh> this reveals the comments author's email address to all subscribers!!
1298
 
                //           $notify_from should get used by default, unless the user has opted in to be the sender!
1299
 
                // fp>If the subscriber has permission to moderate the comments, he SHOULD receive the email address.
 
1455
                // We have a list of email addresses to notify
 
1456
                // @todo (0000) dh> this reveals the comments author's email address to all
 
1457
                // subscribers!! $notify_from should get used by default, unless the user has
 
1458
                // opted in to be the sender! fp> If the subscriber has permission to moderate
 
1459
                // the comments, he SHOULD receive the email address.
1300
1460
                if( $this->get_author_User() )
1301
 
                { // Comment from a registered user:
1302
 
                        $mail_from = $this->author_User->get('email');
1303
 
                        $mail_from_name = $this->author_User->get('preferredname');
 
1461
                {
 
1462
                        // Comment from a registered user
 
1463
                        $mail_from = $this->author_User->get( 'email' );
 
1464
                        $mail_from_name = $this->author_User->get( 'preferredname' );
1304
1465
                }
1305
1466
                elseif( ! empty( $this->author_email ) )
1306
 
                { // non-member, but with email address:
 
1467
                {
 
1468
                        // non-member, but with email address
1307
1469
                        $mail_from = $this->author_email;
1308
1470
                        $mail_from_name = $this->author;
1309
1471
                }
1310
1472
                else
1311
 
                { // Fallback (we have no email address):  fp>TODO: or the subscriber is not allowed to view it.
 
1473
                {
1312
1474
                        global $notify_from;
 
1475
 
 
1476
                        // Fallback (we have no email address): fp>TODO: or the subscriber is not allowed to view it
1313
1477
                        $mail_from = $notify_from;
1314
1478
                        $mail_from_name = NULL;
1315
1479
                }
1316
1480
 
1317
 
                // Send emails:
 
1481
                // Send emails
1318
1482
                foreach( $notify_array as $notify_email => $notify_locale )
1319
1483
                {
1320
 
                        locale_temp_switch($notify_locale);
 
1484
                        locale_temp_switch( $notify_locale );
1321
1485
 
1322
1486
                        switch( $this->type )
1323
1487
                        {
1324
1488
                                case 'trackback':
1325
 
                                        /* TRANS: Subject of the mail to send on new trackbacks. First %s is the blog's shortname, the second %s is the item's title. */
1326
 
                                        $subject = T_('[%s] New trackback on "%s"');
1327
 
                                        break;
 
1489
                                /* TRANS: Subject of the mail to send on new trackbacks. First %s is the blog's shortname, the second %s is the item's title. */
 
1490
                                $subject = T_('[%s] New trackback on "%s"');
 
1491
                                break;
1328
1492
 
1329
1493
                                default:
1330
 
                                        /* TRANS: Subject of the mail to send on new comments. First %s is the blog's shortname, the second %s is the item's title. */
1331
 
                                        $subject = T_('[%s] New comment on "%s"');
 
1494
                                /* TRANS: Subject of the mail to send on new comments. First %s is the blog's shortname, the second %s is the item's title. */
 
1495
                                $subject = T_('[%s] New comment on "%s"');
1332
1496
                        }
1333
1497
 
1334
 
                        $subject = sprintf( $subject, $edited_Blog->get('shortname'), $edited_Item->get('title') );
 
1498
                        $subject = sprintf( $subject, $edited_Blog->get( 'shortname' ), $edited_Item->get( 'title' ) );
1335
1499
 
1336
 
                        $notify_message = T_('Blog').': '.$edited_Blog->get('shortname')."\n"
 
1500
                        $notify_message = T_('Blog').': '.$edited_Blog->get( 'shortname' )."\n"
1337
1501
                                // Mail bloat: .' ( '.str_replace('&amp;', '&', $edited_Blog->gen_blogurl())." )\n"
1338
 
                                .T_('Post').': '.$edited_Item->get('title')."\n";
 
1502
                                .T_('Post').': '.$edited_Item->get( 'title' )."\n";
1339
1503
                                // Mail bloat: .' ( '.str_replace('&amp;', '&', $edited_Item->get_permanent_url())." )\n";
1340
 
                                // TODO: fp> We MAY want to force short URL and avoid it to wrap on a new line in the mail which may prevent people from clicking
1341
1504
 
1342
1505
                        switch( $this->type )
1343
1506
                        {
1344
1507
                                case 'trackback':
1345
 
                                        $user_domain = gethostbyaddr($this->author_IP);
1346
 
                                        $notify_message .= T_('Website').": $this->author (IP: $this->author_IP, $user_domain)\n";
 
1508
                                $user_domain = gethostbyaddr( $this->author_IP );
 
1509
                                $notify_message .= T_('Website').": $this->author (IP: $this->author_IP, $user_domain)\n";
 
1510
                                $notify_message .= T_('Url').": $this->author_url\n";
 
1511
                                break;
 
1512
 
 
1513
                                default:
 
1514
                                if( $this->get_author_User() )
 
1515
                                {
 
1516
                                        // Comment from a registered user
 
1517
                                        $notify_message .= T_('Author').': '.$this->author_User->get( 'preferredname' ).' ('.$this->author_User->get( 'login' ).")\n";
 
1518
                                }
 
1519
                                else
 
1520
                                {
 
1521
                                        // Comment from visitor
 
1522
                                        $user_domain = gethostbyaddr( $this->author_IP );
 
1523
                                        $notify_message .= T_('Author').": $this->author (IP: $this->author_IP, $user_domain)\n";
 
1524
                                        $notify_message .= T_('Email').": $this->author_email\n";
1347
1525
                                        $notify_message .= T_('Url').": $this->author_url\n";
1348
 
                                        break;
1349
 
 
1350
 
                                default:
1351
 
                                        if( $this->get_author_User() )
1352
 
                                        { // Comment from a registered user:
1353
 
                                                $notify_message .= T_('Author').': '.$this->author_User->get('preferredname').' ('.$this->author_User->get('login').")\n";
1354
 
                                        }
1355
 
                                        else
1356
 
                                        { // Comment from visitor:
1357
 
                                                $user_domain = gethostbyaddr($this->author_IP);
1358
 
                                                $notify_message .= T_('Author').": $this->author (IP: $this->author_IP, $user_domain)\n";
1359
 
                                                $notify_message .= T_('Email').": $this->author_email\n";
1360
 
                                                $notify_message .= T_('Url').": $this->author_url\n";
1361
 
                                        }
 
1526
                                }
1362
1527
                        }
1363
1528
 
1364
 
                        $notify_message =
1365
 
                                T_('Comment').': '.str_replace('&amp;', '&', $this->get_permanent_url())."\n"
1366
 
                                // TODO: fp> We MAY want to force a short URL and avoid it to wrap on a new line in the mail which may prevent people from clicking
1367
 
                                .$notify_message;
 
1529
                        $notify_message = T_('Comment').': '.str_replace('&amp;', '&', $this->get_permanent_url())."\n".$notify_message;
1368
1530
 
1369
 
                        if( !empty( $this->rating ) )
 
1531
                        if( ! empty( $this->rating ) )
1370
1532
                        {
1371
1533
                                $notify_message .= T_('Rating').": $this->rating\n";
1372
1534
                        }
1373
1535
 
1374
 
                        $notify_message .= $this->get('content')
 
1536
                        $notify_message .= $this->get( 'content' )
1375
1537
                                ."\n\n-- \n"
1376
1538
                                .T_('Edit/Delete').': '.$admin_url.'?ctrl=items&blog='.$edited_Blog->ID.'&p='.$edited_Item->ID.'&c=1#c'.$this->ID."\n\n"
1377
1539
                                .T_('Edit your subscriptions/notifications').': '.str_replace('&amp;', '&', url_add_param( $edited_Blog->gen_blogurl(), 'disp=subs' ) )."\n";
1381
1543
                                $mail_dump = "Sending notification to $notify_email:<pre>Subject: $subject\n$notify_message</pre>";
1382
1544
 
1383
1545
                                if( $debug >= 2 )
1384
 
                                { // output mail content - NOTE: this will kill sending of headers.
 
1546
                                {
 
1547
                                        // output mail content - NOTE: this will kill sending of headers
1385
1548
                                        echo "<p>$mail_dump</p>";
1386
1549
                                }
1387
 
 
1388
 
                                $Debuglog->add( $mail_dump, 'notification' );
1389
1550
                        }
1390
1551
 
1391
1552
                        send_mail( $notify_email, NULL, $subject, $notify_message, $mail_from, $mail_from_name );
1427
1588
 
1428
1589
        /**
1429
1590
         * Set Item this comment relates to
 
1591
         *
1430
1592
         * @param Item
1431
1593
         */
1432
1594
        function set_Item( & $Item )
1438
1600
 
1439
1601
 
1440
1602
        /**
1441
 
         * Template function: display spam karma of the comment (in percent)
 
1603
         * Display spam karma of the comment (in percent)
1442
1604
         *
1443
1605
         * "%s" gets replaced by the karma value
1444
1606
         *
1447
1609
         */
1448
1610
        function spam_karma( $template = '%s%', $template_unknown = NULL )
1449
1611
        {
1450
 
                if( isset($this->spam_karma) )
 
1612
                if( isset( $this->spam_karma ) )
1451
1613
                {
1452
1614
                        echo str_replace( '%s', $this->spam_karma, $template );
1453
1615
                }
1454
1616
                else
1455
1617
                {
1456
 
                        if( ! isset($template_unknown) )
 
1618
                        if( ! isset( $template_unknown ) )
1457
1619
                        {
1458
1620
                                echo /* TRANS: "not available" */ T_('N/A');
1459
1621
                        }
1467
1629
 
1468
1630
        /**
1469
1631
         * Set the spam karma, as a number.
 
1632
         *
1470
1633
         * @param integer Spam karma (-100 - 100)
1471
 
         * @access protected
1472
1634
         */
1473
1635
        function set_spam_karma( $spam_karma )
1474
1636
        {
1477
1639
 
1478
1640
 
1479
1641
        /**
1480
 
         * Template function: display status of comment
1481
 
         *
1482
 
         * Statuses:
1483
 
         * - published
1484
 
         * - deprecated
1485
 
         * - protected
1486
 
         * - private
1487
 
         * - draft
1488
 
         *
1489
 
         * @param string Output format, see {@link format_to_output()}
 
1642
         * Display status of comment
 
1643
         *
 
1644
         * Can be: published, deprecated, protected, private, or draft
 
1645
         *
 
1646
         * @uses Comment::disp()
 
1647
         * @uses format_to_output()
 
1648
         * @uses Comment::get()
 
1649
         * @param string Output format (see {@link format_to_output()})
1490
1650
         */
1491
1651
        function status( $format = 'htmlbody' )
1492
1652
        {
1498
1658
                }
1499
1659
                else
1500
1660
                {
1501
 
                        echo format_to_output( $this->get('t_status'), $format );
 
1661
                        echo format_to_output( $this->get( 't_status' ), $format );
1502
1662
                }
1503
1663
        }
1504
1664
 
1509
1669
         * <code>
1510
1670
         * $params = array_merge( array(
1511
1671
         *   'before' => '',
1512
 
         *   'after'  => '',
 
1672
         *   'after' => '',
1513
1673
         *   'format' => locale_datefmt(),
1514
 
         *   'useGM'  => false,
 
1674
         *   'useGM' => false,
1515
1675
         * ), $params );
1516
1676
         * </code>
 
1677
         *
 
1678
         * @uses mysql2date()
 
1679
         * @param array Associative array of parameters
1517
1680
         */
1518
1681
        function time( $params = array() )
1519
1682
        {
1520
 
                // Make sure we are not missing any param:
 
1683
                // make sure we aren't missing any required params
1521
1684
                $params = array_merge( array(
1522
 
                                'before' => '',
1523
 
                                'after'  => '',
1524
 
                                'format' => locale_datefmt(),
1525
 
                                'useGM'  => false,
1526
 
                        ), $params );
 
1685
                        'before' => '',
 
1686
                        'after' => '',
 
1687
                        'format' => locale_datefmt(),
 
1688
                        'useGM' => false,
 
1689
                ), $params );
1527
1690
 
1528
1691
                echo $params['before'];
1529
1692
                echo mysql2date( $params['format'], $this->date, $params['useGM'] );
1530
1693
                echo $params['after'];
1531
1694
        }
1532
1695
 
1533
 
 
1534
1696
}
1535
1697
 
1536
1698
?>