Hey Max,
Here is the helper.php file code I have:
[code]<?php
defined('_JEXEC') or die('Restricted access');
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
class modChronocommentsHelper {
function getComments(&$params) {
global $mainframe;
$database =& JFactory::getDBO();
$extra = "";
if($params->get( 'limitsections', '' ))$extra .= " AND b.sectionid IN (".$params->get( 'limitsections', '' ).")";
if($params->get( 'limitcategories', '' ))$extra .= " AND b.catid IN (".$params->get( 'limitcategories', '' ).")";
// changed .$params->get( 'order', 'ASC' ). to: .$params->get( 'order', 'DESC' ). to allow for a descending view of the most recent comments via the module
$query = "SELECT a.*, b.title AS articletitle FROM #__chrono_comments AS a, #__content AS b WHERE a.pageid = b.id AND a.published='1' AND a.verify='1'".$extra." ORDER BY a.datetime ".$params->get( 'order', 'DESC' )." LIMIT 0,".$params->get( 'commentscount', 5 );
$database->setQuery( $query );
$comments = $database->loadObjectList();
$configs = JComponentHelper::getParams('com_chronocomments');
//$current_comment_item = $params->get( 'body', '{name}:{text}<br>' );
$all_comments = '';
foreach($comments as $commentx){
//check cb connection
$avatar = '';
if($configs->get('cbconnection') == '1'){
if (!JComponentHelper::isEnabled('com_comprofiler', true)){
JError::raiseWarning('SOME_ERROR', JText::_('You need to have Community builder installed if you enabled the community builder connection.'));
}else{
if($commentx->userid){
$query = "SELECT avatar FROM #__comprofiler WHERE user_id = '".$commentx->userid."'";
$database->setQuery( $query );
$avatar = $database->loadResult();
if($avatar && file_exists(JPATH_BASE.DS.'images'.DS.'comprofiler'.DS.$avatar)){
$avatar = JURI::Base().'images/comprofiler/'.$avatar;
}
}
}
}
//end cb connection
//get full article link
$query = 'SELECT a.*,' .
' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
' FROM #__content AS a' .
' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' .
' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
' WHERE a.id='.$commentx->pageid;
$database->setQuery( $query );
$article = $database->loadObject();
$page_link = JRoute::_(JURI::Base().'resources/prayer-center#commentID'.$row->id);
//end article link
$current_comment_item = $params->get( 'body', '<strong>{name}:</strong><a href="{page_link}#commentID{id}">{text}</a><br>' );
$comment_elements = array(
'id' => $commentx->id,
'name' => modChronocommentsHelper::censor($commentx->name),
'email' => $commentx->email,
'url' => $commentx->url,
'text' => $params->get( 'limittext', 0 ) ? substr(modChronocommentsHelper::censor(modChronocommentsHelper::bb2html(modChronocommentsHelper::cleanBB($commentx->text))), 0, $params->get( 'limittext', 0 )) : modChronocommentsHelper::censor(modChronocommentsHelper::bb2html(modChronocommentsHelper::cleanBB($commentx->text))),
'datetime' => strftime(JText::_( 'DATETIMEFORMAT' ),strtotime($commentx->datetime)),
'rating' => $commentx->rating,
'pageid' => $commentx->pageid,
'component' => $commentx->component,
'parentid' => $commentx->parentid,
'title' => $commentx->articletitle,
'page_link' => $page_link,
'avatar' => $avatar ? $avatar : JURI::Base().'components/com_chronocomments/images/avatar1.png',
'userid' => $commentx->userid
);
foreach($comment_elements as $comment_element_name => $comment_element_value){
$current_comment_item = preg_replace("/\\{".$comment_element_name."\\}/", $comment_element_value, $current_comment_item);
}
$all_comments .= $current_comment_item;
}
$result = $params->get( 'header', '' ).$all_comments.$params->get( 'footer', '' );
return $result;
}
function bb2html($text){
global $mainframe;
$configs = JComponentHelper::getParams('com_chronocomments');
if($configs->get('bbcode') == '1'){
$bbcode = array(
"/\[i\](.*?)\[\/i\]/is",
"/\[b\](.*?)\[\/b\]/is",
"/\[u\](.*?)\[\/u\]/is",
/*"/\[img\](.*?)\[\/img\]/is",*/
"/\[url=(.*?)\](.*?)\[\/url\]/is",
"/\[url\](.*?)\[\/url\]/is",
"/\[size=(.*?)\](.*?)\[\/size\]/is",
'/\[code\](.*?)\[\/code\]/is',
'/\[quote\](.*?)\[\/quote\]/is',
"/\[list\](.*?)\[\/list\]/is",
"/\[li\](.*?)\[\/li\]/is"
);
$htmlcode = array(
"<i>$1</i>",
"<b>$1</b>",
"<u>$1</u>",
/*"<img src=\"$1\" />",*/
"<a href=\"$1\" rel=\"nofollow\" target=\"_blank\">$2</a>",
"<a href=\"$1\" rel=\"nofollow\" target=\"_blank\">$1</a>",
'<font size=$1>$2</font>',
'<code>$1</code>',
'<p style="font-weight: bold; padding: 0px; margin: 0px;">Quote:</p><blockquote style="padding: 0px; margin: 0px;">$1</blockquote>',
'<ul>$1</ul>',
'<li>$1</li>'
);
$newtext = preg_replace($bbcode, $htmlcode, $text);
$newtext = nl2br($newtext);
return $newtext;
}else{
$newtext = nl2br($text);
return $newtext;
}
}
function censor($text){
global $mainframe;
$newtext = $text;
$configs = JComponentHelper::getParams('com_chronocomments');
if(($configs->get('enablecensor') == '1')&&($configs->get('censorlist'))){
$censors = explode("\n", $configs->get('censorlist'));
foreach($censors as $censor){
$newtext = str_replace($censor, $configs->get('censor_replace'), $newtext);
}
return $newtext;
}else{
return $newtext;
}
}
function cleanBB($text){
$bbcode = array(
"[list]", "
", "", "[/list]",
"
![](", ")
",
"
", "",
"
", "",
"
", "",
'[color="', "[/color]",
"[size=\"", "[/size]",
'[url="', "[/url]",
"[mail=\"", "[/mail]",
"
", "
",
"
", "
");
global $mainframe;
$newtext = $text;
$newtext = str_replace($bbcode, '', $newtext);
return $newtext;
}
}
[/code]