2018-03-16 08:55:26 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2021-03-29 02:40:20 -04:00
|
|
|
* @copyright Copyright (C) 2010-2021, the Friendica project
|
2020-02-09 10:18:46 -05:00
|
|
|
*
|
|
|
|
* @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/>.
|
|
|
|
*
|
2018-03-16 08:55:26 -04:00
|
|
|
*/
|
2020-02-09 10:18:46 -05:00
|
|
|
|
2018-03-16 08:55:26 -04: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 08:55:26 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hashtag module.
|
|
|
|
*/
|
2018-03-16 09:27:04 -04:00
|
|
|
class Hashtag extends BaseModule
|
2018-03-16 08:55:26 -04:00
|
|
|
{
|
2021-11-14 17:13:47 -05:00
|
|
|
public function content(): string
|
2018-03-16 09:27:04 -04:00
|
|
|
{
|
2018-03-16 08:55:26 -04:00
|
|
|
$result = [];
|
|
|
|
|
2018-11-09 13:27:58 -05:00
|
|
|
$t = Strings::escapeHtml($_REQUEST['t']);
|
2018-03-16 08:55:26 -04:00
|
|
|
if (empty($t)) {
|
|
|
|
System::jsonExit($result);
|
|
|
|
}
|
|
|
|
|
2020-04-28 07:52:51 -04:00
|
|
|
$taglist = DBA::select('tag', ['name'], ["`name` LIKE ?", $t . "%"], ['order' => ['name'], 'limit' => 100]);
|
2018-07-20 08:19:26 -04:00
|
|
|
while ($tag = DBA::fetch($taglist)) {
|
2020-04-28 07:52:51 -04:00
|
|
|
$result[] = ['text' => $tag['name']];
|
2018-03-16 08:55:26 -04:00
|
|
|
}
|
2018-07-20 08:19:26 -04:00
|
|
|
DBA::close($taglist);
|
2018-03-16 08:55:26 -04:00
|
|
|
|
|
|
|
System::jsonExit($result);
|
2021-11-14 17:13:47 -05:00
|
|
|
|
|
|
|
return '';
|
2018-03-16 08:55:26 -04:00
|
|
|
}
|
|
|
|
}
|