mirror of
https://github.com/friendica/friendica
synced 2025-04-19 05:50:10 +00:00
hashtag autocomplete
This commit is contained in:
parent
4a0781db19
commit
96c086ea13
2 changed files with 61 additions and 2 deletions
36
src/Module/Hashtag.php
Normal file
36
src/Module/Hashtag.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* @file src/Module/Hashtag.php
|
||||
*/
|
||||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\System;
|
||||
use dba;
|
||||
|
||||
/**
|
||||
* Hashtag module.
|
||||
*/
|
||||
class Hashtag extends BaseModule {
|
||||
|
||||
public static function init()
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$t = escape_tags($_REQUEST['t']);
|
||||
if (empty($t)) {
|
||||
System::jsonExit($result);
|
||||
}
|
||||
|
||||
$taglist = dba::p("SELECT DISTINCT(`term`) FROM `term` WHERE `term` LIKE ? AND `type` = ? ORDER BY `term`",
|
||||
$t . '%',
|
||||
intval(TERM_HASHTAG)
|
||||
);
|
||||
while ($tag = dba::fetch($taglist)) {
|
||||
$result[] = ['text' => strtolower($tag['term'])];
|
||||
}
|
||||
dba::close($taglist);
|
||||
|
||||
System::jsonExit($result);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue