2018-03-16 13:55:26 +01:00
|
|
|
<?php
|
2024-08-24 15:27:00 +02:00
|
|
|
|
|
|
|
// Copyright (C) 2010-2024, the Friendica project
|
|
|
|
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
2020-02-09 16:18:46 +01:00
|
|
|
|
2018-03-16 13:55:26 +01:00
|
|
|
namespace Friendica\Module;
|
|
|
|
|
|
|
|
use Friendica\BaseModule;
|
|
|
|
use Friendica\Core\System;
|
2018-07-20 08:19:26 -04:00
|
|
|
use Friendica\Database\DBA;
|
2018-11-08 10:20:03 -05:00
|
|
|
use Friendica\Util\Strings;
|
2018-03-16 13:55:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hashtag module.
|
|
|
|
*/
|
2018-03-16 14:27:04 +01:00
|
|
|
class Hashtag extends BaseModule
|
2018-03-16 13:55:26 +01:00
|
|
|
{
|
2023-05-06 23:55:34 -04:00
|
|
|
protected function rawContent(array $request = [])
|
2018-03-16 14:27:04 +01:00
|
|
|
{
|
2018-03-16 13:55:26 +01:00
|
|
|
$result = [];
|
|
|
|
|
2023-05-06 23:55:34 -04:00
|
|
|
if (empty($request['t'])) {
|
2023-09-21 12:16:17 -04:00
|
|
|
$this->jsonExit($result);
|
2018-03-16 13:55:26 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 23:55:34 -04:00
|
|
|
$taglist = DBA::select(
|
|
|
|
'tag',
|
|
|
|
['name'],
|
|
|
|
["`name` LIKE ?", Strings::escapeHtml($request['t']) . "%"],
|
|
|
|
['order' => ['name'], 'limit' => 100]
|
|
|
|
);
|
2018-07-20 08:19:26 -04:00
|
|
|
while ($tag = DBA::fetch($taglist)) {
|
2020-04-28 11:52:51 +00:00
|
|
|
$result[] = ['text' => $tag['name']];
|
2018-03-16 13:55:26 +01:00
|
|
|
}
|
2018-07-20 08:19:26 -04:00
|
|
|
DBA::close($taglist);
|
2018-03-16 13:55:26 +01:00
|
|
|
|
2023-09-21 12:16:17 -04:00
|
|
|
$this->jsonExit($result);
|
2018-03-16 13:55:26 +01:00
|
|
|
}
|
|
|
|
}
|