Create new popular server languages widget
- Rename popular profile widget class and template
This commit is contained in:
parent
a1921c999d
commit
e68b68110b
5 changed files with 61 additions and 4 deletions
|
@ -4,7 +4,7 @@ namespace Friendica\Directory\Controllers\Web;
|
|||
|
||||
use Friendica\Directory\Content\Pager;
|
||||
use Friendica\Directory\Views\Widget\PopularCountries;
|
||||
use Friendica\Directory\Views\Widget\PopularLanguages;
|
||||
use Friendica\Directory\Views\Widget\PopularProfileLanguages;
|
||||
use Friendica\Directory\Views\Widget\PopularTags;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
@ -54,7 +54,7 @@ class Directory extends BaseController
|
|||
{
|
||||
$popularTags = new PopularTags($this->atlas, $this->renderer);
|
||||
$popularCountries = new PopularCountries($this->atlas, $this->renderer);
|
||||
$popularLanguages = new PopularLanguages($this->atlas, $this->renderer);
|
||||
$popularLanguages = new PopularProfileLanguages($this->atlas, $this->renderer);
|
||||
|
||||
$pager = new Pager($this->l10n, $request, 20);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Friendica\Directory\Views\Widget;
|
|||
/**
|
||||
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
||||
*/
|
||||
class PopularLanguages
|
||||
class PopularProfileLanguages
|
||||
{
|
||||
/**
|
||||
* @var \Atlas\Pdo\Connection
|
||||
|
@ -36,6 +36,6 @@ class PopularLanguages
|
|||
'languages' => $languages
|
||||
];
|
||||
|
||||
return $this->renderer->fetch('widget/popularlanguages.phtml', $vars);
|
||||
return $this->renderer->fetch('widget/popularprofilelanguages.phtml', $vars);
|
||||
}
|
||||
}
|
44
src/classes/Views/Widget/PopularServerLanguages.php
Normal file
44
src/classes/Views/Widget/PopularServerLanguages.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Directory\Views\Widget;
|
||||
|
||||
/**
|
||||
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
||||
*/
|
||||
class PopularServerLanguages
|
||||
{
|
||||
/**
|
||||
* @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 LEFT(`language`, 2) AS `language`, COUNT(*) AS `total`
|
||||
FROM `server`
|
||||
WHERE `reg_policy` != "REGISTER_CLOSED"
|
||||
AND `available`
|
||||
AND NOT `hidden`
|
||||
AND `language` IS NOT NULL
|
||||
GROUP BY LEFT(`language`, 2)
|
||||
ORDER BY `total` DESC
|
||||
LIMIT 10';
|
||||
$languages = $this->connection->fetchAll($stmt);
|
||||
|
||||
$vars = [
|
||||
'languages' => $languages
|
||||
];
|
||||
|
||||
return $this->renderer->fetch('widget/popularserverlanguages.phtml', $vars);
|
||||
}
|
||||
}
|
13
src/templates/widget/popularserverlanguages.phtml
Normal file
13
src/templates/widget/popularserverlanguages.phtml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<div>
|
||||
<h3><?php echo $this->__('Filter by language')?></h3>
|
||||
<ul>
|
||||
<?php foreach ($languages as $language): ?>
|
||||
<li>
|
||||
<a href="<?php echo $this->escapeHtmlAttr($this->r('servers', ['language' => $language['language']])) ?>">
|
||||
<?php echo $this->e(Friendica\Directory\Utils\L10n::localeToLanguageString($language['language'])) ?>
|
||||
(<?php echo $this->e($language['total'])?>)
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
Loading…
Reference in a new issue