]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/ItemContent.php
Merge pull request #8265 from nupplaphil/task/add_license
[friendica.git] / src / Model / ItemContent.php
index 25ae6b84241e3cc4fac78e77dd3f24402527f6ae..c6d3e82944047c54636b9a4c555ebef0c9d22aee 100644 (file)
@@ -1,20 +1,34 @@
 <?php
-
 /**
- * @file src/Model/ItemContent.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  */
 
 namespace Friendica\Model;
 
-use Friendica\BaseObject;
 use Friendica\Content\Text;
-use Friendica\Core\PConfig;
 use Friendica\Core\Protocol;
+use Friendica\DI;
 
-class ItemContent extends BaseObject
+class ItemContent
 {
        /**
-        * @brief Convert a message into plaintext for connectors to other networks
+        * Convert a message into plaintext for connectors to other networks
         *
         * @param array  $item           The message array that is about to be posted
         * @param int    $limit          The maximum number of characters when posting to that network
@@ -22,9 +36,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 = '')
        {
@@ -89,7 +104,7 @@ class ItemContent extends BaseObject
                        }
                }
 
-               $html = Text\BBCode::convert($post['text'] . defaults($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'));
 
@@ -98,7 +113,7 @@ class ItemContent extends BaseObject
                        if ($post['type'] == 'link') {
                                $link = $post['url'];
                        } elseif ($post['type'] == 'text') {
-                               $link = defaults($post, 'url', '');
+                               $link = $post['url'] ?? '';
                        } elseif ($post['type'] == 'video') {
                                $link = $post['url'];
                        } elseif ($post['type'] == 'photo') {
@@ -158,7 +173,7 @@ class ItemContent extends BaseObject
                                        $post['url'] = $item['plink'];
                                } elseif (strpos($item['body'], '[share') !== false) {
                                        $post['url'] = $item['plink'];
-                               } elseif (PConfig::get($item['uid'], 'system', 'no_intelligent_shortening')) {
+                               } elseif (DI::pConfig()->get($item['uid'], 'system', 'no_intelligent_shortening')) {
                                        $post['url'] = $item['plink'];
                                }
                                $msg = Text\Plaintext::shorten($msg, $limit);