Merge pull request #4399 from MrPetovan/task/3878-move-include-bbcode-to-src

Move include/bbcode to src/ part 1 : Everything but bbcode()
This commit is contained in:
Tobias Diekershoff 2018-02-07 07:18:39 +01:00 committed by GitHub
commit 85c8bf0228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 1615 additions and 1505 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/** @file boot.php /**
* * @file_tag_unsave_file boot.php
* This file defines some global constants and includes the central App class. * This file defines some global constants and includes the central App class.
*/ */
@ -24,11 +24,13 @@ use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
require_once 'include/text.php'; require_once 'include/text.php';
@ -232,47 +234,51 @@ define('CP_USERS_AND_GLOBAL', 2);
/** /**
* @name Protocols * @name Protocols
* @deprecated since version 3.6
* @see Conversation
* *
* Different protocols that we are storing * Different protocols that we are storing
* @{ * @{
*/ */
define('PROTOCOL_UNKNOWN', 0); define('PROTOCOL_UNKNOWN' , Conversation::PROTOCOL_UNKNOWN);
define('PROTOCOL_DFRN', 1); define('PROTOCOL_DFRN' , Conversation::PROTOCOL_DFRN);
define('PROTOCOL_DIASPORA', 2); define('PROTOCOL_DIASPORA' , Conversation::PROTOCOL_DIASPORA);
define('PROTOCOL_OSTATUS_SALMON', 3); define('PROTOCOL_OSTATUS_SALMON' , Conversation::PROTOCOL_OSTATUS_SALMON);
define('PROTOCOL_OSTATUS_FEED', 4); // Deprecated define('PROTOCOL_OSTATUS_FEED' , Conversation::PROTOCOL_OSTATUS_FEED); // Deprecated
define('PROTOCOL_GS_CONVERSATION', 5); // Deprecated define('PROTOCOL_GS_CONVERSATION', Conversation::PROTOCOL_GS_CONVERSATION); // Deprecated
define('PROTOCOL_SPLITTED_CONV', 6); define('PROTOCOL_SPLITTED_CONV' , Conversation::PROTOCOL_SPLITTED_CONV);
/** /**
* @} * @}
*/ */
/** /**
* @name Network * @name Network constants
* @deprecated since version 3.6
* @see Protocol
* *
* Network and protocol family types * Network and protocol family types
* @{ * @{
*/ */
define('NETWORK_DFRN', 'dfrn'); // Friendica, Mistpark, other DFRN implementations define('NETWORK_DFRN' , Protocol::DFRN); // Friendica, Mistpark, other DFRN implementations
define('NETWORK_ZOT', 'zot!'); // Zot! - Currently unsupported define('NETWORK_ZOT' , Protocol::ZOT); // Zot! - Currently unsupported
define('NETWORK_OSTATUS', 'stat'); // GNU-social, Pleroma, Mastodon, other OStatus implementations define('NETWORK_OSTATUS' , Protocol::OSTATUS); // GNU-social, Pleroma, Mastodon, other OStatus implementations
define('NETWORK_FEED', 'feed'); // RSS/Atom feeds with no known "post/notify" protocol define('NETWORK_FEED' , Protocol::FEED); // RSS/Atom feeds with no known "post/notify" protocol
define('NETWORK_DIASPORA', 'dspr'); // Diaspora define('NETWORK_DIASPORA' , Protocol::DIASPORA); // Diaspora
define('NETWORK_MAIL', 'mail'); // IMAP/POP define('NETWORK_MAIL' , Protocol::MAIL); // IMAP/POP
define('NETWORK_FACEBOOK', 'face'); // Facebook API define('NETWORK_FACEBOOK' , Protocol::FACEBOOK); // Facebook API
define('NETWORK_LINKEDIN', 'lnkd'); // LinkedIn define('NETWORK_LINKEDIN' , Protocol::LINKEDIN); // LinkedIn
define('NETWORK_XMPP', 'xmpp'); // XMPP - Currently unsupported define('NETWORK_XMPP' , Protocol::XMPP); // XMPP - Currently unsupported
define('NETWORK_MYSPACE', 'mysp'); // MySpace - Currently unsupported define('NETWORK_MYSPACE' , Protocol::MYSPACE); // MySpace - Currently unsupported
define('NETWORK_GPLUS', 'goog'); // Google+ define('NETWORK_GPLUS' , Protocol::GPLUS); // Google+
define('NETWORK_PUMPIO', 'pump'); // pump.io define('NETWORK_PUMPIO' , Protocol::PUMPIO); // pump.io
define('NETWORK_TWITTER', 'twit'); // Twitter define('NETWORK_TWITTER' , Protocol::TWITTER); // Twitter
define('NETWORK_DIASPORA2', 'dspc'); // Diaspora connector define('NETWORK_DIASPORA2', Protocol::DIASPORA2); // Diaspora connector
define('NETWORK_STATUSNET', 'stac'); // Statusnet connector define('NETWORK_STATUSNET', Protocol::STATUSNET); // Statusnet connector
define('NETWORK_APPNET', 'apdn'); // app.net - Dead protocol define('NETWORK_APPNET' , Protocol::APPNET); // app.net - Dead protocol
define('NETWORK_NEWS', 'nntp'); // Network News Transfer Protocol - Currently unsupported define('NETWORK_NEWS' , Protocol::NEWS); // Network News Transfer Protocol - Currently unsupported
define('NETWORK_ICALENDAR', 'ical'); // iCalendar - Currently unsupported define('NETWORK_ICALENDAR', Protocol::ICALENDAR); // iCalendar - Currently unsupported
define('NETWORK_PNUT', 'pnut'); // pnut.io - Currently unsupported define('NETWORK_PNUT' , Protocol::PNUT); // pnut.io - Currently unsupported
define('NETWORK_PHANTOM', 'unkn'); // Place holder define('NETWORK_PHANTOM' , Protocol::PHANTOM); // Place holder
/** /**
* @} * @}
*/ */

View File

@ -165,7 +165,7 @@ line
code</code></td> code</code></td>
</tr> </tr>
<tr> <tr>
<td>[code=php]function text_highlight($s,$lang)[/code]</td> <td>[code=php]function text_highlight($s,$lang)[/code]<sup><a href="#supported-code">1</a></sup></td>
<td><code><div class="hl-main"><ol class="hl-main"><li><span class="hl-code">&nbsp;</span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">text_highlight</span><span class="hl-brackets">(</span><span class="hl-var">$s</span><span class="hl-code">,</span><span class="hl-var">$lang</span><span class="hl-brackets">)</span></li></ol></div></code></td> <td><code><div class="hl-main"><ol class="hl-main"><li><span class="hl-code">&nbsp;</span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">text_highlight</span><span class="hl-brackets">(</span><span class="hl-var">$s</span><span class="hl-code">,</span><span class="hl-var">$lang</span><span class="hl-brackets">)</span></li></ol></div></code></td>
</tr> </tr>
<tr> <tr>
@ -208,6 +208,27 @@ code</code></td>
</tr> </tr>
</table> </table>
<a name="supported-code">1</a>: Supported language parameter values for code highlighting:
- abap
- avrc
- cpp
- css
- diff
- dtd
- html
- java
- javascript
- js
- mysql
- perl
- php
- python
- ruby
- sh
- sql
- vbscript
- xml
### Titles ### Titles
<table class="bbcodes"> <table class="bbcodes">

View File

@ -2,12 +2,14 @@
/** /**
* @file include/acl_selectors.php * @file include/acl_selectors.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\GContact; use Friendica\Model\GContact;
@ -248,7 +250,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
} }
if ($privmail) { if ($privmail) {
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false); $trimmed = Protocol::formatMention($rr['url'], $rr['name']);
} else { } else {
$trimmed = mb_substr($rr['name'],0,20); $trimmed = mb_substr($rr['name'],0,20);
} }

View File

@ -2751,7 +2751,7 @@ function api_get_entitities(&$text, $bbcode)
return []; return [];
} }
$bbcode = bb_CleanPictureLinks($bbcode); $bbcode = BBCode::cleanPictureLinks($bbcode);
// Change pure links in text to bbcode uris // Change pure links in text to bbcode uris
$bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode); $bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
@ -5171,7 +5171,7 @@ function api_clean_plain_items($Text)
{ {
$include_entities = strtolower(x($_REQUEST, 'include_entities') ? $_REQUEST['include_entities'] : "false"); $include_entities = strtolower(x($_REQUEST, 'include_entities') ? $_REQUEST['include_entities'] : "false");
$Text = bb_CleanPictureLinks($Text); $Text = BBCode::cleanPictureLinks($Text);
$URLSearchString = "^\[\]"; $URLSearchString = "^\[\]";
$Text = preg_replace("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text); $Text = preg_replace("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);

View File

@ -76,10 +76,10 @@ function diaspora2bb($s) {
$s = preg_replace('/([^\]=]|^)(https?\:\/\/)([a-zA-Z0-9:\/\-?&;.=_~#%$!+,@]+(?<!,))/ism', '$1[url=$2$3]$2$3[/url]', $s); $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 = 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 = BBCode::pregReplaceInTag('/\[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 = BBCode::pregReplaceInTag('/\[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 = BBCode::pregReplaceInTag('/\[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?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism' , '[vimeo]$1[/vimeo]' , 'url', $s);
// remove duplicate adjacent code tags // remove duplicate adjacent code tags
$s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s); $s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s);
@ -130,7 +130,7 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) {
// Since Diaspora is creating a summary for links, this function removes them before posting // Since Diaspora is creating a summary for links, this function removes them before posting
if ($fordiaspora) { if ($fordiaspora) {
$Text = bb_remove_share_information($Text); $Text = BBCode::removeShareInformation($Text);
} }
/** /**

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector; use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -72,7 +73,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
$newbody = ''; $newbody = '';
$cnt = 1; $cnt = 1;
$pos = get_bb_tag_pos($origbody, 'url', 1); $pos = BBCode::getTagPosition($origbody, 'url', 0);
while ($pos !== false && $cnt < 1000) { while ($pos !== false && $cnt < 1000) {
$search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is'; $search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is';
@ -90,7 +91,8 @@ function item_redir_and_replace_images($body, $images, $cid) {
$newbody .= $subject; $newbody .= $subject;
$cnt++; $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; $newbody .= $origbody;
@ -347,7 +349,7 @@ function localize_item(&$item) {
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is"; $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
if (preg_match($photo_pattern, $item['body'])) { if (preg_match($photo_pattern, $item['body'])) {
$photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]'; $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 // add sparkle links to appropriate permalinks

View File

@ -2,9 +2,11 @@
/** /**
* @file mod/display.php * @file mod/display.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -171,7 +173,7 @@ function display_fetchauthor($a, $item) {
$profiledata["photo"] = $matches[1]; $profiledata["photo"] = $matches[1];
} }
$profiledata["nickname"] = $profiledata["name"]; $profiledata["nickname"] = $profiledata["name"];
$profiledata["network"] = GetProfileUsername($profiledata["url"], "", false, true); $profiledata["network"] = Protocol::matchByProfileUrl($profiledata["url"]);
$profiledata["address"] = ""; $profiledata["address"] = "";
$profiledata["about"] = ""; $profiledata["about"] = "";

File diff suppressed because it is too large Load Diff

View File

@ -34,4 +34,41 @@ class Plaintext
return $msg; return $msg;
} }
/**
* Returns the character positions of the provided boundaries, optionally skipping a number of first occurrences
*
* @param string $text Text to search
* @param string $open Left boundary
* @param string $close Right boundary
* @param int $occurrences Number of first occurrences to skip
* @return boolean|array
*/
public static function getBoundariesPosition($text, $open, $close, $occurrences = 0)
{
if ($occurrences < 0) {
$occurrences = 0;
}
$start_pos = -1;
for ($i = 0; $i <= $occurrences; $i++) {
if ($start_pos !== false) {
$start_pos = strpos($text, $open, $start_pos + 1);
}
}
if ($start_pos === false) {
return false;
}
$end_pos = strpos($text, $close, $start_pos);
if ($end_pos === false) {
return false;
}
$res = ['start' => $start_pos, 'end' => $end_pos];
return $res;
}
} }

124
src/Core/Protocol.php Normal file
View File

@ -0,0 +1,124 @@
<?php
/*
* @file src/Core/Protocol.php
*/
namespace Friendica\Core;
use Friendica\Util\Network;
/**
* Manage compatibility with federated networks
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class Protocol
{
const DFRN = 'dfrn'; // Friendica, Mistpark, other DFRN implementations
const DIASPORA = 'dspr'; // Diaspora
const DIASPORA2 = 'dspc'; // Diaspora connector
const STATUSNET = 'stac'; // Statusnet connector
const OSTATUS = 'stat'; // GNU-social, Pleroma, Mastodon, other OStatus implementations
const FEED = 'feed'; // RSS/Atom feeds with no known "post/notify" protocol
const MAIL = 'mail'; // IMAP/POP
const XMPP = 'xmpp'; // XMPP - Currently unsupported
const FACEBOOK = 'face'; // Facebook API
const LINKEDIN = 'lnkd'; // LinkedIn
const MYSPACE = 'mysp'; // MySpace - Currently unsupported
const GPLUS = 'goog'; // Google+
const PUMPIO = 'pump'; // pump.io
const TWITTER = 'twit'; // Twitter
const APPNET = 'apdn'; // app.net - Dead protocol
const NEWS = 'nntp'; // Network News Transfer Protocol - Currently unsupported
const ICALENDAR = 'ical'; // iCalendar - Currently unsupported
const PNUT = 'pnut'; // pnut.io - Currently unsupported
const ZOT = 'zot!'; // Zot! - Currently unsupported
const PHANTOM = 'unkn'; // Place holder
/**
* Returns the address string for the provided profile URL
*
* @param string $profile_url
* @return string
* @throws Exception
*/
public static function getAddrFromProfileUrl($profile_url)
{
$network = self::matchByProfileUrl($profile_url, $matches);
if ($network === self::PHANTOM) {
throw new Exception('Unknown network for profile URL: ' . $profile_url);
}
$addr = $matches[2] . '@' . $matches[1];
return $addr;
}
/**
* Guesses the network from a profile URL
*
* @param string $profile_url
* @param array $matches preg_match return array: [0] => Full match [1] => hostname [2] => username
* @return type
*/
public static function matchByProfileUrl($profile_url, &$matches = [])
{
if (preg_match('=https?://(twitter\.com)/(.*)=ism', $profile_url, $matches)) {
return self::TWITTER;
}
if (preg_match('=https?://(alpha\.app\.net)/(.*)=ism', $profile_url, $matches)) {
return self::APPNET;
}
if (preg_match('=https?://(plus\.google\.com)/(.*)=ism', $profile_url, $matches)) {
return self::GPLUS;
}
if (preg_match('=https?://(.*)/profile/(.*)=ism', $profile_url, $matches)) {
return self::DFRN;
}
if (preg_match('=https?://(.*)/u/(.*)=ism', $profile_url, $matches)) {
return self::DIASPORA;
}
if (preg_match('=https?://(.*)/channel/(.*)=ism', $profile_url, $matches)) {
// RedMatrix/Hubzilla is identified as Diaspora - friendica can't connect directly to it
return self::DIASPORA;
}
if (preg_match('=https?://(.*)/user/(.*)=ism', $profile_url, $matches)) {
$statusnet_host = $matches[1];
$statusnet_user = $matches[2];
$UserData = Network::fetchUrl('http://' . $statusnet_host . '/api/users/show.json?user_id=' . $statusnet_user);
$user = json_decode($UserData);
if ($user) {
$matches[2] = $user->screen_name;
return self::STATUSNET;
}
}
// pumpio (http://host.name/user)
if (preg_match('=https?://([\.\w]+)/([\.\w]+)$=ism', $profile_url, $matches)) {
return self::PUMPIO;
}
return self::PHANTOM;
}
/**
* Returns a formatted mention from a profile URL and a display name
*
* @param string $profile_url
* @param string $display_name
* @return string
*/
public static function formatMention($profile_url, $display_name)
{
return $display_name . '(' . self::getAddrFromProfileUrl($profile_url) . ')';
}
}

View File

@ -11,6 +11,14 @@ require_once "include/dba.php";
class Conversation class Conversation
{ {
const PROTOCOL_UNKNOWN = 0;
const PROTOCOL_DFRN = 1;
const PROTOCOL_DIASPORA = 2;
const PROTOCOL_OSTATUS_SALMON = 3;
const PROTOCOL_OSTATUS_FEED = 4; // Deprecated
const PROTOCOL_GS_CONVERSATION = 5; // Deprecated
const PROTOCOL_SPLITTED_CONV = 6;
/** /**
* @brief Store the conversation data * @brief Store the conversation data
* *

View File

@ -10,6 +10,7 @@ namespace Friendica\Protocol;
use Friendica\App; use Friendica\App;
use Friendica\Content\OEmbed; use Friendica\Content\OEmbed;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -29,8 +30,6 @@ use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Content\Text\BBCode;
use dba; use dba;
use DOMDocument; use DOMDocument;
use DOMXPath; use DOMXPath;
@ -929,7 +928,7 @@ class DFRN
} }
// Remove the abstract element. It is only locally important. // Remove the abstract element. It is only locally important.
$body = remove_abstract($body); $body = BBCode::stripAbstract($body);
if ($type == 'html') { if ($type == 'html') {
$htmlbody = $body; $htmlbody = $body;

View File

@ -6,7 +6,9 @@
* Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus> * Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus>
* *
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\Text\Plaintext;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
@ -15,7 +17,6 @@ use Friendica\Core\PConfig;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Object\Image;
$frio = "view/theme/frio"; $frio = "view/theme/frio";
@ -90,10 +91,8 @@ function frio_uninstall()
*/ */
function frio_item_photo_links(App $a, &$body_info) function frio_item_photo_links(App $a, &$body_info)
{ {
$phototypes = Image::supportedTypes(); $occurence = 0;
$occurence = 1; $p = Plaintext::getBoundariesPosition($body_info['html'], "<a", ">");
$p = bb_find_open_close($body_info['html'], "<a", ">");
while ($p !== false && ($occurence++ < 500)) { while ($p !== false && ($occurence++ < 500)) {
$link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']); $link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
$matches = []; $matches = [];
@ -112,7 +111,7 @@ function frio_item_photo_links(App $a, &$body_info)
$body_info['html'] = str_replace($link, $newlink, $body_info['html']); $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);
} }
} }
@ -302,7 +301,7 @@ function frio_acl_lookup(App $a, &$results)
$search_txt = dbesc(protect_sprintf(preg_quote($results["search"]))); $search_txt = dbesc(protect_sprintf(preg_quote($results["search"])));
$searching = true; $searching = true;
} }
$sql_extra = ''; $sql_extra = '';
if ($searching) { if ($searching) {
$sql_extra .= " AND (`attag` LIKE '%%" . dbesc($search_txt) . "%%' OR `name` LIKE '%%" . dbesc($search_txt) . "%%' OR `nick` LIKE '%%" . dbesc($search_txt) . "%%') "; $sql_extra .= " AND (`attag` LIKE '%%" . dbesc($search_txt) . "%%' OR `name` LIKE '%%" . dbesc($search_txt) . "%%' OR `nick` LIKE '%%" . dbesc($search_txt) . "%%') ";

View File

@ -10,9 +10,9 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\Text\Plaintext;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Object\Image;
function frost_init(App $a) { function frost_init(App $a) {
$a->videowidth = 400; $a->videowidth = 400;
@ -49,10 +49,8 @@ function frost_uninstall() {
function frost_item_photo_links(App $a, &$body_info) function frost_item_photo_links(App $a, &$body_info)
{ {
$phototypes = Image::supportedTypes(); $occurence = 0;
$p = Plaintext::getBoundariesPosition($body_info['html'], '<a', '>');
$occurence = 1;
$p = bb_find_open_close($body_info['html'], "<a", ">");
while($p !== false && ($occurence++ < 500)) { while($p !== false && ($occurence++ < 500)) {
$link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']); $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'], "<a", ">", $occurence); $p = Plaintext::getBoundariesPosition($body_info['html'], '<a', '>', $occurence);
} }
} }