From ab0f359602052bc82035335cb47c3e40f2474141 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 7 Mar 2018 16:48:34 -0500 Subject: [PATCH] Replace htmlt2* with HTML class methods - Remove references to include/html2*.php --- pumpio/pumpio.php | 10 ++++------ statusnet/statusnet.php | 10 ++++------ windowsphonepush/windowsphonepush.php | 5 ++--- wppost/wppost.php | 8 ++++---- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index a1ca2ade..8426c535 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -7,6 +7,7 @@ */ use Friendica\Content\Text\BBCode; +use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -782,8 +783,6 @@ function pumpio_fetchtimeline(&$a, $uid) { $public = true; if ($public && !stristr($post->generator->displayName, $application_name)) { - require_once('include/html2bbcode.php'); - $_SESSION["authenticated"] = true; $_SESSION["uid"] = $uid; @@ -798,11 +797,11 @@ function pumpio_fetchtimeline(&$a, $uid) { } if ($post->object->displayName != "") - $_REQUEST["title"] = html2bbcode($post->object->displayName); + $_REQUEST["title"] = HTML::toBBCode($post->object->displayName); else $_REQUEST["title"] = ""; - $_REQUEST["body"] = html2bbcode($post->object->content); + $_REQUEST["body"] = HTML::toBBCode($post->object->content); // To-Do: Picture has to be cached and stored locally if ($post->object->fullImage->url != "") { @@ -1062,7 +1061,6 @@ function pumpio_dodelete(&$a, $uid, $self, $post, $own_id) { function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcompletion = true) { require_once('include/items.php'); - require_once('include/html2bbcode.php'); if (($post->verb == "like") || ($post->verb == "favorite")) return pumpio_dolike($a, $uid, $self, $post, $own_id); @@ -1191,7 +1189,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet $postarray['author-avatar'] = $post->actor->image->url; $postarray['plink'] = $post->object->url; $postarray['app'] = $post->generator->displayName; - $postarray['body'] = html2bbcode($post->object->content); + $postarray['body'] = HTML::toBBCode($post->object->content); $postarray['object'] = json_encode($post); if ($post->object->fullImage->url != "") diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index c54ff55f..ad2da322 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -38,11 +38,11 @@ define('STATUSNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'statusnetoauth.php'; require_once 'include/enotify.php'; -use Codebird\Codebird; use CodebirdSN\CodebirdSN; use Friendica\App; use Friendica\Content\OEmbed; use Friendica\Content\Text\BBCode; +use Friendica\Content\Text\HTML; use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Config; @@ -582,7 +582,7 @@ function statusnet_post_hook(App $a, &$b) // New code that is able to post pictures require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'codebirdsn.php'; - $cb = \CodebirdSN\CodebirdSN::getInstance(); + $cb = CodebirdSN::getInstance(); $cb->setAPIEndpoint($api); $cb->setConsumerKey($ckey, $csecret); $cb->setToken($otoken, $osecret); @@ -1031,7 +1031,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "") require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'codebirdsn.php'; - $cb = \CodebirdSN\CodebirdSN::getInstance(); + $cb = CodebirdSN::getInstance(); $cb->setConsumerKey($ckey, $csecret); $cb->setToken($otoken, $osecret); @@ -1068,8 +1068,6 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "") function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_existing_contact) { - require_once "include/html2bbcode.php"; - logger("statusnet_createpost: start", LOGGER_DEBUG); $api = PConfig::get($uid, 'statusnet', 'baseapi'); @@ -1186,7 +1184,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $postarray['allow_cid'] = '<' . $self['id'] . '>'; } - $postarray['body'] = html2bbcode($content->statusnet_html); + $postarray['body'] = HTML::toBBCode($content->statusnet_html); $converted = statusnet_convertmsg($a, $postarray['body'], false); $postarray['body'] = $converted["body"]; diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index 206b0883..3aaf1d30 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -28,6 +28,7 @@ use Friendica\App; use Friendica\Content\Text\BBCode; +use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -211,10 +212,8 @@ function windowsphonepush_cron() if (substr($body, 0, 4) == "[url") { $body = "URL/Image ..."; } else { - require_once("include/html2plain.php"); - $body = BBCode::convert($body, false, 2, true); - $body = html2plain($body, 0); + $body = HTML::toPlaintext($body, 0); $body = ((strlen($body) > 137) ? substr($body, 0, 137) . "..." : $body); } } else { diff --git a/wppost/wppost.php b/wppost/wppost.php index 8d14b170..a2c11293 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -5,7 +5,9 @@ * Version: 1.1 * Author: Mike Macgirvin */ + use Friendica\Content\Text\BBCode; +use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -146,7 +148,7 @@ function wppost_settings_post(&$a,&$b) { PConfig::set(local_user(),'wppost','shortcheck',trim($_POST['wp_shortcheck'])); $wp_backlink_text = notags(trim($_POST['wp_backlink_text'])); $wp_backlink_text = BBCode::convert($wp_backlink_text, false, 8); - $wp_backlink_text = html2plain($wp_backlink_text, 0, true); + $wp_backlink_text = HTML::toPlaintext($wp_backlink_text, 0, true); PConfig::set(local_user(),'wppost','wp_backlink_text', $wp_backlink_text); } @@ -221,8 +223,6 @@ function wppost_send(&$a,&$b) { } if ($wp_username && $wp_password && $wp_blog) { - require_once 'include/html2plain.php'; - $wptitle = trim($b['title']); if (intval(PConfig::get($b['uid'], 'wppost', 'shortcheck'))) { @@ -265,7 +265,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::convert($title, false), 0, true)."\n"; + $title = HTML::toPlaintext(BBCode::convert($title, false), 0, true)."\n"; $pos = strpos($title, "\n"); $trailer = ""; if (($pos == 0) || ($pos > 100)) { -- 2.39.5