First commit
This commit is contained in:
commit
201edf2e4a
115 changed files with 29451 additions and 0 deletions
44
src/classes/Views/Widget/PopularCountries.php
Normal file
44
src/classes/Views/Widget/PopularCountries.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Directory\Views\Widget;
|
||||
|
||||
/**
|
||||
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||
*/
|
||||
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`
|
||||
ORDER BY COUNT(`country`) DESC
|
||||
LIMIT 20';
|
||||
$countries = $this->connection->fetchAll($stmt);
|
||||
|
||||
$vars = [
|
||||
'title' => 'Popular Countries',
|
||||
'countries' => $countries
|
||||
];
|
||||
|
||||
return $this->renderer->fetch('widget/popularcountries.phtml', $vars);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue