<?php
+/**
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
namespace Friendica\Module\Search;
-use Friendica\BaseModule;
-use Friendica\Content\ContactSelector;
-use Friendica\Content\Pager;
use Friendica\Content\Widget;
-use Friendica\Core\L10n;
-use Friendica\Core\Renderer;
-use Friendica\Module\BaseSearchModule;
-use Friendica\Util\Proxy as ProxyUtils;
-use Friendica\Util\Strings;
-use Friendica\Model;
+use Friendica\DI;
+use Friendica\Module\BaseSearch;
+use Friendica\Module\Security\Login;
/**
- * Multi search module, which is needed for further search operations
+ * Directory search module
*/
-class Directory extends BaseSearchModule
+class Directory extends BaseSearch
{
- public static function content()
+ protected function content(array $request = []): string
{
if (!local_user()) {
- notice(L10n::t('Permission denied.'));
+ notice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
- $a = self::getApp();
-
- if (empty($a->page['aside'])) {
- $a->page['aside'] = '';
- }
-
- $a->page['aside'] .= Widget::findPeople();
- $a->page['aside'] .= Widget::follow();
-
- return self::performSearch();
- }
-
- public static function performSearch($prefix = '')
- {
- $a = self::getApp();
- $config = $a->getConfig();
-
- $community = false;
-
- $localSearch = $config->get('system', 'poco_local_search');
-
- $search = $prefix . Strings::escapeTags(trim(defaults($_REQUEST, 'search', '')));
-
- if (!$search) {
- return '';
- }
-
- $header = '';
+ $search = trim(rawurldecode($_REQUEST['search'] ?? ''));
- if (strpos($search, '@') === 0) {
- $search = substr($search, 1);
- $header = L10n::t('People Search - %s', $search);
- $results = Model\Search::searchUser($search);
+ if (empty(DI::page()['aside'])) {
+ DI::page()['aside'] = '';
}
- if (strpos($search, '!') === 0) {
- $search = substr($search, 1);
- $community = true;
- $header = L10n::t('Forum Search - %s', $search);
- }
-
- $pager = new Pager($a->query_string);
-
- if ($localSearch && empty($results)) {
- $pager->setItemsPerPage(80);
- $results = Model\Search::searchLocal($search, $pager->getStart(), $pager->getItemsPerPage(), $community);
-
- } elseif (strlen($config->get('system', 'directory')) && empty($results)) {
- $results = Model\Search::searchDirectory($search, $pager->getPage());
- $pager->setItemsPerPage($results->getItemsPage());
- }
+ DI::page()['aside'] .= Widget::findPeople();
+ DI::page()['aside'] .= Widget::follow();
- return self::printResult($results, $pager, $header);
+ return self::performContactSearch($search);
}
}