当前位置: 首页>>代码示例>>PHP>>正文


PHP JComments::prepareComment方法代码示例

本文整理汇总了PHP中JComments::prepareComment方法的典型用法代码示例。如果您正苦于以下问题:PHP JComments::prepareComment方法的具体用法?PHP JComments::prepareComment怎么用?PHP JComments::prepareComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JComments的用法示例。


在下文中一共展示了JComments::prepareComment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveComment

 function saveComment($values = array())
 {
     if (JCommentsSecurity::badRequest() == 1) {
         JCommentsSecurity::notAuth();
     }
     $db =& JCommentsFactory::getDBO();
     $config =& JCommentsFactory::getConfig();
     $response =& JCommentsFactory::getAjaxResponse();
     $values = JCommentsAJAX::prepareValues($_POST);
     $comment = new JCommentsDB($db);
     $id = (int) $values['id'];
     if ($comment->load($id)) {
         $acl =& JCommentsFactory::getACL();
         if ($acl->canEdit($comment)) {
             if ($values['comment'] == '') {
                 JCommentsAJAX::showErrorMessage(JText::_('ERROR_EMPTY_COMMENT'), 'comment');
             } else {
                 if ($config->getInt('comment_maxlength') != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) > $config->getInt('comment_maxlength')) {
                     JCommentsAJAX::showErrorMessage(JText::_('ERROR_TOO_LONG_COMMENT'), 'comment');
                 } else {
                     if ($config->getInt('comment_minlength') != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) < $config->getInt('comment_minlength')) {
                         JCommentsAJAX::showErrorMessage(JText::_('Your comment is too short'), 'comment');
                     } else {
                         $bbcode =& JCommentsFactory::getBBCode();
                         $comment->comment = $values['comment'];
                         $comment->comment = $bbcode->filter($comment->comment);
                         $comment->published = $acl->check('autopublish');
                         if ($config->getInt('comment_title') != 0 && isset($values['title'])) {
                             $comment->title = stripslashes((string) $values['title']);
                         }
                         if ($config->getInt('author_homepage') == 1 && isset($values['homepage'])) {
                             $comment->homepage = JCommentsText::url($values['homepage']);
                         } else {
                             $comment->homepage = '';
                         }
                         $allowed = true;
                         if ($config->getInt('enable_mambots') == 1) {
                             require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
                             JCommentsPluginHelper::importPlugin('jcomments');
                             JCommentsPluginHelper::trigger('onBeforeCommentChanged', array(&$comment, &$response, &$allowed));
                         }
                         if ($allowed == false) {
                             return $response;
                         }
                         $comment->store();
                         $comment->checkin();
                         $comment->datetime = $comment->date;
                         if ($config->getInt('enable_mambots') == 1) {
                             JCommentsPluginHelper::importPlugin('jcomments');
                             JCommentsPluginHelper::trigger('onAfterCommentChanged', array(&$comment, &$response));
                         }
                         if ($config->getInt('enable_notification') == 1) {
                             if ($config->check('notification_type', 1) == true) {
                                 JComments::sendNotification($comment, false);
                             }
                         }
                         JComments::prepareComment($comment);
                         $tmpl =& JCommentsFactory::getTemplate();
                         $tmpl->load('tpl_comment');
                         $tmpl->addVar('tpl_comment', 'get_comment_body', 1);
                         $tmpl->addObject('tpl_comment', 'comment', $comment);
                         $html = $tmpl->renderTemplate('tpl_comment');
                         $html = JCommentsText::jsEscape($html);
                         $response->addScript("jcomments.updateComment(" . $comment->id . ", '{$html}');");
                     }
                 }
             }
         } else {
             $response->addAlert(JText::_('ERROR_CANT_EDIT'));
         }
     }
     unset($comment);
     return $response;
 }
开发者ID:omarmm,项目名称:MangLuoiBDS,代码行数:74,代码来源:jcomments.ajax.php

示例2: getCommentsTree

 function getCommentsTree($object_id, $object_group = 'com_content', $search_text = '')
 {
     global $my;
     $object_id = (int) $object_id;
     $object_group = trim($object_group);
     $acl =& JCommentsFactory::getACL();
     $dbo =& JCommentsFactory::getDBO();
     $config =& JCommentsFactory::getConfig();
     $canPublish = $acl->canPublish();
     $canComment = $acl->canComment();
     $where = '';
     if ($search_text) {
         $words = explode(' ', $search_text);
         $wheres = array();
         foreach ($words as $word) {
             $wheres2 = array();
             $wheres2[] = "LOWER(name) LIKE '%{$word}%'";
             $wheres2[] = "LOWER(comment) LIKE '%{$word}%'";
         }
         if (isset($wheres2) && count($wheres2)) {
             $where .= ' AND (';
             $where .= implode(' OR ', $wheres2);
             $where .= ' )';
         }
     }
     if ($canComment == 0) {
         $total = JLMS_JComments::getCommentsCount($object_id, $object_group, $where);
         if ($total == 0) {
             return '';
         }
     }
     $query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment" . "\n , c.email, c.homepage, c.date as datetime, c.ip, c.published, c.checked_out, c.checked_out_time" . "\n , c.isgood, c.ispoor" . "\n , v.value as voted" . "\n FROM #__jcomments AS c" . "\n LEFT JOIN #__jcomments_votes AS v ON c.id = v.commentid " . ($my->id ? " AND  v.userid = " . $my->id : " AND  v.ip = '" . $acl->getUserIP() . "'") . "\n WHERE c.object_id = " . $object_id . "\n AND c.object_group = '" . $object_group . "'" . (JCommentsMultilingual::isEnabled() ? "\nAND c.lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . ($canPublish == 0 ? "\nAND c.published = 1" : "") . $where . "\n ORDER BY c.parent, c.date ASC";
     $dbo->setQuery($query);
     $rows = $dbo->loadObjectList();
     $tmpl =& JCommentsFactory::getTemplate($object_id, $object_group);
     $tmpl->load('tpl_tree');
     $tmpl->load('tpl_comment');
     if (count($rows)) {
         $isLocked = $config->getInt('object_locked', 0) == 1;
         $tmpl->addVar('tpl_tree', 'comments-refresh', intval(!$isLocked));
         $tmpl->addVar('tpl_tree', 'comments-rss', intval($config->getInt('enable_rss') && !$isLocked));
         $tmpl->addVar('tpl_tree', 'comments-can-subscribe', intval($my->id && $acl->check('enable_subscribe') && !$isLocked));
         if ($my->id && $acl->check('enable_subscribe')) {
             require_once JCOMMENTS_BASE . DS . 'jcomments.subscription.php';
             $manager =& JCommentsSubscriptionManager::getInstance();
             $isSubscribed = $manager->isSubscribed($object_id, $object_group, $my->id);
             $tmpl->addVar('tpl_tree', 'comments-user-subscribed', $isSubscribed);
         }
         $i = 1;
         if ($config->getInt('enable_mambots') == 1) {
             require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
             JCommentsPluginHelper::importPlugin('jcomments');
             JCommentsPluginHelper::trigger('onBeforeDisplayCommentsList', array(&$rows));
             if ($acl->check('enable_gravatar')) {
                 JCommentsPluginHelper::trigger('onPrepareAvatars', array(&$rows));
             }
         }
         require_once JCOMMENTS_LIBRARIES . DS . 'joomlatune' . DS . 'tree.php';
         $tree = new JoomlaTuneTree($rows);
         $items = $tree->get();
         foreach ($rows as $row) {
             if ($config->getInt('enable_mambots') == 1) {
                 JCommentsPluginHelper::trigger('onBeforeDisplayComment', array(&$row));
             }
             // run autocensor, replace quotes, smiles and other pre-view processing
             JComments::prepareComment($row);
             // setup toolbar
             if (!$acl->canModerate($row)) {
                 $tmpl->addVar('tpl_comment', 'comments-panel-visible', 0);
             } else {
                 $tmpl->addVar('tpl_comment', 'comments-panel-visible', 1);
                 $tmpl->addVar('tpl_comment', 'button-edit', $acl->canEdit($row));
                 $tmpl->addVar('tpl_comment', 'button-delete', $acl->canDelete($row));
                 $tmpl->addVar('tpl_comment', 'button-publish', $acl->canPublish($row));
                 $tmpl->addVar('tpl_comment', 'button-ip', $acl->canViewIP($row));
             }
             $tmpl->addVar('tpl_comment', 'comment-show-vote', $config->getInt('enable_voting'));
             $tmpl->addVar('tpl_comment', 'comment-show-email', $acl->canViewEmail($row));
             $tmpl->addVar('tpl_comment', 'comment-show-homepage', $acl->canViewHomepage($row));
             $tmpl->addVar('tpl_comment', 'comment-show-title', $config->getInt('comment_title'));
             $tmpl->addVar('tpl_comment', 'button-vote', $acl->canVote($row));
             $tmpl->addVar('tpl_comment', 'button-quote', $acl->canQuote($row));
             $tmpl->addVar('tpl_comment', 'button-reply', $acl->canReply($row));
             $tmpl->addVar('tpl_comment', 'avatar', $acl->check('enable_gravatar'));
             if (isset($items[$row->id])) {
                 $tmpl->addVar('tpl_comment', 'comment-number', '');
                 $tmpl->addObject('tpl_comment', 'comment', $row);
                 $items[$row->id]->html = $tmpl->renderTemplate('tpl_comment');
                 $i++;
             }
         }
         $tmpl->addObject('tpl_tree', 'comments-items', $items);
         unset($rows);
     }
     return $tmpl->renderTemplate('tpl_tree');
 }
开发者ID:parkmi,项目名称:dolschool14,代码行数:96,代码来源:jc_integration.php

示例3: getCommentItem

 public static function getCommentItem(&$comment)
 {
     $acl = JCommentsFactory::getACL();
     $config = JCommentsFactory::getConfig();
     if ($acl->check('enable_gravatar')) {
         JCommentsEventHelper::trigger('onPrepareAvatar', array(&$comment));
     }
     // run autocensor, replace quotes, smilies and other pre-view processing
     JComments::prepareComment($comment);
     $tmpl = JCommentsFactory::getTemplate($comment->object_id, $comment->object_group);
     $tmpl->load('tpl_comment');
     // setup toolbar
     if (!$acl->canModerate($comment)) {
         $tmpl->addVar('tpl_comment', 'comments-panel-visible', 'visibility', 0);
     } else {
         $tmpl->addVar('tpl_comment', 'comments-panel-visible', 1);
         $tmpl->addVar('tpl_comment', 'button-edit', $acl->canEdit($comment));
         $tmpl->addVar('tpl_comment', 'button-delete', $acl->canDelete($comment));
         $tmpl->addVar('tpl_comment', 'button-publish', $acl->canPublish($comment));
         $tmpl->addVar('tpl_comment', 'button-ip', $acl->canViewIP($comment));
         $tmpl->addVar('tpl_comment', 'button-ban', $acl->canBan($comment));
         $tmpl->addVar('tpl_comment', 'comment-show-email', $acl->canViewEmail());
         $tmpl->addVar('tpl_comment', 'comment-show-homepage', $acl->canViewHomepage());
     }
     $tmpl->addVar('tpl_comment', 'comment-show-vote', $config->getInt('enable_voting'));
     $tmpl->addVar('tpl_comment', 'comment-show-email', $acl->canViewEmail($comment));
     $tmpl->addVar('tpl_comment', 'comment-show-homepage', $acl->canViewHomepage($comment));
     $tmpl->addVar('tpl_comment', 'comment-show-title', $config->getInt('comment_title'));
     $tmpl->addVar('tpl_comment', 'button-vote', $acl->canVote($comment));
     $tmpl->addVar('tpl_comment', 'button-quote', $acl->canQuote($comment));
     $tmpl->addVar('tpl_comment', 'button-reply', $acl->canReply($comment));
     $tmpl->addVar('tpl_comment', 'button-report', $acl->canReport($comment));
     $tmpl->addVar('tpl_comment', 'comment-number', '');
     $tmpl->addVar('tpl_comment', 'avatar', $acl->check('enable_gravatar') && !$comment->deleted);
     $tmpl->addObject('tpl_comment', 'comment', $comment);
     return $tmpl->renderTemplate('tpl_comment');
 }
开发者ID:korolariya,项目名称:gameportal,代码行数:37,代码来源:jcomments.php

示例4: getCommentListItem

 function getCommentListItem(&$comment)
 {
     $acl =& JCommentsFactory::getACL();
     $config =& JCommentsFactory::getConfig();
     if ($config->getInt('enable_mambots') == 1) {
         require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
         JCommentsPluginHelper::importPlugin('jcomments');
         JCommentsPluginHelper::trigger('onBeforeDisplayComment', array(&$comment));
         if ($acl->check('enable_gravatar')) {
             JCommentsPluginHelper::trigger('onPrepareAvatar', array(&$comment));
         }
     }
     // run autocensor, replace quotes, smiles and other pre-view processing
     JComments::prepareComment($comment);
     $total = JCommentsModel::getCommentsCount($comment->object_id, $comment->object_group, ' AND parent = ' . $comment->parent);
     $tmpl = JCommentsFactory::getTemplate($comment->object_id, $comment->object_group);
     $tmpl->load('tpl_list');
     $tmpl->load('tpl_comment');
     // setup toolbar
     if (!$acl->canModerate($comment)) {
         $tmpl->addVar('tpl_comment', 'comments-panel-visible', 'visibility', 0);
     } else {
         $tmpl->addVar('tpl_comment', 'comments-panel-visible', 1);
         $tmpl->addVar('tpl_comment', 'button-edit', $acl->canEdit($comment));
         $tmpl->addVar('tpl_comment', 'button-delete', $acl->canDelete($comment));
         $tmpl->addVar('tpl_comment', 'button-publish', $acl->canPublish($comment));
         $tmpl->addVar('tpl_comment', 'button-ip', $acl->canViewIP($comment));
         $tmpl->addVar('tpl_comment', 'comment-show-email', $acl->canViewEmail());
         $tmpl->addVar('tpl_comment', 'comment-show-homepage', $acl->canViewHomepage());
     }
     $tmpl->addVar('tpl_comment', 'comment-show-vote', $config->getInt('enable_voting'));
     $tmpl->addVar('tpl_comment', 'comment-show-email', $acl->canViewEmail($comment));
     $tmpl->addVar('tpl_comment', 'comment-show-homepage', $acl->canViewHomepage($comment));
     $tmpl->addVar('tpl_comment', 'comment-show-title', $config->getInt('comment_title'));
     $tmpl->addVar('tpl_comment', 'button-vote', $acl->canVote($comment));
     $tmpl->addVar('tpl_comment', 'button-quote', $acl->canQuote($comment));
     $tmpl->addVar('tpl_comment', 'button-reply', $acl->canReply($comment));
     $tmpl->addVar('tpl_comment', 'button-report', $acl->canReport($comment));
     $tmpl->addVar('tpl_comment', 'comment-number', '');
     $tmpl->addVar('tpl_comment', 'avatar', $acl->check('enable_gravatar'));
     $tmpl->addObject('tpl_comment', 'comment', $comment);
     $commentItem = $tmpl->renderTemplate('tpl_comment');
     $tmpl->addVar('tpl_list', 'comment-id', $comment->id);
     $tmpl->addVar('tpl_list', 'comment-item', $commentItem);
     $tmpl->addVar('tpl_list', 'comment-modulo', $total % 2 ? 1 : 0);
     return $tmpl->renderTemplate('tpl_list');
 }
开发者ID:omarmm,项目名称:MangLuoiBDS,代码行数:47,代码来源:jcomments.php


注:本文中的JComments::prepareComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。