make alt_pager work for articles/cards
This commit is contained in:
parent
9c512bb645
commit
4423f4c930
@ -127,6 +127,10 @@ class Articles extends \Zotlabs\Web\Controller {
|
|||||||
$editor = '';
|
$editor = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$itemspage = get_pconfig(local_channel(),'system','itemspage');
|
||||||
|
\App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
|
||||||
|
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
|
||||||
|
|
||||||
|
|
||||||
$sql_extra = item_permissions_sql($owner);
|
$sql_extra = item_permissions_sql($owner);
|
||||||
$sql_item = '';
|
$sql_item = '';
|
||||||
@ -142,7 +146,7 @@ class Articles extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
$r = q("select * from item
|
$r = q("select * from item
|
||||||
where item.uid = %d and item_type = %d
|
where item.uid = %d and item_type = %d
|
||||||
$sql_extra $sql_item order by item.created desc",
|
$sql_extra $sql_item order by item.created desc $pager_sql",
|
||||||
intval($owner),
|
intval($owner),
|
||||||
intval(ITEM_TYPE_ARTICLE)
|
intval(ITEM_TYPE_ARTICLE)
|
||||||
);
|
);
|
||||||
@ -153,6 +157,8 @@ class Articles extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
|
|
||||||
|
$pager_total = count($r);
|
||||||
|
|
||||||
$parents_str = ids_to_querystr($r,'id');
|
$parents_str = ids_to_querystr($r,'id');
|
||||||
|
|
||||||
$items = q("SELECT item.*, item.id AS item_id
|
$items = q("SELECT item.*, item.id AS item_id
|
||||||
@ -174,13 +180,18 @@ class Articles extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
$mode = 'articles';
|
$mode = 'articles';
|
||||||
|
|
||||||
$content = conversation($items,$mode,false,'traditional');
|
if(get_pconfig(local_channel(),'system','articles_list_mode'))
|
||||||
|
$page_mode = 'list';
|
||||||
|
else
|
||||||
|
$page_mode = 'traditional';
|
||||||
|
|
||||||
|
$content = conversation($items,$mode,false,$page_mode);
|
||||||
|
|
||||||
$o = replace_macros(get_markup_template('cards.tpl'), [
|
$o = replace_macros(get_markup_template('cards.tpl'), [
|
||||||
'$title' => t('Articles'),
|
'$title' => t('Articles'),
|
||||||
'$editor' => $editor,
|
'$editor' => $editor,
|
||||||
'$content' => $content,
|
'$content' => $content,
|
||||||
'$pager' => alt_pager($a,count($items))
|
'$pager' => alt_pager($a,$pager_total)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
@ -131,6 +131,11 @@ class Cards extends \Zotlabs\Web\Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$itemspage = get_pconfig(local_channel(),'system','itemspage');
|
||||||
|
\App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
|
||||||
|
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
|
||||||
|
|
||||||
|
|
||||||
$sql_extra = item_permissions_sql($owner);
|
$sql_extra = item_permissions_sql($owner);
|
||||||
$sql_item = '';
|
$sql_item = '';
|
||||||
|
|
||||||
@ -145,7 +150,7 @@ class Cards extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
$r = q("select * from item
|
$r = q("select * from item
|
||||||
where uid = %d and item_type = %d
|
where uid = %d and item_type = %d
|
||||||
$sql_extra $sql_item order by item.created desc",
|
$sql_extra $sql_item order by item.created desc $pager_sql",
|
||||||
intval($owner),
|
intval($owner),
|
||||||
intval(ITEM_TYPE_CARD)
|
intval(ITEM_TYPE_CARD)
|
||||||
);
|
);
|
||||||
@ -157,6 +162,8 @@ class Cards extends \Zotlabs\Web\Controller {
|
|||||||
$items_result = [];
|
$items_result = [];
|
||||||
if($r) {
|
if($r) {
|
||||||
|
|
||||||
|
$pager_total = count($r);
|
||||||
|
|
||||||
$parents_str = ids_to_querystr($r, 'id');
|
$parents_str = ids_to_querystr($r, 'id');
|
||||||
|
|
||||||
$items = q("SELECT item.*, item.id AS item_id
|
$items = q("SELECT item.*, item.id AS item_id
|
||||||
@ -176,13 +183,18 @@ class Cards extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
$mode = 'cards';
|
$mode = 'cards';
|
||||||
|
|
||||||
$content = conversation($items_result, $mode, false, 'traditional');
|
if(get_pconfig(local_channel(),'system','articles_list_mode'))
|
||||||
|
$page_mode = 'list';
|
||||||
|
else
|
||||||
|
$page_mode = 'traditional';
|
||||||
|
|
||||||
|
$content = conversation($items_result, $mode, false, $page_mode);
|
||||||
|
|
||||||
$o = replace_macros(get_markup_template('cards.tpl'), [
|
$o = replace_macros(get_markup_template('cards.tpl'), [
|
||||||
'$title' => t('Cards'),
|
'$title' => t('Cards'),
|
||||||
'$editor' => $editor,
|
'$editor' => $editor,
|
||||||
'$content' => $content,
|
'$content' => $content,
|
||||||
'$pager' => alt_pager($a, count($items_result))
|
'$pager' => alt_pager($a, $pager_total))
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
Reference in New Issue
Block a user