2018-03-16 12:55:26 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2020-02-09 15:18:46 +00:00
|
|
|
* @copyright Copyright (C) 2020, Friendica
|
|
|
|
*
|
|
|
|
* @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 12:55:26 +00:00
|
|
|
*/
|
2020-02-09 15:18:46 +00:00
|
|
|
|
2018-03-16 12:55:26 +00:00
|
|
|
namespace Friendica\Module;
|
|
|
|
|
|
|
|
use Friendica\BaseModule;
|
|
|
|
use Friendica\Core\System;
|
2018-07-20 12:19:26 +00:00
|
|
|
use Friendica\Database\DBA;
|
2018-11-08 15:20:03 +00:00
|
|
|
use Friendica\Util\Strings;
|
2020-04-26 16:15:39 +00:00
|
|
|
use Friendica\Model\Tag;
|
2020-04-13 19:24:22 +00:00
|
|
|
use Friendica\Model\Term;
|
2018-03-16 12:55:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hashtag module.
|
|
|
|
*/
|
2018-03-16 13:27:04 +00:00
|
|
|
class Hashtag extends BaseModule
|
2018-03-16 12:55:26 +00:00
|
|
|
{
|
2018-03-16 13:27:04 +00:00
|
|
|
|
2019-11-05 21:48:54 +00:00
|
|
|
public static function content(array $parameters = [])
|
2018-03-16 13:27:04 +00:00
|
|
|
{
|
2018-03-16 12:55:26 +00:00
|
|
|
$result = [];
|
|
|
|
|
2018-11-09 18:27:58 +00:00
|
|
|
$t = Strings::escapeHtml($_REQUEST['t']);
|
2018-03-16 12:55:26 +00:00
|
|
|
if (empty($t)) {
|
|
|
|
System::jsonExit($result);
|
|
|
|
}
|
|
|
|
|
2018-07-20 12:19:26 +00:00
|
|
|
$taglist = DBA::p("SELECT DISTINCT(`term`) FROM `term` WHERE `term` LIKE ? AND `type` = ? ORDER BY `term`",
|
2018-03-16 12:55:26 +00:00
|
|
|
$t . '%',
|
2020-04-26 16:15:39 +00:00
|
|
|
intval(Tag::HASHTAG)
|
2018-03-16 12:55:26 +00:00
|
|
|
);
|
2018-07-20 12:19:26 +00:00
|
|
|
while ($tag = DBA::fetch($taglist)) {
|
2018-03-29 04:47:14 +00:00
|
|
|
$result[] = ['text' => $tag['term']];
|
2018-03-16 12:55:26 +00:00
|
|
|
}
|
2018-07-20 12:19:26 +00:00
|
|
|
DBA::close($taglist);
|
2018-03-16 12:55:26 +00:00
|
|
|
|
|
|
|
System::jsonExit($result);
|
|
|
|
}
|
|
|
|
}
|