use Friendica\Network\HTTPException;
use Friendica\Object\Search\ContactResult;
use Friendica\Object\Search\ResultList;
+use Friendica\Util\Network;
/**
* Base class for search modules
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
- public static function performContactSearch($search, $prefix = '')
+ public static function performContactSearch(string $search, string $prefix = ''): string
{
$config = DI::config();
$header = '';
if (strpos($search, '@') === 0) {
- $search = substr($search, 1);
+ $search = trim(substr($search, 1));
$type = Search::TYPE_PEOPLE;
$header = DI::l10n()->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'));
}
* @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 '';
}
// 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());
+ $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,
'$contacts' => $entries,