X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItemContent.php;h=136323385c9c3355d1857ca1f909125e76a499b4;hb=08edeae2f996854d0028d0f73a08a1f3ee7741da;hp=21dbd34d0a4feb7a7e62d5631c51992123933056;hpb=37e5272f921bfe4cac111dc69867bce90def32cf;p=friendica.git diff --git a/src/Model/ItemContent.php b/src/Model/ItemContent.php index 21dbd34d0a..136323385c 100644 --- a/src/Model/ItemContent.php +++ b/src/Model/ItemContent.php @@ -6,15 +6,11 @@ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Content\Text; use Friendica\Core\PConfig; +use Friendica\Core\Protocol; -require_once 'boot.php'; -require_once 'include/items.php'; -require_once 'include/text.php'; - -class ItemContent extends BaseObject +class ItemContent { /** * @brief Convert a message into plaintext for connectors to other networks @@ -25,9 +21,10 @@ class ItemContent extends BaseObject * @param int $htmlmode This controls the behavior of the BBCode conversion * @param string $target_network Name of the network where the post should go to. * - * @see \Friendica\Content\Text\BBCode::getAttachedData - * * @return array Same array structure than \Friendica\Content\Text\BBCode::getAttachedData + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @see \Friendica\Content\Text\BBCode::getAttachedData + * */ public static function getPlaintextPost($item, $limit = 0, $includedlinks = false, $htmlmode = 2, $target_network = '') { @@ -68,14 +65,13 @@ class ItemContent extends BaseObject } else {// Try to guess the correct target network switch ($htmlmode) { case 8: - $abstract = Text\BBCode::getAbstract($item['body'], NETWORK_TWITTER); + $abstract = Text\BBCode::getAbstract($item['body'], Protocol::TWITTER); break; + case 7: - $abstract = Text\BBCode::getAbstract($item['body'], NETWORK_STATUSNET); - break; - case 6: - $abstract = Text\BBCode::getAbstract($item['body'], NETWORK_APPNET); + $abstract = Text\BBCode::getAbstract($item['body'], Protocol::STATUSNET); break; + default: // We don't know the exact target. // We fetch an abstract since there is a posting limit. if ($limit > 0) { @@ -93,7 +89,7 @@ class ItemContent extends BaseObject } } - $html = Text\BBCode::convert($post['text'] . $post['after'], false, $htmlmode); + $html = Text\BBCode::convert($post['text'] . ($post['after'] ?? ''), false, $htmlmode); $msg = Text\HTML::toPlaintext($html, 0, true); $msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8')); @@ -102,7 +98,7 @@ class ItemContent extends BaseObject if ($post['type'] == 'link') { $link = $post['url']; } elseif ($post['type'] == 'text') { - $link = $post['url']; + $link = $post['url'] ?? ''; } elseif ($post['type'] == 'video') { $link = $post['url']; } elseif ($post['type'] == 'photo') {