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