X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FBaseSearch.php;h=675deb8fb26abf935d43f3d51ad4ce12277bab62;hb=d2429b109601ab875f0ed0802b349edee07fba06;hp=ca940ae4ead916fd0258aa8026e0f98dcf0467da;hpb=01640a7045e146759bc936dd499ac27738b78940;p=friendica.git
diff --git a/src/Module/BaseSearch.php b/src/Module/BaseSearch.php
index ca940ae4ea..675deb8fb2 100644
--- a/src/Module/BaseSearch.php
+++ b/src/Module/BaseSearch.php
@@ -1,6 +1,6 @@
t('People Search - %s', $search);
if (strrpos($search, '@') > 0) {
- $results = Search::getContactsFromProbe($search);
+ $results = Search::getContactsFromProbe(Network::convertToIdn($search));
}
}
if (strpos($search, '!') === 0) {
- $search = substr($search, 1);
+ $search = trim(substr($search, 1));
$type = Search::TYPE_FORUM;
$header = DI::l10n()->t('Forum Search - %s', $search);
}
- $args = DI::args();
- $pager = new Pager($args->getQueryString());
+ $search = Network::convertToIdn($search);
+
+ if (DI::mode()->isMobile()) {
+ $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
+ DI::config()->get('system', 'itemspage_network_mobile'));
+ } else {
+ $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
+ DI::config()->get('system', 'itemspage_network'));
+ }
+
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
if ($localSearch && empty($results)) {
$pager->setItemsPerPage(80);
$results = Search::getContactsFromLocalDirectory($search, $type, $pager->getStart(), $pager->getItemsPerPage());
- } elseif (strlen($config->get('system', 'directory')) && empty($results)) {
+ } elseif (Search::getGlobalDirectory() && empty($results)) {
$results = Search::getContactsFromGlobalDirectory($search, $type, $pager->getPage());
$pager->setItemsPerPage($results->getItemsPage());
+ } else {
+ $results = new ResultList();
}
return self::printResult($results, $pager, $header);
@@ -106,78 +115,38 @@ class BaseSearch extends BaseModule
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
- protected static function printResult(ResultList $results, Pager $pager, $header = '')
+ protected static function printResult(ResultList $results, Pager $pager, string $header = ''): string
{
if ($results->getTotal() == 0) {
- info(DI::l10n()->t('No matches'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('No matches'));
return '';
}
- $id = 0;
+ $filtered = 0;
+
$entries = [];
foreach ($results->getResults() as $result) {
-
// in case the result is a contact result, add a contact-specific entry
if ($result instanceof ContactResult) {
-
- $alt_text = '';
- $location = '';
- $about = '';
- $accountType = '';
- $photo_menu = [];
-
- // If We already know this contact then don't show the "connect" button
- if ($result->getCid() > 0 || $result->getPCid() > 0) {
- $connLink = "";
- $connTxt = "";
- $contact = Model\Contact::getById(
- ($result->getCid() > 0) ? $result->getCid() : $result->getPCid()
- );
-
- if (!empty($contact)) {
- $photo_menu = Model\Contact::photoMenu($contact);
- $details = Contact::getContactTemplateVars($contact);
- $alt_text = $details['alt_text'];
- $location = $contact['location'];
- $about = $contact['about'];
- $accountType = Model\Contact::getAccountType($contact);
- } else {
- $photo_menu = [];
- }
- } else {
- $connLink = DI::baseUrl()->get() . '/follow/?url=' . $result->getUrl();
- $connTxt = DI::l10n()->t('Connect');
-
- $photo_menu['profile'] = [DI::l10n()->t("View Profile"), Model\Contact::magicLink($result->getUrl())];
- $photo_menu['follow'] = [DI::l10n()->t("Connect/Follow"), $connLink];
+ if (Network::isUriBlocked($result->getUrl())) {
+ $filtered++;
+ continue;
}
- $photo = str_replace("http:///photo/", Search::getGlobalDirectory() . "/photo/", $result->getPhoto());
-
- $entry = [
- 'alt_text' => $alt_text,
- 'url' => Model\Contact::magicLink($result->getUrl()),
- 'itemurl' => $result->getItem(),
- 'name' => $result->getName(),
- 'thumb' => ProxyUtils::proxifyUrl($photo, false, ProxyUtils::SIZE_THUMB),
- 'img_hover' => $result->getTags(),
- 'conntxt' => $connTxt,
- 'connlnk' => $connLink,
- 'photo_menu' => $photo_menu,
- 'details' => $location,
- 'tags' => $result->getTags(),
- 'about' => $about,
- 'account_type' => $accountType,
- 'network' => ContactSelector::networkToName($result->getNetwork(), $result->getUrl()),
- 'id' => ++$id,
- ];
- $entries[] = $entry;
+ $contact = Model\Contact::getByURLForUser($result->getUrl(), DI::userSession()->getLocalUserId());
+ if (!empty($contact)) {
+ $entries[] = Contact::getContactTemplateVars($contact);
+ }
}
}
- $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
+ $tpl = Renderer::getMarkupTemplate('contact/list.tpl');
return Renderer::replaceMacros($tpl, [
- 'title' => $header,
+ '$title' => $header,
+ '$filtered' => $filtered ? DI::l10n()->tt(
+ '%d result was filtered out because your node blocks the domain it is registered on. You can review the list of domains your node is currently blocking in the About page.',
+ '%d results were filtered out because your node blocks the domain they are registered on. You can review the list of domains your node is currently blocking in the About page.',
+ $filtered) : '',
'$contacts' => $entries,
'$paginate' => $pager->renderFull($results->getTotal()),
]);