- foreach($items as $item) {
-
- $comment = '';
- $template = $tpl;
- $commentww = '';
- $sparkle = '';
- $owner_url = $owner_photo = $owner_name = '';
-
- // We've already parsed out like/dislike for special treatment. We can ignore them now
-
- if(((activity_match($item['verb'],ACTIVITY_LIKE))
- || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
- && ($item['id'] != $item['parent']))
- continue;
-
- $toplevelpost = (($item['id'] == $item['parent']) ? true : false);
- $toplevelprivate = false;
-
- // Take care of author collapsing and comment collapsing
- // (author collapsing is currently disabled)
- // If a single author has more than 3 consecutive top-level posts, squash the remaining ones.
- // If there are more than two comments, squash all but the last 2.
-
- if($toplevelpost) {
- $toplevelprivate = (($toplevelpost && $item['private']) ? true : false);
- $item_writeable = (($item['writable'] || $item['self']) ? true : false);
-
- $comments_seen = 0;
- $comments_collapsed = false;
- $comment_lastcollapsed = false;
- $comment_firstcollapsed = false;
-
- $threadsid++;
- $threads[$threadsid]['id'] = $item['item_id'];
- $threads[$threadsid]['private'] = $item['private'];
- $threads[$threadsid]['items'] = array();
-
- }
- else {
-
- // prevent private email reply to public conversation from leaking.
- if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
- continue;
-
- $comments_seen ++;
- $comment_lastcollapsed = false;
- $comment_firstcollapsed = false;
- }
-
- $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false);
- $show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false);
-
-
- if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
-
- if (!$comments_collapsed){
- $threads[$threadsid]['num_comments'] = sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),$comments[$item['parent']] );
- $threads[$threadsid]['hide_text'] = t('show more');
- $comments_collapsed = true;
- $comment_firstcollapsed = true;
- }
- }
- if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
-
- $comment_lastcollapsed = true;
- }
-
- $redirect_url = $a->get_baseurl($ssl_state) . '/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']))))
- ? t('Private Message')
- : false);
-
-
- // Top-level wall post not written by the wall owner (wall-to-wall)
- // First figure out who owns it.
-
- $osparkle = '';
-
- if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
-
- if($item['wall']) {
-
- // On the network page, I am the owner. On the display page it will be the profile owner.
- // This will have been stored in $a->page_contact by our calling page.
- // Put this person as the wall owner of the wall-to-wall notice.
-
- $owner_url = zrl($a->page_contact['url']);
- $owner_photo = $a->page_contact['thumb'];
- $owner_name = $a->page_contact['name'];
- $template = $wallwall;
- $commentww = 'ww';
- }
-
- if((! $item['wall']) && $item['owner-link']) {
-
- $owner_linkmatch = (($item['owner-link']) && link_compare($item['owner-link'],$item['author-link']));
- $alias_linkmatch = (($item['alias']) && link_compare($item['alias'],$item['author-link']));
- $owner_namematch = (($item['owner-name']) && $item['owner-name'] == $item['author-name']);
- if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
-
- // The author url doesn't match the owner (typically the contact)
- // and also doesn't match the contact alias.
- // The name match is a hack to catch several weird cases where URLs are
- // all over the park. It can be tricked, but this prevents you from
- // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
- // well that it's the same Bob Smith.
-
- // But it could be somebody else with the same name. It just isn't highly likely.
-
-
- $owner_url = $item['owner-link'];
- $owner_photo = $item['owner-avatar'];
- $owner_name = $item['owner-name'];
- $template = $wallwall;
- $commentww = 'ww';
- // If it is our contact, use a friendly redirect link
- if((link_compare($item['owner-link'],$item['url']))
- && ($item['network'] === NETWORK_DFRN)) {
- $owner_url = $redirect_url;
- $osparkle = ' sparkle';
- }
- else
- $owner_url = zrl($owner_url);