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/profile.php | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 8 deletions(-) (limited to 'mod/profile.php') diff --git a/mod/profile.php b/mod/profile.php index d33c9aeb2..9544512ba 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -243,31 +243,52 @@ function profile_content(&$a, $update = 0) { 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`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 ) + AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1 $sql_extra ", intval($a->profile['profile_uid']) ); - if(count($r)) + if(count($r)) { $a->set_pager_total($r[0]['total']); + $a->set_pager_itemspage(40); + } - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, - `contact`.`thumb`, `contact`.`self`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` + $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`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 ) + AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1 $sql_extra - ORDER BY `parent` DESC, `gravity` ASC, `id` ASC LIMIT %d ,%d ", + LIMIT %d ,%d ", intval($a->profile['profile_uid']), 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`.`network`, `contact`.`rel`, + `contact`.`thumb`, `contact`.`self`, + `contact`.`id` AS `cid`, `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`.`blocked` = 0 AND `contact`.`pending` = 0 + AND `item`.`parent` IN ( %s ) + $sql_extra + ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ", + intval($a->profile['profile_uid']), + dbesc($parents_str) + ); + } if($is_owner && ! $update) $o .= get_birthdays(); @@ -292,6 +313,16 @@ function profile_content(&$a, $update = 0) { if($r !== false && count($r)) { + $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'); @@ -311,6 +342,25 @@ function profile_content(&$a, $update = 0) { && ($item['id'] != $item['parent'])) continue; + 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 .= ''; + } + $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) ? '
' . t('Private Message') . '
' -- cgit v1.2.3