From c962f5c4bcc26fa7bad98a714cdb5e92b6acb57c Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 27 Mar 2011 19:53:36 -0700 Subject: comment collapsing, pagination wasn't advancing past 16 --- mod/network.php | 72 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 11 deletions(-) (limited to 'mod/network.php') diff --git a/mod/network.php b/mod/network.php index 97bc0713d..08bc5af4c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -183,8 +183,11 @@ function network_content(&$a, $update = 0) { intval($_SESSION['uid']) ); - if(count($r)) + if(count($r)) { $a->set_pager_total($r[0]['total']); + $a->set_pager_itemspage(40); + } + if($nouveau) { $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, @@ -203,21 +206,41 @@ function network_content(&$a, $update = 0) { ); } else { - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact` + $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid` + FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` = `parentitem`.`id` + AND `item`.`parent` = `item`.`id` $sql_extra - ORDER BY `parentitem`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC LIMIT %d ,%d ", + ORDER BY `item`.`created` DESC LIMIT %d ,%d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']) ); + + $parents_arr = array(); + $parents_str = ''; + + if(count($r)) { + foreach($r as $rr) + $parents_arr[] = $rr['item_id']; + $parents_str = implode(', ', $parents_arr); + + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, + `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, + `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` + FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact` + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 + AND `contact`.`id` = `item`.`contact-id` + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s ) + $sql_extra + ORDER BY `parentitem`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC ", + intval(local_user()), + dbesc($parents_str) + ); + } } $author_contacts = extract_item_authors($r,local_user()); @@ -302,15 +325,25 @@ function network_content(&$a, $update = 0) { } - + $comments = array(); + foreach($r as $rr) { + if(intval($rr['gravity']) == 6) { + if(! x($comments,$rr['parent'])) + $comments[$rr['parent']] = 1; + else + $comments[$rr['parent']] += 1; + } + } foreach($r as $item) { like_puller($a,$item,$alike,'like'); like_puller($a,$item,$dlike,'dislike'); } + $comments_collapsed = false; foreach($r as $item) { + $comment = ''; $template = $tpl; $commentww = ''; @@ -320,9 +353,26 @@ function network_content(&$a, $update = 0) { if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent'])) continue; - $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + if($item['id'] == $item['parent']) { + $comments_seen = 0; + $comments_collapsed = false; + } + else + $comments_seen ++; + + if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { + if(! $comments_collapsed) { + $o .= ''; + $o .= ''; + } + $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) -- cgit v1.2.3 From 7defb1768bff1c3da7ea63957cf8c7c928d379ab Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 27 Mar 2011 20:37:44 -0700 Subject: collapse posts by same author (but not you). --- mod/network.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'mod/network.php') diff --git a/mod/network.php b/mod/network.php index 08bc5af4c..21b818f9c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -325,6 +325,7 @@ function network_content(&$a, $update = 0) { } + $comments = array(); foreach($r as $rr) { if(intval($rr['gravity']) == 6) { @@ -341,9 +342,11 @@ function network_content(&$a, $update = 0) { } $comments_collapsed = false; + $blowhard = 0; + $blowhard_count = 0; + foreach($r as $item) { - $comment = ''; $template = $tpl; $commentww = ''; @@ -354,6 +357,20 @@ function network_content(&$a, $update = 0) { continue; if($item['id'] == $item['parent']) { + if($blowhard == $item['cid'] && (! $item['self'])) { + $blowhard_count ++; + if($blowhard_count == 3) { + $o .= '' . ''; + } + } + $comments_seen = 0; $comments_collapsed = false; } @@ -369,7 +386,7 @@ function network_content(&$a, $update = 0) { } } if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) { - $o .= ''; + $o .= ''; } $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; -- cgit v1.2.3 From 77fbd2f78c6a24201a26d5c4ec60ad5fb42c48dd Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 27 Mar 2011 20:43:45 -0700 Subject: tweaks to author collapsing --- mod/network.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'mod/network.php') diff --git a/mod/network.php b/mod/network.php index 21b818f9c..f68b399f8 100644 --- a/mod/network.php +++ b/mod/network.php @@ -365,10 +365,9 @@ function network_content(&$a, $update = 0) { } else { $blowhard = $item['cid']; - if($blowhard_count > 3) { - $blowhard_count = 0; + if($blowhard_count > 3) $o .= ''; - } + $blowhard_count = 0; } $comments_seen = 0; -- cgit v1.2.3 From 1f6c6c466a449ba422c4e67744577f6c35b3ce0b Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 28 Mar 2011 00:49:20 -0700 Subject: author collapse: close off before pagination --- mod/network.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mod/network.php') diff --git a/mod/network.php b/mod/network.php index f68b399f8..17d36dfb2 100644 --- a/mod/network.php +++ b/mod/network.php @@ -546,6 +546,10 @@ function network_content(&$a, $update = 0) { } if(! $update) { + if($blowhard_count > 3) + $o .= ''; + + $o .= paginate($a); $o .= '
' . t('Shared content is covered by the Creative Commons Attribution 3.0 license.') . '
'; } -- cgit v1.2.3