Example #1
0
 public static function prepareComment(&$comment)
 {
     if (isset($comment->_skip_prepare) && $comment->_skip_prepare == 1) {
         return;
     }
     JCommentsEventHelper::trigger('onJCommentsCommentBeforePrepare', array(&$comment));
     $config = JCommentsFactory::getConfig();
     $acl = JCommentsFactory::getACL();
     // run autocensor
     if ($acl->check('enable_autocensor')) {
         $comment->comment = JCommentsText::censor($comment->comment);
         if ($comment->title != '') {
             $comment->title = JCommentsText::censor($comment->title);
         }
     }
     // replace deleted comment text with predefined message
     if ($comment->deleted == 1) {
         $comment->comment = JText::_('COMMENT_TEXT_COMMENT_HAS_BEEN_DELETED');
         $comment->username = '';
         $comment->name = '';
         $comment->email = '';
         $comment->homepage = '';
         $comment->userid = 0;
         $comment->isgood = 0;
         $comment->ispoor = 0;
     }
     // replace BBCode tags
     $comment->comment = JCommentsFactory::getBBCode()->replace($comment->comment);
     if ($config->getInt('enable_custom_bbcode')) {
         $comment->comment = JCommentsFactory::getCustomBBCode()->replace($comment->comment);
     }
     // fix long words problem
     $word_maxlength = $config->getInt('word_maxlength');
     if ($word_maxlength > 0) {
         $comment->comment = JCommentsText::fixLongWords($comment->comment, $word_maxlength);
         if ($comment->title != '') {
             $comment->title = JCommentsText::fixLongWords($comment->title, $word_maxlength);
         }
     }
     if ($acl->check('emailprotection')) {
         $comment->comment = JComments::maskEmail($comment->id, $comment->comment);
     }
     // autolink urls
     if ($acl->check('autolinkurls')) {
         $comment->comment = preg_replace_callback(_JC_REGEXP_LINK, array('JComments', 'urlProcessor'), $comment->comment);
         if ($acl->check('emailprotection') != 1) {
             $comment->comment = preg_replace(_JC_REGEXP_EMAIL, '<a href="mailto:\\1@\\2">\\1@\\2</a>', $comment->comment);
         }
     }
     // replace smilies' codes with images
     if ($config->get('enable_smilies') == '1') {
         $comment->comment = JCommentsFactory::getSmilies()->replace($comment->comment);
     }
     $comment->author = JComments::getCommentAuthorName($comment);
     // Gravatar support
     $comment->gravatar = md5(strtolower($comment->email));
     if (empty($comment->avatar)) {
         $comment->avatar = '<img src="http://www.gravatar.com/avatar/' . $comment->gravatar . '?d=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="' . htmlspecialchars($comment->author) . '" />';
     }
     JCommentsEventHelper::trigger('onJCommentsCommentAfterPrepare', array(&$comment));
 }
Example #2
0
 function prepareComment(&$comment)
 {
     if (isset($comment->_skip_prepare) && $comment->_skip_prepare == 1) {
         return;
     }
     $config =& JCommentsFactory::getConfig();
     $bbcode =& JCommentsFactory::getBBCode();
     $acl =& JCommentsFactory::getACL();
     // convert to datetime if variable contains string value
     if (is_string($comment->datetime)) {
         $comment->datetime = strtotime($comment->datetime);
     }
     // run autocensor
     if ($acl->check('enable_autocensor')) {
         $comment->comment = JCommentsText::censor($comment->comment);
     }
     // replace BBCode tags
     $comment->comment = $bbcode->replace($comment->comment);
     if ($config->getInt('enable_custom_bbcode')) {
         $customBBCode =& JCommentsFactory::getCustomBBCode();
         $comment->comment = $customBBCode->replace($comment->comment);
     }
     // fix long words problem
     $word_maxlength = $config->getInt('word_maxlength');
     if ($word_maxlength > 0) {
         $comment->comment = JCommentsText::fixLongWords($comment->comment, $word_maxlength);
         if ($comment->title != '') {
             $comment->title = JCommentsText::fixLongWords($comment->title, $word_maxlength);
         }
     }
     if ($acl->check('emailprotection')) {
         $comment->comment = JComments::maskEmail($comment->id, $comment->comment);
     }
     // autolink urls
     if ($acl->check('autolinkurls')) {
         $comment->comment = preg_replace_callback(_JC_REGEXP_LINK, array('JComments', 'urlProcessor'), $comment->comment);
         if ($acl->check('emailprotection') != 1) {
             $comment->comment = preg_replace(_JC_REGEXP_EMAIL, '<a href="mailto:\\1@\\2">\\1@\\2</a>', $comment->comment);
         }
     }
     // replace smile codes with images
     if ($config->get('enable_smiles') == '1') {
         $smiles =& JCommentsFactory::getSmiles();
         $comment->comment = $smiles->replace($comment->comment);
     }
     // Gravatar support
     $comment->gravatar = md5(strtolower($comment->email));
     if (empty($comment->avatar)) {
         $comment->avatar = '<img src="http://www.gravatar.com/avatar.php?gravatar_id=' . $comment->gravatar . '&amp;default=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="" />';
     }
     $comment->author = JComments::getCommentAuthorName($comment);
     if ($config->getInt('enable_mambots') == 1) {
         JCommentsPluginHelper::trigger('onAfterPrepareComment', array(&$comment));
     }
 }