3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\Search;
25 use Friendica\BaseModule;
26 use Friendica\Core\L10n;
27 use Friendica\Core\System;
28 use Friendica\Database\Database;
29 use Friendica\Model\User;
30 use Friendica\Module\Response;
31 use Friendica\Util\Profiler;
32 use Friendica\Util\Proxy;
33 use Psr\Log\LoggerInterface;
36 * Search users because of their public/private tags
38 class Tags extends BaseModule
40 const DEFAULT_ITEMS_PER_PAGE = 80;
45 public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Database $database, array $server, array $parameters = [])
47 parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
49 $this->database = $database;
52 protected function rawContent(array $request = [])
54 $tags = $request['s'] ?? '';
55 $perPage = intval($request['n'] ?? self::DEFAULT_ITEMS_PER_PAGE);
56 $page = intval($request['p'] ?? 1);
57 $startRec = ($page - 1) * $perPage;
64 'items_page' => $perPage,
66 'results' => $results,
71 "`net-publish` AND MATCH(`pub_keywords`) AGAINST (?)",
75 $totalCount = $this->database->count('owner-view', $condition);
76 if ($totalCount === 0) {
79 'items_page' => $perPage,
81 'results' => $results,
85 $searchStmt = $this->database->select('owner-view',
86 ['pub_keywords', 'name', 'nickname', 'uid'],
88 ['limit' => [$startRec, $perPage]]);
90 while ($searchResult = $this->database->fetch($searchStmt)) {
92 'name' => $searchResult['name'],
93 'url' => $this->baseUrl . '/profile/' . $searchResult['nickname'],
94 'photo' => User::getAvatarUrl($searchResult, Proxy::SIZE_THUMB),
98 $this->database->close($searchStmt);
101 'total' => $totalCount,
102 'items_page' => $perPage,
104 'results' => $results,