Source for file _functions_comments.php
Documentation is available at _functions_comments.php
* 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/}
* @author This file built upon code from original b2 - http://cafelog.com/
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
require_once dirname(__FILE__
).
'/_class_comment.php';
* generic comments/trackbacks/pingbacks numbering
* fplanque: added stuff to load all number for this page at ounce
global $DB, $debug, $postdata, $tablecomments, $cache_ctp_number, $use_cache, $preview;
{ // we are in preview mode, no comments yet!
if( $mode ==
'feedbacks' ) $mode =
'ctp';
// fplanque added: load whole cache
if (!isset
($cache_ctp_number) ||
(!$use_cache))
global $postIDlist, $postIDarray;
// if( $debug ) echo "LOADING generic_ctp_number CACHE for posts: $postIDlist<br />";
foreach( $postIDarray as $tmp_post_id)
{ // Initializes each post to nocount!
$cache_ctp_number[$tmp_post_id] =
array( 'comments' =>
0, 'trackbacks' =>
0, 'pingbacks' =>
0, 'ctp' =>
0);
$query =
"SELECT comment_post_ID, comment_type, COUNT(*) AS type_count
WHERE comment_post_ID IN ($postIDlist)
GROUP BY comment_post_ID, comment_type";
$rows =
$DB->get_results( $query );
if( count( $rows ) ) foreach( $rows as $row )
switch( $row->comment_type )
$cache_ctp_number[$row->comment_post_ID]['comments'] =
$row->type_count;
$cache_ctp_number[$row->comment_post_ID]['trackbacks'] =
$row->type_count;
$cache_ctp_number[$row->comment_post_ID]['pingbacks'] =
$row->type_count;
$cache_ctp_number[$row->comment_post_ID]['ctp'] +=
$row->type_count;
if (!isset
($cache_ctp_number[$post_id]) ||
(!$use_cache))
{ // this should be extremely rare...
// echo "CACHE not set for $post_id";
$query =
"SELECT comment_post_ID, comment_type, COUNT(*) AS type_count
WHERE comment_post_ID = $post_id
GROUP BY comment_post_ID, comment_type";
$rows =
$DB->get_results( $query );
if( count( $rows ) ) foreach( $rows as $row )
switch( $row->comment_type )
$cache_ctp_number[$row->comment_post_ID]['comments'] =
$row->type_count;
$cache_ctp_number[$row->comment_post_ID]['trackbacks'] =
$row->type_count;
$cache_ctp_number[$row->comment_post_ID]['pingbacks'] =
$row->type_count;
$cache_ctp_number[$row->comment_post_ID]['ctp'] +=
$row->type_count;
$ctp_number =
$cache_ctp_number[$post_id];
if (($mode !=
'comments') &&
($mode !=
'trackbacks') &&
($mode !=
'pingbacks') &&
($mode !=
'ctp')) {
return $ctp_number[$mode];
{ // less flexible, but saves mysql queries
global $DB, $rowc,$id,$commentdata,$tablecomments, $baseurl;
WHERE comment_ID = $comment_ID";
$myrow =
$DB->get_row( $query, ARRAY_A );
$myrow['comment_post_ID'] =
$rowc->comment_post_ID;
$myrow['comment_content'] =
$rowc->comment_content;
$myrow['comment_karma'] =
$rowc->comment_karma;
$myrow['comment_type'] =
$rowc->comment_type;
if( isset
($rowc->ID) ) $myrow['post_ID'] =
$rowc->ID;
if( isset
($rowc->post_title) ) $myrow['post_title'] =
$rowc->post_title;
if( isset
($rowc->blog_name) ) $myrow['blog_name'] =
$rowc->blog_name;
if( isset
($rowc->blog_siteurl) ) $myrow['blog_siteurl'] =
$baseurl.
$rowc->blog_siteurl;
if( isset
($rowc->blog_stub) ) $myrow['blog_stub'] =
$rowc->blog_stub;
global $DB, $cache_Comments, $use_cache, $tablecomments, $querycount;
if((empty($cache_Comments[$comment_ID])) OR (!$use_cache))
{ // Load this entry into cache:
WHERE comment_ID = $comment_ID";
if( $row =
$DB->get_row( $query, ARRAY_A ) )
$cache_Comments[$comment_ID] =
new Comment( $row ); // COPY !
if( empty( $cache_Comments[ $comment_ID ] ) ) die('Requested comment does not exist!');
return $cache_Comments[ $comment_ID ];
* Display "Last comments" title if these have been requested
* {@internal last_comments_title(-) }}
* @param string Prefix to be displayed if something is going to be displayed
* @param mixed Output format, see {@link format_to_output()} or false to
* return value instead of displaying it
if( $disp ==
'comments' )
$info =
$prefix.
T_('Last comments');
/***** Comment tags *****/
* @deprecated deprecated by {@link Item::feedback_link()}
if( $zero ==
'#' ) $zero =
T_('Leave a comment');
if( $one ==
'#' ) $one =
T_('1 comment');
if( $more ==
'#' ) $more =
T_('%d comments');
// original hack by dodo@regretless.com
global $id,$postdata,$tablecomments,$c,$querycount,$cache_commentsnumber,$use_cache;
} elseif ($number ==
1) {
* {@internal comments_link(-)}}
* Displays link to comments page
* @deprecated deprecated by {@link Item::feedback_link()}
if( ($file ==
'') ||
($file ==
'/') )
{ // include trackback // fplanque: added
{ // include pingback // fplanque: added
* This will include the javascript that is required to open comments,
* trackback and pingback in popup windows.
* You should put this tag before the </head> tag in your template.
* {@internal comments_popup_script(-)}}
* @param integer width of window or false
* @param integer height of window or false
* @param boolean do you want a scrollbar
* @param boolean do you want a status bar
* @param boolean do you want the windows to be resizable
$scrollbars =
true, $status =
true, $resizable =
true )
global $b2commentsjavascript;
$b2commentsjavascript =
true;
if( $width ) $properties[] =
'width='.
$width;
if( $height ) $properties[] =
'height='.
$height;
$properties[] =
'scrollbars='.
intval( $scrollbars );
$properties[] =
'status='.
intval( $status );
$properties[] =
'resizable='.
intval( $resizable );
$properties =
implode( ',', $properties );
<script language="javascript" type="text/javascript">
window.open( url, '_blank', '
<?php echo
$properties; ?>');
* @deprecated deprecated by {@link Item::feedback_link()}
global $blog, $id, $b2commentspopupfile, $b2commentsjavascript;
if($b2commentsjavascript)
echo
'" onclick="b2open(this.href); return false"';
{ // if comments_popup_script() is not in the template, display simple comment link
echo
' class="'.
$CSSclass.
'"';
* @deprecated deprecated by {@link DataObject::ID()}
global $commentdata; echo
$commentdata['comment_ID'];
* @deprecated deprecated by {@link Comment::author()}
echo
$commentdata['comment_author'];
* comment_author_email(-)
* @deprecated deprecated by {@link Comment::author_email()}
global $commentdata; echo
antispambot( $commentdata['comment_author_email'] );
* @deprecated deprecated by {@link Comment::author_url()}
$url =
trim($commentdata['comment_author_url']);
$url =
(!stristr($url, '://')) ?
'http://'.
$url :
$url;
* comment_author_url_basedomain(-)
* comment_author_email_link(-)
* @deprecated deprecated by {@link Comment::author_email()}
$email=
$commentdata['comment_author_email'];
if ((!empty($email)) &&
($email !=
'@')) {
$display =
($linktext !=
'') ?
$linktext :
antispambot($email);
echo
'<a href="mailto:'.
antispambot($email).
'">'.
$display.
'</a>';
* comment_author_url_link(-)
* @deprecated deprecated by {@link $Comment->author_url()}
$url =
trim($commentdata['comment_author_url']);
$url =
(!stristr($url, '://')) ?
'http://'.
$url :
$url;
if ((!empty($url)) &&
($url !=
'http://') &&
($url !=
'http://url'))
$display =
($linktext !=
'') ?
$linktext :
$url;
echo
'<a href="'.
$url.
'">'.
$display.
'</a>';
* @deprecated deprecated by {@link Comment::author_ip()}
global $commentdata; echo
$commentdata['comment_author_IP'];
* @deprecated deprecated by {@link $Comment::content()}
$comment =
$commentdata['comment_content'];
* @deprecated deprecated by {@link $Comment::date()}
echo
mysql2date($d, $commentdata['comment_date']);
* @deprecated deprecated by {@link $Comment::time()}
echo
mysql2date($d, $commentdata['comment_date']);
* @deprecated deprecated by {@link $Comment::post_title()}
$title =
$commentdata['post_title'];
* @deprecated deprecated by {@link $Comment::post_link()}
echo
gen_permalink( $commentdata['blog_siteurl'].
'/'.
$commentdata['blog_stub'], $commentdata['post_ID'], 'id', 'single' );
$blog_name =
$commentdata['blog_name'];