Add count display for account type tabs
- Add translations strings to AccountTypeTabs
This commit is contained in:
parent
651849b18e
commit
4dad98fa04
|
@ -77,7 +77,11 @@ AGAINST (:query IN BOOLEAN MODE)";
|
||||||
|
|
||||||
$values = ['query' => $query];
|
$values = ['query' => $query];
|
||||||
|
|
||||||
|
|
||||||
$account_type = $args['account_type'] ?? '';
|
$account_type = $args['account_type'] ?? '';
|
||||||
|
|
||||||
|
$accountTypeTabs = $this->accountTypeTabs->render('search', $account_type, $sql_where, $values, ['q' => $originalQuery, 'field' => $field]);
|
||||||
|
|
||||||
if ($account_type) {
|
if ($account_type) {
|
||||||
$sql_where .= '
|
$sql_where .= '
|
||||||
AND `account_type` = :account_type';
|
AND `account_type` = :account_type';
|
||||||
|
@ -93,7 +97,7 @@ AND `account_type` = :account_type';
|
||||||
'field' => $field,
|
'field' => $field,
|
||||||
'fieldName' => $fieldName,
|
'fieldName' => $fieldName,
|
||||||
'count' => $count,
|
'count' => $count,
|
||||||
'accountTypeTabs' => $this->accountTypeTabs->render('search', $account_type, ['q' => $originalQuery, 'field' => $field]),
|
'accountTypeTabs' => $accountTypeTabs,
|
||||||
'profiles' => $profiles,
|
'profiles' => $profiles,
|
||||||
'pager_full' => $pager->renderFull($count),
|
'pager_full' => $pager->renderFull($count),
|
||||||
'pager_minimal' => $pager->renderMinimal($count),
|
'pager_minimal' => $pager->renderMinimal($count),
|
||||||
|
|
|
@ -27,28 +27,39 @@ class AccountTypeTabs
|
||||||
$this->router = $router;
|
$this->router = $router;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(string $route_name, string $current_type = '', array $queryParams = []): string
|
public function render(string $route_name, string $current_type = '', $condition = '', $values = [], array $queryParams = []): string
|
||||||
{
|
{
|
||||||
$stmt = '
|
|
||||||
SELECT DISTINCT(`account_type`) AS `account_type`
|
$stmt = 'SELECT `account_type`, COUNT(*) AS `count`
|
||||||
FROM `profile`
|
FROM `profile` p
|
||||||
WHERE `available`
|
JOIN `server` s ON s.`id` = p.`server_id` AND s.`available` AND NOT s.`hidden`
|
||||||
AND NOT `hidden`';
|
WHERE p.`available`
|
||||||
$account_types = $this->connection->fetchAll($stmt);
|
AND NOT p.`hidden`
|
||||||
|
AND ' . $condition . '
|
||||||
|
GROUP BY p.`account_type`
|
||||||
|
ORDER BY `filled_fields` DESC, `last_activity` DESC, `updated` DESC';
|
||||||
|
$account_types = $this->connection->fetchAll($stmt, $values);
|
||||||
|
|
||||||
$tabs = [
|
$tabs = [
|
||||||
[
|
[
|
||||||
'title' => 'All',
|
'title' => $this->renderer->p__('account-type', 'All'),
|
||||||
'link' => $this->router->pathFor($route_name, [], $queryParams),
|
'link' => $this->router->pathFor($route_name, [], $queryParams),
|
||||||
'active' => empty($current_type)
|
'active' => empty($current_type)
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($account_types as $account_type) {
|
foreach ($account_types as $account_type) {
|
||||||
|
switch ($account_type['account_type']) {
|
||||||
|
case 'People': $title = $this->renderer->np__('account-type', 'People (%d)', 'People (%d)', $account_type['count']); break;
|
||||||
|
case 'Forum' : $title = $this->renderer->np__('account-type', 'Forum (%d)', 'Forums (%d)', $account_type['count']); break;
|
||||||
|
default: $title = $this->renderer->np__('account-type', $account_type['account_type']. ' (%d)', $account_type['account_type']. ' (%d)', $account_type['count']);
|
||||||
|
}
|
||||||
|
|
||||||
$tabs[] = [
|
$tabs[] = [
|
||||||
'title' => $account_type['account_type'],
|
'title' => $title,
|
||||||
'link' => $this->router->pathFor($route_name, ['account_type' => strtolower($account_type['account_type'])], $queryParams),
|
'link' => $this->router->pathFor($route_name, ['account_type' => strtolower($account_type['account_type'])], $queryParams),
|
||||||
'active' => strtolower($account_type['account_type']) == strtolower($current_type)
|
'active' => strtolower($account_type['account_type']) == strtolower($current_type),
|
||||||
|
'disabled' => $account_type['count'] == 0
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue