X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fconversation.php;h=409d67907675ed8cf9cddec41f1f62719403dad6;hb=cabaea38ac46132963011c724d9c0b380bb5d7c0;hp=f6da5d858a963e3ade605ab3a8622988542ddcf3;hpb=91ad7936f3a4e0b241d9c193436507d2d74d8b1b;p=friendica.git diff --git a/include/conversation.php b/include/conversation.php index f6da5d858a..409d679076 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -4,10 +4,8 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Content\ContactSelector; use Friendica\Content\Feature; -use Friendica\Content\Item as ContentItem; use Friendica\Content\Pager; use Friendica\Content\Text\BBCode; use Friendica\Core\Config; @@ -18,8 +16,8 @@ use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Session; -use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\Profile; @@ -87,7 +85,7 @@ function item_redir_and_replace_images($body, $images, $cid) { while ($pos !== false && $cnt < 1000) { $search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is'; - $replace = '[url=' . System::baseUrl() . '/redir/' . $cid + $replace = '[url=' . DI::baseUrl() . '/redir/' . $cid . '?f=1&url=' . '$1' . '][!#saved_image' . '$2' .'#!][/url]'; $newbody .= substr($origbody, 0, $pos['start']['open']); @@ -141,8 +139,7 @@ function localize_item(&$item) During the further steps of the database restructuring I would like to address this issue. */ - /** @var Activity $activity */ - $activity = BaseObject::getClass(Activity::class); + $activity = DI::activity(); $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; if ($activity->match($item['verb'], Activity::LIKE) @@ -399,10 +396,9 @@ function count_descendants($item) { function visible_activity($item) { - /** @var Activity $activity */ - $activity = BaseObject::getClass(Activity::class); + $activity = DI::activity(); - if ($activity->isHidden($item['verb'])) { + if (empty($item['verb']) || $activity->isHidden($item['verb'])) { return false; } @@ -483,7 +479,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ */ $live_update_div = '
' . "\r\n" . "\r\n"; } } elseif ($mode === 'contacts') { @@ -552,7 +548,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ if (!$update) { $live_update_div = '
' . "\r\n" - . "\r\n"; } } elseif ($mode === 'search') { @@ -562,7 +558,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ $page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false); if (!$update) { - $_SESSION['return_path'] = $a->query_string; + $_SESSION['return_path'] = DI::args()->getQueryString(); } $cb = ['items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview]; @@ -668,10 +664,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ $body = Item::prepareBody($item, true, $preview); - /** @var ContentItem $contItem */ - $contItem = BaseObject::getClass(ContentItem::class); - - list($categories, $folders) = $contItem->determineCategoriesTerms($item); + list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); if (!empty($item['content-warning']) && PConfig::get(local_user(), 'system', 'disable_cw', false)) { $title = ucfirst($item['content-warning']); @@ -684,7 +677,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ 'id' => ($preview ? 'P0' : $item['id']), 'guid' => ($preview ? 'Q0' : $item['guid']), 'network' => $item['network'], - 'network_name' => ContactSelector::networkToName($item['network'], $item['author-link']), + 'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']), 'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']), 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']), 'profile_url' => $profile_link, @@ -692,7 +685,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ 'name' => $profile_name, 'sparkle' => $sparkle, 'lock' => $lock, - 'thumb' => System::removedBaseUrl(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)), + 'thumb' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)), 'title' => $title, 'body' => $body, 'tags' => $tags['tags'], @@ -712,7 +705,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ 'indent' => '', 'owner_name' => $owner_name, 'owner_url' => $owner_url, - 'owner_photo' => System::removedBaseUrl(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)), + 'owner_photo' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)), 'plink' => Item::getPlink($item), 'edpost' => false, 'isstarred' => $isstarred, @@ -785,8 +778,8 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ } $o = Renderer::replaceMacros($page_template, [ - '$baseurl' => System::baseUrl($ssl_state), - '$return_path' => $a->query_string, + '$baseurl' => DI::baseUrl()->get($ssl_state), + '$return_path' => DI::args()->getQueryString(), '$live_update' => $live_update_div, '$remove' => L10n::t('remove'), '$mode' => $mode, @@ -801,10 +794,12 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ /** * Fetch all comments from a query. Additionally set the newest resharer as thread owner. * - * @param $thread_items Database statement with thread posts + * @param array $thread_items Database statement with thread posts + * @param boolean $pinned Is the item pinned? + * * @return array items with parents and comments */ -function conversation_fetch_comments($thread_items) { +function conversation_fetch_comments($thread_items, $pinned) { $comments = []; $parentlines = []; $lineno = 0; @@ -822,6 +817,10 @@ function conversation_fetch_comments($thread_items) { $parentlines[] = $lineno; } + if ($row['gravity'] == GRAVITY_PARENT) { + $row['pinned'] = $pinned; + } + $comments[] = $row; $lineno++; } @@ -872,7 +871,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid) $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params); - $comments = conversation_fetch_comments($thread_items); + $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false); if (count($comments) != 0) { $items = array_merge($items, $comments); @@ -1025,10 +1024,7 @@ function builtin_activity_puller($item, &$conv_responses) { return; } - /** @var Activity $activity */ - $activity = BaseObject::getClass(Activity::class); - - if ($activity->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) { + if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) { $author = ['uid' => 0, 'id' => $item['author-id'], 'network' => $item['author-network'], 'url' => $item['author-link']]; $url = Contact::magicLinkByContact($author); @@ -1174,9 +1170,9 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) $geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : ''; $tpl = Renderer::getMarkupTemplate('jot-header.tpl'); - $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [ + DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [ '$newpost' => 'true', - '$baseurl' => System::baseUrl(true), + '$baseurl' => DI::baseUrl()->get(true), '$geotag' => $geotag, '$nickname' => $x['nickname'], '$ispublic' => L10n::t('Visible to everybody'), @@ -1196,7 +1192,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) $private_post = 0; } - $query_str = $a->query_string; + $query_str = DI::args()->getQueryString(); if (strpos($query_str, 'public=1') !== false) { $query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str); } @@ -1247,7 +1243,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) '$posttype' => $notes_cid ? Item::PT_PERSONAL_NOTE : Item::PT_ARTICLE, '$content' => $x['content'] ?? '', '$post_id' => $x['post_id'] ?? '', - '$baseurl' => System::baseUrl(true), + '$baseurl' => DI::baseUrl()->get(true), '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$pvisit' => $notes_cid ? 'none' : $x['visitor'], @@ -1473,7 +1469,7 @@ function conv_sort(array $item_list, $order) $parents[$i]['children'] = sort_item_children($parents[$i]['children']); } - if (PConfig::get(local_user(), 'system', 'smart_threading', 0)) { + if (!PConfig::get(local_user(), 'system', 'no_smart_threading', 0)) { foreach ($parents as $i => $parent) { $parents[$i] = smart_flatten_conversation($parent); } @@ -1541,12 +1537,6 @@ function sort_thr_received_rev(array $a, array $b) */ function sort_thr_commented(array $a, array $b) { - if ($b['pinned'] && !$a['pinned']) { - return 1; - } elseif (!$b['pinned'] && $a['pinned']) { - return -1; - } - return strcmp($b['commented'], $a['commented']); }