Merge pull request #7296 from MrPetovan/task/smilies-replace
Limit smilies replacement to BBCode::convert
This commit is contained in:
commit
26accbe3ef
5 changed files with 13 additions and 12 deletions
|
@ -140,16 +140,12 @@ function redir_private_images($a, &$item)
|
||||||
* @brief Given a text string, convert from bbcode to html and add smilie icons.
|
* @brief Given a text string, convert from bbcode to html and add smilie icons.
|
||||||
*
|
*
|
||||||
* @param string $text String with bbcode.
|
* @param string $text String with bbcode.
|
||||||
* @return string Formattet HTML.
|
* @return string Formatted HTML
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
function prepare_text($text) {
|
function prepare_text($text)
|
||||||
if (stristr($text, '[nosmile]')) {
|
{
|
||||||
$s = BBCode::convert($text);
|
$s = BBCode::convert($text);
|
||||||
} else {
|
|
||||||
$s = Smilies::replace(BBCode::convert($text));
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim($s);
|
return trim($s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,7 @@ function message_content(App $a)
|
||||||
|
|
||||||
$from_name_e = $message['from-name'];
|
$from_name_e = $message['from-name'];
|
||||||
$subject_e = $message['title'];
|
$subject_e = $message['title'];
|
||||||
$body_e = Smilies::replace(BBCode::convert($message['body']));
|
$body_e = BBCode::convert($message['body']);
|
||||||
$to_name_e = $message['name'];
|
$to_name_e = $message['name'];
|
||||||
|
|
||||||
$contact = Contact::getDetailsByURL($message['from-url']);
|
$contact = Contact::getDetailsByURL($message['from-url']);
|
||||||
|
|
|
@ -267,17 +267,18 @@ class Smilies
|
||||||
* @return string HTML Output
|
* @return string HTML Output
|
||||||
*
|
*
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @todo : Rework because it doesn't work correctly
|
|
||||||
*/
|
*/
|
||||||
private static function pregHeart($x)
|
private static function pregHeart($x)
|
||||||
{
|
{
|
||||||
if (strlen($x[1]) == 1) {
|
if (strlen($x[1]) == 1) {
|
||||||
return $x[0];
|
return $x[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$t = '';
|
$t = '';
|
||||||
for ($cnt = 0; $cnt < strlen($x[1]); $cnt ++) {
|
for ($cnt = 0; $cnt < strlen($x[1]); $cnt ++) {
|
||||||
$t .= '<img class="smiley" src="' . System::baseUrl() . '/images/smiley-heart.gif" alt="<3" />';
|
$t .= '❤';
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = str_replace($x[0], $t, $x[0]);
|
$r = str_replace($x[0], $t, $x[0]);
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1395,6 +1395,7 @@ class BBCode extends BaseObject
|
||||||
|
|
||||||
// This is actually executed in Item::prepareBody()
|
// This is actually executed in Item::prepareBody()
|
||||||
|
|
||||||
|
$nosmile = strpos($text, '[nosmile]') !== false;
|
||||||
$text = str_replace('[nosmile]', '', $text);
|
$text = str_replace('[nosmile]', '', $text);
|
||||||
|
|
||||||
// Check for font change text
|
// Check for font change text
|
||||||
|
@ -1572,7 +1573,7 @@ class BBCode extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace non graphical smilies for external posts
|
// Replace non graphical smilies for external posts
|
||||||
if ($simple_html) {
|
if (!$nosmile && !$for_plaintext) {
|
||||||
$text = Smilies::replace($text);
|
$text = Smilies::replace($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@ class BBCodeTest extends MockedTest
|
||||||
$this->configMock->shouldReceive('get')
|
$this->configMock->shouldReceive('get')
|
||||||
->with('system', 'url')
|
->with('system', 'url')
|
||||||
->andReturn('friendica.local');
|
->andReturn('friendica.local');
|
||||||
|
$this->configMock->shouldReceive('get')
|
||||||
|
->with('system', 'no_smilies')
|
||||||
|
->andReturn(false);
|
||||||
$this->mockL10nT();
|
$this->mockL10nT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue