1
1
Fork 0

Replace html2bbcode calls by HTML::toBBCode

This commit is contained in:
Hypolite Petovan 2018-03-07 16:24:13 -05:00
parent 3bb2f72d05
commit b5666bd27f
9 changed files with 32 additions and 30 deletions

View file

@ -10,6 +10,7 @@ use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -1096,7 +1097,7 @@ function api_statuses_mediap($type)
$purifier = new HTMLPurifier($config);
$txt = $purifier->purify($txt);
}
$txt = html2bbcode($txt);
$txt = HTML::toBBCode($txt);
$a->argv[1]=$user_info['screen_name']; //should be set to username?
@ -1147,7 +1148,7 @@ function api_statuses_update($type)
$purifier = new HTMLPurifier($config);
$txt = $purifier->purify($txt);
$_REQUEST['body'] = html2bbcode($txt);
$_REQUEST['body'] = HTML::toBBCode($txt);
}
} else {
$_REQUEST['body'] = requestdata('status');

View file

@ -3,12 +3,9 @@
* @file mod/babel.php
*/
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Markdown;
use Friendica\Content\Text;
use Friendica\Core\L10n;
require_once 'include/html2bbcode.php';
function visible_lf($s)
{
return str_replace("\n", '<br />', $s);
@ -37,31 +34,31 @@ function babel_content()
$o .= '<h2>' . L10n::t('Source input: ') . '</h2>' . EOL . EOL;
$o .= visible_lf($text) . EOL . EOL;
$html = BBCode::convert($text);
$o .= '<h2>' . L10n::t("bbcode \x28raw HTML\x28: ") . '</h2>' . EOL . EOL;
$html = Text\BBCode::convert($text);
$o .= '<h2>' . L10n::t("BBCode::convert \x28raw HTML\x28: ") . '</h2>' . EOL . EOL;
$o .= htmlspecialchars($html) . EOL . EOL;
$o .= '<h2>' . L10n::t('bbcode: ') . '</h2>' . EOL . EOL;
$o .= '<h2>' . L10n::t('BBCode::convert: ') . '</h2>' . EOL . EOL;
$o .= $html . EOL . EOL;
$bbcode = html2bbcode($html);
$o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
$bbcode = Text\HTML::toBBCode($html);
$o .= '<h2>' . L10n::t('BBCode::convert => HTML::toBBCode: ') . '</h2>' . EOL . EOL;
$o .= visible_lf($bbcode) . EOL . EOL;
$diaspora = BBCode::toMarkdown($text);
$diaspora = Text\BBCode::toMarkdown($text);
$o .= '<h2>' . L10n::t('BBCode::toMarkdown: ') . '</h2>' . EOL . EOL;
$o .= visible_lf($diaspora) . EOL . EOL;
$html = Markdown::convert($diaspora);
$html = Text\Markdown::convert($diaspora);
$o .= '<h2>' . L10n::t('BBCode::toMarkdown => Markdown::convert: ') . '</h2>' . EOL . EOL;
$o .= $html . EOL . EOL;
$bbcode = Markdown::toBBCode($diaspora);
$bbcode = Text\Markdown::toBBCode($diaspora);
$o .= '<h2>' . L10n::t('BBCode::toMarkdown => Markdown::toBBCode: ') . '</h2>' . EOL . EOL;
$o .= visible_lf($bbcode) . EOL . EOL;
$bbcode = html2bbcode($html);
$o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
$bbcode = Text\HTML::toBBCode($html);
$o .= '<h2>' . L10n::t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode: ') . '</h2>' . EOL . EOL;
$o .= visible_lf($bbcode) . EOL . EOL;
}
@ -70,8 +67,8 @@ function babel_content()
$o .= '<h2>' . L10n::t("Source input \x28Diaspora format\x29: ") . '</h2>' . EOL . EOL;
$o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
$bb = Markdown::toBBCode($d2bbtext);
$o .= '<h2>' . L10n::t('diaspora2bb: ') . '</h2>' . EOL . EOL;
$bb = Text\Markdown::toBBCode($d2bbtext);
$o .= '<h2>' . L10n::t('Markdown::toBBCode: ') . '</h2>' . EOL . EOL;
$o .= '<pre>' . $bb . '</pre>' . EOL . EOL;
}

View file

@ -52,7 +52,7 @@ function oexchange_content(App $a) {
$post['profile_uid'] = local_user();
$post['return'] = '/oexchange/done' ;
$post['body'] = html2bbcode($s);
$post['body'] = Friendica\Content\Text\HTML::toBBCode($s);
$post['type'] = 'wall';
$_REQUEST = $post;

View file

@ -94,7 +94,7 @@ class Markdown extends BaseObject
$s = str_replace('&#35;', '#', $s);
$s = html2bbcode($s);
$s = Friendica\Content\Text\HTML::toBBCode($s);
// protect the recycle symbol from turning into a tag, but without unescaping angles and naked ampersands
$s = str_replace('&#x2672;', html_entity_decode('&#x2672;', ENT_QUOTES, 'UTF-8'), $s);

View file

@ -2454,7 +2454,7 @@ class DFRN
$purifier = new HTMLPurifier($config);
$item['body'] = $purifier->purify($item['body']);
$item['body'] = @html2bbcode($item['body']);
$item['body'] = @Friendica\Content\Text\HTML::toBBCode($item['body']);
}
/// @todo We should check for a repeated post and if we know the repeated author.

View file

@ -4,6 +4,8 @@
*/
namespace Friendica\Protocol;
use Friendica\Content\Text\HTML;
require_once 'include/html2plain.php';
/**
@ -111,7 +113,7 @@ class Email
if (trim($ret['body']) == '') {
$ret['body'] = self::messageGetPart($mbox, $uid, $struc, 0, 'plain');
} else {
$ret['body'] = html2bbcode($ret['body']);
$ret['body'] = HTML::toBBCode($ret['body']);
}
} else {
$text = '';
@ -128,7 +130,7 @@ class Email
}
}
if (trim($html) != '') {
$ret['body'] = html2bbcode($html);
$ret['body'] = HTML::toBBCode($html);
} else {
$ret['body'] = $text;
}

View file

@ -363,7 +363,7 @@ class Feed {
if (self::titleIsBody($item["title"], $body)) {
$item["title"] = "";
}
$item["body"] = html2bbcode($body, $basepath);
$item["body"] = Friendica\Content\Text\HTML::toBBCode($body, $basepath);
if (($item["body"] == '') && ($item["title"] != '')) {
$item["body"] = $item["title"];

View file

@ -5,6 +5,7 @@
namespace Friendica\Protocol;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -168,7 +169,7 @@ class OStatus
$value = $xpath->evaluate('atom:author/poco:note/text()', $context)->item(0)->nodeValue;
if ($value != "") {
$contact["about"] = html2bbcode($value);
$contact["about"] = HTML::toBBCode($value);
}
$value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
@ -557,7 +558,7 @@ class OStatus
*/
private static function processPost($xpath, $entry, &$item, $importer)
{
$item["body"] = html2bbcode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue);
$item["body"] = HTML::toBBCode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue);
$item["object-type"] = $xpath->query('activity:object-type/text()', $entry)->item(0)->nodeValue;
if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) || ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
@ -659,7 +660,7 @@ class OStatus
if (($item["verb"] == ACTIVITY_POST) && $xpath->evaluate('boolean(atom:summary)', $entry)) {
$clear_text = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
$item["body"] = html2bbcode($clear_text) . '[spoiler]' . $item["body"] . '[/spoiler]';
$item["body"] = HTML::toBBCode($clear_text) . '[spoiler]' . $item["body"] . '[/spoiler]';
}
if (($self != '') && empty($item['protocol'])) {
@ -1014,7 +1015,7 @@ class OStatus
$item["author-link"] = $orig_author["author-link"];
$item["author-avatar"] = $orig_author["author-avatar"];
$item["body"] = html2bbcode($orig_body);
$item["body"] = HTML::toBBCode($orig_body);
$item["created"] = $orig_created;
$item["edited"] = $orig_edited;

View file

@ -9,6 +9,7 @@
namespace Friendica\Protocol;
use Friendica\Content\Text\HTML;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
@ -155,7 +156,7 @@ class PortableContact
}
if (isset($entry->aboutMe)) {
$about = html2bbcode($entry->aboutMe);
$about = HTML::toBBCode($entry->aboutMe);
}
if (isset($entry->gender)) {
@ -1669,7 +1670,7 @@ class PortableContact
}
if (isset($entry->aboutMe)) {
$about = html2bbcode($entry->aboutMe);
$about = HTML::toBBCode($entry->aboutMe);
}
if (isset($entry->gender)) {