X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FModule%2FBaseSearch.php;h=675deb8fb26abf935d43f3d51ad4ce12277bab62;hb=d2429b109601ab875f0ed0802b349edee07fba06;hp=bccfc94de594d9c0b6d42d8a78adf5bc5272203d;hpb=2a431b580f2e8f6a596e84175932e793678cde63;p=friendica.git
diff --git a/src/Module/BaseSearch.php b/src/Module/BaseSearch.php
index bccfc94de5..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);
}
+ $search = Network::convertToIdn($search);
+
if (DI::mode()->isMobile()) {
- $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+ $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+ $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
@@ -92,9 +94,11 @@ class BaseSearch extends BaseModule
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);
@@ -111,28 +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) {
- notice(DI::l10n()->t('No matches'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('No matches'));
return '';
}
+ $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) {
- $contact = Model\Contact::getByURLForUser($result->getUrl(), local_user());
+ if (Network::isUriBlocked($result->getUrl())) {
+ $filtered++;
+ continue;
+ }
+
+ $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()),
]);