friendica-github/src/Module/Hashtag.php

42 lines
805 B
PHP
Raw Normal View History

2018-03-16 13:55:26 +01:00
<?php
2024-08-24 15:27:00 +02:00
// Copyright (C) 2010-2024, the Friendica project
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
//
// SPDX-License-Identifier: AGPL-3.0-or-later
2018-03-16 13:55:26 +01:00
namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\System;
use Friendica\Database\DBA;
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
{
protected function rawContent(array $request = [])
2018-03-16 14:27:04 +01:00
{
2018-03-16 13:55:26 +01:00
$result = [];
if (empty($request['t'])) {
$this->jsonExit($result);
2018-03-16 13:55:26 +01:00
}
$taglist = DBA::select(
'tag',
['name'],
["`name` LIKE ?", Strings::escapeHtml($request['t']) . "%"],
['order' => ['name'], 'limit' => 100]
);
while ($tag = DBA::fetch($taglist)) {
2020-04-28 11:52:51 +00:00
$result[] = ['text' => $tag['name']];
2018-03-16 13:55:26 +01:00
}
DBA::close($taglist);
2018-03-16 13:55:26 +01:00
$this->jsonExit($result);
2018-03-16 13:55:26 +01:00
}
}