diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index 72f49a40ba..166cf97197 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -2,16 +2,18 @@
/**
* @file include/acl_selectors.php
*/
+
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Core\Network;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
-use Friendica\Util\Network;
+use Friendica\Util\Network as NetworkUtil;
require_once "mod/proxy.php";
@@ -248,7 +250,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
}
if ($privmail) {
- $trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
+ $trimmed = Network::formatMention($rr['url'], $rr['name']);
} else {
$trimmed = mb_substr($rr['name'],0,20);
}
@@ -734,7 +736,7 @@ function navbar_complete(App $a) {
if (! $localsearch) {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
- $x = Network::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
+ $x = NetworkUtil::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
if ($x['success']) {
$j = json_decode($x['body'],true);
if ($j && isset($j['results'])) {
diff --git a/include/api.php b/include/api.php
index e50bc92a8e..a477060135 100644
--- a/include/api.php
+++ b/include/api.php
@@ -2753,7 +2753,7 @@ function api_get_entitities(&$text, $bbcode)
return [];
}
- $bbcode = bb_CleanPictureLinks($bbcode);
+ $bbcode = BBCode::cleanPictureLinks($bbcode);
// Change pure links in text to bbcode uris
$bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
@@ -5173,7 +5173,7 @@ function api_clean_plain_items($Text)
{
$include_entities = strtolower(x($_REQUEST, 'include_entities') ? $_REQUEST['include_entities'] : "false");
- $Text = bb_CleanPictureLinks($Text);
+ $Text = BBCode::cleanPictureLinks($Text);
$URLSearchString = "^\[\]";
$Text = preg_replace("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 0cb50e95ee..c1c9fa4c3d 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -76,10 +76,10 @@ function diaspora2bb($s) {
$s = preg_replace('/([^\]=]|^)(https?\:\/\/)([a-zA-Z0-9:\/\-?&;.=_~#%$!+,@]+(? 0) {
- $abstract = fetch_abstract($b["body"]);
+ $abstract = self::getAbstract($b["body"]);
}
}
}
@@ -518,7 +519,7 @@ class BBCode
} else {
$scaled = $mtch[1];
}
- $i = Network::fetchUrl($scaled);
+ $i = NetworkUtil::fetchUrl($scaled);
if (!$i) {
return $srctext;
}
@@ -924,9 +925,9 @@ class BBCode
*/
public static function pregReplaceInTag($pattern, $replace, $name, $text)
{
- $occurence = 1;
- $pos = get_bb_tag_pos($text, $name, $occurence);
- while ($pos !== false && $occurence < 1000) {
+ $occurrences = 0;
+ $pos = self::getTagPosition($text, $name, $occurrences);
+ while ($pos !== false && $occurrences++ < 1000) {
$start = substr($text, 0, $pos['start']['open']);
$subject = substr($text, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
$end = substr($text, $pos['end']['close']);
@@ -937,14 +938,13 @@ class BBCode
$subject = preg_replace($pattern, $replace, $subject);
$text = $start . $subject . $end;
- $occurence++;
- $pos = get_bb_tag_pos($text, $name, $occurence);
+ $pos = self::getTagPosition($text, $name, $occurrences);
}
return $text;
}
- public static function extractImagesFromItemBody($body)
+ private static function extractImagesFromItemBody($body)
{
$saved_image = [];
$orig_body = $body;
@@ -985,7 +985,7 @@ class BBCode
return ['body' => $new_body, 'images' => $saved_image];
}
- public static function interpolateSavedImagesIntoItemBody($body, array $images)
+ private static function interpolateSavedImagesIntoItemBody($body, array $images)
{
$newbody = $body;
@@ -1012,7 +1012,7 @@ class BBCode
* @param bool|int $simplehtml
* @return string
*/
- public static function convertShare($share, $simplehtml)
+ private static function convertShare($share, $simplehtml)
{
$attributes = $share[2];
@@ -1082,13 +1082,13 @@ class BBCode
if (x($data, "name") && x($data, "addr")) {
$userid_compact = $data["name"] . " (" . $data["addr"] . ")";
} else {
- $userid_compact = GetProfileUsername($profile, $author, true);
+ $userid_compact = Network::getAddrFromProfileUrl($profile, $author);
}
if (x($data, "addr")) {
$userid = $data["addr"];
} else {
- $userid = GetProfileUsername($profile, $author, false);
+ $userid = Network::formatMention($profile, $author);
}
if (x($data, "name")) {
@@ -1378,7 +1378,7 @@ class BBCode
$text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'self::escapeNoparseCallback', $text);
// Remove the abstract element. It is a non visible element.
- $text = remove_abstract($text);
+ $text = self::removeAbstract($text);
// Move all spaces out of the tags
$text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $text);
@@ -1388,7 +1388,7 @@ class BBCode
// large data sizes. Stash them away while we do bbcode conversion, and then put them back
// in after we've done all the regex matching. We cannot use any preg functions to do this.
- $extracted = bb_extract_images($text);
+ $extracted = self::extractImagesFromItemBody($text);
$text = $extracted['body'];
$saved_image = $extracted['images'];
@@ -1767,7 +1767,7 @@ class BBCode
// Shared content
$text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism",
function ($match) use ($simple_html) {
- return bb_ShareAttributes($match, $simple_html);
+ return self::convertShare($match, $simple_html);
}, $text);
$text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '
', $text);
@@ -1902,7 +1902,7 @@ class BBCode
$text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . L10n::t('Invalid link protocol') . '">', $text);
if ($saved_image) {
- $text = bb_replace_images($text, $saved_image);
+ $text = self::interpolateSavedImagesIntoItemBody($text, $saved_image);
}
// Clean up the HTML by loading and saving the HTML with the DOM.
@@ -1959,7 +1959,7 @@ class BBCode
* @param string $addon The addon for which the abstract is meant for
* @return string The abstract
*/
- public static function getAbstract($text, $addon = "")
+ private static function getAbstract($text, $addon = "")
{
$abstract = "";
$abstracts = [];
diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php
index 2269bffcfd..5d26e663c0 100644
--- a/src/Protocol/DFRN.php
+++ b/src/Protocol/DFRN.php
@@ -10,6 +10,7 @@ namespace Friendica\Protocol;
use Friendica\App;
use Friendica\Content\OEmbed;
+use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@@ -29,8 +30,6 @@ use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\XML;
-use Friendica\Content\Text\BBCode;
-
use dba;
use DOMDocument;
use DOMXPath;
@@ -931,7 +930,7 @@ class DFRN
}
// Remove the abstract element. It is only locally important.
- $body = remove_abstract($body);
+ $body = BBCode::removeAbstract($body);
if ($type == 'html') {
$htmlbody = $body;
diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php
index 3c4d5120cf..3f401612e2 100644
--- a/view/theme/frio/theme.php
+++ b/view/theme/frio/theme.php
@@ -6,7 +6,9 @@
* Author: Rabuzarus
*
*/
+
use Friendica\App;
+use Friendica\Content\Text\Plaintext;
use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\Config;
@@ -15,7 +17,6 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Profile;
-use Friendica\Object\Image;
$frio = "view/theme/frio";
@@ -90,10 +91,8 @@ function frio_uninstall()
*/
function frio_item_photo_links(App $a, &$body_info)
{
- $phototypes = Image::supportedTypes();
- $occurence = 1;
- $p = bb_find_open_close($body_info['html'], "");
-
+ $occurence = 0;
+ $p = Plaintext::getBoundariesPosition($body_info['html'], "");
while ($p !== false && ($occurence++ < 500)) {
$link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
$matches = [];
@@ -112,7 +111,7 @@ function frio_item_photo_links(App $a, &$body_info)
$body_info['html'] = str_replace($link, $newlink, $body_info['html']);
}
- $p = bb_find_open_close($body_info['html'], "", $occurence);
+ $p = Plaintext::getBoundariesPosition($body_info['html'], "", $occurence);
}
}
@@ -302,7 +301,7 @@ function frio_acl_lookup(App $a, &$results)
$search_txt = dbesc(protect_sprintf(preg_quote($results["search"])));
$searching = true;
}
-
+
$sql_extra = '';
if ($searching) {
$sql_extra .= " AND (`attag` LIKE '%%" . dbesc($search_txt) . "%%' OR `name` LIKE '%%" . dbesc($search_txt) . "%%' OR `nick` LIKE '%%" . dbesc($search_txt) . "%%') ";
diff --git a/view/theme/frost/theme.php b/view/theme/frost/theme.php
index 1692560341..dd1a0cebaf 100644
--- a/view/theme/frost/theme.php
+++ b/view/theme/frost/theme.php
@@ -10,9 +10,9 @@
*/
use Friendica\App;
+use Friendica\Content\Text\Plaintext;
use Friendica\Core\Addon;
use Friendica\Core\System;
-use Friendica\Object\Image;
function frost_init(App $a) {
$a->videowidth = 400;
@@ -49,10 +49,8 @@ function frost_uninstall() {
function frost_item_photo_links(App $a, &$body_info)
{
- $phototypes = Image::supportedTypes();
-
- $occurence = 1;
- $p = bb_find_open_close($body_info['html'], "");
+ $occurence = 0;
+ $p = Plaintext::getBoundariesPosition($body_info['html'], '');
while($p !== false && ($occurence++ < 500)) {
$link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
@@ -73,7 +71,7 @@ function frost_item_photo_links(App $a, &$body_info)
}
- $p = bb_find_open_close($body_info['html'], "", $occurence);
+ $p = Plaintext::getBoundariesPosition($body_info['html'], '', $occurence);
}
}