Source for file _class_comment.php
Documentation is available at _class_comment.php
* This file implements comments
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
require_once dirname(__FILE__
).
'/_class_dataobject.php';
global $tablecomments, $ItemCache;
// Call parent constructor:
parent::DataObject( $tablecomments, 'comment_', 'comment_ID' );
$this->ID =
$db_row['comment_ID'];
$this->Item =
$ItemCache->get_by_ID( $db_row['comment_post_ID'] );
$author_ID =
$db_row['comment_author_ID'];
$this->type =
$db_row['comment_type'];
$this->status =
$db_row['comment_status'];
$this->author =
$db_row['comment_author'];
$url =
trim( $db_row['comment_author_url'] );
$url =
preg_replace('#&([^amp\;])#is', '&$1', $url); // Escape &
$this->author_ip =
$db_row['comment_author_IP'];
$this->date =
$db_row['comment_date'];
$this->content =
$db_row['comment_content'];
$this->karma =
$db_row['comment_karma'];
function set( $parname, $parvalue )
die ('coment->Post assignement not handled');
parent::set_param( $parname, 'number', $parvalue );
parent::set_param( $parname, 'string', $parvalue );
* Template function: display anchor for permalinks to refer to
* {@internal Comment::anchor(-) }}
echo
'<a name="c'.
$this->ID.
'"></a>';
* Template function: display author of comment
* {@internal Comment::author(-) }}
* @param string String to display before author name if not a user
* @param string String to display after author name if not a user
* @param string String to display before author name if he's a user
* @param string String to display after author name if he's a user
* @param string Output format, see {@link format_to_output()}
* @param boolean true for link, false if you want NO html link
function author( $before =
'', $after =
'#', $before_user =
'', $after_user =
'#',
$format =
'htmlbody', $makelink =
false )
if( $after_user ==
'#' ) $after_user =
' ['.
T_('Member').
']';
{ // Display info recorded at edit time:
if( $after ==
'#' ) $after =
' ['.
T_('Visitor').
']';
if( $makelink ) echo
'<a href="'.
$this->author_url.
'">';
$this->disp( 'author', $format );
if( $makelink ) echo
'</a>';
* Template function: display comment's author's IP
* {@internal Comment::author_ip(-) }}
* @param string String to display before IP, if IP exists
* @param string String to display after IP, if IP exists
* Template function: display link to comment author's provided email
* {@internal Comment::author_email(-) }}
* @param string String to display for link: leave empty to display email
* @param string String to display before email, if email exists
* @param string String to display after email, if email exists
* @param boolean false if you want NO html link
function author_email( $linktext=
'', $before=
'', $after=
'', $makelink =
true )
if( $makelink ) echo
'<a href="mailto:'.
$email.
'">';
echo
($linktext !=
'') ?
$linktext :
$email;
if( $makelink ) echo
'</a>';
* Template function: display link to comment author's provided URL
* {@internal Comment::author_url(-) }}
* @param string String to display for link: leave empty to display URL
* @param string String to display before link, if link exists
* @param string String to display after link, if link exists
* @param boolean false if you want NO html link
* @return boolean true if URL has been displayed
function author_url( $linktext=
'', $before=
'', $after=
'', $makelink =
true )
if( $makelink ) echo
'<a href="'.
$url.
'" rel="nofollow">';
echo
($linktext !=
'') ?
$linktext :
$url;
if( $makelink ) echo
'</a>';
* Provide link to edit a comment if user has edit rights
* {@internal Comment::edit_link(-)}}
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
function edit_link( $before =
' ', $after =
' ', $text =
'#', $title =
'#', $class =
'' )
global $current_User, $admin_url;
if( ! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get( 'blog_ID' ) ) )
{ // If User has no permission to edit comments:
if( $text ==
'#' ) $text =
T_('Edit');
if( $title ==
'#' ) $title =
T_('Edit this comment');
echo
'<a href="'.
$admin_url.
'/b2edit.php?action=editcomment&comment='.
$this->ID;
echo
'" title="'.
$title.
'"';
if( !empty( $class ) ) echo
' class="'.
$class.
'"';
* Displays button for deleeing the Comment if user has proper rights
* {@internal Comment::delete_link(-)}}
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
* @param boolean true to make this a button instead of a link
function delete_link( $before =
' ', $after =
' ', $text =
'#', $title =
'#', $class =
'', $button =
false )
global $current_User, $admin_url;
if( ! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get( 'blog_ID' ) ) )
{ // If User has permission to edit comments:
if( $text ==
'#' ) $text =
T_('Delete');
if( $title ==
'#' ) $title =
T_('Delete this comment');
$url =
$admin_url.
'/edit_actions.php?action=deletecomment&comment_ID='.
$this->ID;
echo
'<input type="button"';
echo
' value="'.
$text.
'" title="'.
$title.
'" onclick="if ( confirm(\'';
/* TRANS: Warning this is a javascript string */
echo
T_('You are about to delete this comment!\\n\\\'Cancel\\\' to stop, \\\'OK\\\' to delete.');
echo
'\') ) { document.location.href=\''.
$url.
'\' }"';
if( !empty( $class ) ) echo
' class="'.
$class.
'"';
echo
'<a href="'.
$url.
'" title="'.
$title.
'" onclick="return confirm(\'';
/* TRANS: Warning this is a javascript string */
echo
T_('You are about to delete this comment!\\n\\\'Cancel\\\' to stop, \\\'OK\\\' to delete.');
if( !empty( $class ) ) echo
' class="'.
$class.
'"';
* Template function: display permalink to this comment
* {@internal Comment::permalink(-) }}
* @param string 'urltitle', 'pid', 'archive#id' or 'archive#title'
* @param string url to use
function permalink( $mode =
'', $blogurl=
'' )
$mode =
$Settings->get( 'permalink_type' );
// some permalink modes are not acceptable here:
$post_permalink =
$this->Item->gen_permalink( $mode, $blogurl );
echo
$post_permalink.
'#c'.
$this->ID;
* Template function: display content of comment
* {@internal Comment::content(-) }}
* @param string Output format, see {@link format_to_output()}
function content( $format =
'htmlbody' )
* Template function: display date (datetime) of comment
* {@internal Comment::date(-) }}
* @param string date/time format: leave empty to use locale default date format
* @param boolean true if you want GMT
function date( $format=
'', $useGM =
false )
* Template function: display time (datetime) of comment
* {@internal Comment::time(-) }}
* @param string date/time format: leave empty to use locale default time format
* @param boolean true if you want GMT
function time( $format=
'', $useGM =
false )