Implement pagination for people page.
This commit is contained in:
@@ -95,16 +95,19 @@ class Tag
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function getAlbums($id_parent = 0, $return_format = 'array')
|
||||
public static function getAlbums($id_parent = 0, $offset = 0, $limit = 24, $return_format = 'array')
|
||||
{
|
||||
$rows = Registry::get('db')->queryAssocs('
|
||||
SELECT *
|
||||
FROM tags
|
||||
WHERE id_parent = {int:id_parent} AND kind = {string:kind}
|
||||
ORDER BY tag ASC',
|
||||
ORDER BY tag ASC
|
||||
LIMIT {int:offset}, {int:limit}',
|
||||
[
|
||||
'id_parent' => $id_parent,
|
||||
'kind' => 'Album',
|
||||
'offset' => $offset,
|
||||
'limit' => $limit,
|
||||
]);
|
||||
|
||||
if ($return_format == 'object')
|
||||
@@ -118,16 +121,19 @@ class Tag
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function getPeople($id_parent = 0, $return_format = 'array')
|
||||
public static function getPeople($id_parent = 0, $offset = 0, $limit = 24, $return_format = 'array')
|
||||
{
|
||||
$rows = Registry::get('db')->queryAssocs('
|
||||
SELECT *
|
||||
FROM tags
|
||||
WHERE id_parent = {int:id_parent} AND kind = {string:kind}
|
||||
ORDER BY tag ASC',
|
||||
ORDER BY tag ASC
|
||||
LIMIT {int:offset}, {int:limit}',
|
||||
[
|
||||
'id_parent' => $id_parent,
|
||||
'kind' => 'Person',
|
||||
'offset' => $offset,
|
||||
'limit' => $limit,
|
||||
]);
|
||||
|
||||
if ($return_format == 'object')
|
||||
@@ -322,12 +328,23 @@ class Tag
|
||||
['tags' => $tags]);
|
||||
}
|
||||
|
||||
public static function getCount($only_active = 1)
|
||||
public static function getCount($only_active = 1, $kind = '')
|
||||
{
|
||||
return $db->queryValue('
|
||||
$where = [];
|
||||
if ($only_active)
|
||||
$where[] = 'count > 0';
|
||||
if (!empty($kind))
|
||||
$where[] = 'kind = {string:kind}';
|
||||
|
||||
if (!empty($where))
|
||||
$where = 'WHERE ' . implode(' AND ', $where);
|
||||
else
|
||||
$where = '';
|
||||
|
||||
return Registry::get('db')->queryValue('
|
||||
SELECT COUNT(*)
|
||||
FROM tags' . ($only_active ? '
|
||||
WHERE count > 0' : ''));
|
||||
FROM tags ' . $where,
|
||||
['kind' => $kind]);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
|
||||
Reference in New Issue
Block a user