From 7b95efedd15b318b39710153de918d28b3305cc9 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Fri, 26 Jan 2018 19:26:37 -0500 Subject: [PATCH 1/2] Update function calls update function calls and remove require_once --- buffer/buffer.php | 10 +++++----- statusnet/statusnet.php | 9 ++++----- tumblr/tumblr.php | 4 ++-- twitter/twitter.php | 14 ++++++-------- wppost/wppost.php | 15 +++++++-------- 5 files changed, 24 insertions(+), 28 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index 02dd7ffbc..aef9a0fdc 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -8,6 +8,7 @@ require 'addon/buffer/bufferapp.php'; use Friendica\App; +use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -273,8 +274,7 @@ function buffer_send(App $a, &$b) if($access_token) { $buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token); - require_once("include/plaintext.php"); - require_once("include/network.php"); + require_once 'include/network.php'; $profiles = $buffer->go('/profiles'); if (is_array($profiles)) { @@ -339,7 +339,7 @@ function buffer_send(App $a, &$b) $item["body"] = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$item["body"]); } - $post = plaintext($item, $limit, $includedlinks, $htmlmode); + $post = Plaintext::toPlaintext($item, $limit, $includedlinks, $htmlmode); logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG); // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures @@ -365,8 +365,8 @@ function buffer_send(App $a, &$b) if (($profile->service == "twitter") && isset($post["url"]) && ($post["type"] != "photo")) $post["text"] .= " ".$post["url"]; elseif (($profile->service == "appdotnet") && isset($post["url"]) && isset($post["title"]) && ($post["type"] != "photo")) { - $post["title"] = shortenmsg($post["title"], 90); - $post["text"] = shortenmsg($post["text"], $limit - (24 + strlen($post["title"]))); + $post["title"] = Plaintext::shortenMsg($post["title"], 90); + $post["text"] = Plaintext::shortenMsg($post["text"], $limit - (24 + strlen($post["title"]))); $post["text"] .= "\n[".$post["title"]."](".$post["url"].")"; } elseif (($profile->service == "appdotnet") && isset($post["url"]) && ($post["type"] != "photo")) $post["text"] .= " ".$post["url"]; diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index f9b770a99..3296acbeb 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -47,6 +47,7 @@ require_once 'include/enotify.php'; use Friendica\App; use Friendica\Content\OEmbed; +use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -639,13 +640,12 @@ function statusnet_post_hook(App $a, &$b) PConfig::set($b['uid'], 'statusnet', 'max_char', $max_char); $tempfile = ""; - require_once "include/plaintext.php"; require_once "include/network.php"; - $msgarr = plaintext($b, $max_char, true, 7); + $msgarr = Plaintext::toPlaintext($b, $max_char, true, 7); $msg = $msgarr["text"]; if (($msg == "") && isset($msgarr["title"])) - $msg = shortenmsg($msgarr["title"], $max_char - 50); + $msg = Plaintext::shortenMsg($msgarr["title"], $max_char - 50); $image = ""; @@ -785,7 +785,6 @@ function statusnet_prepare_body(App $a, &$b) $max_char = 140; } - require_once "include/plaintext.php"; $item = $b["item"]; $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"]; @@ -810,7 +809,7 @@ function statusnet_prepare_body(App $a, &$b) } } - $msgarr = plaintext($item, $max_char, true, 7); + $msgarr = Plaintext::toPlaintext($item, $max_char, true, 7); $msg = $msgarr["text"]; if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) { diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 008027c04..4e518e431 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -10,6 +10,7 @@ require_once 'library/OAuth1.php'; require_once 'addon/tumblr/tumblroauth/tumblroauth.php'; +use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -358,9 +359,8 @@ function tumblr_send(&$a,&$b) { $tags = implode(',',$tag_arr); $title = trim($b['title']); - require_once('include/plaintext.php'); - $siteinfo = get_attached_data($b["body"]); + $siteinfo = Plaintext::getAttachedData($b["body"]); $params = [ 'state' => 'published', diff --git a/twitter/twitter.php b/twitter/twitter.php index 244eaee7d..f0ed88cfd 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -61,6 +61,7 @@ use Friendica\App; use Friendica\Content\OEmbed; +use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -524,12 +525,11 @@ function twitter_post_hook(App $a, &$b) $tweet = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $max_char = 280; - require_once "include/plaintext.php"; - $msgarr = plaintext($b, $max_char, true, 8); + $msgarr = Plaintext::toPlaintext($b, $max_char, true, 8); $msg = $msgarr["text"]; if (($msg == "") && isset($msgarr["title"])) { - $msg = shortenmsg($msgarr["title"], $max_char - 50); + $msg = Plaintext::shortenMsg($msgarr["title"], $max_char - 50); } $image = ""; @@ -593,12 +593,11 @@ function twitter_post_hook(App $a, &$b) if (strlen($msg) && ($image == "")) { // ----------------- $max_char = 280; - require_once "include/plaintext.php"; - $msgarr = plaintext($b, $max_char, true, 8); + $msgarr = Plaintext::toPlaintext($b, $max_char, true, 8); $msg = $msgarr["text"]; if (($msg == "") && isset($msgarr["title"])) { - $msg = shortenmsg($msgarr["title"], $max_char - 50); + $msg = Plaintext::shortenMsg($msgarr["title"], $max_char - 50); } if (isset($msgarr["url"])) { @@ -771,7 +770,6 @@ function twitter_prepare_body(App $a, &$b) if ($b["preview"]) { $max_char = 280; - require_once "include/plaintext.php"; $item = $b["item"]; $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"]; @@ -791,7 +789,7 @@ function twitter_prepare_body(App $a, &$b) } } - $msgarr = plaintext($item, $max_char, true, 8); + $msgarr = Plaintext::toPlaintext($item, $max_char, true, 8); $msg = $msgarr["text"]; if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) { diff --git a/wppost/wppost.php b/wppost/wppost.php index 88ae5a4f2..a64ffc3db 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -5,6 +5,7 @@ * Version: 1.1 * Author: Mike Macgirvin */ +use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -218,18 +219,16 @@ function wppost_send(&$a,&$b) { $wp_backlink_text = L10n::t('Read the orig­i­nal post and com­ment stream on Friendica'); } - if($wp_username && $wp_password && $wp_blog) { - - require_once('include/bbcode.php'); - require_once('include/html2plain.php'); - require_once('include/plaintext.php'); + if ($wp_username && $wp_password && $wp_blog) { + require_once 'include/bbcode.php'; + require_once 'include/html2plain.php'; $wptitle = trim($b['title']); - if (intval(PConfig::get($b['uid'],'wppost','shortcheck'))) { + if (intval(PConfig::get($b['uid'], 'wppost', 'shortcheck'))) { // Checking, if its a post that is worth a blog post $postentry = false; - $siteinfo = get_attached_data($b["body"]); + $siteinfo = Plaintext::getAttachedData($b["body"]); // Is it a link to an aricle, a video or a photo? if (isset($siteinfo["type"])) { @@ -256,7 +255,7 @@ function wppost_send(&$a,&$b) { // If the title is empty then try to guess if ($wptitle == '') { // Fetch information about the post - $siteinfo = get_attached_data($b["body"]); + $siteinfo = Plaintext::getAttachedData($b["body"]); if (isset($siteinfo["title"])) { $wptitle = $siteinfo["title"]; } From 9c9088069a349b7370c35bbc6dfd38b7f820b746 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Fri, 26 Jan 2018 20:04:00 -0500 Subject: [PATCH 2/2] Plaintext was renamed to BBCode update class name --- buffer/buffer.php | 8 ++++---- statusnet/statusnet.php | 8 ++++---- tumblr/tumblr.php | 4 ++-- twitter/twitter.php | 12 ++++++------ wppost/wppost.php | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index aef9a0fdc..a82fd4fc3 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -8,7 +8,7 @@ require 'addon/buffer/bufferapp.php'; use Friendica\App; -use Friendica\Content\Text\Plaintext; +use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -339,7 +339,7 @@ function buffer_send(App $a, &$b) $item["body"] = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$item["body"]); } - $post = Plaintext::toPlaintext($item, $limit, $includedlinks, $htmlmode); + $post = BBCode::toPlaintext($item, $limit, $includedlinks, $htmlmode); logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG); // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures @@ -365,8 +365,8 @@ function buffer_send(App $a, &$b) if (($profile->service == "twitter") && isset($post["url"]) && ($post["type"] != "photo")) $post["text"] .= " ".$post["url"]; elseif (($profile->service == "appdotnet") && isset($post["url"]) && isset($post["title"]) && ($post["type"] != "photo")) { - $post["title"] = Plaintext::shortenMsg($post["title"], 90); - $post["text"] = Plaintext::shortenMsg($post["text"], $limit - (24 + strlen($post["title"]))); + $post["title"] = BBCode::shortenMsg($post["title"], 90); + $post["text"] = BBCode::shortenMsg($post["text"], $limit - (24 + strlen($post["title"]))); $post["text"] .= "\n[".$post["title"]."](".$post["url"].")"; } elseif (($profile->service == "appdotnet") && isset($post["url"]) && ($post["type"] != "photo")) $post["text"] .= " ".$post["url"]; diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 3296acbeb..40239af71 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -47,7 +47,7 @@ require_once 'include/enotify.php'; use Friendica\App; use Friendica\Content\OEmbed; -use Friendica\Content\Text\Plaintext; +use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -641,11 +641,11 @@ function statusnet_post_hook(App $a, &$b) $tempfile = ""; require_once "include/network.php"; - $msgarr = Plaintext::toPlaintext($b, $max_char, true, 7); + $msgarr = BBCode::toPlaintext($b, $max_char, true, 7); $msg = $msgarr["text"]; if (($msg == "") && isset($msgarr["title"])) - $msg = Plaintext::shortenMsg($msgarr["title"], $max_char - 50); + $msg = BBCode::shortenMsg($msgarr["title"], $max_char - 50); $image = ""; @@ -809,7 +809,7 @@ function statusnet_prepare_body(App $a, &$b) } } - $msgarr = Plaintext::toPlaintext($item, $max_char, true, 7); + $msgarr = BBCode::toPlaintext($item, $max_char, true, 7); $msg = $msgarr["text"]; if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) { diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 4e518e431..20a27f455 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -10,7 +10,7 @@ require_once 'library/OAuth1.php'; require_once 'addon/tumblr/tumblroauth/tumblroauth.php'; -use Friendica\Content\Text\Plaintext; +use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -360,7 +360,7 @@ function tumblr_send(&$a,&$b) { $title = trim($b['title']); - $siteinfo = Plaintext::getAttachedData($b["body"]); + $siteinfo = BBCode::getAttachedData($b["body"]); $params = [ 'state' => 'published', diff --git a/twitter/twitter.php b/twitter/twitter.php index f0ed88cfd..57a9db2b4 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -61,7 +61,7 @@ use Friendica\App; use Friendica\Content\OEmbed; -use Friendica\Content\Text\Plaintext; +use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -525,11 +525,11 @@ function twitter_post_hook(App $a, &$b) $tweet = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $max_char = 280; - $msgarr = Plaintext::toPlaintext($b, $max_char, true, 8); + $msgarr = BBCode::toPlaintext($b, $max_char, true, 8); $msg = $msgarr["text"]; if (($msg == "") && isset($msgarr["title"])) { - $msg = Plaintext::shortenMsg($msgarr["title"], $max_char - 50); + $msg = BBCode::shortenMsg($msgarr["title"], $max_char - 50); } $image = ""; @@ -593,11 +593,11 @@ function twitter_post_hook(App $a, &$b) if (strlen($msg) && ($image == "")) { // ----------------- $max_char = 280; - $msgarr = Plaintext::toPlaintext($b, $max_char, true, 8); + $msgarr = BBCode::toPlaintext($b, $max_char, true, 8); $msg = $msgarr["text"]; if (($msg == "") && isset($msgarr["title"])) { - $msg = Plaintext::shortenMsg($msgarr["title"], $max_char - 50); + $msg = BBCode::shortenMsg($msgarr["title"], $max_char - 50); } if (isset($msgarr["url"])) { @@ -789,7 +789,7 @@ function twitter_prepare_body(App $a, &$b) } } - $msgarr = Plaintext::toPlaintext($item, $max_char, true, 8); + $msgarr = BBCode::toPlaintext($item, $max_char, true, 8); $msg = $msgarr["text"]; if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) { diff --git a/wppost/wppost.php b/wppost/wppost.php index a64ffc3db..f2f9b9357 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -5,7 +5,7 @@ * Version: 1.1 * Author: Mike Macgirvin */ -use Friendica\Content\Text\Plaintext; +use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -228,7 +228,7 @@ function wppost_send(&$a,&$b) { if (intval(PConfig::get($b['uid'], 'wppost', 'shortcheck'))) { // Checking, if its a post that is worth a blog post $postentry = false; - $siteinfo = Plaintext::getAttachedData($b["body"]); + $siteinfo = BBCode::getAttachedData($b["body"]); // Is it a link to an aricle, a video or a photo? if (isset($siteinfo["type"])) { @@ -255,7 +255,7 @@ function wppost_send(&$a,&$b) { // If the title is empty then try to guess if ($wptitle == '') { // Fetch information about the post - $siteinfo = Plaintext::getAttachedData($b["body"]); + $siteinfo = BBCode::getAttachedData($b["body"]); if (isset($siteinfo["title"])) { $wptitle = $siteinfo["title"]; }