From da1b47a029e678aee8b99ee11eec972dfb9a1a2b Mon Sep 17 00:00:00 2001 From: Domovoy Date: Mon, 23 Jul 2012 12:56:47 +0200 Subject: [PATCH 01/29] Progress on #1. Comments are now threaded, at least in the database, for normal view. --- include/conversation.php | 7 +++++-- mod/item.php | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 4a9142bb20..67445c2904 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -582,7 +582,9 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); - $show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false); + // The comment box should now appear under each writable item, not only at the end of the thread, don't bother with $comments_seen + //$show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false); + $show_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { @@ -681,12 +683,13 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { + // The parent is now the item itself, not his parent $comment = replace_macros($cmnt_tpl,array( '$return_path' => '', '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'), '$id' => $item['item_id'], - '$parent' => $item['parent'], + '$parent' => $item['item_id'], '$qcomment' => $qcomment, '$profile_uid' => $profile_owner, '$mylink' => $a->contact['url'], diff --git a/mod/item.php b/mod/item.php index fddc3fd124..cc1e628c80 100644 --- a/mod/item.php +++ b/mod/item.php @@ -77,14 +77,15 @@ function item_post(&$a) { ); } // if this isn't the real parent of the conversation, find it - if($r !== false && count($r)) { + // We are now threading the comments, the parent may have a parent + /*if($r !== false && count($r)) { $parid = $r[0]['parent']; if($r[0]['id'] != $r[0]['parent']) { $r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1", intval($parid) ); } - } + }*/ if(($r === false) || (! count($r))) { notice( t('Unable to locate original post.') . EOL); From 2a1657e3617faff8964e979a7a8482dfc0ec08d9 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Mon, 23 Jul 2012 13:58:47 +0200 Subject: [PATCH 02/29] Revert "Progress on #1. Comments are now threaded, at least in the database, for normal view." This reverts commit da1b47a029e678aee8b99ee11eec972dfb9a1a2b. Useless, comments are already threaded in the database using parent-uri --- include/conversation.php | 7 ++----- mod/item.php | 5 ++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 67445c2904..4a9142bb20 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -582,9 +582,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); - // The comment box should now appear under each writable item, not only at the end of the thread, don't bother with $comments_seen - //$show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false); - $show_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)) { @@ -683,13 +681,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { - // The parent is now the item itself, not his parent $comment = replace_macros($cmnt_tpl,array( '$return_path' => '', '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'), '$id' => $item['item_id'], - '$parent' => $item['item_id'], + '$parent' => $item['parent'], '$qcomment' => $qcomment, '$profile_uid' => $profile_owner, '$mylink' => $a->contact['url'], diff --git a/mod/item.php b/mod/item.php index cc1e628c80..fddc3fd124 100644 --- a/mod/item.php +++ b/mod/item.php @@ -77,15 +77,14 @@ function item_post(&$a) { ); } // if this isn't the real parent of the conversation, find it - // We are now threading the comments, the parent may have a parent - /*if($r !== false && count($r)) { + if($r !== false && count($r)) { $parid = $r[0]['parent']; if($r[0]['id'] != $r[0]['parent']) { $r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1", intval($parid) ); } - }*/ + } if(($r === false) || (! count($r))) { notice( t('Unable to locate original post.') . EOL); From 8ecf8167db91f43ec91ab77e194064662a1710c8 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Fri, 27 Jul 2012 22:08:57 +0200 Subject: [PATCH 03/29] Threaded comments are starting to work. For now, only on normal view, and not during update --- include/conversation.php | 997 ++++++++++++++++++++---------- mod/item.php | 3 +- mod/network.php | 2 +- view/theme/duepuntozero/style.css | 6 +- view/threaded_conversation.tpl | 13 + view/wall_thread.tpl | 91 +++ 6 files changed, 781 insertions(+), 331 deletions(-) create mode 100644 view/threaded_conversation.tpl create mode 100644 view/wall_thread.tpl diff --git a/include/conversation.php b/include/conversation.php index 4a9142bb20..2794d8ab3b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -299,6 +299,292 @@ function localize_item(&$item){ } +/** + * Recursively prepare a thread for HTML + */ + +function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $profile_owner) { + $result = array(); + + $wall_template = 'wall_thread.tpl'; + $wallwall_template = 'wallwall_thread.tpl'; + $items_seen = 0; + $nb_items = count($items); + $lastcollapsed = false; + $firstcollapsed = false; + + foreach($items as $item) { + // prevent private email reply to public conversation from leaking. + if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { + // Don't count it as a visible item + $nb_items--; + continue; + } + + $items_seen++; + + $alike = array(); + $dlike = array(); + $comment = ''; + $template = $wall_template; + $commentww = ''; + $sparkle = ''; + $owner_url = $owner_photo = $owner_name = ''; + $buttons = ''; + $dropping = false; + $star = false; + $isstarred = "unstarred"; + $photo = $item['photo']; + $thumb = $item['thumb']; + $indent = ''; + $osparkle = ''; + + $toplevelpost = (($item['id'] == $item['parent']) ? true : false); + $item_writeable = (($item['writable'] || $item['self']) ? true : false); + $show_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); + $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) + || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) + ? t('Private Message') + : false); + $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid'] ; + $shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false); + if(local_user() && link_compare($a->contact['url'],$item['author-link'])) + $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); + else + $edpost = false; + if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) + $dropping = true; + + $drop = array( + 'dropping' => $dropping, + 'select' => t('Select'), + 'delete' => t('Delete'), + ); + + $filer = (($profile_owner == local_user()) ? t("save to folder") : false); + + $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); + $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); + if($item['author-link'] && (! $item['author-name'])) + $profile_name = $item['author-link']; + + $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'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($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)); + + $tags=array(); + foreach(explode(',',$item['tag']) as $tag){ + $tag = trim($tag); + if ($tag!="") $tags[] = bbcode($tag); + } + + like_puller($a,$item,$alike,'like'); + like_puller($a,$item,$dlike,'dislike'); + + $like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : ''); + $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : ''); + + if($toplevelpost) { + if((! $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_template; + $commentww = 'ww'; + } + } + else if($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_template; + $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); + } + } + if($profile_owner == local_user()) { + $isstarred = (($item['starred']) ? "starred" : "unstarred"); + + $star = array( + 'do' => t("add star"), + 'undo' => t("remove star"), + 'toggle' => t("toggle star status"), + 'classdo' => (($item['starred']) ? "hidden" : ""), + 'classundo' => (($item['starred']) ? "" : "hidden"), + 'starred' => t('starred'), + 'tagger' => t("add tag"), + 'classtagger' => "", + ); + } + } else { + $indent = 'comment'; + // Collapse comments + if($nb_items > 2) { + if(!$firstcollapsed && ($items_seen <= ($nb_items - 2))) { + $firstcollapsed = true; + } + else if($items_seen == ($nb_items - 1)) { + $lastcollapsed = true; + } + } + } + + logger('item, page_writeable:'. ($page_writeable ? 'yes' : 'no') .', show comment box: '. ($show_comment_box ? 'yes' : 'no'), LOGGER_DEBUG); + if($page_writeable) { + $buttons = array( + 'like' => array( t("I like this \x28toggle\x29"), t("like")), + 'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")), + ); + if ($shareable) $buttons['share'] = array( t('Share this'), t('share')); + + + if($show_comment_box) { + $qc = $qcomment = null; + + if(in_array('qcomment',$a->plugins)) { + $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); + $qcomment = (($qc) ? explode("\n",$qc) : null); + } + + $comment = replace_macros($cmnt_tpl,array( + '$return_path' => '', + '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), + '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'), + '$id' => $item['item_id'], + '$parent' => $item['item_id'], + '$qcomment' => $qcomment, + '$profile_uid' => $profile_owner, + '$mylink' => $a->contact['url'], + '$mytitle' => t('This is you'), + '$myphoto' => $a->contact['thumb'], + '$comment' => t('Comment'), + '$submit' => t('Submit'), + '$edbold' => t('Bold'), + '$editalic' => t('Italic'), + '$eduline' => t('Underline'), + '$edquote' => t('Quote'), + '$edcode' => t('Code'), + '$edimg' => t('Image'), + '$edurl' => t('Link'), + '$edvideo' => t('Video'), + '$preview' => t('Preview'), + '$ww' => (($mode === 'network') ? $commentww : '') + )); + } + } + + if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) + $indent .= ' shiny'; + + localize_item($item); + + $body = prepare_body($item,true); + + $tmp_item = array( + // collapse comments in template. I don't like this much... + 'comment_firstcollapsed' => $comment_firstcollapsed, + 'comment_lastcollapsed' => $comment_lastcollapsed, + // template to use to render item (wall, walltowall, search) + 'template' => $template, + + 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), + 'tags' => $tags, + 'body' => template_escape($body), + 'text' => strip_tags(template_escape($body)), + 'id' => $item['item_id'], + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), + 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $owner_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), + 'to' => t('to'), + 'wall' => t('Wall-to-Wall'), + 'vwall' => t('via Wall-To-Wall:'), + 'profile_url' => $profile_link, + 'item_photo_menu' => item_photo_menu($item), + 'name' => template_escape($profile_name), + 'thumb' => $profile_avatar, + 'osparkle' => $osparkle, + 'sparkle' => $sparkle, + 'title' => template_escape($item['title']), + 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'lock' => $lock, + 'location' => template_escape($location), + 'indent' => $indent, + 'owner_url' => $owner_url, + 'owner_photo' => $owner_photo, + 'owner_name' => template_escape($owner_name), + 'plink' => get_plink($item), + 'edpost' => $edpost, + 'isstarred' => $isstarred, + 'star' => $star, + 'filer' => $filer, + 'drop' => $drop, + 'vote' => $buttons, + 'like' => $like, + 'dislike' => $dislike, + 'comment' => $comment, + 'previewing' => $previewing, + 'wait' => t('Please wait'), + ); + + $arr = array('item' => $item, 'output' => $tmp_item); + call_hooks('display_item', $arr); + + $item_result = $arr['output']; + + $item_result['children'] = array(); + if(count($item['children'])) { + $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner); + } + $item_result['private'] = $item['private']; + $result[] = $item_result; + } + + return $result; +} + /** * "Render" a conversation or list of items for HTML display. * There are two major forms of display: @@ -311,7 +597,7 @@ function localize_item(&$item){ */ if(!function_exists('conversation')) { -function conversation(&$a, $items, $mode, $update, $preview = false) { +function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = false) { require_once('bbcode.php'); @@ -500,364 +786,386 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { { // Normal View + // Threaded comments, $thr_c is used for now since we don't know what other parts of friendica uses this function + // Better not rely on the new code for stuff we haven't examined yet + if($thr_c) { + // get all the topmost parents + // this shouldn't be needed, as we should have only them in ou array + // But for now, this array respects the old style, just in case - // Figure out how many comments each parent has - // (Comments all have gravity of 6) - // Store the result in the $comments array - - $comments = array(); - foreach($items as $item) { - if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) { - if(! x($comments,$item['parent'])) - $comments[$item['parent']] = 1; - else - $comments[$item['parent']] += 1; - } elseif(! x($comments,$item['parent'])) - $comments[$item['parent']] = 0; // avoid notices later on - } - - // map all the like/dislike activities for each parent item - // Store these in the $alike and $dlike arrays - - foreach($items as $item) { - like_puller($a,$item,$alike,'like'); - like_puller($a,$item,$dlike,'dislike'); - } - - $comments_collapsed = false; - $comments_seen = 0; - $comment_lastcollapsed = false; - $comment_firstcollapsed = false; - $blowhard = 0; - $blowhard_count = 0; - - - 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); - - - // 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) { - - $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; + $threads = array(); + foreach($items as $item) { + if($item['id'] == $item['parent']) { + $threads[] = $item; } } - if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) { - $comment_lastcollapsed = true; + $threads = prepare_threads_body($a, $threads, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $previewing); + } else { + + + // Figure out how many comments each parent has + // (Comments all have gravity of 6) + // Store the result in the $comments array + + $comments = array(); + foreach($items as $item) { + if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) { + if(! x($comments,$item['parent'])) + $comments[$item['parent']] = 1; + else + $comments[$item['parent']] += 1; + } elseif(! x($comments,$item['parent'])) + $comments[$item['parent']] = 0; // avoid notices later on } - $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid'] ; + // map all the like/dislike activities for each parent item + // Store these in the $alike and $dlike arrays - $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) - || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) - ? t('Private Message') - : false); + foreach($items as $item) { + like_puller($a,$item,$alike,'like'); + like_puller($a,$item,$dlike,'dislike'); + } + + $comments_collapsed = false; + $comments_seen = 0; + $comment_lastcollapsed = false; + $comment_firstcollapsed = false; + $blowhard = 0; + $blowhard_count = 0; - // Top-level wall post not written by the wall owner (wall-to-wall) - // First figure out who owns it. + foreach($items as $item) { - $osparkle = ''; + $comment = ''; + $template = $tpl; + $commentww = ''; + $sparkle = ''; + $owner_url = $owner_photo = $owner_name = ''; - if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) { + // We've already parsed out like/dislike for special treatment. We can ignore them now - if($item['wall']) { + if(((activity_match($item['verb'],ACTIVITY_LIKE)) + || (activity_match($item['verb'],ACTIVITY_DISLIKE))) + && ($item['id'] != $item['parent'])) + continue; - // 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. + $toplevelpost = (($item['id'] == $item['parent']) ? true : 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) { + + $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(); - $owner_url = zrl($a->page_contact['url']); - $owner_photo = $a->page_contact['thumb']; - $owner_name = $a->page_contact['name']; - $template = $wallwall; - $commentww = 'ww'; } + else { - if((! $item['wall']) && $item['owner-link']) { + // prevent private email reply to public conversation from leaking. + if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) + continue; - $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)) { + $comments_seen ++; + $comment_lastcollapsed = false; + $comment_firstcollapsed = false; + } - // 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. + $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); + // Show comment box on every writable item + $show_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); - // 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); + 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))) { - $likebuttons = ''; - $shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false); - - if($page_writeable) { -/* if($toplevelpost) { */ - $likebuttons = array( - 'like' => array( t("I like this \x28toggle\x29"), t("like")), - 'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")), - ); - if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share')); -/* } */ - - $qc = $qcomment = null; - - if(in_array('qcomment',$a->plugins)) { - $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); - $qcomment = (($qc) ? explode("\n",$qc) : null); + $comment_lastcollapsed = true; } - if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { - $comment = replace_macros($cmnt_tpl,array( - '$return_path' => '', - '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), - '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'), - '$id' => $item['item_id'], - '$parent' => $item['parent'], - '$qcomment' => $qcomment, - '$profile_uid' => $profile_owner, - '$mylink' => $a->contact['url'], - '$mytitle' => t('This is you'), - '$myphoto' => $a->contact['thumb'], - '$comment' => t('Comment'), - '$submit' => t('Submit'), - '$edbold' => t('Bold'), - '$editalic' => t('Italic'), - '$eduline' => t('Underline'), - '$edquote' => t('Quote'), - '$edcode' => t('Code'), - '$edimg' => t('Image'), - '$edurl' => t('Link'), - '$edvideo' => t('Video'), - '$preview' => t('Preview'), - '$ww' => (($mode === 'network') ? $commentww : '') - )); + $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid'] ; + + $lock = ((($item['private'] == 1) || (($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); + } + } } - } - if(local_user() && link_compare($a->contact['url'],$item['author-link'])) - $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); - else - $edpost = false; + $likebuttons = ''; + $shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false); - $drop = ''; - $dropping = false; + if($page_writeable) { + /* if($toplevelpost) { */ + $likebuttons = array( + 'like' => array( t("I like this \x28toggle\x29"), t("like")), + 'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")), + ); + if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share')); + /* } */ - if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) - $dropping = true; + $qc = $qcomment = null; - $drop = array( - 'dropping' => $dropping, - 'select' => t('Select'), - 'delete' => t('Delete'), - ); + if(in_array('qcomment',$a->plugins)) { + $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); + $qcomment = (($qc) ? explode("\n",$qc) : null); + } - $star = false; - $filer = false; - - $isstarred = "unstarred"; - if ($profile_owner == local_user()) { - if($toplevelpost) { - $isstarred = (($item['starred']) ? "starred" : "unstarred"); - - $star = array( - 'do' => t("add star"), - 'undo' => t("remove star"), - 'toggle' => t("toggle star status"), - 'classdo' => (($item['starred']) ? "hidden" : ""), - 'classundo' => (($item['starred']) ? "" : "hidden"), - 'starred' => t('starred'), - 'tagger' => t("add tag"), - 'classtagger' => "", - ); + if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { + $comment = replace_macros($cmnt_tpl,array( + '$return_path' => '', + '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), + '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'), + '$id' => $item['item_id'], + '$parent' => $item['item_id'], + '$qcomment' => $qcomment, + '$profile_uid' => $profile_owner, + '$mylink' => $a->contact['url'], + '$mytitle' => t('This is you'), + '$myphoto' => $a->contact['thumb'], + '$comment' => t('Comment'), + '$submit' => t('Submit'), + '$edbold' => t('Bold'), + '$editalic' => t('Italic'), + '$eduline' => t('Underline'), + '$edquote' => t('Quote'), + '$edcode' => t('Code'), + '$edimg' => t('Image'), + '$edurl' => t('Link'), + '$edvideo' => t('Video'), + '$preview' => t('Preview'), + '$ww' => (($mode === 'network') ? $commentww : '') + )); + } } - $filer = t("save to folder"); + + if(local_user() && link_compare($a->contact['url'],$item['author-link'])) + $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); + else + $edpost = false; + + $drop = ''; + $dropping = false; + + if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) + $dropping = true; + + $drop = array( + 'dropping' => $dropping, + 'select' => t('Select'), + 'delete' => t('Delete'), + ); + + $star = false; + $filer = false; + + $isstarred = "unstarred"; + if ($profile_owner == local_user()) { + if($toplevelpost) { + $isstarred = (($item['starred']) ? "starred" : "unstarred"); + + $star = array( + 'do' => t("add star"), + 'undo' => t("remove star"), + 'toggle' => t("toggle star status"), + 'classdo' => (($item['starred']) ? "hidden" : ""), + 'classundo' => (($item['starred']) ? "" : "hidden"), + 'starred' => t('starred'), + 'tagger' => t("add tag"), + 'classtagger' => "", + ); + } + $filer = t("save to folder"); + } + + + $photo = $item['photo']; + $thumb = $item['thumb']; + + // Post was remotely authored. + + $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); + + $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); + + if($item['author-link'] && (! $item['author-name'])) + $profile_name = $item['author-link']; + + $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'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($thumb)); + + $like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : ''); + $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : ''); + + $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); + call_hooks('render_location',$locate); + + $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate)); + + $indent = (($toplevelpost) ? '' : ' comment'); + + if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) + $indent .= ' shiny'; + + // + localize_item($item); + + + $tags=array(); + foreach(explode(',',$item['tag']) as $tag){ + $tag = trim($tag); + if ($tag!="") $tags[] = bbcode($tag); + } + + // Build the HTML + + $body = prepare_body($item,true); + //$tmp_item = replace_macros($template, + $tmp_item = array( + // collapse comments in template. I don't like this much... + 'comment_firstcollapsed' => $firstcollapsed, + 'comment_lastcollapsed' => $lastcollapsed, + // template to use to render item (wall, walltowall, search) + 'template' => $template, + + 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), + 'tags' => $tags, + 'body' => template_escape($body), + 'text' => strip_tags(template_escape($body)), + 'id' => $item['item_id'], + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), + 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $owner-name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), + 'to' => t('to'), + 'wall' => t('Wall-to-Wall'), + 'vwall' => t('via Wall-To-Wall:'), + 'profile_url' => $profile_link, + 'item_photo_menu' => item_photo_menu($item), + 'name' => template_escape($profile_name), + 'thumb' => $profile_avatar, + 'osparkle' => $osparkle, + 'sparkle' => $sparkle, + 'title' => template_escape($item['title']), + 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'lock' => $lock, + 'location' => template_escape($location), + 'indent' => $indent, + 'owner_url' => $owner_url, + 'owner_photo' => $owner_photo, + 'owner_name' => template_escape($owner_name), + 'plink' => get_plink($item), + 'edpost' => $edpost, + 'isstarred' => $isstarred, + 'star' => $star, + 'filer' => $filer, + 'drop' => $drop, + 'vote' => $likebuttons, + 'like' => $like, + 'dislike' => $dislike, + 'comment' => $comment, + 'previewing' => $previewing, + 'wait' => t('Please wait'), + + ); + + + $arr = array('item' => $item, 'output' => $tmp_item); + call_hooks('display_item', $arr); + + $threads[$threadsid]['items'][] = $arr['output']; } - - - $photo = $item['photo']; - $thumb = $item['thumb']; - - // Post was remotely authored. - - $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); - - $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); - - if($item['author-link'] && (! $item['author-name'])) - $profile_name = $item['author-link']; - - $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'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($thumb)); - - $like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : ''); - $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : ''); - - $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); - call_hooks('render_location',$locate); - - $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate)); - - $indent = (($toplevelpost) ? '' : ' comment'); - - if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) - $indent .= ' shiny'; - - // - localize_item($item); - - - $tags=array(); - foreach(explode(',',$item['tag']) as $tag){ - $tag = trim($tag); - if ($tag!="") $tags[] = bbcode($tag); - } - - // Build the HTML - - $body = prepare_body($item,true); - //$tmp_item = replace_macros($template, - $tmp_item = array( - // collapse comments in template. I don't like this much... - 'comment_firstcollapsed' => $comment_firstcollapsed, - 'comment_lastcollapsed' => $comment_lastcollapsed, - // template to use to render item (wall, walltowall, search) - 'template' => $template, - - 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), - 'tags' => $tags, - 'body' => template_escape($body), - 'text' => strip_tags(template_escape($body)), - 'id' => $item['item_id'], - 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), - 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $owner-name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), - 'to' => t('to'), - 'wall' => t('Wall-to-Wall'), - 'vwall' => t('via Wall-To-Wall:'), - 'profile_url' => $profile_link, - 'item_photo_menu' => item_photo_menu($item), - 'name' => template_escape($profile_name), - 'thumb' => $profile_avatar, - 'osparkle' => $osparkle, - 'sparkle' => $sparkle, - 'title' => template_escape($item['title']), - 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - 'lock' => $lock, - 'location' => template_escape($location), - 'indent' => $indent, - 'owner_url' => $owner_url, - 'owner_photo' => $owner_photo, - 'owner_name' => template_escape($owner_name), - 'plink' => get_plink($item), - 'edpost' => $edpost, - 'isstarred' => $isstarred, - 'star' => $star, - 'filer' => $filer, - 'drop' => $drop, - 'vote' => $likebuttons, - 'like' => $like, - 'dislike' => $dislike, - 'comment' => $comment, - 'previewing' => $previewing, - 'wait' => t('Please wait'), - - ); - - - $arr = array('item' => $item, 'output' => $tmp_item); - call_hooks('display_item', $arr); - - $threads[$threadsid]['items'][] = $arr['output']; } } } + $page_template = get_markup_template("conversation.tpl"); + if($thr_c) + $page_template = get_markup_template("threaded_conversation.tpl"); $o = replace_macros($page_template, array( '$baseurl' => $a->get_baseurl($ssl_state), '$mode' => $mode, @@ -1159,12 +1467,43 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { } +function get_item_children($arr, $parent) { + $children = array(); + foreach($arr as $item) { + if(($item['id'] != $item['parent']) && ($item['thr-parent'] == $parent['uri'])) { + $item['children'] = get_item_children($arr, $item); + $children[] = $item; + } + } + return $children; +} + +function sort_item_children($items) { + $result = $items; + usort($result,'sort_thr_created_rev'); + foreach($result as $k => $i) { + if(count($result[$k]['children'])) { + $result[$k]['children'] = sort_item_children($result[$k]['children']); + } + } + return $result; +} + +function add_children_to_list($children, &$arr) { + foreach($children as $y) { + $arr[] = $y; + if(count($y['children'])) + add_children_to_list($y['children'], $arr); + } +} + function conv_sort($arr,$order) { if((!(is_array($arr) && count($arr)))) return array(); $parents = array(); + $children = array(); foreach($arr as $x) if($x['id'] == $x['parent']) @@ -1177,21 +1516,22 @@ function conv_sort($arr,$order) { if(count($parents)) foreach($parents as $i=>$_x) - $parents[$i]['children'] = array(); + $parents[$i]['children'] = get_item_children($arr, $_x); - foreach($arr as $x) { + /*foreach($arr as $x) { if($x['id'] != $x['parent']) { $p = find_thread_parent_index($parents,$x); if($p !== false) $parents[$p]['children'][] = $x; } - } + }*/ if(count($parents)) { foreach($parents as $k => $v) { if(count($parents[$k]['children'])) { - $y = $parents[$k]['children']; + $parents[$k]['children'] = sort_item_children($parents[$k]['children']); + /*$y = $parents[$k]['children']; usort($y,'sort_thr_created_rev'); - $parents[$k]['children'] = $y; + $parents[$k]['children'] = $y;*/ } } } @@ -1201,8 +1541,9 @@ function conv_sort($arr,$order) { foreach($parents as $x) { $ret[] = $x; if(count($x['children'])) - foreach($x['children'] as $y) - $ret[] = $y; + add_children_to_list($x['children'], $ret); + /*foreach($x['children'] as $y) + $ret[] = $y;*/ } } diff --git a/mod/item.php b/mod/item.php index fddc3fd124..012f2989b0 100644 --- a/mod/item.php +++ b/mod/item.php @@ -79,6 +79,7 @@ function item_post(&$a) { // if this isn't the real parent of the conversation, find it if($r !== false && count($r)) { $parid = $r[0]['parent']; + $parent_uri = $r[0]['uri']; if($r[0]['id'] != $r[0]['parent']) { $r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1", intval($parid) @@ -96,7 +97,7 @@ function item_post(&$a) { $parent = $r[0]['id']; // multi-level threading - preserve the info but re-parent to our single level threading - if(($parid) && ($parid != $parent)) + //if(($parid) && ($parid != $parent)) $thr_parent = $parent_uri; if($parent_item['contact-id'] && $uid) { diff --git a/mod/network.php b/mod/network.php index 17368ab92d..2ca3c5b06f 100644 --- a/mod/network.php +++ b/mod/network.php @@ -687,7 +687,7 @@ function network_content(&$a, $update = 0) { $mode = (($nouveau) ? 'network-new' : 'network'); - $o .= conversation($a,$items,$mode,$update); + $o .= conversation($a,$items,$mode,$update, false, true); if(! $update) { if(! get_pconfig(local_user(),'system','alt_pager')) { diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 1be81d738e..e17f8319bc 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -935,8 +935,12 @@ input#dfrn-url { } -.wall-item-content-wrapper.comment { +.tread-wrapper .tread-wrapper { margin-left: 50px; +} + +.wall-item-content-wrapper.comment { +# margin-left: 50px; background: #EEEEEE; } diff --git a/view/threaded_conversation.tpl b/view/threaded_conversation.tpl new file mode 100644 index 0000000000..f60839e495 --- /dev/null +++ b/view/threaded_conversation.tpl @@ -0,0 +1,13 @@ +{{ for $threads as $item }} +{{ inc $item.template }}{{ endinc }} +{{ endfor }} + +
+ +{{ if $dropping }} + +
+{{ endif }} diff --git a/view/wall_thread.tpl b/view/wall_thread.tpl new file mode 100644 index 0000000000..56e21bb828 --- /dev/null +++ b/view/wall_thread.tpl @@ -0,0 +1,91 @@ +
+ {{if $item.comment_firstcollapsed}} +
+ $item.num_comments $item.hide_text +
+ {{endif}} + + +
+
+
+
+ + $item.name + + menu +
+
    + $item.item_photo_menu +
+
+
+
+
+ {{ if $item.lock }}
$item.lock
+ {{ else }}
{{ endif }} +
$item.location
+
+
+
+ $item.name +
$item.ago
+ +
+
+
$item.title
+
+
$item.body +
+ {{ for $item.tags as $tag }} + $tag + {{ endfor }} +
+
+
+
+ {{ if $item.vote }} + + {{ endif }} + {{ if $item.plink }} + + {{ endif }} + {{ if $item.edpost }} + + {{ endif }} + + {{ if $item.star }} + + + {{ endif }} + {{ if $item.filer }} + + {{ endif }} +
+ {{ if $item.drop.dropping }}{{ endif }} +
+ {{ if $item.drop.dropping }}{{ endif }} +
+
+
+
+ +
$item.dislike
+
+ $item.comment +
+
+
+{{ for $item.children as $item }} + {{ inc $item.template }}{{ endinc }} +{{ endfor }} +
From d558d255405f6a8d35ce7fb16c175cf28de430f3 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Fri, 27 Jul 2012 22:47:18 +0200 Subject: [PATCH 04/29] CommentBox is now hidden by default, this can be toggled with a fake link --- include/conversation.php | 2 -- view/comment_item.tpl | 3 ++- view/head.tpl | 9 +++++++++ view/theme/duepuntozero/comment_item.tpl | 3 ++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 2794d8ab3b..2a085666d7 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -473,7 +473,6 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr } } - logger('item, page_writeable:'. ($page_writeable ? 'yes' : 'no') .', show comment box: '. ($show_comment_box ? 'yes' : 'no'), LOGGER_DEBUG); if($page_writeable) { $buttons = array( 'like' => array( t("I like this \x28toggle\x29"), t("like")), @@ -489,7 +488,6 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); $qcomment = (($qc) ? explode("\n",$qc) : null); } - $comment = replace_macros($cmnt_tpl,array( '$return_path' => '', '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), diff --git a/view/comment_item.tpl b/view/comment_item.tpl index a1d4e1043a..b2be6f94e3 100644 --- a/view/comment_item.tpl +++ b/view/comment_item.tpl @@ -1,5 +1,6 @@
-
+ $comment + diff --git a/view/head.tpl b/view/head.tpl index 8a75a4b8e0..e5495b329f 100644 --- a/view/head.tpl +++ b/view/head.tpl @@ -96,6 +96,15 @@ } } + function showHideCommentBox(id) { + if( $('#comment-edit-form-' + id).is(':visible')) { + $('#comment-edit-form-' + id).hide(); + } + else { + $('#comment-edit-form-' + id).show(); + } + } + diff --git a/view/theme/duepuntozero/comment_item.tpl b/view/theme/duepuntozero/comment_item.tpl index ea24d95cc3..63c05f335c 100755 --- a/view/theme/duepuntozero/comment_item.tpl +++ b/view/theme/duepuntozero/comment_item.tpl @@ -1,5 +1,6 @@
- + $comment + From eaf0d04bfb4aaa37c12181ee0ca0f9661905d4b4 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Fri, 27 Jul 2012 22:58:51 +0200 Subject: [PATCH 05/29] Comment box is now inside the item. Makes it easier to know what we are commenting on. --- view/theme/darkzero/style.css | 2 +- view/wall_thread.tpl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/view/theme/darkzero/style.css b/view/theme/darkzero/style.css index 55644e462d..5cd7eed659 100644 --- a/view/theme/darkzero/style.css +++ b/view/theme/darkzero/style.css @@ -28,7 +28,7 @@ background: #444; } .wall-item-tools { background-color: #444444; background-image: none;} -.comment-wwedit-wrapper{ background-color: #333333; } +.comment-wwedit-wrapper{ background-color: #444444; } .comment-edit-preview{ color: #000000; } .wall-item-content-wrapper.comment { background-color: #444444; border: 0px;} .photo-top-album-name{ background-color: #333333; } diff --git a/view/wall_thread.tpl b/view/wall_thread.tpl index 56e21bb828..aac5dbe2b2 100644 --- a/view/wall_thread.tpl +++ b/view/wall_thread.tpl @@ -76,13 +76,13 @@ {{ if $item.drop.dropping }}{{ endif }}
+
+ $item.comment +
$item.dislike
-
- $item.comment -
{{ for $item.children as $item }} From 8ea30873421c6384b72648265290ff5576201d8c Mon Sep 17 00:00:00 2001 From: Domovoy Date: Sun, 29 Jul 2012 17:13:21 +0200 Subject: [PATCH 06/29] Collapsing is back for threaded comments. Comment box is displayed at the end of the thread. Comments on comments are all collapsed --- include/conversation.php | 31 +++++++++++++++++++++---------- view/theme/darkzero/style.css | 2 +- view/theme/duepuntozero/style.css | 1 - view/wall_thread.tpl | 22 +++++++++++----------- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 020908b1e5..5743a2929e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -303,15 +303,13 @@ function localize_item(&$item){ * Recursively prepare a thread for HTML */ -function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $profile_owner) { +function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all=false) { $result = array(); $wall_template = 'wall_thread.tpl'; $wallwall_template = 'wallwall_thread.tpl'; $items_seen = 0; $nb_items = count($items); - $lastcollapsed = false; - $firstcollapsed = false; foreach($items as $item) { // prevent private email reply to public conversation from leaking. @@ -338,6 +336,8 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr $thumb = $item['thumb']; $indent = ''; $osparkle = ''; + $lastcollapsed = false; + $firstcollapsed = false; $toplevelpost = (($item['id'] == $item['parent']) ? true : false); $item_writeable = (($item['writable'] || $item['self']) ? true : false); @@ -463,11 +463,15 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr } else { $indent = 'comment'; // Collapse comments - if($nb_items > 2) { - if(!$firstcollapsed && ($items_seen <= ($nb_items - 2))) { + if(($nb_items > 2) || $collapse_all) { + if($items_seen == 1) { $firstcollapsed = true; } - else if($items_seen == ($nb_items - 1)) { + if($collapse_all) { + if($items_seen == $nb_items) + $lastcollapsed = true; + } + else if($items_seen == ($nb_items - 2)) { $lastcollapsed = true; } } @@ -524,8 +528,8 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr $tmp_item = array( // collapse comments in template. I don't like this much... - 'comment_firstcollapsed' => $comment_firstcollapsed, - 'comment_lastcollapsed' => $comment_lastcollapsed, + 'comment_firstcollapsed' => $firstcollapsed, + 'comment_lastcollapsed' => $lastcollapsed, // template to use to render item (wall, walltowall, search) 'template' => $template, @@ -571,10 +575,16 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr call_hooks('display_item', $arr); $item_result = $arr['output']; + if($firstcollapsed) { + $item_result['num_comments'] = sprintf( tt('%d comment','%d comments',$nb_items),$nb_items ); + $item_result['hide_text'] = t('show more'); + } $item_result['children'] = array(); if(count($item['children'])) { - $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner); + if(!$toplevelpost && !$collapse_all) + $collapse_all = true; + $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all); } $item_result['private'] = $item['private']; $result[] = $item_result; @@ -799,7 +809,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa } $threads = prepare_threads_body($a, $threads, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $previewing); - } else { + } + else { // Figure out how many comments each parent has diff --git a/view/theme/darkzero/style.css b/view/theme/darkzero/style.css index 5cd7eed659..55644e462d 100644 --- a/view/theme/darkzero/style.css +++ b/view/theme/darkzero/style.css @@ -28,7 +28,7 @@ background: #444; } .wall-item-tools { background-color: #444444; background-image: none;} -.comment-wwedit-wrapper{ background-color: #444444; } +.comment-wwedit-wrapper{ background-color: #333333; } .comment-edit-preview{ color: #000000; } .wall-item-content-wrapper.comment { background-color: #444444; border: 0px;} .photo-top-album-name{ background-color: #333333; } diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index e17f8319bc..9a8cffa2be 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -1181,7 +1181,6 @@ input#dfrn-url { .comment-wwedit-wrapper { margin-top: 15px; background: #f3f3f3; - margin-left: 50px; } .comment-edit-photo { diff --git a/view/wall_thread.tpl b/view/wall_thread.tpl index aac5dbe2b2..96a98ca82a 100644 --- a/view/wall_thread.tpl +++ b/view/wall_thread.tpl @@ -1,12 +1,10 @@ +{{if $item.comment_firstcollapsed}} +
+ $item.num_comments $item.hide_text +
+ {{endif}} From 25015d3ab941e3549681cd1f1482d43dff170669 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Sun, 29 Jul 2012 18:39:38 +0200 Subject: [PATCH 07/29] Update now handles threaded items. --- include/conversation.php | 7 ++++--- js/main.js | 3 +-- view/wall_thread.tpl | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 5743a2929e..d32a9a6667 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -582,11 +582,13 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr $item_result['children'] = array(); if(count($item['children'])) { + $collapse_all_children = $collapse_all; if(!$toplevelpost && !$collapse_all) - $collapse_all = true; - $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all); + $collapse_all_children = true; + $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all_children); } $item_result['private'] = $item['private']; + $item_result['toplevel'] = ($toplevelpost ? 'toplevel_item' : ''); $result[] = $item_result; } @@ -812,7 +814,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa } else { - // Figure out how many comments each parent has // (Comments all have gravity of 6) // Store the result in the $comments array diff --git a/js/main.js b/js/main.js index c7db9a0691..6ab574c4e8 100644 --- a/js/main.js +++ b/js/main.js @@ -280,8 +280,7 @@ //}); // add a new thread - - $('.tread-wrapper',data).each(function() { + $('.toplevel_item',data).each(function() { var ident = $(this).attr('id'); if($('#' + ident).length == 0 && profile_page == 1) { diff --git a/view/wall_thread.tpl b/view/wall_thread.tpl index 96a98ca82a..8142a7842a 100644 --- a/view/wall_thread.tpl +++ b/view/wall_thread.tpl @@ -4,7 +4,7 @@ {{ if $item.drop.dropping }}{{ endif }} -
-
- $item.comment -
+
+ {{ if $item.threaded }} + {{ if $item.comment }} +
+ $item.comment +
+ {{ endif }} + {{ endif }}
@@ -87,5 +91,10 @@ {{ inc $item.template }}{{ endinc }} {{ endfor }} +{{ if $item.flatten }} +
+ $item.comment +
+{{ endif }} {{if $item.comment_lastcollapsed}}{{endif}} From 5d1eb37b9b04c44ee4c627bdd7fd53e6b1a3dffd Mon Sep 17 00:00:00 2001 From: Domovoy Date: Sun, 5 Aug 2012 13:30:51 +0200 Subject: [PATCH 18/29] Remote items should be threaded now --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/items.php b/include/items.php index 3b09dfa688..13e4897aac 100755 --- a/include/items.php +++ b/include/items.php @@ -925,6 +925,8 @@ function item_store($arr,$force_parent = false) { $arr['origin'] = ((x($arr,'origin')) ? intval($arr['origin']) : 0 ); $arr['guid'] = ((x($arr,'guid')) ? notags(trim($arr['guid'])) : get_guid()); + + $arr['thr-parent'] = $arr['parent-uri']; if($arr['parent-uri'] === $arr['uri']) { $parent_id = 0; $parent_deleted = 0; @@ -950,7 +952,6 @@ function item_store($arr,$force_parent = false) { // and re-attach to the conversation parent. if($r[0]['uri'] != $r[0]['parent-uri']) { - $arr['thr-parent'] = $arr['parent-uri']; $arr['parent-uri'] = $r[0]['parent-uri']; $z = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `parent-uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1", @@ -992,7 +993,6 @@ function item_store($arr,$force_parent = false) { if($force_parent) { logger('item_store: $force_parent=true, reply converted to top-level post.'); $parent_id = 0; - $arr['thr-parent'] = $arr['parent-uri']; $arr['parent-uri'] = $arr['uri']; $arr['gravity'] = 0; } From dac88fce56776cdd2e6957e6c4e9fa0988537e94 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Sun, 5 Aug 2012 15:08:31 +0200 Subject: [PATCH 19/29] Remove database update, use fallback solution instead. --- boot.php | 2 +- include/conversation.php | 7 ++++++- update.php | 9 +-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/boot.php b/boot.php index 014b840f27..7e3e9fee7b 100644 --- a/boot.php +++ b/boot.php @@ -13,7 +13,7 @@ require_once('library/Mobile_Detect/Mobile_Detect.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '3.0.1425' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1155 ); +define ( 'DB_UPDATE_VERSION', 1154 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/include/conversation.php b/include/conversation.php index 345bb34ad8..706bcdde67 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1151,7 +1151,12 @@ function get_item_children($arr, $parent) { foreach($arr as $item) { if($item['id'] != $item['parent']) { if(get_config('system','thread_allow')) { - if($item['thr-parent'] == $parent['uri']) { + // Fallback to parent-uri if thr-parent is not set + $thr_parent = $item['thr-parent']; + if($thr_parent == '') + $thr_parent = $item['parent-uri']; + + if($thr_parent == $parent['uri']) { $item['children'] = get_item_children($arr, $item); $children[] = $item; } diff --git a/update.php b/update.php index c41acf6fbc..19e6cf3bdf 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ Date: Sun, 5 Aug 2012 15:35:12 +0200 Subject: [PATCH 20/29] Preview was not working --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/item.php b/mod/item.php index d82d54cfff..fe7513de00 100644 --- a/mod/item.php +++ b/mod/item.php @@ -604,7 +604,7 @@ function item_post(&$a) { if($preview) { require_once('include/conversation.php'); - $o = conversation($a,array(array_merge($contact_record,$datarray)),'search'); + $o = conversation($a,array(array_merge($contact_record,$datarray)),'search', false); logger('preview: ' . $o); echo json_encode(array('preview' => $o)); killme(); From 707dd216ce092dfdf592a042269a3a8504f60359 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Sun, 5 Aug 2012 19:27:54 +0200 Subject: [PATCH 21/29] Diaspora doesn't support threaded comments --- include/diaspora.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index a23c11bd21..0b2add337f 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2257,12 +2257,13 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) { $myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); // $theiraddr = $contact['addr']; - if($item['thr-parent']) { + // Diaspora doesn't support threaded comments + /*if($item['thr-parent']) { $p = q("select guid, type, uri, `parent-uri` from item where uri = '%s' limit 1", dbesc($item['thr-parent']) ); } - else { + else {*/ // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent. // The only item with `parent` and `id` as the parent id is the parent item. @@ -2270,7 +2271,7 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) { intval($item['parent']), intval($item['parent']) ); - } + //} if(count($p)) $parent = $p[0]; else From 5b374c4050c85151e18a0089fd990052f1185436 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Sun, 5 Aug 2012 19:30:21 +0200 Subject: [PATCH 22/29] Diaspora doesn't support threaded comments (forgot some) --- include/diaspora.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 0b2add337f..96b0b184e0 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2333,13 +2333,13 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { $body = $item['body']; $text = html_entity_decode(bb2diaspora($body)); - - if($item['thr-parent']) { + // Diaspora doesn't support threaded comments + /*if($item['thr-parent']) { $p = q("select guid, type, uri, `parent-uri` from item where uri = '%s' limit 1", dbesc($item['thr-parent']) ); } - else { + else {*/ // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent. // The only item with `parent` and `id` as the parent id is the parent item. @@ -2347,7 +2347,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { intval($item['parent']), intval($item['parent']) ); - } + //} if(count($p)) $parent = $p[0]; else From fd7ea5cc915daa7416d1abc9935d0fbe0b83a182 Mon Sep 17 00:00:00 2001 From: Fabrixxm Date: Sun, 5 Aug 2012 16:55:20 -0400 Subject: [PATCH 23/29] quattro: support threaded comments --- view/theme/quattro/dark/style.css | 31 +++++ view/theme/quattro/green/style.css | 31 +++++ view/theme/quattro/quattro.less | 30 +++++ view/theme/quattro/threaded_conversation.tpl | 45 +++++++ view/theme/quattro/wall_item_tag.tpl | 4 +- view/theme/quattro/wall_thread.tpl | 112 +++++++++++++++++ view/theme/quattro/wallwall_thread.tpl | 119 +++++++++++++++++++ 7 files changed, 371 insertions(+), 1 deletion(-) create mode 100644 view/theme/quattro/threaded_conversation.tpl create mode 100644 view/theme/quattro/wall_thread.tpl create mode 100644 view/theme/quattro/wallwall_thread.tpl diff --git a/view/theme/quattro/dark/style.css b/view/theme/quattro/dark/style.css index 087d9c746f..6bd9ab06fb 100644 --- a/view/theme/quattro/dark/style.css +++ b/view/theme/quattro/dark/style.css @@ -1068,6 +1068,9 @@ section { color: #2d2d2d; border: 1px solid #2d2d2d; } +.threaded .wall-item-comment-wrapper { + margin-left: 0px; +} .comment-edit-preview { width: 710px; border: 1px solid #2d2d2d; @@ -1139,6 +1142,34 @@ section { width: 25px; height: 25px; } +/* threaded comments */ +.children > .children { + margin-left: 40px; +} +.children > .children .wall-item-container { + width: 710px; +} +.children > .children > .children { + margin-left: 40px; +} +.children > .children > .children .wall-item-container { + width: 670px; +} +.children > .children > .children > .children { + margin-left: 40px; +} +.children > .children > .children > .children .wall-item-container { + width: 630px; +} +.children > .children > .children > .children > .children { + margin-left: 40px; +} +.children > .children > .children > .children > .children .wall-item-container { + width: 590px; +} +.children > .children > .children > .children > .children .children { + margin-left: 0px; +} span[id^="showmore-teaser"] { background: url("showmore-bg.jpg") no-repeat center bottom; } diff --git a/view/theme/quattro/green/style.css b/view/theme/quattro/green/style.css index 9c28473c61..2e97027b4b 100644 --- a/view/theme/quattro/green/style.css +++ b/view/theme/quattro/green/style.css @@ -1068,6 +1068,9 @@ section { color: #2d2d2d; border: 1px solid #2d2d2d; } +.threaded .wall-item-comment-wrapper { + margin-left: 0px; +} .comment-edit-preview { width: 710px; border: 1px solid #2d2d2d; @@ -1139,6 +1142,34 @@ section { width: 25px; height: 25px; } +/* threaded comments */ +.children > .children { + margin-left: 40px; +} +.children > .children .wall-item-container { + width: 710px; +} +.children > .children > .children { + margin-left: 40px; +} +.children > .children > .children .wall-item-container { + width: 670px; +} +.children > .children > .children > .children { + margin-left: 40px; +} +.children > .children > .children > .children .wall-item-container { + width: 630px; +} +.children > .children > .children > .children > .children { + margin-left: 40px; +} +.children > .children > .children > .children > .children .wall-item-container { + width: 590px; +} +.children > .children > .children > .children > .children .children { + margin-left: 0px; +} span[id^="showmore-teaser"] { background: url("showmore-bg.jpg") no-repeat center bottom; } diff --git a/view/theme/quattro/quattro.less b/view/theme/quattro/quattro.less index b5f0af6696..55b2d73ac5 100644 --- a/view/theme/quattro/quattro.less +++ b/view/theme/quattro/quattro.less @@ -538,6 +538,8 @@ section { } } +.threaded .wall-item-comment-wrapper { margin-left: 0px; } + .comment-edit-preview { width: 710px; border: 1px solid @Grey5; @@ -594,6 +596,34 @@ section { } .wwto .contact-photo { width: 25px; height: 25px; } +/* threaded comments */ +.children { + + &> .children { + margin-left: 40px; + .wall-item-container { width: 710px; } + + &> .children { + margin-left: 40px; + .wall-item-container { width: 670px; } + + &> .children { + margin-left: 40px; + .wall-item-container { width: 630px; } + + &> .children { + margin-left: 40px; + .wall-item-container { width: 590px; } + + .children { + margin-left: 0px; + } + } + } + } + } +} + span[id^="showmore-teaser"]{ background: url("showmore-bg.jpg") no-repeat center bottom; } diff --git a/view/theme/quattro/threaded_conversation.tpl b/view/theme/quattro/threaded_conversation.tpl new file mode 100644 index 0000000000..305ace92ef --- /dev/null +++ b/view/theme/quattro/threaded_conversation.tpl @@ -0,0 +1,45 @@ +{{ for $threads as $item }} +
+ {{if $mode == display}} + {{ else }} + {{if $item.comment_firstcollapsed}} +
+ $item.num_comments $item.hide_text +
+ {{endif}} + {{ endif }} + + {{ if $item.type == tag }} + {{ inc wall_item_tag.tpl }}{{ endinc }} + {{ else }} + {{ inc $item.template }}{{ endinc }} + {{ endif }} + +
+{{ endfor }} + +
+ +{{ if $dropping }} + + $dropping + +{{ endif }} + + + +{{ if $mode == display }} + +{{ endif }} + diff --git a/view/theme/quattro/wall_item_tag.tpl b/view/theme/quattro/wall_item_tag.tpl index 926fc929d2..205fcfebc0 100644 --- a/view/theme/quattro/wall_item_tag.tpl +++ b/view/theme/quattro/wall_item_tag.tpl @@ -13,11 +13,13 @@
$item.location
- $item.body + $item.ago $item.body
+{{ if $item.flatten }}
$item.comment
+{{ endif }} diff --git a/view/theme/quattro/wall_thread.tpl b/view/theme/quattro/wall_thread.tpl new file mode 100644 index 0000000000..b51dc3d7df --- /dev/null +++ b/view/theme/quattro/wall_thread.tpl @@ -0,0 +1,112 @@ + +
+ $item.star.starred + {{ if $item.lock }}$item.lock{{ endif }} + +
+ +
+
+
+
+ + $item.name + + menu + + +
+
$item.location
+
+
+ {{ if $item.title }}

$item.title

{{ endif }} + $item.body +
+
+
+ +
+ {{ for $item.tags as $tag }} + $tag + {{ endfor }} +
+
+
+
+ {{ if $item.plink }}$item.plink.title{{ endif }} +
+
+
+ $item.name $item.ago +
+ +
+ {{ if $item.star }} + $item.star.do + $item.star.undo + $item.star.tagger + {{ endif }} + {{ if $item.filer }} + $item.filer + {{ endif }} + + {{ if $item.vote }} + $item.vote.like.1 + $item.vote.dislike.1 + {{ endif }} + + {{ if $item.vote.share }} + $item.vote.share.1 + {{ endif }} +
+ +
+ + {{ if $item.drop.dropping }} + + $item.drop.delete + {{ endif }} + {{ if $item.edpost }} + + {{ endif }} +
+ +
+
+
+ + +
$item.dislike
+
+ {{ if $item.threaded }}{{ if $item.comment }} +
+ +
+ $item.comment +
+
+ {{ endif }}{{ endif }} + +
+ + +{{ for $item.children as $item }} +
+ {{ if $item.type == tag }} + {{ inc wall_item_tag.tpl }}{{ endinc }} + {{ else }} + {{ inc $item.template }}{{ endinc }} + {{ endif }} +
+{{ endfor }} + +{{ if $item.flatten }} +
+ $item.comment +
+{{ endif }} diff --git a/view/theme/quattro/wallwall_thread.tpl b/view/theme/quattro/wallwall_thread.tpl new file mode 100644 index 0000000000..038b156d12 --- /dev/null +++ b/view/theme/quattro/wallwall_thread.tpl @@ -0,0 +1,119 @@ +
+ $item.star.starred + {{ if $item.lock }}$item.lock{{ endif }} + +
+ +
+
+
+
+ + $item.name + + menu + + +
+
+ + $item.owner_name + +
+
$item.location
+
+
+ {{ if $item.title }}

$item.title

{{ endif }} + $item.body +
+
+
+ +
+ {{ for $item.tags as $tag }} + $tag + {{ endfor }} +
+
+
+ +
+
+ $item.name $item.ago +
$item.to $item.owner_name $item.vwall + +
+ +
+ {{ if $item.star }} + $item.star.do + $item.star.undo + $item.star.tagger + + {{ endif }} + {{ if $item.filer }} + $item.filer + {{ endif }} + + {{ if $item.vote }} + $item.vote.like.1 + $item.vote.dislike.1 + {{ endif }} + + {{ if $item.vote.share }} + $item.vote.share.1 + {{ endif }} +
+ +
+ + {{ if $item.drop.dropping }} + + $item.drop.delete + {{ endif }} + {{ if $item.edpost }} + + {{ endif }} +
+ +
+
+
+ + +
$item.dislike
+
+ + {{ if $item.threaded }}{{ if $item.comment }} +
+ +
+ $item.comment +
+
+ {{ endif }}{{ endif }} +
+ + +{{ for $item.children as $item }} +
+ {{ if $item.type == tag }} + {{ inc wall_item_tag.tpl }}{{ endinc }} + {{ else }} + {{ inc $item.template }}{{ endinc }} + {{ endif }} +
+{{ endfor }} + +{{ if $item.flatten }} +
+ $item.comment +
+{{ endif }} From 4062312e9c41a337d54beaccd57f8637eb8decad Mon Sep 17 00:00:00 2001 From: Fabrixxm Date: Mon, 6 Aug 2012 04:47:35 -0400 Subject: [PATCH 24/29] quattro: collaps threaded items --- view/theme/quattro/dark/style.css | 21 +++++++++++--------- view/theme/quattro/green/style.css | 21 +++++++++++--------- view/theme/quattro/quattro.less | 9 +++++---- view/theme/quattro/threaded_conversation.tpl | 12 +---------- view/theme/quattro/wall_thread.tpl | 15 ++++++++++++++ view/theme/quattro/wallwall_thread.tpl | 15 ++++++++++++++ 6 files changed, 60 insertions(+), 33 deletions(-) diff --git a/view/theme/quattro/dark/style.css b/view/theme/quattro/dark/style.css index 6bd9ab06fb..5ff0591602 100644 --- a/view/theme/quattro/dark/style.css +++ b/view/theme/quattro/dark/style.css @@ -1143,33 +1143,36 @@ section { height: 25px; } /* threaded comments */ -.children > .children { +.children .children { margin-left: 40px; } -.children > .children .wall-item-container { +.children .children .wall-item-container { width: 710px; } -.children > .children > .children { +.children .children .children { margin-left: 40px; } -.children > .children > .children .wall-item-container { +.children .children .children .wall-item-container { width: 670px; } -.children > .children > .children > .children { +.children .children .children .children { margin-left: 40px; } -.children > .children > .children > .children .wall-item-container { +.children .children .children .children .wall-item-container { width: 630px; } -.children > .children > .children > .children > .children { +.children .children .children .children .children { margin-left: 40px; } -.children > .children > .children > .children > .children .wall-item-container { +.children .children .children .children .children .wall-item-container { width: 590px; } -.children > .children > .children > .children > .children .children { +.children .children .children .children .children .children { margin-left: 0px; } +.threaded .hide-comments-outer { + margin-left: 20px; +} span[id^="showmore-teaser"] { background: url("showmore-bg.jpg") no-repeat center bottom; } diff --git a/view/theme/quattro/green/style.css b/view/theme/quattro/green/style.css index 2e97027b4b..3cc4e8cf61 100644 --- a/view/theme/quattro/green/style.css +++ b/view/theme/quattro/green/style.css @@ -1143,33 +1143,36 @@ section { height: 25px; } /* threaded comments */ -.children > .children { +.children .children { margin-left: 40px; } -.children > .children .wall-item-container { +.children .children .wall-item-container { width: 710px; } -.children > .children > .children { +.children .children .children { margin-left: 40px; } -.children > .children > .children .wall-item-container { +.children .children .children .wall-item-container { width: 670px; } -.children > .children > .children > .children { +.children .children .children .children { margin-left: 40px; } -.children > .children > .children > .children .wall-item-container { +.children .children .children .children .wall-item-container { width: 630px; } -.children > .children > .children > .children > .children { +.children .children .children .children .children { margin-left: 40px; } -.children > .children > .children > .children > .children .wall-item-container { +.children .children .children .children .children .wall-item-container { width: 590px; } -.children > .children > .children > .children > .children .children { +.children .children .children .children .children .children { margin-left: 0px; } +.threaded .hide-comments-outer { + margin-left: 20px; +} span[id^="showmore-teaser"] { background: url("showmore-bg.jpg") no-repeat center bottom; } diff --git a/view/theme/quattro/quattro.less b/view/theme/quattro/quattro.less index 55b2d73ac5..a424ee0207 100644 --- a/view/theme/quattro/quattro.less +++ b/view/theme/quattro/quattro.less @@ -599,19 +599,19 @@ section { /* threaded comments */ .children { - &> .children { + & .children { margin-left: 40px; .wall-item-container { width: 710px; } - &> .children { + & .children { margin-left: 40px; .wall-item-container { width: 670px; } - &> .children { + & .children { margin-left: 40px; .wall-item-container { width: 630px; } - &> .children { + & .children { margin-left: 40px; .wall-item-container { width: 590px; } @@ -623,6 +623,7 @@ section { } } } +.threaded .hide-comments-outer { margin-left: 20px; } span[id^="showmore-teaser"]{ background: url("showmore-bg.jpg") no-repeat center bottom; diff --git a/view/theme/quattro/threaded_conversation.tpl b/view/theme/quattro/threaded_conversation.tpl index 305ace92ef..491c47302f 100644 --- a/view/theme/quattro/threaded_conversation.tpl +++ b/view/theme/quattro/threaded_conversation.tpl @@ -1,16 +1,6 @@ {{ for $threads as $item }}
- {{if $mode == display}} - {{ else }} - {{if $item.comment_firstcollapsed}} -
- $item.num_comments $item.hide_text -
- {{endif}} - {{ endif }} - + {{ if $item.type == tag }} {{ inc wall_item_tag.tpl }}{{ endinc }} {{ else }} diff --git a/view/theme/quattro/wall_thread.tpl b/view/theme/quattro/wall_thread.tpl index b51dc3d7df..4d454f00db 100644 --- a/view/theme/quattro/wall_thread.tpl +++ b/view/theme/quattro/wall_thread.tpl @@ -1,3 +1,13 @@ +{{if $mode == display}} +{{ else }} +{{if $item.comment_firstcollapsed}} +
+ $item.num_comments $item.hide_text +
+ {{endif}} +{{ endif }} + {{ if $item.flatten }}
$item.comment diff --git a/view/theme/quattro/wallwall_thread.tpl b/view/theme/quattro/wallwall_thread.tpl index 038b156d12..cc2f8e3627 100644 --- a/view/theme/quattro/wallwall_thread.tpl +++ b/view/theme/quattro/wallwall_thread.tpl @@ -1,3 +1,13 @@ +{{if $mode == display}} +{{ else }} +{{if $item.comment_firstcollapsed}} +
+ $item.num_comments $item.hide_text +
+ {{endif}} +{{ endif }} + {{ if $item.flatten }}
$item.comment From 4cc6bf660c04c4b361eee8db59e5beb83e6b1081 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Tue, 7 Aug 2012 09:53:53 +0200 Subject: [PATCH 25/29] The number of comments shown when collapsed is the total of all the descendant items. --- include/conversation.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/include/conversation.php b/include/conversation.php index 706bcdde67..73c3337d52 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -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 */ @@ -311,6 +326,8 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr $items_seen = 0; $nb_items = count($items); + $total_children = $nb_items; + foreach($items as $item) { // prevent private email reply to public conversation from leaking. 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 = ''; $lastcollapsed = false; $firstcollapsed = false; + $total_children += count_descendants($item); $toplevelpost = (($item['id'] == $item['parent']) ? 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']; 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'); } From 4b514ea9893d9814cf8a000ef165d24a96fdaf7d Mon Sep 17 00:00:00 2001 From: Domovoy Date: Tue, 7 Aug 2012 10:04:47 +0200 Subject: [PATCH 26/29] Fallback so that we alway have a thr-parent --- mod/item.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mod/item.php b/mod/item.php index fe7513de00..c7b755eaed 100644 --- a/mod/item.php +++ b/mod/item.php @@ -545,6 +545,10 @@ function item_post(&$a) { $uri = item_new_uri($a->get_hostname(),$profile_uid); + // Fallback so that we alway have a thr-parent + if(!$thr_parent) + $thr_parent = $uri; + $datarray = array(); $datarray['uid'] = $profile_uid; $datarray['type'] = $post_type; From c0024daff7675361fa6d5afa34a78bee1373254a Mon Sep 17 00:00:00 2001 From: Domovoy Date: Tue, 7 Aug 2012 12:02:06 +0200 Subject: [PATCH 27/29] Added view/wallwall_thread.tpl --- view/wallwall_thread.tpl | 86 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 view/wallwall_thread.tpl diff --git a/view/wallwall_thread.tpl b/view/wallwall_thread.tpl new file mode 100644 index 0000000000..b7cca3fab9 --- /dev/null +++ b/view/wallwall_thread.tpl @@ -0,0 +1,86 @@ + +
+
+
+
+ + $item.owner_name +
+
$item.wall
+
+ + $item.name + menu +
+
    + $item.item_photo_menu +
+
+ +
+
+
+ {{ if $item.lock }}
$item.lock
+ {{ else }}
{{ endif }} +
$item.location
+
+
+
+ $item.name $item.to $item.owner_name $item.vwall
+
$item.ago
+
+
+
$item.title
+
+
$item.body +
+ {{ for $item.tags as $tag }} + $tag + {{ endfor }} +
+
+
+
+ {{ if $item.vote }} + + {{ endif }} + {{ if $item.plink }} + + {{ endif }} + {{ if $item.edpost }} + + {{ endif }} + + {{ if $item.star }} + + + {{ endif }} + {{ if $item.filer }} + + {{ endif }} + +
+ {{ if $item.drop.dropping }}{{ endif }} +
+ {{ if $item.drop.dropping }}{{ endif }} +
+
+
+
+ +
$item.dislike
+
+
+ $item.comment +
+ +
+
+ From 5ca71d04b2de63b969c6c367f2f05067b2c9dd46 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Tue, 7 Aug 2012 12:08:36 +0200 Subject: [PATCH 28/29] Wall to wall items should now be threaded too. --- view/wallwall_thread.tpl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/view/wallwall_thread.tpl b/view/wallwall_thread.tpl index b7cca3fab9..3986b065c1 100644 --- a/view/wallwall_thread.tpl +++ b/view/wallwall_thread.tpl @@ -1,3 +1,10 @@ +{{if $item.comment_firstcollapsed}} +
+ $item.num_comments $item.hide_text +
+ +{{ for $item.children as $item }} + {{ inc $item.template }}{{ endinc }} +{{ endfor }} +{{ if $item.flatten }} +
+ $item.comment +
+{{ endif }} +
+{{if $item.comment_lastcollapsed}}
{{endif}} From afaa5f20384cce82f58de47ae73245d36a87dd97 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Tue, 7 Aug 2012 12:13:42 +0200 Subject: [PATCH 29/29] Removed useless comment box (from old non-threaded template, to comment box where displayed) --- view/wallwall_thread.tpl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/view/wallwall_thread.tpl b/view/wallwall_thread.tpl index 3986b065c1..89f121f210 100644 --- a/view/wallwall_thread.tpl +++ b/view/wallwall_thread.tpl @@ -90,11 +90,6 @@
$item.dislike
-
-
- $item.comment -
-
{{ for $item.children as $item }}