本文整理汇总了PHP中DiscussHelper::wordFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::wordFilter方法的具体用法?PHP DiscussHelper::wordFilter怎么用?PHP DiscussHelper::wordFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::wordFilter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbcodeHtmlSwitcher
public static function bbcodeHtmlSwitcher($post = '', $type = '', $isEditing = false)
{
$config = DiscussHelper::getConfig();
if ($type == 'question') {
$editor = $config->get('layout_editor');
} else {
if ($type == 'reply') {
$editor = $config->get('layout_reply_editor');
} else {
if ($type == 'signature' || $type == 'description') {
$temp = $post;
$post = new stdClass();
$post->content_raw = $temp;
$post->content_type = 'bbcode';
$editor = 'bbcode';
}
}
}
if ($editor != 'bbcode') {
$editor = 'html';
}
if ($post->content_type == 'bbcode') {
if ($editor == 'bbcode') {
//If content_type is bbcode and editor is bbcode
if ($isEditing) {
$content = $post->content_raw;
} else {
$content = $post->content_raw;
//$content = DiscussHelper::getHelper( 'String' )->escape( $content );
$content = EasyDiscussParser::bbcode($content);
$content = EasyDiscussParser::removeBrTag($content);
}
} else {
//If content_type is bbcode and editor is html
// Need content raw to work
//$content = DiscussHelper::getHelper( 'String' )->escape( $post->content_raw );
$content = EasyDiscussParser::bbcode($content);
$content = EasyDiscussParser::removeBrTag($content);
}
} else {
if ($editor == 'bbcode') {
//If content_type is html and editor is bbcode
if ($isEditing) {
$content = EasyDiscussParser::quoteBbcode($post->content_raw);
$content = EasyDiscussParser::smiley2bbcode($content);
// we need to parse smiley 1st before we parse htmltobbcode.
$content = EasyDiscussParser::html2bbcode($content);
} else {
$content = $post->content_raw;
//Quote all bbcode here
$content = EasyDiscussParser::quoteBbcode($content);
}
} else {
//If content_type is html and editor is html
$content = $post->content_raw;
}
}
// Apply censorship
$content = DiscussHelper::wordFilter($content);
return $content;
}
示例2: getContent
public function getContent()
{
if (!isset($this->_data['content'])) {
$this->_data['content'] = DiscussHelper::wordFilter($this->content);
}
return $this->_data['content'];
}
示例3: display
public function display($tpl = null)
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$config = DiscussHelper::getConfig();
// Sorting and filters.
$sort = JRequest::getString('sort', DiscussHelper::getDefaultRepliesSorting());
$filteractive = JRequest::getString('filter', 'allposts');
$id = JRequest::getInt('id');
$acl = DiscussHelper::getHelper('ACL');
// Add noindex for print view by default.
if (JRequest::getInt('print') == 1) {
$doc->setMetadata('robots', 'noindex,follow');
}
// Get current logged in user.
$my = JFactory::getUser();
// Determine if the logged in user is an admin.
$isAdmin = DiscussHelper::isSiteAdmin();
// Load the post table out.
$post = DiscussHelper::getTable('Post');
$state = $post->load($id);
// Need raw content for later use
$post->content_raw = $post->content;
// If id is not found, we need to redirect gracefully.
if (!$state || !$post->published || !$id) {
return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
}
if ($post->private && $my->id != $post->user_id && !$isAdmin && !DiscussHelper::isModerator($post->category_id, $my->id)) {
return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
}
// Check whether this is a valid discussion
if ($post->parent_id != 0 || $post->published == DISCUSS_ID_PENDING && (!$isAdmin && $post->user_id != $my->id)) {
return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
}
// check the discussion is under moderation
if ($post->published == 4 && !DiscussHelper::isModerator($post->category_id, $my->id) && !$isAdmin) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NOTICE_POST_SUBMITTED_UNDER_MODERATION'), 'error');
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
$app->close();
}
// Load the category.
$category = DiscussHelper::getTable('Category');
$category->load((int) $post->category_id);
if ($post->category_id && !$category->canAccess()) {
return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
}
// Add pathway for category here.
DiscussHelper::getHelper('Pathway')->setCategoryPathway($category);
// Set breadcrumbs for this discussion.
$this->setPathway($this->escape($post->title));
// Mark as viewed for notifications.
$this->logView();
// Update hit count for this discussion.
$post->hit();
// Set page headers
$this->setPageHeaders($post);
// Before sending the title and content to be parsed, we need to store this temporarily in case it needs to be accessed.
$post->title_clear = $post->title;
// Filter badwords
$post->title = DiscussHelper::wordFilter($post->title);
$post->content = DiscussHelper::wordFilter($post->content);
// Get the tags for this discussion
$postsTagsModel = $this->getModel('PostsTags');
$tags = $postsTagsModel->getPostTags($id);
// Get adsense codes here.
$adsense = DiscussHelper::getAdsense();
$postsModel = DiscussHelper::getModel('Posts');
// Get the answer for this discussion.
$answer = $postsModel->getAcceptedReply($post->id);
// Format the answer object.
if ($answer) {
$answer = DiscussHelper::formatReplies($answer, $category);
$answer = $answer[0];
}
// Get a list of replies for this post.
$data = $this->getReplies($category, $post, $sort, $answer);
$replies = $data->replies;
$totalReplies = $data->total;
$hasMoreReplies = $data->more;
$readMoreURI = $data->readmore;
// Get comments for the post
$commentLimit = $config->get('main_comment_pagination') ? $config->get('main_comment_pagination_count') : null;
$post->comments = false;
if ($config->get('main_commentpost')) {
$comments = $post->getComments($commentLimit);
$post->comments = DiscussHelper::formatComments($comments);
}
// get reply comments count
$post->commentsCount = $post->getTotalComments();
// Get the post access object here.
$access = $post->getAccess($category);
$post->access = $access;
// Add custom values.
$postOwner = $post->getOwner();
$profileTable = DiscussHelper::getTable('Profile');
if ($postOwner->id) {
$profileTable->load($postOwner->id);
}
$post->user = $profileTable;
// update user's post read flag
//.........这里部分代码省略.........
示例4: saveReply
/**
* Triggers when an edited reply is saved.
*
* @since 3.0
* @param null
* @return null
*/
public function saveReply()
{
// Load ajax library
$ajax = DiscussHelper::getHelper('Ajax');
$config = DiscussHelper::getConfig();
// Get the posted data
$data = JRequest::get('post');
// Prepare the output data
$output = array();
$output['id'] = $data['post_id'];
$acl = DiscussHelper::getHelper('ACL');
$my = JFactory::getUser();
// Check for empty content
$this->checkEmpty($data, $ajax);
// Rebind the post data because it may contain HTML codes
$data['content'] = JRequest::getVar('content', '', 'post', 'none', JREQUEST_ALLOWRAW);
$data['content_type'] = DiscussHelper::getEditorType('reply');
// Load up the post table
$post = DiscussHelper::getTable('Post');
$post->load($data['post_id']);
// Bind the post table with the data
$post->bind($data);
// Check if the post data is valid
if (!$post->id || !$data['post_id']) {
$ajax->reject('error', JText::_('COM_EASYDISCUSS_SYSTEM_INVALID_ID'));
return $ajax->send();
}
// Only allow users with proper access
$isModerator = DiscussHelper::getHelper('Moderator')->isModerator($post->category_id);
// Do not allow unauthorized access
if (!DiscussHelper::isSiteAdmin() && $post->user_id != $my->id && !$acl->allowed('edit_reply', 0) && !$isModerator) {
$ajax->reject('error', JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
$ajax->send();
}
// Get the new content from the post data
$post->content = $data['content'];
// Validate captcha
$this->checkCaptcha($data);
// @rule: Bind parameters
if ($config->get('reply_field_references')) {
$post->bindParams($data);
}
// Bind file attachments
if ($acl->allowed('add_attachment', '0')) {
$post->bindAttachments();
}
// Determines if this is a new post.
$isNew = false;
// @trigger: onBeforeSave
DiscussEventsHelper::importPlugin('content');
DiscussEventsHelper::onContentBeforeSave('post', $post, $isNew);
// Try to store the post now
if (!$post->store()) {
$ajax->reject('error', JText::_('COM_EASYDISCUSS_ERROR'));
$ajax->send();
}
// Process polls
$this->processPolls($post);
// Process custom fields
$this->saveCustomFieldsValue($post->id);
// @trigger: onAfterSave
DiscussEventsHelper::onContentAfterSave('post', $post, $isNew);
// Filter for badwords
$post->title = DiscussHelper::wordFilter($post->title);
$post->content = DiscussHelper::wordFilter($post->content);
// Determines if the user is allowed to delete this post
$canDelete = false;
if (DiscussHelper::isSiteAdmin() || $acl->allowed('delete_reply', '0') || $post->user_id == $my->id) {
$canDelete = true;
}
// URL References
$post->references = $post->getReferences();
// Get the voted state
$voteModel = DiscussHelper::getModel('Votes');
$post->voted = $voteModel->hasVoted($post->id);
// Get total votes for this post
$post->totalVote = $post->sum_totalvote;
// Load profile info
$creator = DiscussHelper::getTable('Profile');
$creator->load($post->user_id);
// Assign creator
$post->user = $creator;
// Format the content.
$tmp = $post->content;
$post->content_raw = $post->content;
$post->content = DiscussHelper::formatContent($post);
// Once the formatting is done, we need to escape the raw content
$post->content_raw = DiscussHelper::getHelper('String')->escape($tmp);
// Store the default values
//default value
$post->isVoted = 0;
$post->total_vote_cnt = 0;
$post->likesAuthor = '';
//.........这里部分代码省略.........
示例5: save
//.........这里部分代码省略.........
$durationObj->daydiff = 0;
$durationObj->timediff = '00:00:01';
$comment->duration = DiscussHelper::getDurationString($durationObj);
// Set the comment creator.
$comment->creator = $profile;
// Try to detect if the comment is posted to the main question or a reply.
$liveNotificationText = '';
if ($post->parent_id) {
$question = DiscussHelper::getTable('Post');
$question->load($post->parent_id);
$liveNotificationText = 'COM_EASYDISCUSS_COMMENT_REPLY_NOTIFICATION_TITLE';
} else {
$question = DiscussHelper::getTable('Post');
$question->load($id);
$liveNotificationText = 'COM_EASYDISCUSS_COMMENT_QUESTION_NOTIFICATION_TITLE';
}
// Create notification item in EasySocial
DiscussHelper::getHelper('EasySocial')->notify('new.comment', $post, $question, $comment);
if ($comment->published && !$question->private) {
// AUP integrations
DiscussHelper::getHelper('Aup')->assign(DISCUSS_POINTS_NEW_COMMENT, $comment->user_id, '');
// jomsocial activity stream
DiscussHelper::getHelper('jomsocial')->addActivityComment($post, $question);
DiscussHelper::getHelper('easysocial')->commentDiscussionStream($comment, $post, $question);
}
// Add notification to the post owner.
if ($post->user_id != $my->id && $comment->published && $config->get('main_notifications_comments')) {
$notification = DiscussHelper::getTable('Notifications');
$notification->bind(array('title' => JText::sprintf($liveNotificationText, $question->title), 'cid' => $question->id, 'type' => DISCUSS_NOTIFICATIONS_COMMENT, 'target' => $post->user_id, 'author' => $my->id, 'permalink' => 'index.php?option=com_easydiscuss&view=post&id=' . $question->id));
$notification->store();
}
// Try to assign badge and points to the current user.
// Only assign points and badge when they are commenting a post that are not posted by them
// if( $my->id != $post->user_id )
// {
// Add logging for user.
DiscussHelper::getHelper('History')->log('easydiscuss.new.comment', $my->id, JText::_('COM_EASYDISCUSS_BADGES_HISTORY_NEW_COMMENT'), $post->id);
// Assign badge for EasySocial
DiscussHelper::getHelper('EasySocial')->assignBadge('create.comment', $my->id, JText::_('COM_EASYDISCUSS_BADGES_HISTORY_NEW_COMMENT'));
DiscussHelper::getHelper('Badges')->assign('easydiscuss.new.comment', $my->id);
DiscussHelper::getHelper('Points')->assign('easydiscuss.new.comment', $my->id, $comment);
// }
// Apply badword filtering for the comment.
$comment->comment = DiscussHelper::wordFilter($comment->comment);
$emailData = array();
$emailData['commentContent'] = $comment->comment;
$emailData['commentAuthor'] = $profile->getName();
$emailData['commentAuthorAvatar'] = $profile->getAvatar();
$emailData['postTitle'] = $question->title;
$emailData['postLink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $question->id, false, true);
$emails = array();
// Send email to the post owner only if the commenter is not the post owner.
if ($post->user_id != 0 && $post->id != $my->id) {
$user = JFactory::getUser($post->user_id);
$emails[] = $user->email;
}
// Retrieve the list of user emails from the list of comments made on the post.
$existingComments = $post->getComments();
if ($existingComments) {
foreach ($existingComments as $existingComment) {
// Only add the email when the user id is not the current logged in user who is posting the comment.
// It should not send email to the post owner as well since the post owner will already get a notification.
if ($existingComment->user_id != 0 && $existingComment->user_id != $my->id && $existingComment->user_id != $post->user_id) {
$user = JFactory::getUser($existingComment->user_id);
$emails[] = $user->email;
}
}
}
// Ensure the emails are all unique.
$emails = array_unique($emails);
// Only send email when email is not empty.
if (!empty($emails)) {
$notify = DiscussHelper::getNotification();
$notify->addQueue($emails, JText::sprintf('COM_EASYDISCUSS_EMAIL_TITLE_NEW_COMMENT', JString::substr($question->content, 0, 15)) . '...', '', 'email.post.comment.new.php', $emailData);
}
//revert the comment form
// $ajax->script('discuss.comment.cancel()');
// Process comment triggers.
if ($config->get('main_content_trigger_comments')) {
$comment->content = $comment->comment;
// process content plugins
DiscussEventsHelper::importPlugin('content');
DiscussEventsHelper::onContentPrepare('comment', $comment);
$comment->event = new stdClass();
$results = DiscussEventsHelper::onContentBeforeDisplay('comment', $comment);
$comment->event->beforeDisplayContent = trim(implode("\n", $results));
$results = DiscussEventsHelper::onContentAfterDisplay('comment', $comment);
$comment->event->afterDisplayContent = trim(implode("\n", $results));
$comment->comment = $comment->content;
}
// Get the parent post post id
$postId = $post->parent_id ? $post->parent_id : $post->id;
// Get the result of the posted comment.
$theme = new DiscussThemes();
$theme->set('comment', $comment);
$theme->set('postId', $postId);
$output = $theme->fetch('post.reply.comment.item.php');
$ajax->resolve($output);
return $ajax->send();
}
示例6: getData
public static function getData($params)
{
$db = DiscussHelper::getDBO();
$count = (int) $params->get('count', 10);
$filter = (int) $params->get('filter_option', 0);
$state = (int) $params->get('filter_state', 0);
$includeSubcat = (bool) $params->get('include_subcategories', 0);
$catId = intval($params->get('category', 0));
$tagId = intval($params->get('tags', 0));
$limitQuery = '';
$catQuery = '';
$exclusionQuery = '';
if (!empty($count)) {
$limitQuery = 'LIMIT 0,' . $count;
}
if ($state == 1) {
// Unanswered
$stateQuery = ' AND a.`isresolve`=' . $db->Quote(0);
$stateQuery .= ' AND a.`answered`=' . $db->Quote(0);
//Order query
$orderBy = 'ORDER BY a.`replied` DESC ';
} else {
$stateQuery = '';
$orderBy = 'ORDER BY a.`created` DESC ';
}
if ($filter == 0 || $filter == 1) {
if ($filter == 1 && !empty($catId)) {
if (!$includeSubcat) {
$catQuery = ' AND a.`category_id` = ' . $db->quote($catId) . ' ';
} else {
$catIds = array($catId);
self::appendChildCategories($catId, $catIds);
JArrayHelper::toInteger($catIds);
$catQuery = ' AND a.`category_id` IN (' . implode(',', $catIds) . ') ';
}
}
$excludedCategories = DiscussHelper::getPrivateCategories();
if (!empty($excludedCategories)) {
$exclusionQuery .= ' AND a.`category_id` NOT IN (' . implode(',', $excludedCategories) . ')';
}
$query = 'SELECT a.*, (SELECT COUNT(1) FROM `#__discuss_posts` WHERE `parent_id` = a.`id` AND `published`="1") AS `num_replies` FROM ' . $db->nameQuote('#__discuss_posts') . ' AS a ' . 'WHERE a.`published`=' . $db->Quote(1) . ' ' . 'AND a.`parent_id`=' . $db->Quote(0) . ' ' . $catQuery . $exclusionQuery . $stateQuery . $groupByQuery . $orderBy . $limitQuery;
}
if ($filter == 2) {
$query = 'SELECT a.*, (SELECT COUNT(1) FROM `#__discuss_posts` WHERE `parent_id` = a.`id` AND `published`="1") AS `num_replies` ' . ' FROM ' . $db->nameQuote('#__discuss_posts') . ' AS a' . ' LEFT JOIN ' . $db->nameQuote('#__discuss_posts_tags') . ' AS c' . ' ON a.' . $db->nameQuote('id') . '= c.' . $db->nameQuote('post_id') . ' WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote(1) . ' AND a.' . $db->nameQuote('parent_id') . '=' . $db->Quote(0) . ' AND b.' . $db->nameQuote('published') . '=' . $db->Quote(1) . ' AND c.' . $db->nameQuote('tag_id') . '=' . $db->Quote($tagId) . $stateQuery . $groupByQuery . $orderBy . $limitQuery;
}
if ($filter == 3) {
// If featured post + unanswered settings in backend showing no post in the madule
// is because featured post considered as answered
// this behaviour is respecting to the component's "unanswered tab"
$query = 'SELECT a.*, (SELECT COUNT(1) FROM `#__discuss_posts` WHERE `parent_id` = a.`id` AND `published`="1") AS `num_replies` ' . ' FROM ' . $db->nameQuote('#__discuss_posts') . ' AS a' . ' WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote(1) . ' AND a.' . $db->nameQuote('parent_id') . '=' . $db->Quote(0) . ' AND a.' . $db->nameQuote('featured') . '=' . $db->Quote(1) . $stateQuery . $groupByQuery . $orderBy . $limitQuery;
}
$db->setQuery($query);
if (!($result = $db->loadObjectList())) {
return false;
}
$posts = array();
require_once DISCUSS_HELPERS . '/parser.php';
foreach ($result as $row) {
$profile = DiscussHelper::getTable('Profile');
$profile->load($row->user_id);
$row->profile = $profile;
$row->content = EasyDiscussParser::bbcode($row->content);
$row->title = DiscussHelper::wordFilter($row->title);
$row->content = DiscussHelper::wordFilter($row->content);
// Process bbcode
$row->content = EasyDiscussParser::bbcode($row->content);
$posts[] = $row;
}
// Append profile objects to the result
return $posts;
}
示例7: saveReply
//.........这里部分代码省略.........
}
}
}
}
}
if (!empty($postTable->id)) {
//Clear off previous records before storing
$ruleModel = DiscussHelper::getModel('CustomFields');
$ruleModel->deleteCustomFieldsValue($postTable->id, 'update');
// Process custom fields.
$fieldIds = JRequest::getVar('customFields');
if (!empty($fieldIds)) {
foreach ($fieldIds as $fieldId) {
$fields = JRequest::getVar('customFieldValue_' . $fieldId);
if (!empty($fields)) {
// Cater for custom fields select list
// To detect if there is no value selected for the select list custom fields
if (in_array('defaultList', $fields)) {
$tempKey = array_search('defaultList', $fields);
$fields[$tempKey] = '';
}
}
$postTable->bindCustomFields($fields, $fieldId);
}
}
}
// @trigger: onAfterSave
DiscussEventsHelper::onContentAfterSave('post', $postTable, $isNew);
//get parent post
$parentId = $postTable->parent_id;
$parentTable = DiscussHelper::getTable('Post');
$parentTable->load($parentId);
// filtering badwords
$postTable->title = DiscussHelper::wordFilter($postTable->title);
$postTable->content = DiscussHelper::wordFilter($postTable->content);
//all access control goes here.
$canDelete = false;
if (DiscussHelper::isSiteAdmin() || $acl->allowed('delete_reply', '0') || $postTable->user_id == $user->id) {
$canDelete = true;
}
// @rule: URL References
$postTable->references = $postTable->getReferences();
// set for vote status
$voteModel = DiscussHelper::getModel('Votes');
$postTable->voted = $voteModel->hasVoted($postTable->id);
// get total vote for this reply
$postTable->totalVote = $postTable->sum_totalvote;
//load porfile info and auto save into table if user is not already exist in discuss's user table.
$creator = DiscussHelper::getTable('Profile');
$creator->load($postTable->user_id);
$postTable->user = $creator;
//default value
$postTable->isVoted = 0;
$postTable->total_vote_cnt = 0;
$postTable->likesAuthor = '';
$postTable->minimize = 0;
if ($config->get('main_content_trigger_replies')) {
// process content plugins
DiscussEventsHelper::importPlugin('content');
DiscussEventsHelper::onContentPrepare('reply', $postTable);
$postTable->event = new stdClass();
$results = DiscussEventsHelper::onContentBeforeDisplay('reply', $postTable);
$postTable->event->beforeDisplayContent = trim(implode("\n", $results));
$results = DiscussEventsHelper::onContentAfterDisplay('reply', $postTable);
$postTable->event->afterDisplayContent = trim(implode("\n", $results));
}