X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FSearch%2FIndex.php;h=1a7d4bf61f41b63b453bc498308166d73c50e53a;hb=15581ba91f78e8019ba0f1c674df12cc3d5b1eb7;hp=debaec7301516ad3353d95c903d485005716913e;hpb=a54bc0d82044cd865d0fe7f5fbf9978ae68697ac;p=friendica.git diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index debaec7301..1a7d4bf61f 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -1,6 +1,6 @@ $search]); + notice(DI::l10n()->t('No results.')); + return $o; + } + $tag = $tag || DI::config()->get('system', 'only_tag_search'); // Here is the way permissions work in the search module... @@ -147,29 +155,39 @@ class Index extends BaseSearch DI::config()->get('system', 'itemspage_network')); } + $last_uriid = isset($_GET['last_uriid']) ? intval($_GET['last_uriid']) : 0; + $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage); if ($tag) { Logger::info('Start tag search.', ['q' => $search]); - $uriids = Tag::getURIIdListByTag($search, local_user(), $pager->getStart(), $pager->getItemsPerPage()); + $uriids = Tag::getURIIdListByTag($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid); $count = Tag::countByTag($search, local_user()); } else { Logger::info('Start fulltext search.', ['q' => $search]); - $uriids = ItemContent::getURIIdListBySearch($search, local_user(), $pager->getStart(), $pager->getItemsPerPage()); - $count = ItemContent::countBySearch($search, local_user()); + $uriids = Post\Content::getURIIdListBySearch($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid); + $count = Post\Content::countBySearch($search, local_user()); } if (!empty($uriids)) { - $params = ['order' => ['id' => true], 'group_by' => ['uri-id']]; - $items = Item::selectForUser(local_user(), [], ['uri-id' => $uriids], $params); - $r = Item::inArray($items); + $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, local_user()]; + $condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]); + $params = ['order' => ['id' => true]]; + $items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params)); } - if (!DBA::isResult($r)) { - notice(DI::l10n()->t('No results.')); + if (empty($items)) { + if (empty($last_uriid)) { + notice(DI::l10n()->t('No results.')); + } return $o; } + if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { + $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl'); + $o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]); + } + if ($tag) { $title = DI::l10n()->t('Items tagged with: %s', $search); } else { @@ -182,9 +200,14 @@ class Index extends BaseSearch Logger::info('Start Conversation.', ['q' => $search]); - $o .= conversation(DI::app(), $r, 'search', false, false, 'commented', local_user()); + $o .= conversation(DI::app(), $items, 'search', false, false, 'commented', local_user()); + + if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { + $o .= HTML::scrollLoader(); + } else { + $o .= $pager->renderMinimal($count); + } - $o .= $pager->renderMinimal($count); return $o; } @@ -267,7 +290,7 @@ class Index extends BaseSearch } if (!empty($item_id)) { - $item = Item::selectFirst(['guid'], ['id' => $item_id]); + $item = Post::selectFirst(['guid'], ['id' => $item_id]); if (DBA::isResult($item)) { DI::baseUrl()->redirect('display/' . $item['guid']); }