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 PopularCountries
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
{
|
|
|
|
$stmt = '
|
|
|
|
SELECT `country`, COUNT(`country`) AS `total`
|
|
|
|
FROM `profile`
|
|
|
|
WHERE `country` != ""
|
|
|
|
AND `available`
|
|
|
|
GROUP BY `country`
|
2019-05-12 20:00:44 +02:00
|
|
|
ORDER BY `total` DESC
|
2018-11-16 06:00:03 +01:00
|
|
|
LIMIT 10';
|
2018-11-12 03:08:33 +01:00
|
|
|
$countries = $this->connection->fetchAll($stmt);
|
|
|
|
|
|
|
|
$vars = [
|
|
|
|
'countries' => $countries
|
|
|
|
];
|
|
|
|
|
|
|
|
return $this->renderer->fetch('widget/popularcountries.phtml', $vars);
|
|
|
|
}
|
|
|
|
}
|