From 26ea6f69d726a0a9ff87e5db2f42126ec56708f3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 4 Mar 2018 17:39:41 -0500 Subject: [PATCH] Update references to bb2diaspora and diaspora2bb --- mod/babel.php | 6 +++--- src/Protocol/Diaspora.php | 30 ++++++++++++++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/mod/babel.php b/mod/babel.php index 43b5c4e807..ac2e1342e4 100644 --- a/mod/babel.php +++ b/mod/babel.php @@ -49,7 +49,7 @@ function babel_content() $o .= '

' . L10n::t('bbcode => html2bbcode: ') . '

' . EOL . EOL; $o .= visible_lf($bbcode) . EOL . EOL; - $diaspora = bb2diaspora($text); + $diaspora = BBCode::toMarkdown($text); $o .= '

' . L10n::t('bb2diaspora: ') . '

' . EOL . EOL; $o .= visible_lf($diaspora) . EOL . EOL; @@ -57,7 +57,7 @@ function babel_content() $o .= '

' . L10n::t('bb2diaspora => Markdown: ') . '

' . EOL . EOL; $o .= $html . EOL . EOL; - $bbcode = diaspora2bb($diaspora); + $bbcode = Markdown::toBBCode($diaspora); $o .= '

' . L10n::t('bb2diaspora => diaspora2bb: ') . '

' . EOL . EOL; $o .= visible_lf($bbcode) . EOL . EOL; @@ -71,7 +71,7 @@ function babel_content() $o .= '

' . L10n::t("Source input \x28Diaspora format\x29: ") . '

' . EOL . EOL; $o .= '
' . $d2bbtext . '
' . EOL . EOL; - $bb = diaspora2bb($d2bbtext); + $bb = Markdown::toBBCode($d2bbtext); $o .= '

' . L10n::t('diaspora2bb: ') . '

' . EOL . EOL; $o .= '
' . $bb . '
' . EOL . EOL; } diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 1578edb920..a2a4f36031 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -7,9 +7,11 @@ * This implementation here interprets the old and the new protocol and sends the new one. * In the future we will remove most stuff from "validPosting" and interpret only the new protocol. */ + namespace Friendica\Protocol; use Friendica\Content\Text\BBCode; +use Friendica\Content\Text\Markdown; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -1729,7 +1731,7 @@ class Diaspora $datarray["plink"] = self::plink($author, $guid, $parent_item['guid']); - $body = diaspora2bb($text); + $body = Markdown::toBBCode($text); $datarray["body"] = self::replacePeopleGuid($body, $person["url"]); @@ -1796,7 +1798,7 @@ class Diaspora return false; } - $body = diaspora2bb($msg_text); + $body = Markdown::toBBCode($msg_text); $message_uri = $msg_author.":".$msg_guid; $person = self::personByHandle($msg_author); @@ -2130,7 +2132,7 @@ class Diaspora return false; } - $body = diaspora2bb($text); + $body = Markdown::toBBCode($text); $body = self::replacePeopleGuid($body, $person["url"]); @@ -2282,8 +2284,8 @@ class Diaspora $image_url = unxmlify($data->image_url); $birthday = unxmlify($data->birthday); $gender = unxmlify($data->gender); - $about = diaspora2bb(unxmlify($data->bio)); - $location = diaspora2bb(unxmlify($data->location)); + $about = Markdown::toBBCode(unxmlify($data->bio)); + $location = Markdown::toBBCode(unxmlify($data->location)); $searchable = (unxmlify($data->searchable) == "true"); $nsfw = (unxmlify($data->nsfw) == "true"); $tags = unxmlify($data->tag_string); @@ -2660,7 +2662,7 @@ class Diaspora if (self::isReshare($r[0]["body"], true)) { $r = []; } elseif (self::isReshare($r[0]["body"], false) || strstr($r[0]["body"], "[share")) { - $r[0]["body"] = diaspora2bb(bb2diaspora($r[0]["body"])); + $r[0]["body"] = Markdown::toBBCode(BBCode::toMarkdown($r[0]["body"])); $r[0]["body"] = self::replacePeopleGuid($r[0]["body"], $r[0]["author-link"]); @@ -2695,7 +2697,7 @@ class Diaspora if (DBM::is_result($r)) { // If it is a reshared post from another network then reformat to avoid display problems with two share elements if (self::isReshare($r[0]["body"], false)) { - $r[0]["body"] = diaspora2bb(bb2diaspora($r[0]["body"])); + $r[0]["body"] = Markdown::toBBCode(BBCode::toMarkdown($r[0]["body"])); $r[0]["body"] = self::replacePeopleGuid($r[0]["body"], $r[0]["author-link"]); } @@ -2939,7 +2941,7 @@ class Diaspora } } - $body = diaspora2bb($text); + $body = Markdown::toBBCode($text); $datarray = []; @@ -3590,14 +3592,14 @@ class Diaspora $eventdata['end'] = DateTimeFormat::convert($event['finish'], "UTC", $eventdata['timezone'], $mask); } if ($event['summary']) { - $eventdata['summary'] = html_entity_decode(bb2diaspora($event['summary'])); + $eventdata['summary'] = html_entity_decode(BBCode::toMarkdown($event['summary'])); } if ($event['desc']) { - $eventdata['description'] = html_entity_decode(bb2diaspora($event['desc'])); + $eventdata['description'] = html_entity_decode(BBCode::toMarkdown($event['desc'])); } if ($event['location']) { $location = []; - $location["address"] = html_entity_decode(bb2diaspora($event['location'])); + $location["address"] = html_entity_decode(BBCode::toMarkdown($event['location'])); $location["lat"] = 0; $location["lng"] = 0; $eventdata['location'] = $location; @@ -3647,7 +3649,7 @@ class Diaspora $body = $item["body"]; // convert to markdown - $body = html_entity_decode(bb2diaspora($body)); + $body = html_entity_decode(BBCode::toMarkdown($body)); // Adding the title if (strlen($title)) { @@ -3832,7 +3834,7 @@ class Diaspora $parent = $p[0]; - $text = html_entity_decode(bb2diaspora($item["body"])); + $text = html_entity_decode(BBCode::toMarkdown($item["body"])); $created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM); $comment = ["author" => self::myHandle($owner), @@ -4068,7 +4070,7 @@ class Diaspora "participants" => $cnv["recips"] ]; - $body = bb2diaspora($item["body"]); + $body = BBCode::toMarkdown($item["body"]); $created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM); $msg = [