]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Use a constant for the avatar base path
[friendica.git] / src / Model / Item.php
index 3ff7909aa1729f3a66ae83827f4ad30b0de5ff02..496757910ae367a43a006b32513d1606fbdfd06c 100644 (file)
@@ -2709,7 +2709,7 @@ class Item
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @todo Remove reference, simply return "rendered-html" and "rendered-hash"
         */
-       public static function putInCache(&$item)
+       private static function putInCache(&$item)
        {
                // Save original body to prevent addons to modify it
                $body = $item['body'];
@@ -2722,8 +2722,6 @@ class Item
                        || $rendered_hash != hash('md5', BBCode::VERSION . '::' . $body)
                        || DI::config()->get('system', 'ignore_cache')
                ) {
-                       self::addRedirToImageTags($item);
-
                        $item['rendered-html'] = BBCode::convertForUriId($item['uri-id'], $item['body']);
                        $item['rendered-hash'] = hash('md5', BBCode::VERSION . '::' . $body);
 
@@ -2748,31 +2746,6 @@ class Item
                $item['body'] = $body;
        }
 
-       /**
-        * Find any non-embedded images in private items and add redir links to them
-        *
-        * @param array &$item The field array of an item row
-        */
-       private static function addRedirToImageTags(array &$item)
-       {
-               $app = DI::app();
-
-               $matches = [];
-               $cnt = preg_match_all('|\[img\](http[^\[]*?/photo/[a-fA-F0-9]+?(-[0-9]\.[\w]+?)?)\[\/img\]|', $item['body'], $matches, PREG_SET_ORDER);
-               if ($cnt) {
-                       foreach ($matches as $mtch) {
-                               if (strpos($mtch[1], '/redir') !== false) {
-                                       continue;
-                               }
-
-                               if ((local_user() == $item['uid']) && ($item['private'] == self::PRIVATE) && ($item['contact-id'] != $app->getContactId()) && ($item['network'] == Protocol::DFRN)) {
-                                       $img_url = 'redir/' . $item['contact-id'] . '?url=' . urlencode($mtch[1]);
-                                       $item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']);
-                               }
-                       }
-               }
-       }
-
        /**
         * Given an item array, convert the body element from bbcode to html and add smilie icons.
         * If attach is true, also add icons for item attachments.
@@ -3227,6 +3200,12 @@ class Item
                                'orig_title' => DI::l10n()->t('View on separate page'),
                        ];
 
+                       if (!empty($plink) && ($item['private'] == self::PRIVATE)) {
+                               $author = ['uid' => 0, 'id' => $item['author-id'],
+                                       'network' => $item['author-network'], 'url' => $item['author-link']];
+                               $plink = Contact::magicLinkByContact($author, $plink);
+                       }
+
                        if (!empty($plink)) {
                                $ret['href'] = DI::baseUrl()->remove($plink);
                                $ret['title'] = DI::l10n()->t('Link to source');