]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
The user isn't used in the template
[friendica.git] / include / conversation.php
index 24bb7434cab75d8d75536cd29d4b276cd458e80e..6cb6a78e63f3d02e7da80dc1417ac6aa0352b6e5 100644 (file)
@@ -47,91 +47,6 @@ use Friendica\Util\Strings;
 use Friendica\Util\Temporal;
 use Friendica\Util\XML;
 
-function item_extract_images($body) {
-
-       $saved_image = [];
-       $orig_body = $body;
-       $new_body = '';
-
-       $cnt = 0;
-       $img_start = strpos($orig_body, '[img');
-       $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
-       $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
-       while (($img_st_close !== false) && ($img_end !== false)) {
-
-               $img_st_close++; // make it point to AFTER the closing bracket
-               $img_end += $img_start;
-
-               if (!strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
-                       // This is an embedded image
-
-                       $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
-                       $new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
-
-                       $cnt++;
-               } else {
-                       $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
-               }
-
-               $orig_body = substr($orig_body, $img_end + strlen('[/img]'));
-
-               if ($orig_body === false) {
-                       // in case the body ends on a closing image tag
-                       $orig_body = '';
-               }
-
-               $img_start = strpos($orig_body, '[img');
-               $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
-               $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
-       }
-
-       $new_body = $new_body . $orig_body;
-
-       return ['body' => $new_body, 'images' => $saved_image];
-}
-
-function item_redir_and_replace_images($body, $images, $cid) {
-
-       $origbody = $body;
-       $newbody = '';
-
-       $cnt = 1;
-       $pos = BBCode::getTagPosition($origbody, 'url', 0);
-       while ($pos !== false && $cnt < 1000) {
-
-               $search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is';
-               $replace = '[url=' . DI::baseUrl() . '/redir/' . $cid
-                                  . '?url=' . '$1' . '][!#saved_image' . '$2' .'#!][/url]';
-
-               $newbody .= substr($origbody, 0, $pos['start']['open']);
-               $subject = substr($origbody, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
-               $origbody = substr($origbody, $pos['end']['close']);
-               if ($origbody === false) {
-                       $origbody = '';
-               }
-
-               $subject = preg_replace($search, $replace, $subject);
-               $newbody .= $subject;
-
-               $cnt++;
-               // Isn't this supposed to use $cnt value for $occurrences? - @MrPetovan
-               $pos = BBCode::getTagPosition($origbody, 'url', 0);
-       }
-       $newbody .= $origbody;
-
-       $cnt = 0;
-       foreach ($images as $image) {
-               /*
-                * We're depending on the property of 'foreach' (specified on the PHP website) that
-                * it loops over the array starting from the first element and going sequentially
-                * to the last element.
-                */
-               $newbody = str_replace('[!#saved_image' . $cnt . '#!]', '[img]' . $image . '[/img]', $newbody);
-               $cnt++;
-       }
-       return $newbody;
-}
-
 /**
  * Render actions localized
  *
@@ -141,11 +56,6 @@ function item_redir_and_replace_images($body, $images, $cid) {
  */
 function localize_item(&$item)
 {
-       $extracted = item_extract_images($item['body']);
-       if ($extracted['images']) {
-               $item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
-       }
-
        /// @todo The following functionality needs to be cleaned up.
        if (!empty($item['verb'])) {
                $activity = DI::activity();
@@ -260,13 +170,6 @@ function localize_item(&$item)
                }
        }
 
-       // add zrl's to public images
-       $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
-       if (preg_match($photo_pattern, $item['body'])) {
-               $photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' , true) . '][img' . '$4' . ']h' . '$5'  . '[/img][/url]';
-               $item['body'] = BBCode::pregReplaceInTag($photo_pattern, $photo_replace, 'url', $item['body']);
-       }
-
        // add sparkle links to appropriate permalinks
        // Only create a redirection to a magic link when logged in
        if (!empty($item['plink']) && Session::isAuthenticated()) {
@@ -369,7 +272,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
 
        $ssl_state = (local_user() ? true : false);
 
-       $profile_owner = 0;
        $live_update_div = '';
 
        $blocklist = conv_get_blocklist();
@@ -378,7 +280,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
 
        if ($mode === 'network') {
                $items = conversation_add_children($items, false, $order, $uid);
-               $profile_owner = local_user();
                if (!$update) {
                        /*
                         * The special div is needed for liveUpdate to kick in for this page.
@@ -405,7 +306,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                }
        } elseif ($mode === 'profile') {
                $items = conversation_add_children($items, false, $order, $uid);
-               $profile_owner = $a->profile['uid'];
 
                if (!$update) {
                        $tab = 'posts';
@@ -419,13 +319,12 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                 */
 
                                $live_update_div = '<div id="live-profile"></div>' . "\r\n"
-                                       . "<script> var profile_uid = " . $a->profile['uid']
+                                       . "<script> var profile_uid = " . $uid
                                        . "; var netargs = '?f='; </script>\r\n";
                        }
                }
        } elseif ($mode === 'notes') {
                $items = conversation_add_children($items, false, $order, local_user());
-               $profile_owner = local_user();
 
                if (!$update) {
                        $live_update_div = '<div id="live-notes"></div>' . "\r\n"
@@ -434,7 +333,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                }
        } elseif ($mode === 'display') {
                $items = conversation_add_children($items, false, $order, $uid);
-               $profile_owner = $a->profile['uid'];
 
                if (!$update) {
                        $live_update_div = '<div id="live-display"></div>' . "\r\n"
@@ -443,7 +341,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                }
        } elseif ($mode === 'community') {
                $items = conversation_add_children($items, true, $order, $uid);
-               $profile_owner = 0;
 
                if (!$update) {
                        $live_update_div = '<div id="live-community"></div>' . "\r\n"
@@ -454,7 +351,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                }
        } elseif ($mode === 'contacts') {
                $items = conversation_add_children($items, false, $order, $uid);
-               $profile_owner = 0;
 
                if (!$update) {
                        $live_update_div = '<div id="live-contact"></div>' . "\r\n"
@@ -465,7 +361,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                $live_update_div = '<div id="live-search"></div>' . "\r\n";
        }
 
-       $page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
+       $page_dropping = ((local_user() && local_user() == $uid) ? true : false);
 
        if (!$update) {
                $_SESSION['return_path'] = DI::args()->getQueryString();
@@ -624,7 +520,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                        'indent' => '',
                                        'owner_name' => '',
                                        'owner_url' => '',
-                                       'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']),
+                                       'owner_photo' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['owner-link'], $item['uid'], Proxy::SIZE_THUMB)),
                                        'plink' => Item::getPlink($item),
                                        'edpost' => false,
                                        'isstarred' => 'unstarred',
@@ -703,7 +599,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                '$remove' => DI::l10n()->t('remove'),
                '$mode' => $mode,
                '$update' => $update,
-               '$user' => $a->user,
                '$threads' => $threads,
                '$dropping' => ($page_dropping ? DI::l10n()->t('Delete Selected Items') : False),
        ]);
@@ -1238,7 +1133,6 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
                '$preview'      => DI::l10n()->t('Preview'),
                '$jotplugins'   => $jotplugins,
                '$notes_cid'    => $notes_cid,
-               '$sourceapp'    => DI::l10n()->t($a->sourcename),
                '$cancel'       => DI::l10n()->t('Cancel'),
                '$rand_num'     => Crypto::randomDigits(12),