]> git.mxchange.org Git - friendica.git/commitdiff
Refactor bbcode() into BBCode::convert()
authorHypolite Petovan <mrpetovan@gmail.com>
Thu, 15 Feb 2018 02:33:55 +0000 (21:33 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Thu, 15 Feb 2018 02:33:55 +0000 (21:33 -0500)
21 files changed:
include/api.php
include/bb2diaspora.php
include/enotify.php
include/event.php
include/text.php
mod/babel.php
mod/contacts.php
mod/display.php
mod/message.php
mod/notify.php
mod/photos.php
mod/ping.php
mod/poco.php
mod/register.php
mod/tagrm.php
src/Content/Text/BBCode.php
src/Core/NotificationsManager.php
src/Model/Profile.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Protocol/OStatus.php

index 67df83fe14da138f15c1d064b6de8ce620f53dba..013d47fe23bb3e6a3f2acf1cd1e32436c84b5bf5 100644 (file)
@@ -2604,13 +2604,12 @@ function api_format_messages($item, $recipient, $sender)
        if (x($_GET, 'getText')) {
                $ret['title'] = $item['title'];
                if ($_GET['getText'] == 'html') {
-                       $ret['text'] = bbcode($item['body'], false, false);
+                       $ret['text'] = BBCode::convert($item['body'], false);
                } elseif ($_GET['getText'] == 'plain') {
-                       //$ret['text'] = html2plain(bbcode($item['body'], false, false, true), 0);
-                       $ret['text'] = trim(html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 2, true), 0));
+                       $ret['text'] = trim(html2plain(BBCode::convert(api_clean_plain_items($item['body']), false, 2, true), 0));
                }
        } else {
-               $ret['text'] = $item['title'] . "\n" . html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 2, true), 0);
+               $ret['text'] = $item['title'] . "\n" . html2plain(BBCode::convert(api_clean_plain_items($item['body']), false, 2, true), 0);
        }
        if (x($_GET, 'getUserObjects') && $_GET['getUserObjects'] == 'false') {
                unset($ret['sender']);
@@ -2632,7 +2631,7 @@ function api_convert_item($item)
        $attachments = api_get_attachments($body);
 
        // Workaround for ostatus messages where the title is identically to the body
-       $html = bbcode(api_clean_plain_items($body), false, false, 2, true);
+       $html = BBCode::convert(api_clean_plain_items($body), false, 2, true);
        $statusbody = trim(html2plain($html, 0));
 
        // handle data: images
@@ -2650,7 +2649,7 @@ function api_convert_item($item)
                $statustext = substr($statustext, 0, 1000)."... \n".$item["plink"];
        }
 
-       $statushtml = bbcode(api_clean_attachments($body), false, false);
+       $statushtml = BBCode::convert(api_clean_attachments($body), false);
 
        // Workaround for clients with limited HTML parser functionality
        $search = ["<br>", "<blockquote>", "</blockquote>",
@@ -2664,7 +2663,7 @@ function api_convert_item($item)
        $statushtml = str_replace($search, $replace, $statushtml);
 
        if ($item['title'] != "") {
-               $statushtml = "<br><h4>" . bbcode($item['title']) . "</h4><br>" . $statushtml;
+               $statushtml = "<br><h4>" . BBCode::convert($item['title']) . "</h4><br>" . $statushtml;
        }
 
        do {
@@ -2682,7 +2681,7 @@ function api_convert_item($item)
 
        // feeds without body should contain the link
        if (($item['network'] == NETWORK_FEED) && (strlen($item['body']) == 0)) {
-               $statushtml .= bbcode($item['plink']);
+               $statushtml .= BBCode::convert($item['plink']);
        }
 
        $entities = api_get_entitities($statustext, $body);
@@ -3053,18 +3052,18 @@ function api_format_items_profiles($profile_row)
                'religion'         => $profile_row['religion'],
                'public_keywords'  => $profile_row['pub_keywords'],
                'private_keywords' => $profile_row['prv_keywords'],
-               'likes'            => bbcode(api_clean_plain_items($profile_row['likes'])    , false, false, 2, false),
-               'dislikes'         => bbcode(api_clean_plain_items($profile_row['dislikes']) , false, false, 2, false),
-               'about'            => bbcode(api_clean_plain_items($profile_row['about'])    , false, false, 2, false),
-               'music'            => bbcode(api_clean_plain_items($profile_row['music'])    , false, false, 2, false),
-               'book'             => bbcode(api_clean_plain_items($profile_row['book'])     , false, false, 2, false),
-               'tv'               => bbcode(api_clean_plain_items($profile_row['tv'])       , false, false, 2, false),
-               'film'             => bbcode(api_clean_plain_items($profile_row['film'])     , false, false, 2, false),
-               'interest'         => bbcode(api_clean_plain_items($profile_row['interest']) , false, false, 2, false),
-               'romance'          => bbcode(api_clean_plain_items($profile_row['romance'])  , false, false, 2, false),
-               'work'             => bbcode(api_clean_plain_items($profile_row['work'])     , false, false, 2, false),
-               'education'        => bbcode(api_clean_plain_items($profile_row['education']), false, false, 2, false),
-               'social_networks'  => bbcode(api_clean_plain_items($profile_row['contact'])  , false, false, 2, false),
+               'likes'            => BBCode::convert(api_clean_plain_items($profile_row['likes'])    , false, 2),
+               'dislikes'         => BBCode::convert(api_clean_plain_items($profile_row['dislikes']) , false, 2),
+               'about'            => BBCode::convert(api_clean_plain_items($profile_row['about'])    , false, 2),
+               'music'            => BBCode::convert(api_clean_plain_items($profile_row['music'])    , false, 2),
+               'book'             => BBCode::convert(api_clean_plain_items($profile_row['book'])     , false, 2),
+               'tv'               => BBCode::convert(api_clean_plain_items($profile_row['tv'])       , false, 2),
+               'film'             => BBCode::convert(api_clean_plain_items($profile_row['film'])     , false, 2),
+               'interest'         => BBCode::convert(api_clean_plain_items($profile_row['interest']) , false, 2),
+               'romance'          => BBCode::convert(api_clean_plain_items($profile_row['romance'])  , false, 2),
+               'work'             => BBCode::convert(api_clean_plain_items($profile_row['work'])     , false, 2),
+               'education'        => BBCode::convert(api_clean_plain_items($profile_row['education']), false, 2),
+               'social_networks'  => BBCode::convert(api_clean_plain_items($profile_row['contact'])  , false, 2),
                'homepage'         => $profile_row['homepage'],
                'users'            => null
        ];
index c1c9fa4c3d8d7a2ee030c39728573bd360e5919d..7e20037a0b20116fe4f50f492b55e31bda479bd8 100644 (file)
@@ -164,7 +164,7 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) {
 
        // Convert it to HTML - don't try oembed
        if ($fordiaspora) {
-               $Text = bbcode($Text, $preserve_nl, false, 3);
+               $Text = BBCode::convert($Text, false, 3);
 
                // Add all tags that maybe were removed
                if (preg_match_all("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $OriginalText, $tags)) {
@@ -178,7 +178,7 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) {
                        $Text = $Text." ".$tagline;
                }
        } else {
-               $Text = bbcode($Text, $preserve_nl, false, 4);
+               $Text = BBCode::convert($Text, false, 4);
        }
 
        // mask some special HTML chars from conversation to markdown
index 2b8c36e257d9c58929337feb927f3dd7c1093ae1..2b6eec576c8b63b007c05442acb3a20e1a9f1b5d 100644 (file)
@@ -3,6 +3,7 @@
  * @file include/enotify.php
  */
 
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -448,7 +449,7 @@ function notification($params)
                $datarray = [];
                $datarray['hash']  = $hash;
                $datarray['name']  = $params['source_name'];
-               $datarray['name_cache'] = strip_tags(bbcode($params['source_name']));
+               $datarray['name_cache'] = strip_tags(BBCode::convert($params['source_name']));
                $datarray['url']   = $params['source_link'];
                $datarray['photo'] = $params['source_photo'];
                $datarray['date']  = DateTimeFormat::utcNow();
@@ -519,7 +520,7 @@ function notification($params)
 
                $itemlink = System::baseUrl().'/notify/view/'.$notify_id;
                $msg = replace_macros($epreamble, ['$itemlink' => $itemlink]);
-               $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg)));
+               $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(BBCode::convert($msg)));
                q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d",
                        dbesc($msg),
                        dbesc($msg_cache),
@@ -567,9 +568,9 @@ function notification($params)
                }
 
                // textversion keeps linebreaks
-               $textversion = strip_tags(str_replace("<br>", "\n", html_entity_decode(bbcode(stripslashes(str_replace(["\\r\\n", "\\r", "\\n"], "\n",
+               $textversion = strip_tags(str_replace("<br>", "\n", html_entity_decode(BBCode::convert(stripslashes(str_replace(["\\r\\n", "\\r", "\\n"], "\n",
                        $body))),ENT_QUOTES, 'UTF-8')));
-               $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(["\\r\\n", "\\r", "\\n\\n", "\\n"],
+               $htmlversion = html_entity_decode(BBCode::convert(stripslashes(str_replace(["\\r\\n", "\\r", "\\n\\n", "\\n"],
                        "<br />\n", $body))), ENT_QUOTES, 'UTF-8');
 
                $datarray = [];
index cce2a98cc0565de78b998e2f9d0a6c51796c2615..c86ba732b8ef80ed26b59f762610d6dc8896e666 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 use Friendica\Content\Feature;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
@@ -38,9 +39,9 @@ function format_event_html($ev, $simple = false) {
        );
 
        if ($simple) {
-               $o = "<h3>" . bbcode($ev['summary']) . "</h3>";
+               $o = "<h3>" . BBCode::convert($ev['summary']) . "</h3>";
 
-               $o .= "<div>" . bbcode($ev['desc']) . "</div>";
+               $o .= "<div>" . BBCode::convert($ev['desc']) . "</div>";
 
                $o .= "<h4>" . L10n::t('Starts:') . "</h4><p>" . $event_start . "</p>";
 
@@ -57,7 +58,7 @@ function format_event_html($ev, $simple = false) {
 
        $o = '<div class="vevent">' . "\r\n";
 
-       $o .= '<div class="summary event-summary">' . bbcode($ev['summary']) . '</div>' . "\r\n";
+       $o .= '<div class="summary event-summary">' . BBCode::convert($ev['summary']) . '</div>' . "\r\n";
 
        $o .= '<div class="event-start"><span class="event-label">' . L10n::t('Starts:') . '</span>&nbsp;<span class="dtstart" title="'
                . DateTimeFormat::utc($ev['start'], (($ev['adjust']) ? DateTimeFormat::ATOM : 'Y-m-d\TH:i:s' ))
@@ -71,11 +72,11 @@ function format_event_html($ev, $simple = false) {
                        . '</span></div>' . "\r\n";
        }
 
-       $o .= '<div class="description event-description">' . bbcode($ev['desc']) . '</div>' . "\r\n";
+       $o .= '<div class="description event-description">' . BBCode::convert($ev['desc']) . '</div>' . "\r\n";
 
        if (strlen($ev['location'])) {
                $o .= '<div class="event-location"><span class="event-label">' . L10n::t('Location:') . '</span>&nbsp;<span class="location">'
-                       . bbcode($ev['location'])
+                       . BBCode::convert($ev['location'])
                        . '</span></div>' . "\r\n";
 
                // Include a map of the location if the [map] BBCode is used.
@@ -610,15 +611,15 @@ function process_events($arr) {
                                $drop = [System::baseUrl() . '/events/drop/' . $rr['id'], L10n::t('Delete event'), '', ''];
                        }
 
-                       $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
+                       $title = strip_tags(html_entity_decode(BBCode::convert($rr['summary']), ENT_QUOTES, 'UTF-8'));
                        if (! $title) {
-                               list($title, $_trash) = explode("<br", bbcode($rr['desc']), 2);
+                               list($title, $_trash) = explode("<br", BBCode::convert($rr['desc']), 2);
                                $title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
                        }
 
                        $html = format_event_html($rr);
-                       $rr['desc'] = bbcode($rr['desc']);
-                       $rr['location'] = bbcode($rr['location']);
+                       $rr['desc'] = BBCode::convert($rr['desc']);
+                       $rr['location'] = BBCode::convert($rr['location']);
                        $events[] = [
                                'id'     => $rr['id'],
                                'start'  => $start,
index ca88091d4f12e7f951b2bdc21682a08641b94b21..ee5d4763ef984fc2939bc5131567f0e2c1fb46e5 100644 (file)
@@ -7,6 +7,7 @@ use Friendica\App;
 use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Content\Smilies;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -15,7 +16,7 @@ use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Item;
 use Friendica\Model\Profile;
-use Friendica\Model\Term;
+use Friendica\Render\FriendicaSmarty;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Map;
 
@@ -1427,9 +1428,9 @@ function prepare_text($text) {
        require_once 'include/bbcode.php';
 
        if (stristr($text, '[nosmile]')) {
-               $s = bbcode($text);
+               $s = BBCode::convert($text);
        } else {
-               $s = Smilies::replace(bbcode($text));
+               $s = Smilies::replace(BBCode::convert($text));
        }
 
        return trim($s);
index 3b4fb5bf2bfcd018a332ca887295465c57a69e36..683bc5fed1cc7911adfd047d28921bfe4f20de29 100644 (file)
@@ -2,6 +2,8 @@
 /**
  * @file mod/babel.php
  */
+
+use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\Markdown;
 use Friendica\Core\L10n;
 
@@ -37,7 +39,7 @@ function babel_content()
                $o .= '<h2>' . L10n::t('Source input: ') . '</h2>' . EOL . EOL;
                $o .= visible_lf($text) . EOL . EOL;
 
-               $html = bbcode($text);
+               $html = BBCode::convert($text);
                $o .= '<h2>' . L10n::t("bbcode \x28raw HTML\x28: ") . '</h2>' . EOL . EOL;
                $o .= htmlspecialchars($html) . EOL . EOL;
 
index 3f7eb342b1c5e5139ddaa492eb13a4025308df25..09090e541a502e5254c726f2ca070421051d1b72 100644 (file)
@@ -6,6 +6,7 @@
 use Friendica\App;
 use Friendica\Content\ContactSelector;
 use Friendica\Content\Nav;
+use Friendica\Content\Text\BBCode;
 use Friendica\Content\Widget;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
@@ -646,11 +647,11 @@ function contacts_content(App $a)
                        '$profileurllabel' => L10n::t('Profile URL'),
                        '$profileurl' => $contact['url'],
                        '$account_type' => Contact::getAccountType($contact),
-                       '$location' => bbcode($contact["location"]),
+                       '$location' => BBCode::convert($contact["location"]),
                        '$location_label' => L10n::t("Location:"),
-                       '$xmpp' => bbcode($contact["xmpp"]),
+                       '$xmpp' => BBCode::convert($contact["xmpp"]),
                        '$xmpp_label' => L10n::t("XMPP:"),
-                       '$about' => bbcode($contact["about"], false, false),
+                       '$about' => BBCode::convert($contact["about"], false),
                        '$about_label' => L10n::t("About:"),
                        '$keywords' => $contact["keywords"],
                        '$keywords_label' => L10n::t("Tags:"),
index eb196b0979671d808b49045ef87f72c2bd127f67..1e1515f10f24f4d06b0d30c5b27588e3c3038671 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 use Friendica\App;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\Protocol;
@@ -368,8 +369,8 @@ function display_content(App $a, $update = false, $update_uid = 0) {
        // Preparing the meta header
        require_once 'include/bbcode.php';
        require_once 'include/html2plain.php';
-       $description = trim(html2plain(bbcode($s[0]["body"], false, false), 0, true));
-       $title = trim(html2plain(bbcode($s[0]["title"], false, false), 0, true));
+       $description = trim(html2plain(BBCode::convert($s[0]["body"], false), 0, true));
+       $title = trim(html2plain(BBCode::convert($s[0]["title"], false), 0, true));
        $author_name = $s[0]["author-name"];
 
        $image = $a->remove_baseurl($s[0]["author-thumb"]);
index 8940ee44b7832f207d8cb188298c069c6d1b71c1..d51fe0a779ab375eb1b8f0b9c0d2dcdde276bead 100644 (file)
@@ -6,6 +6,7 @@
 use Friendica\App;
 use Friendica\Content\Nav;
 use Friendica\Content\Smilies;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
@@ -376,7 +377,7 @@ function message_content(App $a)
 
                        $from_name_e = $message['from-name'];
                        $subject_e = $message['title'];
-                       $body_e = Smilies::replace(bbcode($message['body']));
+                       $body_e = Smilies::replace(BBCode::convert($message['body']));
                        $to_name_e = $message['name'];
 
                        $contact = Contact::getDetailsByURL($message['from-url']);
index dff7d147f0e10dfb788c7c05c98bc04bb8030ba4..a65e14debb8e6ce5dec7b8b3d032967e159aac2c 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 use Friendica\App;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\L10n;
 use Friendica\Core\NotificationsManager;
 use Friendica\Core\System;
@@ -69,7 +70,7 @@ function notify_content(App $a)
                        $notif_content .= replace_macros($not_tpl, [
                                '$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'],
                                '$item_image' => $it['photo'],
-                               '$item_text' => strip_tags(bbcode($it['msg'])),
+                               '$item_text' => strip_tags(BBCode::convert($it['msg'])),
                                '$item_when' => Temporal::getRelativeDate($it['date'])
                        ]);
                }
index 4b031e5b5e5c674deb5a5e8b94287d3a768ae4c0..863a848d61f53917ed0a679ff4eaddb09ab31ffa 100644 (file)
@@ -6,6 +6,7 @@
 use Friendica\App;
 use Friendica\Content\Feature;
 use Friendica\Content\Nav;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -17,7 +18,6 @@ use Friendica\Model\Group;
 use Friendica\Model\Item;
 use Friendica\Model\Photo;
 use Friendica\Model\Profile;
-use Friendica\Model\Term;
 use Friendica\Network\Probe;
 use Friendica\Object\Image;
 use Friendica\Protocol\DFRN;
@@ -1411,7 +1411,7 @@ function photos_content(App $a)
                                if (strlen($tag_str)) {
                                        $tag_str .= ', ';
                                }
-                               $tag_str .= bbcode($t);
+                               $tag_str .= BBCode::convert($t);
                        }
                        $tags = [L10n::t('Tags: '), $tag_str];
                        if ($cmd === 'edit') {
@@ -1574,7 +1574,7 @@ function photos_content(App $a)
 
                                        $name_e = $profile_name;
                                        $title_e = $item['title'];
-                                       $body_e = bbcode($item['body']);
+                                       $body_e = BBCode::convert($item['body']);
 
                                        $comments .= replace_macros($template,[
                                                '$id' => $item['item_id'],
index 62ab2644c9b746b974985cd29510023e518dd038..e24168aa978d5b653d26d7d8cafcd57e35ab9e7d 100644 (file)
@@ -6,6 +6,7 @@
 use Friendica\App;
 use Friendica\Content\Feature;
 use Friendica\Content\ForumManager;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Cache;
 use Friendica\Core\L10n;
@@ -481,8 +482,8 @@ function ping_get_notifications($uid)
                                $notification["name"] = $notification["name_cache"];
                                $notification["message"] = $notification["msg_cache"];
                        } else {
-                               $notification["name"] = strip_tags(bbcode($notification["name"]));
-                               $notification["message"] = format_notification_message($notification["name"], strip_tags(bbcode($notification["msg"])));
+                               $notification["name"] = strip_tags(BBCode::convert($notification["name"]));
+                               $notification["message"] = format_notification_message($notification["name"], strip_tags(BBCode::convert($notification["msg"])));
 
                                q(
                                        "UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d",
index 639ab8469c0f085eb949f6e960e8b71805eb9103..d212bb5f9cb0663db50b1d781f75a34ed285c15a 100644 (file)
@@ -5,6 +5,7 @@
 
 
 use Friendica\App;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\System;
@@ -246,7 +247,7 @@ function poco_init(App $a) {
                                $about = Cache::get("about:" . $contact['updated'] . ":" . $contact['nurl']);
                                if (is_null($about)) {
                                        require_once 'include/bbcode.php';
-                                       $about = bbcode($contact['about'], false, false);
+                                       $about = BBCode::convert($contact['about'], false);
                                        Cache::set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about);
                                }
 
index 40aa7c1bc4e5b61ea00470345cf2428d89705d94..76c5073d59c3aed5c38da966493da661dc75faf7 100644 (file)
@@ -1,9 +1,10 @@
 <?php
 /**
- * @file mod/register.php
+ * @file_tag_list_to_file mod/register.php
  */
 
 use Friendica\App;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -262,7 +263,7 @@ function register_content(App $a)
                '$invite_id'  => $invite_id,
                '$realpeople' => $realpeople,
                '$regtitle'  => L10n::t('Registration'),
-               '$registertext' => x($a->config, 'register_text') ? bbcode($a->config['register_text']) : "",
+               '$registertext' => x($a->config, 'register_text') ? BBCode::convert($a->config['register_text']) : "",
                '$fillwith'  => $fillwith,
                '$fillext'   => $fillext,
                '$oidlabel'  => $oidlabel,
index 2a829932ea1fe07d6225d2b97a81443d01eec43c..b7e72b4da8a833969ac3f1cfc332973ce3134a67 100644 (file)
@@ -2,7 +2,9 @@
 /**
  * @file mod/tagrm.php
  */
+
 use Friendica\App;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
@@ -91,7 +93,7 @@ function tagrm_content(App $a) {
        $o .= '<ul>';
 
        foreach ($arr as $x) {
-               $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . bbcode($x) . '</input></li>';
+               $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . BBCode::convert($x) . '</input></li>';
        }
 
        $o .= '</ul>';
index a81b69e34b42d2f95727336bb2396bb25075eef9..064d5030ee7ab42d019ed83daec21d723dcddf6e 100644 (file)
@@ -174,7 +174,7 @@ class BBCode
                }
 
                if ($title != "") {
-                       $title = bbcode(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, false, true);
+                       $title = BBCode::convert(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, true);
                        $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
                        $title = str_replace(["[", "]"], ["&#91;", "&#93;"], $title);
                        $data["title"] = $title;
@@ -409,7 +409,7 @@ class BBCode
                        }
                }
 
-               $html = bbcode($post["text"].$post["after"], false, false, $htmlmode);
+               $html = BBCode::convert($post["text"].$post["after"], false, $htmlmode);
                $msg = html2plain($html, 0, true);
                $msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'));
 
@@ -706,7 +706,7 @@ class BBCode
                                }
 
                                if ($data["description"] != "" && $data["description"] != $data["title"]) {
-                                       $return .= sprintf('<blockquote>%s</blockquote>', trim(bbcode($data["description"])));
+                                       $return .= sprintf('<blockquote>%s</blockquote>', trim(BBCode::convert($data["description"])));
                                }
 
                                if ($data["type"] == "link") {
index ed12a89141fdc3a5d075418e62b55b386500e149..3d11789e93cad21f57e0a9487db7d5c7aea77a36 100644 (file)
@@ -7,6 +7,7 @@
 namespace Friendica\Core;
 
 use Friendica\BaseObject;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
@@ -46,7 +47,7 @@ class NotificationsManager extends BaseObject
                        $local_time = DateTimeFormat::local($n['date']);
                        $n['timestamp'] = strtotime($local_time);
                        $n['date_rel'] = Temporal::getRelativeDate($n['date']);
-                       $n['msg_html'] = bbcode($n['msg'], false, false, false, false);
+                       $n['msg_html'] = BBCode::convert($n['msg'], false);
                        $n['msg_plain'] = explode("\n", trim(html2plain($n['msg_html'], 0)))[0];
 
                        $rets[] = $n;
@@ -243,7 +244,7 @@ class NotificationsManager extends BaseObject
                                                $default_item_link = System::baseUrl(true) . '/notify/view/' . $it['id'];
                                                $default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
                                                $default_item_url = $it['url'];
-                                               $default_item_text = strip_tags(bbcode($it['msg']));
+                                               $default_item_text = strip_tags(BBCode::convert($it['msg']));
                                                $default_item_when = DateTimeFormat::local($it['date'], 'r');
                                                $default_item_ago = Temporal::getRelativeDate($it['date']);
                                                break;
@@ -843,8 +844,8 @@ class NotificationsManager extends BaseObject
                                        'contact_id' => $it['contact-id'],
                                        'photo' => ((x($it, 'photo')) ? proxy_url($it['photo'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"),
                                        'name' => $it['name'],
-                                       'location' => bbcode($it['glocation'], false, false),
-                                       'about' => bbcode($it['gabout'], false, false),
+                                       'location' => BBCode::convert($it['glocation'], false),
+                                       'about' => BBCode::convert($it['gabout'], false),
                                        'keywords' => $it['gkeywords'],
                                        'gender' => $it['ggender'],
                                        'hidden' => $it['hidden'] == 1,
index f31c83c857f5cb4be4c3d14f15765946b0a26408..d1a705fd7c1193aa86e2f14969f197aab0147716 100644 (file)
@@ -7,6 +7,7 @@ namespace Friendica\Model;
 use Friendica\App;
 use Friendica\Content\Feature;
 use Friendica\Content\ForumManager;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
@@ -487,13 +488,13 @@ class Profile
                }
 
                if (isset($p['about'])) {
-                       $p['about'] = bbcode($p['about']);
+                       $p['about'] = BBCode::convert($p['about']);
                }
 
                if (isset($p['address'])) {
-                       $p['address'] = bbcode($p['address']);
+                       $p['address'] = BBCode::convert($p['address']);
                } else {
-                       $p['address'] = bbcode($p['location']);
+                       $p['address'] = BBCode::convert($p['location']);
                }
 
                if (isset($p['photo'])) {
@@ -667,13 +668,13 @@ class Profile
                                        $istoday = true;
                                }
 
-                               $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
+                               $title = strip_tags(html_entity_decode(BBCode::convert($rr['summary']), ENT_QUOTES, 'UTF-8'));
 
                                if (strlen($title) > 35) {
                                        $title = substr($title, 0, 32) . '... ';
                                }
 
-                               $description = substr(strip_tags(bbcode($rr['desc'])), 0, 32) . '... ';
+                               $description = substr(strip_tags(BBCode::convert($rr['desc'])), 0, 32) . '... ';
                                if (!$description) {
                                        $description = L10n::t('[No description]');
                                }
index 5fe47ac5fdf2ef61563b6e6b5bead486b4ee6336..00064b7e864db52ddcdda019aec789609b64c2be 100644 (file)
@@ -832,7 +832,7 @@ class DFRN
                                }
                        }
                        if ($r->content) {
-                               XML::addElement($doc, $entry, "content", bbcode($r->content), ["type" => "html"]);
+                               XML::addElement($doc, $entry, "content", BBCode::convert($r->content), ["type" => "html"]);
                        }
 
                        return $entry;
@@ -938,7 +938,7 @@ class DFRN
                                $htmlbody = "[b]".$item['title']."[/b]\n\n".$htmlbody;
                        }
 
-                       $htmlbody = bbcode($htmlbody, false, false, 7);
+                       $htmlbody = BBCode::convert($htmlbody, false, 7);
                }
 
                $author = self::addEntryAuthor($doc, "author", $item["author-link"], $item);
index 307b52f785f5e8e14786042073875b1205859815..65b84f3cd40a14136b40069a29601e962e130a14 100644 (file)
@@ -9,6 +9,7 @@
  */
 namespace Friendica\Protocol;
 
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -4197,7 +4198,7 @@ class Diaspora
                        }
 
                        $about = $profile['about'];
-                       $about = strip_tags(bbcode($about));
+                       $about = strip_tags(BBCode::convert($about));
 
                        $location = Profile::formatLocation($profile);
                        $tags = '';
index 7ad6f50f1f05e6eab582a5939d6716ddd14eeee2..ed3c5c0a072cf1977f46616e9f405326e4463549 100644 (file)
@@ -1373,7 +1373,7 @@ class OStatus
                XML::addElement($doc, $author, "uri", $owner["url"]);
                XML::addElement($doc, $author, "name", $owner["nick"]);
                XML::addElement($doc, $author, "email", $owner["addr"]);
-               XML::addElement($doc, $author, "summary", bbcode($owner["about"], false, false, 7));
+               XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, 7));
 
                $attributes = ["rel" => "alternate", "type" => "text/html", "href" => $owner["url"]];
                XML::addElement($doc, $author, "link", "", $attributes);
@@ -1398,7 +1398,7 @@ class OStatus
 
                XML::addElement($doc, $author, "poco:preferredUsername", $owner["nick"]);
                XML::addElement($doc, $author, "poco:displayName", $owner["name"]);
-               XML::addElement($doc, $author, "poco:note", bbcode($owner["about"], false, false, 7));
+               XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, 7));
 
                if (trim($owner["location"]) != "") {
                        $element = $doc->createElement("poco:address");
@@ -1879,7 +1879,7 @@ class OStatus
                        $body = "[b]".$item['title']."[/b]\n\n".$body;
                }
 
-               $body = bbcode($body, false, false, 7);
+               $body = BBCode::convert($body, false, 7);
 
                XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);