2018-11-12 03:08:33 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Directory\Views\Widget;
|
|
|
|
|
|
|
|
/**
|
2020-06-13 19:15:53 +02:00
|
|
|
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
2018-11-12 03:08:33 +01:00
|
|
|
*/
|
|
|
|
class PopularTags
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Atlas\Pdo\Connection
|
|
|
|
*/
|
|
|
|
private $connection;
|
|
|
|
/**
|
|
|
|
* @var \Friendica\Directory\Views\PhpRenderer
|
|
|
|
*/
|
|
|
|
private $renderer;
|
|
|
|
|
|
|
|
public function __construct(\Atlas\Pdo\Connection $connection, \Friendica\Directory\Views\PhpRenderer $renderer)
|
|
|
|
{
|
|
|
|
$this->connection = $connection;
|
|
|
|
$this->renderer = $renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render(): string
|
|
|
|
{
|
2019-05-12 20:00:44 +02:00
|
|
|
$stmt = 'SELECT `term`, COUNT(*) AS `total`
|
|
|
|
FROM `tag`
|
|
|
|
GROUP BY `term`
|
|
|
|
ORDER BY `total` DESC
|
|
|
|
LIMIT 10';
|
2018-11-12 03:08:33 +01:00
|
|
|
$tags = $this->connection->fetchAll($stmt);
|
|
|
|
|
|
|
|
$vars = [
|
|
|
|
'tags' => $tags
|
|
|
|
];
|
|
|
|
|
|
|
|
return $this->renderer->fetch('widget/populartags.phtml', $vars);
|
|
|
|
}
|
|
|
|
}
|