Пример #1
0
 function conversation(&$a, $items, $mode, $update, $preview = false)
 {
     require_once 'include/bbcode.php';
     require_once 'mod/proxy.php';
     $ssl_state = local_user() ? true : false;
     $profile_owner = 0;
     $page_writeable = false;
     $live_update_div = '';
     $arr_blocked = null;
     if (local_user()) {
         $str_blocked = get_pconfig(local_user(), 'system', 'blocked');
         if ($str_blocked) {
             $arr_blocked = explode(',', $str_blocked);
             for ($x = 0; $x < count($arr_blocked); $x++) {
                 $arr_blocked[$x] = trim($arr_blocked[$x]);
             }
         }
     }
     $previewing = $preview ? ' preview ' : '';
     if ($mode === 'network') {
         $profile_owner = local_user();
         $page_writeable = true;
         if (!$update) {
             // The special div is needed for liveUpdate to kick in for this page.
             // We only launch liveUpdate if you aren't filtering in some incompatible
             // way and also you aren't writing a comment (discovered in javascript).
             $live_update_div = '<div id="live-network"></div>' . "\r\n" . "<script> var profile_uid = " . $_SESSION['uid'] . "; var netargs = '" . substr($a->cmd, 8) . '?f=' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : '') . (x($_GET, 'search') ? '&search=' . $_GET['search'] : '') . (x($_GET, 'star') ? '&star=' . $_GET['star'] : '') . (x($_GET, 'order') ? '&order=' . $_GET['order'] : '') . (x($_GET, 'bmark') ? '&bmark=' . $_GET['bmark'] : '') . (x($_GET, 'liked') ? '&liked=' . $_GET['liked'] : '') . (x($_GET, 'conv') ? '&conv=' . $_GET['conv'] : '') . (x($_GET, 'spam') ? '&spam=' . $_GET['spam'] : '') . (x($_GET, 'nets') ? '&nets=' . $_GET['nets'] : '') . (x($_GET, 'cmin') ? '&cmin=' . $_GET['cmin'] : '') . (x($_GET, 'cmax') ? '&cmax=' . $_GET['cmax'] : '') . (x($_GET, 'file') ? '&file=' . $_GET['file'] : '') . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
         }
     } else {
         if ($mode === 'profile') {
             $profile_owner = $a->profile['profile_uid'];
             $page_writeable = can_write_wall($a, $profile_owner);
             if (!$update) {
                 $tab = notags(trim($_GET['tab']));
                 $tab = $tab ? $tab : 'posts';
                 if ($tab === 'posts') {
                     // This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
                     // because browser prefetching might change it on us. We have to deliver it with the page.
                     $live_update_div = '<div id="live-profile"></div>' . "\r\n" . "<script> var profile_uid = " . $a->profile['profile_uid'] . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
                 }
             }
         } else {
             if ($mode === 'notes') {
                 $profile_owner = local_user();
                 $page_writeable = true;
                 if (!$update) {
                     $live_update_div = '<div id="live-notes"></div>' . "\r\n" . "<script> var profile_uid = " . local_user() . "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
                 }
             } else {
                 if ($mode === 'display') {
                     $profile_owner = $a->profile['uid'];
                     $page_writeable = can_write_wall($a, $profile_owner);
                     if (!$update) {
                         $live_update_div = '<div id="live-display"></div>' . "\r\n" . "<script> var profile_uid = " . $_SESSION['uid'] . ";" . " var profile_page = 1; </script>";
                     }
                 } else {
                     if ($mode === 'community') {
                         $profile_owner = 0;
                         $page_writeable = false;
                         if (!$update) {
                             $live_update_div = '<div id="live-community"></div>' . "\r\n" . "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
                         }
                     } else {
                         if ($mode === 'search') {
                             $live_update_div = '<div id="live-search"></div>' . "\r\n";
                         }
                     }
                 }
             }
         }
     }
     $page_dropping = local_user() && local_user() == $profile_owner ? true : false;
     if ($update) {
         $return_url = $_SESSION['return_url'];
     } else {
         $return_url = $_SESSION['return_url'] = $a->query_string;
     }
     load_contact_links(local_user());
     $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview);
     call_hooks('conversation_start', $cb);
     $items = $cb['items'];
     $cmnt_tpl = get_markup_template('comment_item.tpl');
     $hide_comments_tpl = get_markup_template('hide_comments.tpl');
     $alike = array();
     $dlike = array();
     // array with html for each thread (parent+comments)
     $threads = array();
     $threadsid = -1;
     $page_template = get_markup_template("conversation.tpl");
     if ($items && count($items)) {
         if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
             // "New Item View" on network page or search page results
             // - just loop through the items and format them minimally for display
             //			$tpl = get_markup_template('search_item.tpl');
             $tpl = 'search_item.tpl';
             foreach ($items as $item) {
                 if ($arr_blocked) {
                     $blocked = false;
                     foreach ($arr_blocked as $b) {
                         if ($b && link_compare($item['author-link'], $b)) {
                             $blocked = true;
                             break;
                         }
                     }
                     if ($blocked) {
                         continue;
                     }
                 }
                 $threadsid++;
                 $comment = '';
                 $owner_url = '';
                 $owner_photo = '';
                 $owner_name = '';
                 $sparkle = '';
                 if ($mode === 'search' || $mode === 'community') {
                     if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
                         continue;
                     }
                     $nickname = $item['nickname'];
                 } else {
                     $nickname = $a->user['nickname'];
                 }
                 // prevent private email from leaking.
                 if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
                     continue;
                 }
                 $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name'];
                 if ($item['author-link'] && !$item['author-name']) {
                     $profile_name = $item['author-link'];
                 }
                 $tags = array();
                 $hashtags = array();
                 $mentions = array();
                 $taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`", intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
                 foreach ($taglist as $tag) {
                     if ($tag["url"] == "") {
                         $tag["url"] = $searchpath . strtolower($tag["term"]);
                     }
                     if ($tag["type"] == TERM_HASHTAG) {
                         $hashtags[] = "#<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
                         $prefix = "#";
                     } elseif ($tag["type"] == TERM_MENTION) {
                         $mentions[] = "@<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
                         $prefix = "@";
                     }
                     $tags[] = $prefix . "<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
                 }
                 /*foreach(explode(',',$item['tag']) as $tag){
                 			$tag = trim($tag);
                 			if ($tag!="") {
                 				$t = bbcode($tag);
                 				$tags[] = $t;
                 				if($t[0] == '#')
                 					$hashtags[] = $t;
                 				elseif($t[0] == '@')
                 					$mentions[] = $t;
                 			}
                 		}*/
                 $sp = false;
                 $profile_link = best_link_url($item, $sp);
                 if ($profile_link === 'mailbox') {
                     $profile_link = '';
                 }
                 if ($sp) {
                     $sparkle = ' sparkle';
                 } else {
                     $profile_link = zrl($profile_link);
                 }
                 $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']);
                 if ($normalised != 'mailbox' && x($a->contacts[$normalised])) {
                     $profile_avatar = $a->contacts[$normalised]['thumb'];
                 } else {
                     $profile_avatar = strlen($item['author-avatar']) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb'];
                 }
                 $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
                 call_hooks('render_location', $locate);
                 $location = strlen($locate['html']) ? $locate['html'] : render_location_google($locate);
                 localize_item($item);
                 if ($mode === 'network-new') {
                     $dropping = true;
                 } else {
                     $dropping = false;
                 }
                 $drop = array('dropping' => $dropping, 'pagedrop' => $page_dropping, 'select' => t('Select'), 'delete' => t('Delete'));
                 $star = false;
                 $isstarred = "unstarred";
                 $lock = false;
                 $likebuttons = false;
                 $shareable = false;
                 $body = prepare_body($item, true, $preview);
                 list($categories, $folders) = get_cats_and_terms($item);
                 if ($a->theme['template_engine'] === 'internal') {
                     $profile_name_e = template_escape($profile_name);
                     $item['title_e'] = template_escape($item['title']);
                     $body_e = template_escape($body);
                     $tags_e = template_escape($tags);
                     $hashtags_e = template_escape($hashtags);
                     $mentions_e = template_escape($mentions);
                     $location_e = template_escape($location);
                     $owner_name_e = template_escape($owner_name);
                 } else {
                     $profile_name_e = $profile_name;
                     $item['title_e'] = $item['title'];
                     $body_e = $body;
                     $tags_e = $tags;
                     $hashtags_e = $hashtags;
                     $mentions_e = $mentions;
                     $location_e = $location;
                     $owner_name_e = $owner_name;
                 }
                 $tmp_item = array('template' => $tpl, 'id' => $preview ? 'P0' : $item['item_id'], 'network' => $item['item_network'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['author-link']) ? $item['author-link'] : $item['url']), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $profile_name_e, 'sparkle' => $sparkle, 'lock' => $lock, 'thumb' => proxy_url($profile_avatar), 'title' => $item['title_e'], 'body' => $body_e, 'tags' => $tags_e, 'hashtags' => $hashtags_e, 'mentions' => $mentions_e, 'txt_cats' => t('Categories:'), 'txt_folders' => t('Filed under:'), 'has_cats' => count($categories) ? 'true' : '', 'has_folders' => count($folders) ? 'true' : '', 'categories' => $categories, 'folders' => $folders, 'text' => strip_tags($body_e), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), 'location' => $location_e, 'indent' => '', 'owner_name' => $owner_name_e, 'owner_url' => $owner_url, 'owner_photo' => proxy_url($owner_photo), 'plink' => get_plink($item), 'edpost' => false, 'isstarred' => $isstarred, 'star' => $star, 'drop' => $drop, 'vote' => $likebuttons, 'like' => '', 'dislike' => '', 'comment' => '', 'conv' => $preview ? '' : array('href' => $a->get_baseurl($ssl_state) . '/display/' . $item['guid'], 'title' => t('View in context')), 'previewing' => $previewing, 'wait' => t('Please wait'), 'thread_level' => 1);
                 $arr = array('item' => $item, 'output' => $tmp_item);
                 call_hooks('display_item', $arr);
                 $threads[$threadsid]['id'] = $item['item_id'];
                 $threads[$threadsid]['network'] = $item['item_network'];
                 $threads[$threadsid]['items'] = array($arr['output']);
             }
         } else {
             // Normal View
             $page_template = get_markup_template("threaded_conversation.tpl");
             require_once 'object/Conversation.php';
             require_once 'object/Item.php';
             $conv = new Conversation($mode, $preview);
             // get all the topmost parents
             // this shouldn't be needed, as we should have only them in our array
             // But for now, this array respects the old style, just in case
             $threads = array();
             foreach ($items as $item) {
                 if ($arr_blocked) {
                     $blocked = false;
                     foreach ($arr_blocked as $b) {
                         if ($b && link_compare($item['author-link'], $b)) {
                             $blocked = true;
                             break;
                         }
                     }
                     if ($blocked) {
                         continue;
                     }
                 }
                 // Can we put this after the visibility check?
                 like_puller($a, $item, $alike, 'like');
                 like_puller($a, $item, $dlike, 'dislike');
                 // Only add what is visible
                 if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
                     continue;
                 }
                 if (!visible_activity($item)) {
                     continue;
                 }
                 call_hooks('display_item', $arr);
                 $item['pagedrop'] = $page_dropping;
                 if ($item['id'] == $item['parent']) {
                     $item_object = new Item($item);
                     $conv->add_thread($item_object);
                 }
             }
             $threads = $conv->get_template_data($alike, $dlike);
             if (!$threads) {
                 logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
                 $threads = array();
             }
         }
     }
     $o = replace_macros($page_template, array('$baseurl' => $a->get_baseurl($ssl_state), '$return_path' => $a->query_string, '$live_update' => $live_update_div, '$remove' => t('remove'), '$mode' => $mode, '$user' => $a->user, '$threads' => $threads, '$dropping' => $page_dropping && feature_enabled(local_user(), 'multi_delete') ? t('Delete Selected Items') : False));
     return $o;
 }
Пример #2
0
/**
 * @brief "Render" a conversation or list of items for HTML display.
 *
 * There are two major forms of display:
 *  - Sequential or unthreaded ("New Item View" or search results)
 *  - conversation view
 *
 * The $mode parameter decides between the various renderings and also
 * figures out how to determine page owner and other contextual items
 * that are based on unique features of the calling module.
 *
 * @param App &$a
 * @param array $items
 * @param string $mode
 * @param boolean $update
 * @param string $page_mode default traditional
 * @param string $prepared_item
 * @return string
 */
function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $prepared_item = '')
{
    $content_html = '';
    $o = '';
    require_once 'bbcode.php';
    $ssl_state = local_channel() ? true : false;
    if (local_channel()) {
        load_pconfig(local_channel(), '');
    }
    $arr_blocked = null;
    if (local_channel()) {
        $str_blocked = get_pconfig(local_channel(), 'system', 'blocked');
    }
    if (!local_channel() && $mode == 'network') {
        $sys = get_sys_channel();
        $id = $sys['channel_id'];
        $str_blocked = get_pconfig($id, 'system', 'blocked');
    }
    if ($str_blocked) {
        $arr_blocked = explode(',', $str_blocked);
        for ($x = 0; $x < count($arr_blocked); $x++) {
            $arr_blocked[$x] = trim($arr_blocked[$x]);
        }
    }
    $profile_owner = 0;
    $page_writeable = false;
    $live_update_div = '';
    $preview = $page_mode === 'preview' ? true : false;
    $previewing = $preview ? ' preview ' : '';
    if ($mode === 'network') {
        $profile_owner = local_channel();
        $page_writeable = true;
        if (!$update) {
            // The special div is needed for liveUpdate to kick in for this page.
            // We only launch liveUpdate if you aren't filtering in some incompatible
            // way and also you aren't writing a comment (discovered in javascript).
            $live_update_div = '<div id="live-network"></div>' . "\r\n" . "<script> var profile_uid = " . $_SESSION['uid'] . "; var netargs = '" . substr($a->cmd, 8) . '?f=' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : '') . (x($_GET, 'search') ? '&search=' . $_GET['search'] : '') . (x($_GET, 'star') ? '&star=' . $_GET['star'] : '') . (x($_GET, 'order') ? '&order=' . $_GET['order'] : '') . (x($_GET, 'bmark') ? '&bmark=' . $_GET['bmark'] : '') . (x($_GET, 'liked') ? '&liked=' . $_GET['liked'] : '') . (x($_GET, 'conv') ? '&conv=' . $_GET['conv'] : '') . (x($_GET, 'spam') ? '&spam=' . $_GET['spam'] : '') . (x($_GET, 'nets') ? '&nets=' . $_GET['nets'] : '') . (x($_GET, 'cmin') ? '&cmin=' . $_GET['cmin'] : '') . (x($_GET, 'cmax') ? '&cmax=' . $_GET['cmax'] : '') . (x($_GET, 'file') ? '&file=' . $_GET['file'] : '') . (x($_GET, 'uri') ? '&uri=' . $_GET['uri'] : '') . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
        }
    } elseif ($mode === 'channel') {
        $profile_owner = $a->profile['profile_uid'];
        $page_writeable = $profile_owner == local_channel();
        if (!$update) {
            $tab = notags(trim($_GET['tab']));
            if ($tab === 'posts') {
                // This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
                // because browser prefetching might change it on us. We have to deliver it with the page.
                $live_update_div = '<div id="live-channel"></div>' . "\r\n" . "<script> var profile_uid = " . $a->profile['profile_uid'] . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
            }
        }
    } elseif ($mode === 'display') {
        $profile_owner = local_channel();
        $page_writeable = false;
        $live_update_div = '<div id="live-display"></div>' . "\r\n";
    } elseif ($mode === 'page') {
        $profile_owner = $a->profile['uid'];
        $page_writeable = $profile_owner == local_channel();
        $live_update_div = '<div id="live-page"></div>' . "\r\n";
    } elseif ($mode === 'search') {
        $live_update_div = '<div id="live-search"></div>' . "\r\n";
    } elseif ($mode === 'photos') {
        $profile_onwer = $a->profile['profile_uid'];
        $page_writeable = $profile_owner == local_channel();
        $live_update_div = '<div id="live-photos"></div>' . "\r\n";
        // for photos we've already formatted the top-level item (the photo)
        $content_html = $a->data['photo_html'];
    }
    $page_dropping = local_channel() && local_channel() == $profile_owner ? true : false;
    if (!feature_enabled($profile_owner, 'multi_delete')) {
        $page_dropping = false;
    }
    $channel = $a->get_channel();
    $observer = $a->get_observer();
    if ($update) {
        $return_url = $_SESSION['return_url'];
    } else {
        $return_url = $_SESSION['return_url'] = $a->query_string;
    }
    load_contact_links(local_channel());
    $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview);
    call_hooks('conversation_start', $cb);
    $items = $cb['items'];
    $conv_responses = array('like' => array('title' => t('Likes', 'title')), 'dislike' => array('title' => t('Dislikes', 'title')), 'agree' => array('title' => t('Agree', 'title')), 'disagree' => array('title' => t('Disagree', 'title')), 'abstain' => array('title' => t('Abstain', 'title')), 'attendyes' => array('title' => t('Attending', 'title')), 'attendno' => array('title' => t('Not attending', 'title')), 'attendmaybe' => array('title' => t('Might attend', 'title')));
    // array with html for each thread (parent+comments)
    $threads = array();
    $threadsid = -1;
    $page_template = get_markup_template("conversation.tpl");
    if ($items) {
        if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
            // "New Item View" on network page or search page results
            // - just loop through the items and format them minimally for display
            //$tpl = get_markup_template('search_item.tpl');
            $tpl = 'search_item.tpl';
            foreach ($items as $item) {
                if ($arr_blocked) {
                    $blocked = false;
                    foreach ($arr_blocked as $b) {
                        if ($b && $item['author_xchan'] == $b) {
                            $blocked = true;
                            break;
                        }
                    }
                    if ($blocked) {
                        continue;
                    }
                }
                $threadsid++;
                $comment = '';
                $owner_url = '';
                $owner_photo = '';
                $owner_name = '';
                $sparkle = '';
                if ($mode === 'search' || $mode === 'community') {
                    if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
                        continue;
                    }
                    $nickname = $item['nickname'];
                } else {
                    $nickname = $a->user['nickname'];
                }
                $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name'];
                if ($item['author-link'] && !$item['author-name']) {
                    $profile_name = $item['author-link'];
                }
                $tags = array();
                $hashtags = array();
                $mentions = array();
                $sp = false;
                $profile_link = best_link_url($item, $sp);
                if ($sp) {
                    $sparkle = ' sparkle';
                } else {
                    $profile_link = zid($profile_link);
                }
                $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']);
                $profile_name = $item['author']['xchan_name'];
                $profile_link = $item['author']['xchan_url'];
                $profile_avatar = $item['author']['xchan_photo_m'];
                $location = format_location($item);
                localize_item($item);
                if ($mode === 'network-new') {
                    $dropping = true;
                } else {
                    $dropping = false;
                }
                $drop = array('pagedropping' => $page_dropping, 'dropping' => $dropping, 'select' => t('Select'), 'delete' => t('Delete'));
                $star = false;
                $isstarred = "unstarred icon-star-empty";
                $lock = $item['item_private'] || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid']) ? t('Private Message') : false;
                $likebuttons = false;
                $shareable = false;
                $verified = $item['item_flags'] & ITEM_VERIFIED ? t('Message signature validated') : '';
                $forged = $item['sig'] && !($item['item_flags'] & ITEM_VERIFIED) ? t('Message signature incorrect') : '';
                $unverified = '';
                $tags = array();
                $terms = get_terms_oftype($item['term'], array(TERM_HASHTAG, TERM_MENTION, TERM_UNKNOWN));
                if (count($terms)) {
                    foreach ($terms as $tag) {
                        $tags[] = format_term_for_display($tag);
                    }
                }
                $body = prepare_body($item, true);
                $tmp_item = array('template' => $tpl, 'toplevel' => 'toplevel_item', 'mode' => $mode, 'id' => $preview ? 'P0' : $item['item_id'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, $profile_url), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $profile_name, 'sparkle' => $sparkle, 'lock' => $lock, 'thumb' => $profile_avatar, 'title' => $item['title'], 'body' => $body, 'tags' => $tags, 'hashtags' => $hashtags, 'mentions' => $mentions, 'verified' => $verified, 'unverified' => $unverified, 'forged' => $forged, 'txt_cats' => t('Categories:'), 'txt_folders' => t('Filed under:'), 'has_cats' => count($categories) ? 'true' : '', 'has_folders' => count($folders) ? 'true' : '', 'categories' => $categories, 'folders' => $folders, 'text' => strip_tags($body), 'ago' => relative_date($item['created']), 'app' => $item['app'], 'str_app' => sprintf(t(' from %s'), $item['app']), 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'editedtime' => $item['edited'] != $item['created'] ? sprintf(t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r')) : '', 'expiretime' => $item['expires'] !== NULL_DATE ? sprintf(t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')) : '', 'location' => $location, 'indent' => '', 'owner_name' => $owner_name, 'owner_url' => $owner_url, 'owner_photo' => $owner_photo, 'plink' => get_plink($item, false), 'edpost' => false, 'isstarred' => $isstarred, 'star' => $star, 'drop' => $drop, 'vote' => $likebuttons, 'like' => '', 'dislike' => '', 'comment' => '', 'conv' => $preview ? '' : array('href' => z_root() . '/display/' . $item['mid'], 'title' => t('View in context')), 'previewing' => $previewing, 'wait' => t('Please wait'), 'thread_level' => 1);
                $arr = array('item' => $item, 'output' => $tmp_item);
                call_hooks('display_item', $arr);
                //				$threads[$threadsid]['id'] = $item['item_id'];
                $threads[] = $arr['output'];
            }
        } else {
            // Normal View
            //			logger('conv: items: ' . print_r($items,true));
            require_once 'include/ConversationObject.php';
            require_once 'include/ItemObject.php';
            $conv = new Conversation($mode, $preview, $prepared_item);
            // In the display mode we don't have a profile owner.
            if ($mode === 'display' && $items) {
                $conv->set_profile_owner($items[0]['uid']);
            }
            // get all the topmost parents
            // this shouldn't be needed, as we should have only them in our array
            // But for now, this array respects the old style, just in case
            $threads = array();
            foreach ($items as $item) {
                // Check for any blocked authors
                if ($arr_blocked) {
                    $blocked = false;
                    foreach ($arr_blocked as $b) {
                        if ($b && $item['author_xchan'] == $b) {
                            $blocked = true;
                            break;
                        }
                    }
                    if ($blocked) {
                        continue;
                    }
                }
                // Check all the kids too
                if ($arr_blocked && $item['children']) {
                    for ($d = 0; $d < count($item['children']); $d++) {
                        foreach ($arr_blocked as $b) {
                            if ($b && $item['children'][$d]['author_xchan'] == $b) {
                                $item['children'][$d]['author_blocked'] = true;
                            }
                        }
                    }
                }
                builtin_activity_puller($item, $conv_responses);
                if (!visible_activity($item)) {
                    continue;
                }
                $item['pagedrop'] = $page_dropping;
                if ($item['id'] == $item['parent']) {
                    $item_object = new Item($item);
                    $conv->add_thread($item_object);
                    if ($page_mode === 'list') {
                        $item_object->set_template('conv_list.tpl');
                        $item_object->set_display_mode('list');
                    }
                }
            }
            $threads = $conv->get_template_data($conv_responses);
            if (!$threads) {
                logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
                $threads = array();
            }
        }
    }
    if ($page_mode === 'traditional' || $page_mode === 'preview') {
        $page_template = get_markup_template("threaded_conversation.tpl");
    } elseif ($update) {
        $page_template = get_markup_template("convobj.tpl");
    } else {
        $page_template = get_markup_template("conv_frame.tpl");
        $threads = null;
    }
    //	if($page_mode === 'preview')
    //		logger('preview: ' . print_r($threads,true));
    //  Do not un-comment if smarty3 is in use
    //	logger('page_template: ' . $page_template);
    //	logger('nouveau: ' . print_r($threads,true));
    $o .= replace_macros($page_template, array('$baseurl' => $a->get_baseurl($ssl_state), '$photo_item' => $content_html, '$live_update' => $live_update_div, '$remove' => t('remove'), '$mode' => $mode, '$user' => $a->user, '$threads' => $threads, '$wait' => t('Loading...'), '$dropping' => $page_dropping ? t('Delete Selected Items') : False));
    return $o;
}