ChronoComments is the best component for Joomla and I have been working with it for some time now on 2 other sites.
Hi Krem,
Show me some non SEF links for the pages you want the comments to appear at and some for those where you don't want the comments to appear at, you don't need to post the full URL, only the part after index.php is enough!
Regards
Max
Show me some non SEF links for the pages you want the comments to appear at and some for those where you don't want the comments to appear at, you don't need to post the full URL, only the part after index.php is enough!
Regards
Max
Here's the non-SEF link of my only page where I want the comments to be.
Hi kRem,
please attach here your plugins/content/chronocomments.php file and I will make some edits for you so you can try it!
Regards
Max
please attach here your plugins/content/chronocomments.php file and I will make some edits for you so you can try it!
Regards
Max
Here's the code Max,
Thank you very much! 😀
kRem
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$mainframe->registerEvent( 'onPrepareContent', 'plgContentChronocomments' );
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
function plgContentChronocomments( &$row, &$params, $page=0 )
{
global $mainframe;
JPlugin::loadLanguage( 'com_chronocomments' );
$uri = & JFactory::getURI();
$configs = JComponentHelper::getParams('com_chronocomments');
if((JRequest::getVar('print') == '1')&&($configs->get('disable_onprint') == '1'))return;
$user = JFactory::getUser();
$session =& JFactory::getSession();
// first captcha
if($configs->get('captcha') == '1'){
$alphanum = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghijkmnpqrstuvwxyz";
$rand = substr(str_shuffle($alphanum), 0, 5);
$session->set("comment_captcha", md5(strtolower($rand)), md5('chrono'));
$session->set("comment_captcha_orig", $rand, md5('chrono'));
}
//pagination
if($configs->get('enablepagination', '0') == '1'){
$session->set("pagination_current_start", 0, md5('chrono'));
$session->set("pagination_next_start", (0 + (int)$configs->get('paginationcount', '10')), md5('chrono'));
$session->set("pagination_prev_start", (0 - (int)$configs->get('paginationcount', '10')), md5('chrono'));
}
JHTML::_('behavior.mootools');
$js = '<script type="text/javascript">';
$js .= "var CommentPublished = ".(($configs->get('new_posts_published', '2') == '0') ? 0 : ((($configs->get('new_posts_published', '2') == '1')&&($user->guest)) ? 0 : 1)).";";
$js .= "\n";
$js .= "var CommentVerified = ".((($configs->get('new_posts_verified', '0') == '0')|| (($configs->get('new_posts_verified', '0') == '1')&&($user->id))) ? 1 : ((($configs->get('new_posts_verified', '0') == '1')&&($user->guest)) ? 0 : 0)).";";
$js .= "\n";
$js .= "var path = '".JURI::Base()."';";
$js .= "\n";
$js .= "var imtype = '".$configs->get('imtype')."';";
$js .= "\n";
$js .= "var captcha = ".$configs->get('captcha', 0).";";
$js .= "\n";
$js .= "var hideemail = ".$configs->get('hideemail' , 0).";";
$js .= "\n";
$js .= "var hideurl = ".$configs->get('hideurl', 0).";";
$js .= "\n";
$js .= "var loadercolor = '".$configs->get('loaderimage_color', 'b')."';";
$js .= "\n";
$js .= "var ENTER_NAME = '".JText::_( 'ENTER_NAME' )."';";
$js .= "\n";
$js .= "var NAME_LENGTH = '".JText::_( 'NAME_LENGTH' )."';";
$js .= "\n";
$js .= "var ENTER_COMMENT = '".JText::_( 'ENTER_COMMENT' )."';";
$js .= "\n";
$js .= "var ENTER_EMAIL = '".JText::_( 'ENTER_EMAIL' )."';";
$js .= "\n";
$js .= "var URL_HTTP = '".JText::_( 'URL_HTTP' )."';";
$js .= "\n";
$js .= "var WRONG_CODE = '".JText::_( 'WRONG_CODE' )."';";
$js .= "\n";
$js .= "var NOT_VERIFIED = '".JText::_( 'NOT_VERIFIED' )."';";
$js .= "\n";
$js .= "var NOT_PUBLISHED = '".JText::_( 'NOT_PUBLISHED' )."';";
$js .= "\n";
$js .= "var UNPUBLISHED_SUCCESS = '".JText::_( 'UNPUBLISHED_SUCCESS' )."';";
$js .= "\n";
$js .= "var GUEST_CANT_VOTE = '".JText::_( 'GUEST_CANT_VOTE' )."';";
$js .= "\n";
$js .= "var OWNER_CANT_VOTE = '".JText::_( 'OWNER_CANT_VOTE' )."';";
$js .= "\n";
$js .= "</script>";
//Load JS and CSS
$document =& JFactory::getDocument();
//$document->addScriptDeclaration($js);
$document->addScript(JURI::Base().'components/com_chronocomments/msg.js');
$document->addStyleSheet(JURI::Base().'components/com_chronocomments/msg.css');
$document->addCustomTag($js);
$document->addCustomTag('<script type="text/javascript" src="'.JURI::Base().'components/com_chronocomments/scripts.js'.'"></script>');
$document->addCustomTag('<!--[if lte IE 6]> <link href="'.JURI::Base().'components/com_chronocomments/style-ie6.css" rel="stylesheet" type="text/css" /> <![endif]-->');
$document->addCustomTag('<!--[if gte IE 7]> <link href="'.JURI::Base().'components/com_chronocomments/style.css" rel="stylesheet" type="text/css" /> <![endif]-->');
$document->addCustomTag('<!--[if !IE]> <--><link href="'.JURI::Base().'components/com_chronocomments/style.css" rel="stylesheet" type="text/css" /><!--> <![endif]-->');
$document->addCustomTag('<script type="text/javascript" src="'.JURI::Base().'components/com_chronocomments/editor.js'.'"></script>');
//$document->addCustomTag($IEfix);
//$document->addStyleDeclaration($css);
$pageid = $row->id;
$component = JRequest::getVar('option');
//Load templates!
ob_start();
require_once ( JPATH_BASE.DS.'components'.DS.'com_chronocomments'.DS.'templates'.DS.'comment-form.html.php' );
$comment_form = ob_get_clean();
ob_start();
require_once ( JPATH_BASE.DS.'components'.DS.'com_chronocomments'.DS.'templates'.DS.'comment-item.html.php' );
$comment_item = ob_get_clean();
//get comments!
global $mainframe;
$database =& JFactory::getDBO();
$limit = '';
if($configs->get('enablepagination', '0') == '1') $limit = " LIMIT 0, ".$configs->get('paginationcount');
$query = "SELECT * FROM #__chrono_comments WHERE component = '".JRequest::getVar('option')."' AND pageid= '".$pageid."' AND parentid='0' AND published='1' AND verify='1' ORDER BY datetime ASC".$limit;
$database->setQuery( $query );
$comments = $database->loadObjectList();
$comment_items = "";
//$comment_elements = array('id', 'name', 'email', 'url', 'text', 'datetime', 'rating');
foreach($comments as $comment){
$current_comment_item = LoadComment($comment->id, $comment_item);
$comment_items .= $current_comment_item;
}
if((in_array($row->sectionid, (array)$configs->get('comment_sections')))||(in_array($row->catid, (array)$configs->get('comment_categories')))||(in_array($row->id, (array)$configs->get('comment_articles')))){
if(JRequest::getVar('view') == 'article'){
$row->text = $row->text.str_replace("{ALL_COMMENTS}", $comment_items, $comment_form);
//return true;
}else{
if($configs->get('showblogview') == '1'){
$query = "SELECT * FROM #__chrono_comments WHERE component = '".JRequest::getVar('option')."' AND pageid= '".$pageid."' AND published='1' AND verify='1' ORDER BY datetime ASC";
$database->setQuery( $query );
$blogcomments = $database->loadObjectList();
//Get Clean Joomla content item 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='.$row->id;
$database->setQuery( $query );
$article = $database->loadObject();
$page_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
//end link
$language = '<br /><a href="'.$page_link.'#comments">'.JText::_( 'READ N COMMENTS' )."</a>";
$row->text = $row->text.str_replace("{n}", count($blogcomments), $language);
//return true;
}
}
}
}
function LoadComment($commentid, $comment_item){
global $mainframe;
$database =& JFactory::getDBO();
$configs = JComponentHelper::getParams('com_chronocomments');
//load current comment data
$query = "SELECT * FROM #__chrono_comments WHERE id = '".$commentid."'";
$database->setQuery( $query );
$commentx = $database->loadObject();
//define comment elements
//$comment_elements = array('id', 'name', 'email', 'url', 'text', 'datetime', 'rating');
$query = "SELECT * FROM #__chrono_comments WHERE parentid='".$commentid."' AND published='1' AND verify='1' ORDER BY datetime";
$database->setQuery( $query );
$comments = $database->loadObjectList();
if(count($comments)){
$comment_items = "";
foreach($comments as $comment){
$current_comment_item = LoadComment($comment->id, $comment_item);
$comment_items .= '<div class="reply">'.$current_comment_item.'</div>';
}
//$commentx->url = trim($commentx->url) ? $commentx->url : '#';
$current_comment_item = $comment_item;
//remove name link if it doesnt exist
if((!trim($commentx->url))||(trim($commentx->url) == 'http://')){
$current_comment_item = preg_replace(array("/\\{if_comment_url}.*?\{\/if_comment_url}/"), array('span'), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_comment_url}/", "/{\/if_comment_url}/"), array('', ''), $current_comment_item);
}
//check user reputation
$user_reputation = false;
if(!$user_reputation){
$current_comment_item = preg_replace(array("/\\{if_user_reputation}.*?\{\/if_user_reputation}/"), array(''), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_user_reputation}/", "/{\/if_user_reputation}/"), array('', ''), $current_comment_item);
}
if($commentx->rating > 0){
$commentx->rating = '+'.$commentx->rating;
}
//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;
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}else{
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}
}
}
}
if(!$avatar){
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('', ''), $current_comment_item);
}
//render the comment template
$comment_elements = array(
'id' => $commentx->id,
'name' => censor($commentx->name),
'email' => $commentx->email,
'url' => $commentx->url,
'text' => censor(bb2html($commentx->text)),
'datetime' => '<a href="#commentID'.$commentx->id.'">'.JHTML::_('date', $commentx->datetime, JText::_( 'DATETIMEFORMAT' )).'</a>',
'rating' => $commentx->rating,
'parentid' => $commentx->parentid,
'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_".$comment_element_name."\\}/", $comment_element_value, $current_comment_item);
}
return str_replace("{REPLIES}", $comment_items, $current_comment_item);
}else{
$comment_items = "";
$current_comment_item = $comment_item;
//remove name link if it doesnt exist
if((!trim($commentx->url))||(trim($commentx->url) == 'http://')){
$current_comment_item = preg_replace(array("/\\{if_comment_url}.*?\{\/if_comment_url}/"), array('span'), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_comment_url}/", "/{\/if_comment_url}/"), array('', ''), $current_comment_item);
}
//check user reputation
$user_reputation = false;
if(!$user_reputation){
$current_comment_item = preg_replace(array("/\\{if_user_reputation}.*?\{\/if_user_reputation}/"), array(''), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_user_reputation}/", "/{\/if_user_reputation}/"), array('', ''), $current_comment_item);
}
if($commentx->rating > 0){
$commentx->rating = '+'.$commentx->rating;
}
//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;
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}else{
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}
}
}
}
if(!$avatar){
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('', ''), $current_comment_item);
}
//render the comment template
$comment_elements = array(
'id' => $commentx->id,
'name' => censor($commentx->name),
'email' => $commentx->email,
'url' => $commentx->url,
'text' => censor(bb2html($commentx->text)),
'datetime' => '<a href="#commentID'.$commentx->id.'">'.JHTML::_('date', $commentx->datetime, JText::_( 'DATETIMEFORMAT' )).'</a>',
'rating' => $commentx->rating,
'parentid' => $commentx->parentid,
'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_".$comment_element_name."\\}/", $comment_element_value, $current_comment_item);
}
return str_replace("{REPLIES}", $comment_items, $current_comment_item);
}
}
function bb2html($text){
global $mainframe;
$configs = JComponentHelper::getParams('com_chronocomments');
if($configs->get('convertlinks', '1') == '1'){
$text = makeClickableLinks($text);
}
if($configs->get('breaklongwords', '1') == '1'){
$text = textWrap($text, 15, ' ');
}
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 makeClickableLinks($text) {
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\\1">\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1<a href="http://\\2">\\2</a>', $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '<a href="mailto:\\1">\\1</a>', $text);
return $text;
}
function textwrap ($text, $length, $break) {
$pure=strip_tags($text);
$words=str_word_count($pure, 1);
foreach ($words as $word) {
if (strlen($word) > $length) {
$newword=wordwrap($word, $length, $break, TRUE);
$text=str_replace($word, $newword, $text);
}
}
return $text;
}
?>
Thank you very much! 😀
kRem
Hi kRem,
no problems, try this:
no problems, try this:
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$mainframe->registerEvent( 'onPrepareContent', 'plgContentChronocomments' );
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
function plgContentChronocomments( &$row, &$params, $page=0 )
{
global $mainframe;
JPlugin::loadLanguage( 'com_chronocomments' );
$uri = & JFactory::getURI();
$configs = JComponentHelper::getParams('com_chronocomments');
if((JRequest::getVar('print') == '1')&&($configs->get('disable_onprint') == '1'))return;
$user = JFactory::getUser();
$session =& JFactory::getSession();
//changes
if(JRequest::getVar('option') != 'com_content')return;
// first captcha
if($configs->get('captcha') == '1'){
$alphanum = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghijkmnpqrstuvwxyz";
$rand = substr(str_shuffle($alphanum), 0, 5);
$session->set("comment_captcha", md5(strtolower($rand)), md5('chrono'));
$session->set("comment_captcha_orig", $rand, md5('chrono'));
}
//pagination
if($configs->get('enablepagination', '0') == '1'){
$session->set("pagination_current_start", 0, md5('chrono'));
$session->set("pagination_next_start", (0 + (int)$configs->get('paginationcount', '10')), md5('chrono'));
$session->set("pagination_prev_start", (0 - (int)$configs->get('paginationcount', '10')), md5('chrono'));
}
JHTML::_('behavior.mootools');
$js = '<script type="text/javascript">';
$js .= "var CommentPublished = ".(($configs->get('new_posts_published', '2') == '0') ? 0 : ((($configs->get('new_posts_published', '2') == '1')&&($user->guest)) ? 0 : 1)).";";
$js .= "\n";
$js .= "var CommentVerified = ".((($configs->get('new_posts_verified', '0') == '0')|| (($configs->get('new_posts_verified', '0') == '1')&&($user->id))) ? 1 : ((($configs->get('new_posts_verified', '0') == '1')&&($user->guest)) ? 0 : 0)).";";
$js .= "\n";
$js .= "var path = '".JURI::Base()."';";
$js .= "\n";
$js .= "var imtype = '".$configs->get('imtype')."';";
$js .= "\n";
$js .= "var captcha = ".$configs->get('captcha', 0).";";
$js .= "\n";
$js .= "var hideemail = ".$configs->get('hideemail' , 0).";";
$js .= "\n";
$js .= "var hideurl = ".$configs->get('hideurl', 0).";";
$js .= "\n";
$js .= "var loadercolor = '".$configs->get('loaderimage_color', 'b')."';";
$js .= "\n";
$js .= "var ENTER_NAME = '".JText::_( 'ENTER_NAME' )."';";
$js .= "\n";
$js .= "var NAME_LENGTH = '".JText::_( 'NAME_LENGTH' )."';";
$js .= "\n";
$js .= "var ENTER_COMMENT = '".JText::_( 'ENTER_COMMENT' )."';";
$js .= "\n";
$js .= "var ENTER_EMAIL = '".JText::_( 'ENTER_EMAIL' )."';";
$js .= "\n";
$js .= "var URL_HTTP = '".JText::_( 'URL_HTTP' )."';";
$js .= "\n";
$js .= "var WRONG_CODE = '".JText::_( 'WRONG_CODE' )."';";
$js .= "\n";
$js .= "var NOT_VERIFIED = '".JText::_( 'NOT_VERIFIED' )."';";
$js .= "\n";
$js .= "var NOT_PUBLISHED = '".JText::_( 'NOT_PUBLISHED' )."';";
$js .= "\n";
$js .= "var UNPUBLISHED_SUCCESS = '".JText::_( 'UNPUBLISHED_SUCCESS' )."';";
$js .= "\n";
$js .= "var GUEST_CANT_VOTE = '".JText::_( 'GUEST_CANT_VOTE' )."';";
$js .= "\n";
$js .= "var OWNER_CANT_VOTE = '".JText::_( 'OWNER_CANT_VOTE' )."';";
$js .= "\n";
$js .= "</script>";
//Load JS and CSS
$document =& JFactory::getDocument();
//$document->addScriptDeclaration($js);
$document->addScript(JURI::Base().'components/com_chronocomments/msg.js');
$document->addStyleSheet(JURI::Base().'components/com_chronocomments/msg.css');
$document->addCustomTag($js);
$document->addCustomTag('<script type="text/javascript" src="'.JURI::Base().'components/com_chronocomments/scripts.js'.'"></script>');
$document->addCustomTag('<!--[if lte IE 6]> <link href="'.JURI::Base().'components/com_chronocomments/style-ie6.css" rel="stylesheet" type="text/css" /> <![endif]-->');
$document->addCustomTag('<!--[if gte IE 7]> <link href="'.JURI::Base().'components/com_chronocomments/style.css" rel="stylesheet" type="text/css" /> <![endif]-->');
$document->addCustomTag('<!--[if !IE]> <--><link href="'.JURI::Base().'components/com_chronocomments/style.css" rel="stylesheet" type="text/css" /><!--> <![endif]-->');
$document->addCustomTag('<script type="text/javascript" src="'.JURI::Base().'components/com_chronocomments/editor.js'.'"></script>');
//$document->addCustomTag($IEfix);
//$document->addStyleDeclaration($css);
$pageid = $row->id;
$component = JRequest::getVar('option');
//Load templates!
ob_start();
require_once ( JPATH_BASE.DS.'components'.DS.'com_chronocomments'.DS.'templates'.DS.'comment-form.html.php' );
$comment_form = ob_get_clean();
ob_start();
require_once ( JPATH_BASE.DS.'components'.DS.'com_chronocomments'.DS.'templates'.DS.'comment-item.html.php' );
$comment_item = ob_get_clean();
//get comments!
global $mainframe;
$database =& JFactory::getDBO();
$limit = '';
if($configs->get('enablepagination', '0') == '1') $limit = " LIMIT 0, ".$configs->get('paginationcount');
$query = "SELECT * FROM #__chrono_comments WHERE component = '".JRequest::getVar('option')."' AND pageid= '".$pageid."' AND parentid='0' AND published='1' AND verify='1' ORDER BY datetime ASC".$limit;
$database->setQuery( $query );
$comments = $database->loadObjectList();
$comment_items = "";
//$comment_elements = array('id', 'name', 'email', 'url', 'text', 'datetime', 'rating');
foreach($comments as $comment){
$current_comment_item = LoadComment($comment->id, $comment_item);
$comment_items .= $current_comment_item;
}
if((in_array($row->sectionid, (array)$configs->get('comment_sections')))||(in_array($row->catid, (array)$configs->get('comment_categories')))||(in_array($row->id, (array)$configs->get('comment_articles')))){
if(JRequest::getVar('view') == 'article'){
$row->text = $row->text.str_replace("{ALL_COMMENTS}", $comment_items, $comment_form);
//return true;
}else{
if($configs->get('showblogview') == '1'){
//changes
if(JRequest::getVar('layout') != 'blog')return;
$query = "SELECT * FROM #__chrono_comments WHERE component = '".JRequest::getVar('option')."' AND pageid= '".$pageid."' AND published='1' AND verify='1' ORDER BY datetime ASC";
$database->setQuery( $query );
$blogcomments = $database->loadObjectList();
//Get Clean Joomla content item 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='.$row->id;
$database->setQuery( $query );
$article = $database->loadObject();
$page_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
//end link
$language = '<br /><a href="'.$page_link.'#comments">'.JText::_( 'READ N COMMENTS' )."</a>";
$row->text = $row->text.str_replace("{n}", count($blogcomments), $language);
//return true;
}
}
}
}
function LoadComment($commentid, $comment_item){
global $mainframe;
$database =& JFactory::getDBO();
$configs = JComponentHelper::getParams('com_chronocomments');
//load current comment data
$query = "SELECT * FROM #__chrono_comments WHERE id = '".$commentid."'";
$database->setQuery( $query );
$commentx = $database->loadObject();
//define comment elements
//$comment_elements = array('id', 'name', 'email', 'url', 'text', 'datetime', 'rating');
$query = "SELECT * FROM #__chrono_comments WHERE parentid='".$commentid."' AND published='1' AND verify='1' ORDER BY datetime";
$database->setQuery( $query );
$comments = $database->loadObjectList();
if(count($comments)){
$comment_items = "";
foreach($comments as $comment){
$current_comment_item = LoadComment($comment->id, $comment_item);
$comment_items .= '<div class="reply">'.$current_comment_item.'</div>';
}
//$commentx->url = trim($commentx->url) ? $commentx->url : '#';
$current_comment_item = $comment_item;
//remove name link if it doesnt exist
if((!trim($commentx->url))||(trim($commentx->url) == 'http://')){
$current_comment_item = preg_replace(array("/\\{if_comment_url}.*?\{\/if_comment_url}/"), array('span'), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_comment_url}/", "/{\/if_comment_url}/"), array('', ''), $current_comment_item);
}
//check user reputation
$user_reputation = false;
if(!$user_reputation){
$current_comment_item = preg_replace(array("/\\{if_user_reputation}.*?\{\/if_user_reputation}/"), array(''), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_user_reputation}/", "/{\/if_user_reputation}/"), array('', ''), $current_comment_item);
}
if($commentx->rating > 0){
$commentx->rating = '+'.$commentx->rating;
}
//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;
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}else{
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}
}
}
}
if(!$avatar){
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('', ''), $current_comment_item);
}
//render the comment template
$comment_elements = array(
'id' => $commentx->id,
'name' => censor($commentx->name),
'email' => $commentx->email,
'url' => $commentx->url,
'text' => censor(bb2html($commentx->text)),
'datetime' => '<a href="#commentID'.$commentx->id.'">'.JHTML::_('date', $commentx->datetime, JText::_( 'DATETIMEFORMAT' )).'</a>',
'rating' => $commentx->rating,
'parentid' => $commentx->parentid,
'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_".$comment_element_name."\\}/", $comment_element_value, $current_comment_item);
}
return str_replace("{REPLIES}", $comment_items, $current_comment_item);
}else{
$comment_items = "";
$current_comment_item = $comment_item;
//remove name link if it doesnt exist
if((!trim($commentx->url))||(trim($commentx->url) == 'http://')){
$current_comment_item = preg_replace(array("/\\{if_comment_url}.*?\{\/if_comment_url}/"), array('span'), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_comment_url}/", "/{\/if_comment_url}/"), array('', ''), $current_comment_item);
}
//check user reputation
$user_reputation = false;
if(!$user_reputation){
$current_comment_item = preg_replace(array("/\\{if_user_reputation}.*?\{\/if_user_reputation}/"), array(''), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_user_reputation}/", "/{\/if_user_reputation}/"), array('', ''), $current_comment_item);
}
if($commentx->rating > 0){
$commentx->rating = '+'.$commentx->rating;
}
//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;
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}else{
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}
}
}
}
if(!$avatar){
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('', ''), $current_comment_item);
}
//render the comment template
$comment_elements = array(
'id' => $commentx->id,
'name' => censor($commentx->name),
'email' => $commentx->email,
'url' => $commentx->url,
'text' => censor(bb2html($commentx->text)),
'datetime' => '<a href="#commentID'.$commentx->id.'">'.JHTML::_('date', $commentx->datetime, JText::_( 'DATETIMEFORMAT' )).'</a>',
'rating' => $commentx->rating,
'parentid' => $commentx->parentid,
'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_".$comment_element_name."\\}/", $comment_element_value, $current_comment_item);
}
return str_replace("{REPLIES}", $comment_items, $current_comment_item);
}
}
function bb2html($text){
global $mainframe;
$configs = JComponentHelper::getParams('com_chronocomments');
if($configs->get('convertlinks', '1') == '1'){
$text = makeClickableLinks($text);
}
if($configs->get('breaklongwords', '1') == '1'){
$text = textWrap($text, 15, ' ');
}
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 makeClickableLinks($text) {
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\\1">\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1<a href="http://\\2">\\2</a>', $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '<a href="mailto:\\1">\\1</a>', $text);
return $text;
}
function textwrap ($text, $length, $break) {
$pure=strip_tags($text);
$words=str_word_count($pure, 1);
foreach ($words as $word) {
if (strlen($word) > $length) {
$newword=wordwrap($word, $length, $break, TRUE);
$text=str_replace($word, $newword, $text);
}
}
return $text;
}
?>
The code works. However, if you go to the Services page the link shows at the very bottom.
I have similar problem. Check my site: http://www.aeroklub-kranj.si/novice
At the top of this page is the comment link, but I don't want it to be there🙂 Please help..
p.s.
For this category I don't even checked comments to show up:
http://www.aeroklub-kranj.si/povezave
At the top of this page is the comment link, but I don't want it to be there🙂 Please help..
p.s.
For this category I don't even checked comments to show up:
http://www.aeroklub-kranj.si/povezave
Look at my solution. Maybe it will work for you too..
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=16&t=11829&p=18673#p18673
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=16&t=11829&p=18673#p18673
Hi kRem,
may be you can try spektr solution or you need to tell me whats the type of the menu item "services", I can't do any fixes without knowing the link in non SEF format!
Regards
Max
may be you can try spektr solution or you need to tell me whats the type of the menu item "services", I can't do any fixes without knowing the link in non SEF format!
Regards
Max
Hey Max,
I'd rather if you get me a hand. Here are the non SEF links:
BLOG > index.php?option=com_content&Itemid=17&id=10&lang=en&layout=blog&view=section (still showing on description, yet there's none)
Services page > index.php?option=com_content&Itemid=10&id=8&lang=en&layout=blog&view=section (Link shows on description, and messes up the fonts on the slider panel I have)
Web & Graphic Design > index.php?option=com_content&Itemid=13&id=13&lang=en&view=section (link doesn't show on description, yet it messes up the font on the slider panel too)
Unfortunately, I see this is going to happen again. Is there something I could add base on the non-SEF link when it happens again? I really don't want to get rid of this awesome component...
I'd rather if you get me a hand. Here are the non SEF links:
BLOG > index.php?option=com_content&Itemid=17&id=10&lang=en&layout=blog&view=section (still showing on description, yet there's none)
Services page > index.php?option=com_content&Itemid=10&id=8&lang=en&layout=blog&view=section (Link shows on description, and messes up the fonts on the slider panel I have)
Web & Graphic Design > index.php?option=com_content&Itemid=13&id=13&lang=en&view=section (link doesn't show on description, yet it messes up the font on the slider panel too)
Unfortunately, I see this is going to happen again. Is there something I could add base on the non-SEF link when it happens again? I really don't want to get rid of this awesome component...
Hi kRem,
so the problem now is that the comment link appears in the description ?
Max
so the problem now is that the comment link appears in the description ?
Max
Hey Max,
That has been the problem, yes. The link shows up in the description in my sections. The first fix you did removed most of them, but it still shows where it isn't supposed to. I check the source/code of my live page on any web browser and there is always the ChronoComment code (when it isn't supposed to be there).
Thank you very much for helping me.
That has been the problem, yes. The link shows up in the description in my sections. The first fix you did removed most of them, but it still shows where it isn't supposed to. I check the source/code of my live page on any web browser and there is always the ChronoComment code (when it isn't supposed to be there).
Thank you very much for helping me.
do you have cache enabled or something ? I just tried it here and no links are in the description, try my attached code and let me know!
Regards
Max
Regards
Max
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$mainframe->registerEvent( 'onAfterDisplayContent', 'plgContentChronocomments' );
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
function plgContentChronocomments( &$row, &$params, $page=0 )
{
global $mainframe, $addChronoCommentscripts;
if((JRequest::getVar('option') == 'com_newsfeeds')||(JRequest::getVar('option') == 'com_contact'))return;
JPlugin::loadLanguage( 'com_chronocomments' );
$uri = & JFactory::getURI();
$configs = JComponentHelper::getParams('com_chronocomments');
if((JRequest::getVar('print') == '1')&&($configs->get('disable_onprint') == '1'))return;
$user = JFactory::getUser();
$session =& JFactory::getSession();
// first captcha
if($configs->get('captcha') == '1'){
$alphanum = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghijkmnpqrstuvwxyz";
$rand = substr(str_shuffle($alphanum), 0, 5);
$session->set("comment_captcha", md5(strtolower($rand)), md5('chrono'));
$session->set("comment_captcha_orig", $rand, md5('chrono'));
}
//pagination
if($configs->get('enablepagination', '0') == '1'){
$session->set("pagination_current_start", 0, md5('chrono'));
$session->set("pagination_next_start", (0 + (int)$configs->get('paginationcount', '10')), md5('chrono'));
$session->set("pagination_prev_start", (0 - (int)$configs->get('paginationcount', '10')), md5('chrono'));
}
JHTML::_('behavior.mootools');
$js = '<script type="text/javascript">';
$js .= "var CommentPublished = ".(($configs->get('new_posts_published', '2') == '0') ? 0 : ((($configs->get('new_posts_published', '2') == '1')&&($user->guest)) ? 0 : 1)).";";
$js .= "\n";
$js .= "var CommentVerified = ".((($configs->get('new_posts_verified', '0') == '0')|| (($configs->get('new_posts_verified', '0') == '1')&&($user->id))) ? 1 : ((($configs->get('new_posts_verified', '0') == '1')&&($user->guest)) ? 0 : 0)).";";
$js .= "\n";
$js .= "var path = '".JURI::Base()."';";
$js .= "\n";
$js .= "var imtype = '".$configs->get('imtype')."';";
$js .= "\n";
$js .= "var captcha = ".$configs->get('captcha', 0).";";
$js .= "\n";
$js .= "var hideemail = ".$configs->get('hideemail' , 0).";";
$js .= "\n";
$js .= "var hideurl = ".$configs->get('hideurl', 0).";";
$js .= "\n";
$js .= "var loadercolor = '".$configs->get('loaderimage_color', 'b')."';";
$js .= "\n";
$js .= "var ENTER_NAME = '".JText::_( 'ENTER_NAME' )."';";
$js .= "\n";
$js .= "var NAME_LENGTH = '".JText::_( 'NAME_LENGTH' )."';";
$js .= "\n";
$js .= "var ENTER_COMMENT = '".JText::_( 'ENTER_COMMENT' )."';";
$js .= "\n";
$js .= "var ENTER_EMAIL = '".JText::_( 'ENTER_EMAIL' )."';";
$js .= "\n";
$js .= "var URL_HTTP = '".JText::_( 'URL_HTTP' )."';";
$js .= "\n";
$js .= "var WRONG_CODE = '".JText::_( 'WRONG_CODE' )."';";
$js .= "\n";
$js .= "var NOT_VERIFIED = '".JText::_( 'NOT_VERIFIED' )."';";
$js .= "\n";
$js .= "var NOT_PUBLISHED = '".JText::_( 'NOT_PUBLISHED' )."';";
$js .= "\n";
$js .= "var UNPUBLISHED_SUCCESS = '".JText::_( 'UNPUBLISHED_SUCCESS' )."';";
$js .= "\n";
$js .= "var GUEST_CANT_VOTE = '".JText::_( 'GUEST_CANT_VOTE' )."';";
$js .= "\n";
$js .= "var OWNER_CANT_VOTE = '".JText::_( 'OWNER_CANT_VOTE' )."';";
$js .= "\n";
$js .= "</script>";
//Load JS and CSS
$document =& JFactory::getDocument();
//$document->addScriptDeclaration($js);
if(!isset($addChronoCommentscripts)){
$document->addScript(JURI::Base().'components/com_chronocomments/msg.js');
$document->addStyleSheet(JURI::Base().'components/com_chronocomments/msg.css');
$document->addCustomTag($js);
$document->addCustomTag('<script type="text/javascript" src="'.JURI::Base().'components/com_chronocomments/scripts.js'.'"></script>');
$document->addCustomTag('<!--[if lte IE 6]> <link href="'.JURI::Base().'components/com_chronocomments/style-ie6.css" rel="stylesheet" type="text/css" /> <![endif]-->');
$document->addCustomTag('<!--[if gte IE 7]> <link href="'.JURI::Base().'components/com_chronocomments/style.css" rel="stylesheet" type="text/css" /> <![endif]-->');
$document->addCustomTag('<!--[if !IE]> <--><link href="'.JURI::Base().'components/com_chronocomments/style.css" rel="stylesheet" type="text/css" /><!--> <![endif]-->');
$document->addCustomTag('<script type="text/javascript" src="'.JURI::Base().'components/com_chronocomments/editor.js'.'"></script>');
$addChronoCommentscripts = 1;
}
//$document->addCustomTag($IEfix);
//$document->addStyleDeclaration($css);
$pageid = $row->id;
$component = JRequest::getVar('option');
//Load templates!
ob_start();
require_once ( JPATH_BASE.DS.'components'.DS.'com_chronocomments'.DS.'templates'.DS.'comment-form.html.php' );
$comment_form = ob_get_clean();
ob_start();
require_once ( JPATH_BASE.DS.'components'.DS.'com_chronocomments'.DS.'templates'.DS.'comment-item.html.php' );
$comment_item = ob_get_clean();
//get comments!
global $mainframe;
$database =& JFactory::getDBO();
$limit = '';
if($configs->get('enablepagination', '0') == '1') $limit = " LIMIT 0, ".$configs->get('paginationcount');
$query = "SELECT * FROM #__chrono_comments WHERE component = '".JRequest::getVar('option')."' AND pageid= '".$pageid."' AND parentid='0' AND published='1' AND verify='1' ORDER BY datetime ASC".$limit;
$database->setQuery( $query );
$comments = $database->loadObjectList();
$comment_items = "";
//$comment_elements = array('id', 'name', 'email', 'url', 'text', 'datetime', 'rating');
foreach($comments as $comment){
$current_comment_item = LoadComment($comment->id, $comment_item);
$comment_items .= $current_comment_item;
}
if((in_array($row->sectionid, (array)$configs->get('comment_sections')))||(in_array($row->catid, (array)$configs->get('comment_categories')))||(in_array($row->id, (array)$configs->get('comment_articles')))){
if(JRequest::getVar('view') == 'article'){
return str_replace("{ALL_COMMENTS}", $comment_items, $comment_form);
//return true;
}else{
if($configs->get('showblogview') == '1'){
$query = "SELECT * FROM #__chrono_comments WHERE component = '".JRequest::getVar('option')."' AND pageid= '".$pageid."' AND published='1' AND verify='1' ORDER BY datetime ASC";
$database->setQuery( $query );
$blogcomments = $database->loadObjectList();
//Get Clean Joomla content item 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='.$row->id;
$database->setQuery( $query );
$article = $database->loadObject();
$page_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
//end link
$language = '<br /><a href="'.$page_link.'#comments">'.JText::_( 'READ N COMMENTS' )."</a>";
$row->text = $row->text.str_replace("{n}", count($blogcomments), $language);
//return true;
}
}
}
}
function LoadComment($commentid, $comment_item){
global $mainframe;
$database =& JFactory::getDBO();
$configs = JComponentHelper::getParams('com_chronocomments');
//load current comment data
$query = "SELECT * FROM #__chrono_comments WHERE id = '".$commentid."'";
$database->setQuery( $query );
$commentx = $database->loadObject();
//define comment elements
//$comment_elements = array('id', 'name', 'email', 'url', 'text', 'datetime', 'rating');
$query = "SELECT * FROM #__chrono_comments WHERE parentid='".$commentid."' AND published='1' AND verify='1' ORDER BY datetime";
$database->setQuery( $query );
$comments = $database->loadObjectList();
if(count($comments)){
$comment_items = "";
foreach($comments as $comment){
$current_comment_item = LoadComment($comment->id, $comment_item);
$comment_items .= '<div class="reply">'.$current_comment_item.'</div>';
}
//$commentx->url = trim($commentx->url) ? $commentx->url : '#';
$current_comment_item = $comment_item;
//remove name link if it doesnt exist
if((!trim($commentx->url))||(trim($commentx->url) == 'http://')){
$current_comment_item = preg_replace(array("/\\{if_comment_url}.*?\{\/if_comment_url}/"), array('span'), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_comment_url}/", "/{\/if_comment_url}/"), array('', ''), $current_comment_item);
}
//check user reputation
$user_reputation = false;
if(!$user_reputation){
$current_comment_item = preg_replace(array("/\\{if_user_reputation}.*?\{\/if_user_reputation}/"), array(''), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_user_reputation}/", "/{\/if_user_reputation}/"), array('', ''), $current_comment_item);
}
if($commentx->rating > 0){
$commentx->rating = '+'.$commentx->rating;
}
//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;
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}else{
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}
}
}
}
if(!$avatar){
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('', ''), $current_comment_item);
}
//render the comment template
$comment_elements = array(
'id' => $commentx->id,
'name' => censor($commentx->name),
'email' => $commentx->email,
'url' => $commentx->url,
'text' => censor(bb2html($commentx->text)),
'datetime' => '<a href="#commentID'.$commentx->id.'">'.JHTML::_('date', $commentx->datetime, JText::_( 'DATETIMEFORMAT' )).'</a>',
'rating' => $commentx->rating,
'parentid' => $commentx->parentid,
'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_".$comment_element_name."\\}/", $comment_element_value, $current_comment_item);
}
return str_replace("{REPLIES}", $comment_items, $current_comment_item);
}else{
$comment_items = "";
$current_comment_item = $comment_item;
//remove name link if it doesnt exist
if((!trim($commentx->url))||(trim($commentx->url) == 'http://')){
$current_comment_item = preg_replace(array("/\\{if_comment_url}.*?\{\/if_comment_url}/"), array('span'), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_comment_url}/", "/{\/if_comment_url}/"), array('', ''), $current_comment_item);
}
//check user reputation
$user_reputation = false;
if(!$user_reputation){
$current_comment_item = preg_replace(array("/\\{if_user_reputation}.*?\{\/if_user_reputation}/"), array(''), $current_comment_item);
}else{
$current_comment_item = preg_replace(array("/{if_user_reputation}/", "/{\/if_user_reputation}/"), array('', ''), $current_comment_item);
}
if($commentx->rating > 0){
$commentx->rating = '+'.$commentx->rating;
}
//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;
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}else{
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('<a href="'.JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$commentx->userid).'">', '</a>'), $current_comment_item);
}
}
}
}
if(!$avatar){
$current_comment_item = str_replace(array("{a_comment_avatar}", "{/a_comment_avatar}"), array('', ''), $current_comment_item);
}
//render the comment template
$comment_elements = array(
'id' => $commentx->id,
'name' => censor($commentx->name),
'email' => $commentx->email,
'url' => $commentx->url,
'text' => censor(bb2html($commentx->text)),
'datetime' => '<a href="#commentID'.$commentx->id.'">'.JHTML::_('date', $commentx->datetime, JText::_( 'DATETIMEFORMAT' )).'</a>',
'rating' => $commentx->rating,
'parentid' => $commentx->parentid,
'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_".$comment_element_name."\\}/", $comment_element_value, $current_comment_item);
}
return str_replace("{REPLIES}", $comment_items, $current_comment_item);
}
}
function bb2html($text){
global $mainframe;
$configs = JComponentHelper::getParams('com_chronocomments');
if($configs->get('convertlinks', '1') == '1'){
$text = makeClickableLinks($text);
}
if($configs->get('breaklongwords', '1') == '1'){
$text = textWrap($text, 15, ' ');
}
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 makeClickableLinks($text) {
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\\1">\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1<a href="http://\\2">\\2</a>', $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '<a href="mailto:\\1">\\1</a>', $text);
return $text;
}
function textwrap ($text, $length, $break) {
$pure=strip_tags($text);
$words=str_word_count($pure, 1);
foreach ($words as $word) {
if (strlen($word) > $length) {
$newword=wordwrap($word, $length, $break, TRUE);
$text=str_replace($word, $newword, $text);
}
}
return $text;
}
?>
Hey Max, I don't have cache enabled. I disabled for sh404SEF and also for the Joomla site. Is this what you mean?<br /><br />I will try the new code in just a few minutes.
ChronoComments is an excellent option for comments. However, it did not work despite all the help I got from Max (thank you). I can only say to try it and see for yourself if it works on your site or not. I had to switch to JomComment and it worked from the very beginning. However, I use C. Comment in another site and I haven't had any problems whatsoever...
Thanks Krem, I will put this under heavy testing before the new release!
Regards
Max
Regards
Max
I have the same problem - "there are 0 comments" showing on the category description of a article list layout. Also - no one can comment there, when trying to comment you get a message the you are not authorized to comment. I either want to get rid of the comment link or make the comment public accessible (like all the comments on the site).
Thanks!
Thanks!
To me, the BEST comment module is ChronoComments.
This topic is locked and no more replies can be posted.