mirror of
https://github.com/friendica/friendica
synced 2024-11-13 01:42:59 +00:00
The number of comments shown when collapsed is the total of all the descendant items.
This commit is contained in:
parent
f3b1391501
commit
4cc6bf660c
1 changed files with 19 additions and 1 deletions
|
@ -299,6 +299,21 @@ function localize_item(&$item){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the total of comments on this item and its desendants
|
||||||
|
*/
|
||||||
|
function count_descendants($item) {
|
||||||
|
$total = count($item['children']);
|
||||||
|
|
||||||
|
if($total > 0) {
|
||||||
|
foreach($item['children'] as $child) {
|
||||||
|
$total += count_descendants($child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $total;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively prepare a thread for HTML
|
* Recursively prepare a thread for HTML
|
||||||
*/
|
*/
|
||||||
|
@ -311,6 +326,8 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
|
||||||
$items_seen = 0;
|
$items_seen = 0;
|
||||||
$nb_items = count($items);
|
$nb_items = count($items);
|
||||||
|
|
||||||
|
$total_children = $nb_items;
|
||||||
|
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
// prevent private email reply to public conversation from leaking.
|
// prevent private email reply to public conversation from leaking.
|
||||||
if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
|
if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
|
||||||
|
@ -338,6 +355,7 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
|
||||||
$osparkle = '';
|
$osparkle = '';
|
||||||
$lastcollapsed = false;
|
$lastcollapsed = false;
|
||||||
$firstcollapsed = false;
|
$firstcollapsed = false;
|
||||||
|
$total_children += count_descendants($item);
|
||||||
|
|
||||||
$toplevelpost = (($item['id'] == $item['parent']) ? true : false);
|
$toplevelpost = (($item['id'] == $item['parent']) ? true : false);
|
||||||
$item_writeable = (($item['writable'] || $item['self']) ? true : false);
|
$item_writeable = (($item['writable'] || $item['self']) ? true : false);
|
||||||
|
@ -577,7 +595,7 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
|
||||||
|
|
||||||
$item_result = $arr['output'];
|
$item_result = $arr['output'];
|
||||||
if($firstcollapsed) {
|
if($firstcollapsed) {
|
||||||
$item_result['num_comments'] = sprintf( tt('%d comment','%d comments',$nb_items),$nb_items );
|
$item_result['num_comments'] = sprintf( tt('%d comment','%d comments',$total_children),$total_children );
|
||||||
$item_result['hide_text'] = t('show more');
|
$item_result['hide_text'] = t('show more');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue