/**
* @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";
}
if ($privmail) {
- $trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
+ $trimmed = Network::formatMention($rr['url'], $rr['name']);
} else {
$trimmed = mb_substr($rr['name'],0,20);
}
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'])) {
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);
{
$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);
$s = preg_replace('/([^\]=]|^)(https?\:\/\/)([a-zA-Z0-9:\/\-?&;.=_~#%$!+,@]+(?<!,))/ism', '$1[url=$2$3]$2$3[/url]', $s);
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
- $s = bb_tag_preg_replace('/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism', '[youtube]$2[/youtube]', 'url', $s);
- $s = bb_tag_preg_replace('/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism' , '[youtube]$1[/youtube]', 'url', $s);
- $s = bb_tag_preg_replace('/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism' , '[vimeo]$2[/vimeo]' , 'url', $s);
- $s = bb_tag_preg_replace('/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism' , '[vimeo]$1[/vimeo]' , 'url', $s);
+ $s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism', '[youtube]$2[/youtube]', 'url', $s);
+ $s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism' , '[youtube]$1[/youtube]', 'url', $s);
+ $s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism' , '[vimeo]$2[/vimeo]' , 'url', $s);
+ $s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism' , '[vimeo]$1[/vimeo]' , 'url', $s);
// remove duplicate adjacent code tags
$s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s);
// Since Diaspora is creating a summary for links, this function removes them before posting
if ($fordiaspora) {
- $Text = bb_remove_share_information($Text);
+ $Text = BBCode::removeShareInformation($Text);
}
/**
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
+use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
$newbody = '';
$cnt = 1;
- $pos = get_bb_tag_pos($origbody, 'url', 1);
+ $pos = BBCode::getTagPosition($origbody, 'url', 0);
while ($pos !== false && $cnt < 1000) {
$search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is';
$newbody .= $subject;
$cnt++;
- $pos = get_bb_tag_pos($origbody, 'url', 1);
+ // Isn't this supposed to use $cnt value for $occurrences? - @MrPetovan
+ $pos = BBCode::getTagPosition($origbody, 'url', 0);
}
$newbody .= $origbody;
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
if (preg_match($photo_pattern, $item['body'])) {
$photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
- $item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']);
+ $item['body'] = BBCode::pregReplaceInTag($photo_pattern, $photo_replace, 'url', $item['body']);
}
// add sparkle links to appropriate permalinks
/**
* @file mod/display.php
*/
+
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Core\Network;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
$profiledata["photo"] = $matches[1];
}
$profiledata["nickname"] = $profiledata["name"];
- $profiledata["network"] = GetProfileUsername($profiledata["url"], "", false, true);
+ $profiledata["network"] = Network::matchByProfileUrl($profiledata["url"]);
$profiledata["address"] = "";
$profiledata["about"] = "";
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Core\Network;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Object\Image;
use Friendica\Util\Map;
-use Friendica\Util\Network;
+use Friendica\Util\Network as NetworkUtil;
use Friendica\Util\ParseUrl;
require_once "include/bbcode.php";
$body = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url]$2[/url]', $body);
// Remove the abstract
- $body = remove_abstract($body);
+ $body = self::removeAbstract($body);
// At first look at data that is attached via "type-..." stuff
// This will hopefully replaced with a dedicated bbcode later
// Fetch the abstract from the given target network
if ($target_network != "") {
- $default_abstract = fetch_abstract($b["body"]);
- $abstract = fetch_abstract($b["body"], $target_network);
+ $default_abstract = self::getAbstract($b["body"]);
+ $abstract = self::getAbstract($b["body"], $target_network);
// If we post to a network with no limit we only fetch
// an abstract exactly for this network
} else {// Try to guess the correct target network
switch ($htmlmode) {
case 8:
- $abstract = fetch_abstract($b["body"], NETWORK_TWITTER);
+ $abstract = self::getAbstract($b["body"], NETWORK_TWITTER);
break;
case 7:
- $abstract = fetch_abstract($b["body"], NETWORK_STATUSNET);
+ $abstract = self::getAbstract($b["body"], NETWORK_STATUSNET);
break;
case 6:
- $abstract = fetch_abstract($b["body"], NETWORK_APPNET);
+ $abstract = self::getAbstract($b["body"], NETWORK_APPNET);
break;
default: // We don't know the exact target.
// We fetch an abstract since there is a posting limit.
if ($limit > 0) {
- $abstract = fetch_abstract($b["body"]);
+ $abstract = self::getAbstract($b["body"]);
}
}
}
} else {
$scaled = $mtch[1];
}
- $i = Network::fetchUrl($scaled);
+ $i = NetworkUtil::fetchUrl($scaled);
if (!$i) {
return $srctext;
}
*/
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']);
$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;
return ['body' => $new_body, 'images' => $saved_image];
}
- public static function interpolateSavedImagesIntoItemBody($body, array $images)
+ private static function interpolateSavedImagesIntoItemBody($body, array $images)
{
$newbody = $body;
* @param bool|int $simplehtml
* @return string
*/
- public static function convertShare($share, $simplehtml)
+ private static function convertShare($share, $simplehtml)
{
$attributes = $share[2];
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")) {
$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);
// 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'];
// 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", '<br/><img src="' .System::baseUrl() . '/images/lock_icon.gif" alt="' . L10n::t('Encrypted content') . '" title="' . L10n::t('Encrypted content') . '" /><br />', $text);
$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.
* @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 = [];
use Friendica\App;
use Friendica\Content\OEmbed;
+use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\XML;
-use Friendica\Content\Text\BBCode;
-
use dba;
use DOMDocument;
use DOMXPath;
}
// Remove the abstract element. It is only locally important.
- $body = remove_abstract($body);
+ $body = BBCode::removeAbstract($body);
if ($type == 'html') {
$htmlbody = $body;
* Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus>
*
*/
+
use Friendica\App;
+use Friendica\Content\Text\Plaintext;
use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Profile;
-use Friendica\Object\Image;
$frio = "view/theme/frio";
*/
function frio_item_photo_links(App $a, &$body_info)
{
- $phototypes = Image::supportedTypes();
- $occurence = 1;
- $p = bb_find_open_close($body_info['html'], "<a", ">");
-
+ $occurence = 0;
+ $p = Plaintext::getBoundariesPosition($body_info['html'], "<a", ">");
while ($p !== false && ($occurence++ < 500)) {
$link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
$matches = [];
$body_info['html'] = str_replace($link, $newlink, $body_info['html']);
}
- $p = bb_find_open_close($body_info['html'], "<a", ">", $occurence);
+ $p = Plaintext::getBoundariesPosition($body_info['html'], "<a", ">", $occurence);
}
}
$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) . "%%') ";
*/
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;
function frost_item_photo_links(App $a, &$body_info)
{
- $phototypes = Image::supportedTypes();
-
- $occurence = 1;
- $p = bb_find_open_close($body_info['html'], "<a", ">");
+ $occurence = 0;
+ $p = Plaintext::getBoundariesPosition($body_info['html'], '<a', '>');
while($p !== false && ($occurence++ < 500)) {
$link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
}
- $p = bb_find_open_close($body_info['html'], "<a", ">", $occurence);
+ $p = Plaintext::getBoundariesPosition($body_info['html'], '<a', '>', $occurence);
}
}