]> git.mxchange.org Git - friendica.git/commitdiff
Replace html2bbcode calls by HTML::toBBCode
authorHypolite Petovan <mrpetovan@gmail.com>
Wed, 7 Mar 2018 21:24:13 +0000 (16:24 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Wed, 7 Mar 2018 21:24:13 +0000 (16:24 -0500)
include/api.php
mod/babel.php
mod/oexchange.php
src/Content/Text/Markdown.php
src/Protocol/DFRN.php
src/Protocol/Email.php
src/Protocol/Feed.php
src/Protocol/OStatus.php
src/Protocol/PortableContact.php

index 60a9acce0dbd6c1e84eb9170e477290572ae66dd..2f0566b6e07a034e801db97ecc96776208169289 100644 (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');
index 99e6f4078d73de0578b4449c6f993f1abdf7b865..a2d197599c16a370c601ca24d1a3b9b5a03a9b4c 100644 (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;
        }
 
index feca39d3530334f418e785f8ae7790795ad2291c..2e1d7a2dbc9f15b4e0e25a054f0843102123fec3 100644 (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;
index e7383a3fd79341c9e3290b34b3ee04f5e98e40e1..6e982c7f04709c96bf0cb711256ba47cd5d7acdc 100644 (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);
index 5e7cc02a36c1cdf02e0cf84aabea74621d0ca048..a82ae3d255f4adf5f02f9a78060899b66dded215 100644 (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.
index b1eeb94d62f8903023c97ae3bec2074b9e828300..fadd124c961e43b2e32f7228fcde380cb3e63426 100644 (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;
                        }
index 17234ce45af435b9a807561450c9c5e42b6aa329..d54846fc3475740bdd95b728a2c8b07bd8adc9fd 100644 (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"];
index c6f840a66e0b60150f9d57b0574e26df51b88527..9eebc7f2e48970694acc2e87e50cbed954fec98f 100644 (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;
 
index 5b419e42eff3d15deb989d8cc8cac66231f71eca..f5513bddd61d472583f68939737272c75454fcc5 100644 (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)) {