2018-11-16 05:59:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Directory\Views\Widget;
|
|
|
|
|
|
|
|
/**
|
2020-06-13 19:15:53 +02:00
|
|
|
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
2018-11-16 05:59:00 +01:00
|
|
|
*/
|
2020-09-27 21:22:43 +02:00
|
|
|
class PopularProfileLanguages
|
2018-11-16 05:59:00 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @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 LEFT(`language`, 2) AS `language`, COUNT(*) AS `total`
|
|
|
|
FROM `profile`
|
|
|
|
WHERE `language` IS NOT NULL
|
|
|
|
GROUP BY LEFT(`language`, 2)
|
|
|
|
ORDER BY `total` DESC
|
|
|
|
LIMIT 10';
|
2018-11-16 05:59:00 +01:00
|
|
|
$languages = $this->connection->fetchAll($stmt);
|
|
|
|
|
|
|
|
$vars = [
|
|
|
|
'languages' => $languages
|
|
|
|
];
|
|
|
|
|
2020-09-27 21:22:43 +02:00
|
|
|
return $this->renderer->fetch('widget/popularprofilelanguages.phtml', $vars);
|
2018-11-16 05:59:00 +01:00
|
|
|
}
|
|
|
|
}
|