diff options
-rw-r--r-- | include/conversation.php | 14 | ||||
-rw-r--r-- | include/text.php | 33 | ||||
-rw-r--r-- | mod/network.php | 18 | ||||
-rw-r--r-- | object/Item.php | 5 |
4 files changed, 60 insertions, 10 deletions
diff --git a/include/conversation.php b/include/conversation.php index bad511551..7f1973d0d 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -441,6 +441,10 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr else $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($thumb)); + $profile_avatar = $item['author']['xchan_photo']; + $profile_link = zrl($item['author']['xchan_profile']); + $profile_name = $item['author']['xchan_name']; + $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location',$locate); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate)); @@ -615,7 +619,7 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr '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'])), + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_link), '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'), @@ -649,6 +653,7 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr 'thread_level' => $thread_level, ); + logger('tmp_item: ' . print_r($tmp_item,true)); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); @@ -1197,6 +1202,13 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { else $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($thumb)); + + + $profile_avatar = $item['author']['xchan_photo']; + $profile_link = zrl($item['author']['xchan_profile']); + $profile_name = $item['author']['xchan_name']; + + $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']) : ''); diff --git a/include/text.php b/include/text.php index a68782f2a..464396d62 100644 --- a/include/text.php +++ b/include/text.php @@ -1687,4 +1687,37 @@ function ids_to_querystr($arr,$idx = 'id') { foreach($arr as $x) $t[] = $x[$idx]; return(implode(',', $t)); +} + +function xchan_query(&$items) { + $arr = array(); + if($items && count($items)) { + foreach($items as $item) { + if($item['owner_xchan'] && (! in_array($item['owner_xchan'],$arr))) + $arr[] = "'" . dbesc($item['owner_xchan']) . "'"; + if($item['author_xchan'] && (! in_array($item['author_xchan'],$arr))) + $arr[] = "'" . dbesc($item['author_xchan']) . "'"; + } + } + if(count($arr)) { + $chans = q("select * from xchan where xchan_hash in (" . implode(',', $arr) . ")"); + } + if($items && count($items) && $chans && count($chans)) { + for($x = 0; $x < count($items); $x ++) { + $items[$x]['owner'] = find_xchan_in_array($items[$x]['owner_xchan'],$chans); + $items[$x]['author'] = find_xchan_in_array($items[$x]['author_xchan'],$chans); + } + } + +} + +function find_xchan_in_array($xchan,$arr) { + if(count($arr)) { + foreach($arr as $x) { + if($x['xchan_hash'] === $xchan) { + return $x; + } + } + } + return array(); }
\ No newline at end of file diff --git a/mod/network.php b/mod/network.php index 3f06ccb3d..ad3d43102 100644 --- a/mod/network.php +++ b/mod/network.php @@ -602,7 +602,7 @@ function network_content(&$a, $update = 0, $load = false) { if($nouveau && $load) { // "New Item View" - show all items unthreaded in reverse created date order - +/* $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, o.xchan_name as oname, o.xchan_photo as ophoto, o.xchan_profile as ourl, a.xchan_name as aname, a.xchan_photo as aphoto, a.xchan_profile as aurl, @@ -614,7 +614,7 @@ function network_content(&$a, $update = 0, $load = false) { ORDER BY `item`.`received` DESC $pager_sql ", intval($_SESSION['uid']) ); - +*/ require_once('include/items.php'); $items = fetch_post_tags($items); @@ -632,7 +632,7 @@ function network_content(&$a, $update = 0, $load = false) { // Fetch a page full of parent items for this page if($update && (! $load)) { - $r = q("SELECT `parent` AS `item_id`, `contact`.`uid` AS `contact_uid` +/* $r = q("SELECT `parent` AS `item_id`, `contact`.`uid` AS `contact_uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "') @@ -641,7 +641,7 @@ function network_content(&$a, $update = 0, $load = false) { $sql_extra3 $sql_extra $sql_nets ", intval(local_user()) ); - } +*/ } else { $r = q("SELECT `item`.`id` AS `item_id` @@ -660,11 +660,7 @@ function network_content(&$a, $update = 0, $load = false) { $parents_str = ids_to_querystr($r,'item_id'); - $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, - o.xchan_name as oname, o.xchan_photo as ophoto, o.xchan_profile as ourl, - a.xchan_name as aname, a.xchan_photo as aphoto, a.xchan_profile as aurl, - FROM `item` left join xchan as o on xchan_hash = owner_xchan left join xchan as a - on xchan_hash = author_xchan + $items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item` WHERE `item`.`uid` = %d AND `item`.`item_restrict` = 0 AND `item`.`parent` IN ( %s ) $sql_extra ", @@ -672,10 +668,14 @@ function network_content(&$a, $update = 0, $load = false) { dbesc($parents_str) ); + + xchan_query($items); + $items = fetch_post_tags($items); $items = conv_sort($items,$ordering); +logger('items: ' . print_r($items,true)); } else { $items = array(); diff --git a/object/Item.php b/object/Item.php index 14566a5bb..2d62224fc 100644 --- a/object/Item.php +++ b/object/Item.php @@ -132,12 +132,17 @@ class Item extends BaseObject { else $profile_link = zrl($profile_link); + $profile_link = zrl($item['author']['xchan_profile']); + + $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($this->get_data_value('thumb'))); + $profile_avatar = $item['author']['xchan_photo']; + $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location',$locate); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate)); |