]> git.mxchange.org Git - friendica-addons.git/commitdiff
Refactor bbcode() into BBCode::convert()
authorHypolite Petovan <mrpetovan@gmail.com>
Thu, 15 Feb 2018 02:43:40 +0000 (21:43 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Thu, 15 Feb 2018 02:43:40 +0000 (21:43 -0500)
12 files changed:
blogger/blogger.php
dwpost/dwpost.php
ijpost/ijpost.php
impressum/impressum.php
ljpost/ljpost.php
mailstream/mailstream.php
newmemberwidget/newmemberwidget.php
notifyall/notifyall.php
pumpio/pumpio.php
tumblr/tumblr.php
windowsphonepush/windowsphonepush.php
wppost/wppost.php

index 7dfbcc4a2d526f6b9b9d1420fad33751896ea285..76c12bbb65ed5e5b2c6ab22c8ec63afbd6939f70 100644 (file)
@@ -5,6 +5,8 @@
  * Version: 1.0
  *
  */
+
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
@@ -184,7 +186,7 @@ function blogger_send(&$a, &$b)
                require_once('include/bbcode.php');
 
                $title = '<title>' . (($b['title']) ? $b['title'] : L10n::t('Post from Friendica')) . '</title>';
-               $post = $title . bbcode($b['body']);
+               $post = $title . BBCode::convert($b['body']);
                $post = xmlify($post);
 
                $xml = <<< EOT
index d9d06675f687c5a6ba47f79dbbd06daf7fa7fb22..7e8488c376796c85445414fbbc4d678dfaa87cbb 100644 (file)
@@ -8,6 +8,7 @@
  * Author: Cat Gray <https://free-haven.org/profile/catness>
  */
 
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
@@ -182,7 +183,7 @@ function dwpost_send(&$a,&$b) {
                require_once('include/bbcode.php');
 
                $title = $b['title'];
-               $post = bbcode($b['body']);
+               $post = BBCode::convert($b['body']);
                $post = xmlify($post);
                $tags = dwpost_get_tags($b['tag']);
 
index cd4d72cdd8bdc62e7444d12d8b7d985d2a25f2f2..5ccb67612b363b838747325f195e759bda0ef697 100644 (file)
@@ -8,6 +8,7 @@
  * Author: Cat Gray <https://free-haven.org/profile/catness>
  */
 
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
@@ -182,7 +183,7 @@ function ijpost_send(&$a,&$b) {
                require_once('include/datetime.php');
 
                $title = $b['title'];
-               $post = bbcode($b['body']);
+               $post = BBCode::convert($b['body']);
                $post = xmlify($post);
                $tags = ijpost_get_tags($b['tag']);
 
index 3a5efbcc7f23114ad7138688c350bbe189c63552..ae6ddf18daebbc83d32244c6b6b37fde5a0402db 100644 (file)
@@ -10,6 +10,7 @@
 require_once 'include/bbcode.php';
 require_once 'mod/proxy.php';
 
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -39,7 +40,7 @@ function obfuscate_email ($s) {
     return $s;
 }
 function impressum_footer($a, &$b) {
-    $text = proxy_parse_html(bbcode(Config::get('impressum','footer_text'), true));
+    $text = proxy_parse_html(BBCode::convert(Config::get('impressum','footer_text')));
     if (! $text == '') {
         $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->get_baseurl().'/addon/impressum/impressum.css" media="all" />';
         $b .= '<div class="clear"></div>';
@@ -50,8 +51,8 @@ function impressum_show($a,&$b) {
     $b .= '<h3>'.L10n::t('Impressum').'</h3>';
     $owner = Config::get('impressum', 'owner');
     $owner_profile = Config::get('impressum','ownerprofile');
-    $postal = proxy_parse_html(bbcode(Config::get('impressum', 'postal'), true));
-    $notes = proxy_parse_html(bbcode(Config::get('impressum', 'notes'), true));
+    $postal = proxy_parse_html(BBCode::convert(Config::get('impressum', 'postal')));
+    $notes = proxy_parse_html(BBCode::convert(Config::get('impressum', 'notes')));
     $email = obfuscate_email( Config::get('impressum','email') );
     if (strlen($owner)) {
         if (strlen($owner_profile)) {
index 8fbc3b11eac78b9b74bec1ad79793682ea167070..97daf519e8a82a22d459f1c0af4d56fb4355e995 100644 (file)
@@ -8,6 +8,7 @@
  * Author: Cat Gray <https://free-haven.org/profile/catness>
  */
 
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
@@ -182,7 +183,7 @@ function ljpost_send(&$a,&$b) {
                require_once('include/bbcode.php');
 
                $title = xmlify($b['title']);
-               $post = bbcode($b['body']);
+               $post = BBCode::convert($b['body']);
                $post = xmlify($post);
                $tags = ljpost_get_tags($b['tag']);
 
index 4ff4c69d7f4cfe74d56405d489334d98e8307573..acab591453e2710575201b6e4dbc31ea01d8e15d 100644 (file)
@@ -5,6 +5,8 @@
  * Version: 1.1
  * Author: Matthew Exon <http://mat.exon.name>
  */
+
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -180,7 +182,7 @@ function mailstream_sender($item) {
 }
 
 function mailstream_decode_subject($subject) {
-       $html = bbcode($subject);
+       $html = BBCode::convert($subject);
        if (!$html) {
                return $subject;
        }
@@ -285,7 +287,7 @@ function mailstream_send($a, $message_id, $item, $user) {
                $mail->IsHTML(true);
                $mail->CharSet = 'utf-8';
                $template = get_markup_template('mail.tpl', 'addon/mailstream/');
-               $item['body'] = bbcode($item['body']);
+               $item['body'] = BBCode::convert($item['body']);
                $item['url'] = $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item['id'];
                $mail->Body = replace_macros($template, [
                                                 '$upstream' => L10n::t('Upstream'),
index 807c05a5c2797a9b5523a30c4bd4daeb8d680894..6ea83367057e36e7ed0fb7feeb1ed65005a8316a 100644 (file)
@@ -8,6 +8,7 @@
 
 require_once 'include/bbcode.php';
 
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -31,7 +32,7 @@ function newmemberwidget_network_mod_init ( $a, $b) {
            $t .= '<a href="'.$a->get_baseurl().'/profile/'.Config::get('newmemberwidget','localsupport').'" target="_new">'.L10n::t('Local Support Forum').'</a><br />'.EOL;
        $ft = Config::get('newmemberwidget','freetext');
        if (!trim($ft)=="")
-           $t .= '<p>'.bbcode(trim($ft)).'</p>';
+           $t .= '<p>'.BBCode::convert(trim($ft)).'</p>';
        $t .= '</div><div class="clear"></div>';
        $a->page['aside'] = $t . $a->page['aside'];
     }
index e35d7bf194e558113e94ea6a2f465fe29ebbaf97..5ea0db38c614749007d33a81d8254a16713d6642 100644 (file)
@@ -7,6 +7,8 @@
  * Author: Mike Macgirvin (Inital Author of the hubbwall Addon for the Hubzilla Project)
  * Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus> (Port to Friendica)
  */
+
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\L10n;
 use Friendica\Util\Emailer;
 
@@ -49,9 +51,9 @@ function notifyall_post(&$a) {
        $subject = $_REQUEST['subject'];
 
 
-       $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(["\\r", "\\n"],[ "", "\n"], $text))),ENT_QUOTES,'UTF-8'));
+       $textversion = strip_tags(html_entity_decode(BBCode::convert(stripslashes(str_replace(["\\r", "\\n"], ["", "\n"], $text))), ENT_QUOTES, 'UTF-8'));
 
-       $htmlversion = bbcode(stripslashes(str_replace(["\\r","\\n"], ["","<br />\n"],$text)));
+       $htmlversion = BBCode::convert(stripslashes(str_replace(["\\r", "\\n"], ["", "<br />\n"], $text)));
 
        // if this is a test, send it only to the admin(s)
        // admin_email might be a comma separated list, but we need "a@b','c@d','e@f
index 6a7a08cf91efa48c2af80324f2393392201fb3e8..129f2738d3381288b5cb73412889b0ba52b57a4e 100644 (file)
@@ -6,6 +6,7 @@
  * Author: Michael Vogel <http://pirati.ca/profile/heluecht>
  */
 
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
@@ -475,7 +476,7 @@ function pumpio_send(&$a,&$b) {
 
                $title = trim($b['title']);
 
-               $content = bbcode($b['body'], false, false, 4);
+               $content = BBCode::convert($b['body'], false, 4);
 
                $params = [];
 
index 2ba26afc7f70a7c788ba1b452dae947fa1a824d2..831dd61568ba66f36dbef1fe0d158ef0190d8331 100644 (file)
@@ -381,7 +381,7 @@ function tumblr_send(&$a,&$b) {
                switch ($siteinfo["type"]) {
                        case "photo":
                                $params['type'] = "photo";
-                               $params['caption'] = bbcode($body, false, false, 4);
+                               $params['caption'] = BBCode::convert($body, false, 4);
 
                                if (isset($siteinfo["url"]))
                                        $params['link'] = $siteinfo["url"];
@@ -392,22 +392,22 @@ function tumblr_send(&$a,&$b) {
                                $params['type'] = "link";
                                $params['title'] = $title;
                                $params['url'] = $siteinfo["url"];
-                               $params['description'] = bbcode($body, false, false, 4);
+                               $params['description'] = BBCode::convert($body, false, 4);
                                break;
                        case "audio":
                                $params['type'] = "audio";
                                $params['external_url'] = $siteinfo["url"];
-                               $params['caption'] = bbcode($body, false, false, 4);
+                               $params['caption'] = BBCode::convert($body, false, 4);
                                break;
                        case "video":
                                $params['type'] = "video";
                                $params['embed'] = $siteinfo["url"];
-                               $params['caption'] = bbcode($body, false, false, 4);
+                               $params['caption'] = BBCode::convert($body, false, 4);
                                break;
                        default:
                                $params['type'] = "text";
                                $params['title'] = $title;
-                               $params['body'] = bbcode($b['body'], false, false, 4);
+                               $params['body'] = BBCode::convert($b['body'], false, 4);
                                break;
                }
 
@@ -416,7 +416,7 @@ function tumblr_send(&$a,&$b) {
                                                "<p>".$params['caption']."</p>";
 
                if (trim($params['caption']) == "")
-                       $params['caption'] = bbcode("[quote]".$siteinfo["description"]."[/quote]", false, false, 4);
+                       $params['caption'] = BBCode::convert("[quote]" . $siteinfo["description"] . "[/quote]", false, 4);
 
                $consumer_key = Config::get('tumblr','consumer_key');
                $consumer_secret = Config::get('tumblr','consumer_secret');
index 033d2a64a04127844e668a5b654e7b2183f8e2b0..346f550f2de841828d00413adaee6e98d56d1bcb 100644 (file)
@@ -25,7 +25,9 @@
  *        sets the counter back
  *        count only unseen elements which are not type=activity (likes and dislikes not seen as new elements)
  */
+
 use Friendica\App;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
@@ -211,7 +213,7 @@ function windowsphonepush_cron()
                                                } else {
                                                        require_once('include/bbcode.php');
                                                        require_once("include/html2plain.php");
-                                                       $body = bbcode($body, false, false, 2, true);
+                                                       $body = BBCode::convert($body, false, 2, true);
                                                        $body = html2plain($body, 0);
                                                        $body = ((strlen($body) > 137) ? substr($body, 0, 137) . "..." : $body);
                                                }
index e3127e8e6e2c1d51e41350e6ee730e024f5f3328..23f928bcc537ba79315963014a9dcdd608fc24ac 100644 (file)
@@ -145,7 +145,7 @@ function wppost_settings_post(&$a,&$b) {
                PConfig::set(local_user(),'wppost','backlink',trim($_POST['wp_backlink']));
                PConfig::set(local_user(),'wppost','shortcheck',trim($_POST['wp_shortcheck']));
                $wp_backlink_text = notags(trim($_POST['wp_backlink_text']));
-               $wp_backlink_text = bbcode($wp_backlink_text, false, false, 8);
+               $wp_backlink_text = BBCode::convert($wp_backlink_text, false, 8);
                $wp_backlink_text = html2plain($wp_backlink_text, 0, true);
                PConfig::set(local_user(),'wppost','wp_backlink_text', $wp_backlink_text);
 
@@ -266,7 +266,7 @@ function wppost_send(&$a,&$b) {
                                // Remove the share element before fetching the first line
                                $title = trim(preg_replace("/\[share.*?\](.*?)\[\/share\]/ism","\n$1\n",$b['body']));
 
-                               $title = html2plain(bbcode($title, false, false), 0, true)."\n";
+                               $title = html2plain(BBCode::convert($title, false), 0, true)."\n";
                                $pos = strpos($title, "\n");
                                $trailer = "";
                                if (($pos == 0) || ($pos > 100)) {
@@ -279,7 +279,7 @@ function wppost_send(&$a,&$b) {
                }
 
                $title = '<title>' . (($wptitle) ? $wptitle : L10n::t('Post from Friendica')) . '</title>';
-               $post = bbcode($b['body'], false, false, 4);
+               $post = BBCode::convert($b['body'], false, 4);
 
                // If a link goes to youtube then remove the stuff around it. Wordpress detects youtube links and embeds it
                $post = preg_replace('/<a.*?href="(https?:\/\/www.youtube.com\/.*?)".*?>(.*?)<\/a>/ism',"\n$1\n",$post);