本文整理匯總了PHP中JCommentsFactory::getSmiles方法的典型用法代碼示例。如果您正苦於以下問題:PHP JCommentsFactory::getSmiles方法的具體用法?PHP JCommentsFactory::getSmiles怎麽用?PHP JCommentsFactory::getSmiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JCommentsFactory
的用法示例。
在下文中一共展示了JCommentsFactory::getSmiles方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: prepareComment
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 . '&default=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="" />';
}
$comment->author = JComments::getCommentAuthorName($comment);
if ($config->getInt('enable_mambots') == 1) {
JCommentsPluginHelper::trigger('onAfterPrepareComment', array(&$comment));
}
}
示例2: prepareComment
public static function prepareComment(&$comment)
{
if (isset($comment->_skip_prepare) && $comment->_skip_prepare == 1) {
return;
}
JCommentsEvent::trigger('onJCommentsCommentBeforePrepare', array(&$comment));
$config = JCommentsFactory::getConfig();
$bbcode = JCommentsFactory::getBBCode();
$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 = $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);
}
$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.php?gravatar_id=' . $comment->gravatar . '&default=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="' . htmlspecialchars($comment->author) . '" />';
}
JCommentsEvent::trigger('onJCommentsCommentAfterPrepare', array(&$comment));
}
示例3: getList
//.........這裏部分代碼省略.........
if (count($source) == 1 && $source[0] == 'com_content') {
$joins[] = 'JOIN #__content AS cc ON cc.id = o.object_id';
$joins[] = 'LEFT JOIN #__categories AS ct ON ct.id = cc.catid';
$where[] = "c.object_group = " . $db->Quote($source[0]);
$where[] = "(cc.publish_up = '0000-00-00 00:00:00' OR cc.publish_up <= '{$now}')";
$where[] = "(cc.publish_down = '0000-00-00 00:00:00' OR cc.publish_down >= '{$now}')";
$categories = $params->get('catid', array());
if (!is_array($categories)) {
$categories = explode(',', $categories);
}
JArrayHelper::toInteger($categories);
$categories = implode(',', $categories);
if (!empty($categories)) {
$where[] = "cc.catid IN (" . $categories . ")";
}
} else {
if (count($source)) {
$where[] = "c.object_group in ('" . implode("','", $source) . "')";
}
}
$query = "SELECT c.id, c.userid, c.comment, c.title, c.name, c.username, c.email, c.date, c.object_id, c.object_group, '' as avatar" . ", o.title AS object_title, o.link AS object_link, o.access AS object_access, o.userid AS object_owner" . " FROM #__jcomments AS c" . " JOIN #__jcomments_objects AS o ON c.object_id = o.object_id AND c.object_group = o.object_group AND c.lang = o.lang" . (count($joins) ? ' ' . implode(' ', $joins) : '') . (count($where) ? ' WHERE ' . implode(' AND ', $where) : '') . " ORDER BY " . $orderBy;
$db->setQuery($query, 0, $params->get('count'));
$list = $db->loadObjectList();
if (!is_array($list)) {
$list = array();
}
if (count($list)) {
$show_date = $params->get('show_comment_date', 0);
$date_type = $params->get('date_type', '');
$date_format = $params->get('date_format', 'd.m.Y H:i');
$show_author = $params->get('show_comment_author', 0);
$show_object_title = $params->get('show_object_title', 0);
$show_comment_title = $params->get('show_comment_title', 0);
$show_smiles = $params->get('show_smiles', 0);
$show_avatar = $params->get('show_avatar', 0);
$limit_comment_text = (int) $params->get('limit_comment_text', 0);
$config = JCommentsFactory::getConfig();
$bbcode = JCommentsFactory::getBBCode();
$smiles = JCommentsFactory::getSmiles();
$acl = JCommentsFactory::getACL();
if ($show_avatar) {
JPluginHelper::importPlugin('jcomments');
if (version_compare(JVERSION, '3.0', 'ge')) {
$dispatcher = JEventDispatcher::getInstance();
} else {
$dispatcher = JDispatcher::getInstance();
}
$dispatcher->trigger('onPrepareAvatars', array(&$list));
}
foreach ($list as &$item) {
$item->displayDate = '';
if ($show_date) {
if ($date_type == 'relative') {
$item->displayDate = modJCommentsLatestHelper::getRelativeDate($item->date);
} else {
$item->displayDate = JHTML::_('date', $item->date, $date_format);
}
}
$item->displayAuthorName = '';
if ($show_author) {
$item->displayAuthorName = JComments::getCommentAuthorName($item);
}
$item->displayObjectTitle = '';
if ($show_object_title) {
$item->displayObjectTitle = $item->object_title;
}
$item->displayCommentTitle = '';
if ($show_comment_title) {
$item->displayCommentTitle = $item->title;
}
$item->displayCommentLink = $item->object_link . '#comment-' . $item->id;
$text = JCommentsText::censor($item->comment);
$text = preg_replace('#\\[quote[^\\]]*?\\](((?R)|.)*?)\\[\\/quote\\]#ismu', '', $text);
$text = $bbcode->filter($text, true);
$text = JCommentsText::fixLongWords($text, $config->getInt('word_maxlength'), ' ');
if ($acl->check('autolinkurls')) {
$text = preg_replace_callback(_JC_REGEXP_LINK, array('JComments', 'urlProcessor'), $text);
}
$text = JCommentsText::cleanText($text);
if ($limit_comment_text && JString::strlen($text) > $limit_comment_text) {
$text = self::truncateText($text, $limit_comment_text - 1);
}
switch ($show_smiles) {
case 1:
$text = $smiles->replace($text);
break;
case 2:
$text = $smiles->strip($text);
break;
}
$item->displayCommentText = $text;
if ($show_avatar && empty($item->avatar)) {
$gravatar = md5(strtolower($item->email));
$item->avatar = '<img src="http://www.gravatar.com/avatar.php?gravatar_id=' . $gravatar . '&default=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="' . htmlspecialchars(JComments::getCommentAuthorName($item)) . '" />';
}
$item->readmoreText = JText::_('MOD_JCOMMENTS_LATEST_READMORE');
}
}
return $list;
}