registerFunction( 'onPrepareContent', 'botMosComment' ); function botMosComment( $published, &$row, &$params, $page=0 ) { global $database, $mainframe, $option, $task; global $mosConfig_lang, $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_usecaptcha, $my, $Itemid; # Load configuration file require($mosConfig_absolute_path."/administrator/components/com_comment/config.comment.php"); $seclistarray = explode (",", $allow_comments_in_sections); if (in_array ($row->sectionid, $seclistarray)) { # count number of comments $database->setQuery( "SELECT count(*) FROM #__comment WHERE articleid='$row->id' AND published='1'" ); $total = $database->loadResult(); if ($option=='com_content' AND $task=='view' AND !$params->get( 'intro_only' )) { # Check if valid user $is_user = (strtolower($my->usertype) <> ''); if ( $total >= 0 ) { $comments = "
| ".T_('User Comments')." |
| ";
$comments .= " "; $comments .= "".T_('Comment by')." ".((empty($mcrow->mcname)) ? T_('Anonymous') : $mcrow->mcname)." ".T_('on')." ".$mcrow->mcdate ." "; $comments .= $message; if(($i+1)%$comments_per_page == 0 && ($i+1) < $n) { $comments .= " |
| ".T_('Comments')." |
' . T_('Please login or register to add comments').'
'; } else { // replace previously written comment if it exists in case user // has simply mistyped or misread captcha code if (isset($_GET['comments'])) $curr_com = $_GET['comments']; else $curr_com = ''; $comment_form = "\n"; } # show comments then comments form if (in_array ($row->sectionid, $seclistarray)) { $row->text = $row->text.$comments.$comment_form; } # If we are not on the content page itself } elseif (in_array ($row->sectionid, $seclistarray)) { # count number of pages $regex = '/{(mospagebreak)\s*(.*?)}/i'; $matches = array(); preg_match_all( $regex, $row->text, $matches, PREG_SET_ORDER ); $botLimitStart = count($matches); $contentItemId = $mainframe->getItemid($row->id); $link = "index.php?option=com_content&task=view&id=$row->id"; $link .= "&Itemid=".$contentItemId; $link .= $botLimitStart > 0 ? ('&limit=1&limitstart='.$botLimitStart) : ''; $replacementlink = ""; $row->text = $row->text.$replacementlink.T_('Write Comment')." (".$total.T_(' comments').")"; } } return true; } ?>