From 92f3d863fa4a8a96d4f882a91a81d888a58230e5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 18 Dec 2016 16:26:00 -0800 Subject: re-factor item_photo_menu - there is some room for future development, currently it was made compatible with minimal template changes --- Zotlabs/Lib/ThreadItem.php | 2 + include/conversation.php | 166 ++++++++++++++++++++++++++++++++++++++++++++- view/tpl/conv_item.tpl | 17 +++-- view/tpl/search_item.tpl | 13 +++- 4 files changed, 190 insertions(+), 8 deletions(-) diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index a1666e148..e636e5614 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -335,6 +335,8 @@ class ThreadItem { 'wall' => t('Wall-to-Wall'), 'vwall' => t('via Wall-To-Wall:'), 'profile_url' => $profile_link, + 'thread_action_menu' => thread_action_menu($item,$conv->get_mode()), + 'thread_author_menu' => thread_author_menu($item,$conv->get_mode()), 'item_photo_menu' => item_photo_menu($item), 'dreport' => $dreport, 'name' => $profile_name, diff --git a/include/conversation.php b/include/conversation.php index d367c27a6..af64fbb90 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -689,7 +689,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ '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), + 'thread_action_menu' => thread_action_menu($item,$mode), + 'thread_author_menu' => thread_author_menu($item,$mode), 'name' => $profile_name, 'sparkle' => $sparkle, 'lock' => $lock, @@ -960,6 +961,169 @@ function item_photo_menu($item){ return $o; } + +function thread_action_menu($item,$mode = '') { + + $menu = []; + + if((local_channel()) && local_channel() == $item['uid']) { + $menu[] = [ + 'menu' => 'view_source', + 'title' => t('View Source'), + 'icon' => 'eye', + 'action' => 'viewsrc(' . $item['id'] . '); return false;', + 'href' => '#' + ]; + + if(! in_array($mode, [ 'network-new', 'search', 'community'])) { + if($item['parent'] == $item['id'] && (get_observer_hash() != $item['author_xchan'])) { + $menu[] = [ + 'menu' => 'follow_thread', + 'title' => t('Follow Thread'), + 'icon' => 'plus', + 'action' => 'dosubthread(' . $item['id'] . '); return false;', + 'href' => '#' + ]; + } + + $menu[] = [ + 'menu' => 'unfollow_thread', + 'title' => t('Unfollow Thread'), + 'icon' => 'minus', + 'action' => 'dounsubthread(' . $item['id'] . '); return false;', + 'href' => '#' + ]; + } + + } + + + + + $args = [ 'item' => $item, 'mode' => $mode, 'menu' => $menu ]; + call_hooks('thread_action_menu', $args); + + return $args['menu']; + +} + +function thread_author_menu($item, $mode = '') { + + $menu = []; + + $local_channel = local_channel(); + + if($local_channel) { + if(! count(App::$contacts)) + load_contact_links($local_channel); + $channel = App::get_channel(); + $channel_hash = (($channel) ? $channel['channel_hash'] : ''); + } + + $profile_link = chanlink_hash($item['author_xchan']); + if($item['uid'] > 0) + $pm_url = z_root() . '/mail/new/?f=&hash=' . $item['author_xchan']; + + if(App::$contacts && array_key_exists($item['author_xchan'],App::$contacts)) + $contact = App::$contacts[$item['author_xchan']]; + else + if($local_channel && $item['author']['xchan_addr']) + $follow_url = z_root() . '/follow/?f=&url=' . $item['author']['xchan_addr']; + + if($contact) { + $poke_link = z_root() . '/poke/?f=&c=' . $contact['abook_id']; + if (! intval($contact['abook_self'])) + $contact_url = z_root() . '/connedit/' . $contact['abook_id']; + $posts_link = z_root() . '/network/?cid=' . $contact['abook_id']; + + $clean_url = normalise_link($item['author-link']); + } + + $rating_enabled = get_config('system','rating_enabled'); + + $ratings_url = (($rating_enabled) ? z_root() . '/ratings/' . urlencode($item['author_xchan']) : ''); + + if($profile_link) { + $menu[] = [ + 'menu' => 'view_profile', + 'title' => t('View Profile'), + 'icon' => 'fw', + 'action' => '', + 'href' => $profile_link + ]; + } + + if($posts_link) { + $menu[] = [ + 'menu' => 'view_posts', + 'title' => t('Activity/Posts'), + 'icon' => 'fw', + 'action' => '', + 'href' => $posts_link + ]; + } + + if($follow_url) { + $menu[] = [ + 'menu' => 'follow', + 'title' => t('Connect'), + 'icon' => 'fw', + 'action' => '', + 'href' => $follow_url + ]; + } + + if($contact_url) { + $menu[] = [ + 'menu' => 'connedit', + 'title' => t('Edit Connection'), + 'icon' => 'fw', + 'action' => '', + 'href' => $contact_url + ]; + } + + if($pm_url) { + $menu[] = [ + 'menu' => 'prv_message', + 'title' => t('Message'), + 'icon' => 'fw', + 'action' => '', + 'href' => $pm_url + ]; + } + + if($ratings_url) { + $menu[] = [ + 'menu' => 'ratings', + 'title' => t('Ratings'), + 'icon' => 'fw', + 'action' => '', + 'href' => $ratings_url + ]; + } + + if($poke_link) { + $menu[] = [ + 'menu' => 'poke', + 'title' => t('Poke'), + 'icon' => 'fw', + 'action' => '', + 'href' => $poke_link + ]; + } + + $args = [ 'item' => $item, 'mode' => $mode, 'menu' => $menu ]; + call_hooks('thread_author_menu', $args); + + return $args['menu']; + +} + + + + + /** * @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.) * diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl index 35c3d18e7..b5ff475b2 100755 --- a/view/tpl/conv_item.tpl +++ b/view/tpl/conv_item.tpl @@ -166,18 +166,27 @@ {{if $item.star}}
  • {{$item.star.toggle}}
  • {{/if}} + + {{if $item.thread_action_menu}} + {{foreach $item.thread_action_menu as $mitem}} +
  • {{$mitem.title}}
  • + {{/foreach}} + {{/if}} + {{if $item.drop.dropping}}
  • {{$item.drop.delete}}
  • {{/if}} - {{if $item.item_photo_menu}} + + {{if $item.thread_author_menu}} - {{$item.item_photo_menu}} + {{foreach $item.thread_author_menu as $mitem}} +
  • {{$mitem.title}}
  • + {{/foreach}} + {{/if}} {{if $item.edpost && $item.dreport}}
  • {{$item.dreport}}
  • {{/if}} - - {{/if}} diff --git a/view/tpl/search_item.tpl b/view/tpl/search_item.tpl index 51fa8b8dc..a490cb473 100755 --- a/view/tpl/search_item.tpl +++ b/view/tpl/search_item.tpl @@ -74,13 +74,20 @@ {{if $item.attachments}} -- cgit v1.2.3