X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FText%2FBBCode.php;h=8187521582ff253a665b7acd45031d7c3fd54c66;hb=07cea24430420cb0ac2b1d8f870d7292002c7faf;hp=760247f2cb6bd22dce37535f08ea5a9b686adb87;hpb=b0967ffd02ba9b4b1c1d5062fa48a83b1d32843a;p=friendica.git diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 760247f2cb..8187521582 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -24,6 +24,7 @@ use Friendica\Model\Event; use Friendica\Model\Photo; use Friendica\Network\Probe; use Friendica\Object\Image; +use Friendica\Protocol\Activity; use Friendica\Util\Map; use Friendica\Util\Network; use Friendica\Util\ParseUrl; @@ -244,7 +245,7 @@ class BBCode extends BaseObject */ $has_title = !empty($item['title']); - $plink = defaults($item, 'plink', ''); + $plink = $item['plink'] ?? ''; $post = self::getAttachmentData($body); // Get all linked images with alternative image description @@ -276,7 +277,7 @@ class BBCode extends BaseObject if (preg_match_all("(\[url=(.*?)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\])ism", $body, $pictures, PREG_SET_ORDER)) { if ((count($pictures) == 1) && !$has_title) { - if (!empty($item['object-type']) && ($item['object-type'] == ACTIVITY_OBJ_IMAGE)) { + if (!empty($item['object-type']) && ($item['object-type'] == Activity::OBJ_IMAGE)) { // Replace the preview picture with the real picture $url = str_replace('-1.', '-0.', $pictures[0][2]); $data = ['url' => $url, 'type' => 'photo']; @@ -610,7 +611,7 @@ class BBCode extends BaseObject throw new Exception('OEmbed is disabled for this attachment.'); } } catch (Exception $e) { - $data['title'] = defaults($data, 'title', $data['url']); + $data['title'] = ($data['title'] ?? '') ?: $data['url']; if ($simplehtml != 4) { $return = sprintf('
', $data['type']); @@ -645,7 +646,7 @@ class BBCode extends BaseObject } } - return trim(defaults($data, 'text', '') . ' ' . $return . ' ' . defaults($data, 'after', '')); + return trim(($data['text'] ?? '') . ' ' . $return . ' ' . ($data['after'] ?? '')); } public static function removeShareInformation($Text, $plaintext = false, $nolink = false) @@ -655,10 +656,10 @@ class BBCode extends BaseObject if (!$data) { return $Text; } elseif ($nolink) { - return $data['text'] . defaults($data, 'after', ''); + return $data['text'] . ($data['after'] ?? ''); } - $title = htmlentities(defaults($data, 'title', ''), ENT_QUOTES, 'UTF-8', false); + $title = htmlentities($data['title'] ?? '', ENT_QUOTES, 'UTF-8', false); $text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false); if ($plaintext || (($title != '') && strstr($text, $title))) { $data['title'] = $data['url']; @@ -941,7 +942,7 @@ class BBCode extends BaseObject $attributes = []; foreach(['author', 'profile', 'avatar', 'link', 'posted'] as $field) { preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches); - $attributes[$field] = html_entity_decode(defaults($matches, 2, ''), ENT_QUOTES, 'UTF-8'); + $attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8'); } // We only call this so that a previously unknown contact can be added. @@ -960,11 +961,11 @@ class BBCode extends BaseObject Contact::getIdForURL($attributes['profile'], 0, true, $default); $author_contact = Contact::getDetailsByURL($attributes['profile']); - $author_contact['addr'] = defaults($author_contact, 'addr' , Protocol::getAddrFromProfileUrl($attributes['profile'])); + $author_contact['addr'] = ($author_contact['addr'] ?? '') ?: Protocol::getAddrFromProfileUrl($attributes['profile']); - $attributes['author'] = defaults($author_contact, 'name' , $attributes['author']); - $attributes['avatar'] = defaults($author_contact, 'micro', $attributes['avatar']); - $attributes['profile'] = defaults($author_contact, 'url' , $attributes['profile']); + $attributes['author'] = ($author_contact['name'] ?? '') ?: $attributes['author']; + $attributes['avatar'] = ($author_contact['micro'] ?? '') ?: $attributes['avatar']; + $attributes['profile'] = ($author_contact['url'] ?? '') ?: $attributes['profile']; if ($attributes['avatar']) { $attributes['avatar'] = ProxyUtils::proxifyUrl($attributes['avatar'], false, ProxyUtils::SIZE_THUMB); @@ -1241,7 +1242,7 @@ class BBCode extends BaseObject $try_oembed_callback = function ($match) { $url = $match[1]; - $title = defaults($match, 2, null); + $title = $match[2] ?? null; try { $return = OEmbed::getHTML($url, $title);