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 = "
"; $comments .= ""; $comments .= ""; $database->setQuery( "SELECT id as mcid, name as mcname, startdate as mcdate, comments as mccomment FROM #__comment WHERE articleid='$row->id' AND published='1'" ); $mcrows = $database->loadObjectList(); for ($i=0, $n=count( $mcrows ); $i < $n; $i++) { $mcrow = &$mcrows[$i]; $mcrow->mcname = stripslashes($mcrow->mcname); $message = stripslashes(preg_replace("/(\015\012)|(\015)|(\012)/"," 
", $mcrow->mccomment)); $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 .= "
"; $comments .= "{mospagebreak}"; $comments .= ""; $comments .= ""; }else { $comments .= ""; } } $comments .= "
".T_('Comments')."
"; } # show comments form depending on config permissions if (!$allow_anonymous_entries AND !$is_user) { $comment_form = '

' . 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
"; $comment_form .= "\n"; $comment_form .= "\n"; $comment_form .= "\n"; $comment_form .= "\n"; $comment_form .= "\n"; $comment_form .= "\n"; if ($my->username) { $comment_form .= ""; } else { $comment_form .= T_("Your Name / Email Address"). " \n"; } $comment_form .= ""; if ($mosConfig_usecaptcha == '1') { $cflink = 'index.php?option=com_comment&task=captcha-audio&id='.$row->id.'&Itemid='.$Itemid; $comment_form .= "
".T_('Security Check. Please enter this code')." "; $comment_form .= ""; $comment_form .= "".T_("Listen to code").""; } $comment_form .= "

\n
\n
\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; } ?>