mirror of
https://github.com/flarum/core.git
synced 2025-07-29 04:30:56 +02:00
Update for new formatting API.
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
<?php namespace Flarum\Mentions;
|
<?php namespace Flarum\Mentions;
|
||||||
|
|
||||||
class PostMentionsFormatter
|
use Flarum\Core\Formatter\FormatterAbstract;
|
||||||
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
|
class PostMentionsFormatter extends FormatterAbstract
|
||||||
{
|
{
|
||||||
protected $parser;
|
protected $parser;
|
||||||
|
|
||||||
@@ -9,22 +12,15 @@ class PostMentionsFormatter
|
|||||||
$this->parser = $parser;
|
$this->parser = $parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function format($text, $post = null)
|
public function afterPurification($text, Post $post = null)
|
||||||
{
|
{
|
||||||
if ($post) {
|
if ($post) {
|
||||||
$text = $this->parser->replace($text, function ($match) use ($post) {
|
$text = $this->ignoreTags($text, ['a', 'code', 'pre'], function ($text) use ($post) {
|
||||||
|
return $this->parser->replace($text, function ($match) use ($post) {
|
||||||
return '<a href="#/d/'.$post->discussion_id.'/-/'.$match['number'].'" class="mention-post" data-number="'.$match['number'].'">'.$match['username'].'</a>';
|
return '<a href="#/d/'.$post->discussion_id.'/-/'.$match['number'].'" class="mention-post" data-number="'.$match['number'].'">'.$match['username'].'</a>';
|
||||||
}, $text);
|
}, $text);
|
||||||
}
|
|
||||||
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function strip($text)
|
|
||||||
{
|
|
||||||
$text = $this->parser->replace($text, function () {
|
|
||||||
return ' ';
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
<?php namespace Flarum\Mentions;
|
<?php namespace Flarum\Mentions;
|
||||||
|
|
||||||
class UserMentionsFormatter
|
use Flarum\Core\Formatter\FormatterAbstract;
|
||||||
|
use Flarum\Core\Models\Post;
|
||||||
|
|
||||||
|
class UserMentionsFormatter extends FormatterAbstract
|
||||||
{
|
{
|
||||||
protected $parser;
|
protected $parser;
|
||||||
|
|
||||||
@@ -9,11 +12,13 @@ class UserMentionsFormatter
|
|||||||
$this->parser = $parser;
|
$this->parser = $parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function format($text, $post = null)
|
public function afterPurification($text, Post $post = null)
|
||||||
{
|
{
|
||||||
$text = $this->parser->replace($text, function ($match) {
|
$text = $this->ignoreTags($text, ['a', 'code', 'pre'], function ($text) {
|
||||||
|
return $this->parser->replace($text, function ($match) {
|
||||||
return '<a href="#/u/'.$match['username'].'" class="mention-user" data-user="'.$match['username'].'">'.$match['username'].'</a>';
|
return '<a href="#/u/'.$match['username'].'" class="mention-user" data-user="'.$match['username'].'">'.$match['username'].'</a>';
|
||||||
}, $text);
|
}, $text);
|
||||||
|
});
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user