friendica/src/Module/Hashtag.php

39 lines
696 B
PHP
Raw Normal View History

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