From 21881f28855969c211427e0695e3a5f5fe718172 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Fri, 26 Jan 2018 19:14:47 -0500 Subject: [PATCH] Update function calls update to new function calls --- include/api.php | 4 ++-- include/bbcode.php | 6 +++--- mod/item.php | 5 +++-- src/Content/Text/Plaintext.php | 20 ++++++++++---------- src/Protocol/OStatus.php | 5 +++-- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/api.php b/include/api.php index fa4e7f7758..07ff900832 100644 --- a/include/api.php +++ b/include/api.php @@ -8,6 +8,7 @@ use Friendica\App; use Friendica\Content\ContactSelector; use Friendica\Content\Feature; +use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Config; @@ -47,7 +48,6 @@ require_once 'include/html2bbcode.php'; require_once 'mod/wall_upload.php'; require_once 'mod/proxy.php'; require_once 'include/like.php'; -require_once 'include/plaintext.php'; define('API_METHOD_ANY', '*'); define('API_METHOD_GET', 'GET'); @@ -5196,7 +5196,7 @@ function api_clean_plain_items($Text) */ function api_clean_attachments($body) { - $data = get_attachment_data($body); + $data = Plaintext::getAttachmentData($body); if (!$data) { return $body; diff --git a/include/bbcode.php b/include/bbcode.php index 79412f1a3f..2223eac634 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Content\Smilies; use Friendica\Content\OEmbed; +use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\L10n; @@ -15,7 +16,6 @@ use Friendica\Util\Map; require_once 'include/event.php'; require_once 'mod/proxy.php'; -require_once 'include/plaintext.php'; function bb_PictureCacheExt($matches) { if (strpos($matches[3], "data:image/") === 0) { @@ -57,7 +57,7 @@ function bb_map_location($match) { */ function bb_attachment($return, $simplehtml = false, $tryoembed = true) { - $data = get_attachment_data($return); + $data = Plaintext::getAttachmentData($return); if (!$data) { return $return; } @@ -120,7 +120,7 @@ function bb_attachment($return, $simplehtml = false, $tryoembed = true) function bb_remove_share_information($Text, $plaintext = false, $nolink = false) { - $data = get_attachment_data($Text); + $data = Plaintext::getAttachmentData($Text); if (!$data) { return $Text; diff --git a/mod/item.php b/mod/item.php index eaced3e467..2cdb9dd85a 100644 --- a/mod/item.php +++ b/mod/item.php @@ -15,6 +15,7 @@ * information. */ use Friendica\App; +use Friendica\Content\Text\Plaintext; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -506,7 +507,7 @@ function item_post(App $a) { // embedded bookmark or attachment in post? set bookmark flag $bookmark = 0; - $data = get_attachment_data($body); + $data = Plaintext::getAttachmentData($body); if (preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"])) { $objecttype = ACTIVITY_OBJ_BOOKMARK; $bookmark = 1; @@ -524,7 +525,7 @@ function item_post(App $a) { if (!$objecttype) { $objecttype = ACTIVITY_OBJ_NOTE; // Default value require_once 'include/plaintext.php'; - $objectdata = get_attached_data($body); + $objectdata = Plaintext::getAttachedData($body); if ($objectdata["type"] == "link") { $objecttype = ACTIVITY_OBJ_BOOKMARK; diff --git a/src/Content/Text/Plaintext.php b/src/Content/Text/Plaintext.php index 1463e9f349..a72d20ea7a 100644 --- a/src/Content/Text/Plaintext.php +++ b/src/Content/Text/Plaintext.php @@ -28,7 +28,7 @@ class Plaintext * 'title' -> Title of the attachment * 'description' -> Description of the attachment */ - function getOldAttachmentData($body) + private static function getOldAttachmentData($body) { $post = []; @@ -97,12 +97,12 @@ class Plaintext * 'title' -> Title of the attachment * 'description' -> Description of the attachment */ - function getAttachmentData($body) + public static function getAttachmentData($body) { $data = []; if (!preg_match("/(.*)\[attachment(.*?)\](.*?)\[\/attachment\](.*)/ism", $body, $match)) { - return get_old_attachment_data($body); + return self::getOldAttachmentData($body); } $attributes = $match[2]; @@ -202,7 +202,7 @@ class Plaintext return $data; } - function getAttachedData($body, $item = []) + public static function getAttachedData($body, $item = []) { /* - text: @@ -216,7 +216,7 @@ class Plaintext $has_title = !empty($item['title']); $plink = (!empty($item['plink']) ? $item['plink'] : ''); - $post = get_attachment_data($body); + $post = self::getAttachmentData($body); // if nothing is found, it maybe having an image. if (!isset($post["type"])) { @@ -329,7 +329,7 @@ class Plaintext * * @todo For Twitter URLs aren't shortened, but they have to be calculated as if. */ - function shortenMsg($msg, $limit) + public static function shortenMsg($msg, $limit) { $lines = explode("\n", $msg); $msg = ""; @@ -360,7 +360,7 @@ class Plaintext * * @return string The converted message */ - function toPlaintext($b, $limit = 0, $includedlinks = false, $htmlmode = 2, $target_network = "") + public static function toPlaintext($b, $limit = 0, $includedlinks = false, $htmlmode = 2, $target_network = "") { // Remove the hash tags $URLSearchString = "^\[\]"; @@ -374,8 +374,8 @@ class Plaintext // At first look at data that is attached via "type-..." stuff // This will hopefully replaced with a dedicated bbcode later - //$post = get_attached_data($b["body"]); - $post = get_attached_data($body, $b); + //$post = self::getAttachedData($b["body"]); + $post = self::getAttachedData($body, $b); if (($b["title"] != "") && ($post["text"] != "")) { $post["text"] = trim($b["title"]."\n\n".$post["text"]); @@ -496,7 +496,7 @@ class Plaintext } elseif (PConfig::get($b["uid"], "system", "no_intelligent_shortening")) { $post["url"] = $b["plink"]; } - $msg = shortenmsg($msg, $limit); + $msg = self::shortenMsg($msg, $limit); } } diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 0e695416f3..05fac90708 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -5,6 +5,7 @@ namespace Friendica\Protocol; use Friendica\App; +use Friendica\Content\Text\Plaintext; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -1205,7 +1206,7 @@ class OStatus */ private static function formatPicturePost($body) { - $siteinfo = get_attached_data($body); + $siteinfo = Plaintext::getAttachedData($body); if (($siteinfo["type"] == "photo")) { if (isset($siteinfo["preview"])) { @@ -1327,7 +1328,7 @@ class OStatus private static function getAttachment($doc, $root, $item) { $o = ""; - $siteinfo = get_attached_data($item["body"]); + $siteinfo = Plaintext::getAttachedData($item["body"]); switch ($siteinfo["type"]) { case 'photo': -- 2.39.5