]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/BaseSearch.php
The priority is now a class constant
[friendica.git] / src / Module / BaseSearch.php
index ca5bb761275688fd927a36774f05ddb3ea0b43af..276598131b6411513fef1eb3b1fae9655bf519d1 100644 (file)
@@ -30,6 +30,7 @@ use Friendica\Model;
 use Friendica\Network\HTTPException;
 use Friendica\Object\Search\ContactResult;
 use Friendica\Object\Search\ResultList;
+use Friendica\Util\Network;
 
 /**
  * Base class for search modules
@@ -46,7 +47,7 @@ class BaseSearch extends BaseModule
         * @throws HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function performContactSearch($search, $prefix = '')
+       public static function performContactSearch(string $search, string $prefix = ''): string
        {
                $config = DI::config();
 
@@ -63,21 +64,23 @@ class BaseSearch extends BaseModule
                $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',
                                DI::config()->get('system', 'itemspage_network_mobile'));
@@ -110,7 +113,7 @@ 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'));