X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fconversation.php;h=7b358d3dd6f52a254f4cb635634e121cec3d96b8;hb=3fbc873ffe47b7eac2883436bb756138b2969b03;hp=d6b6bd8eee1a0b05928499ddd773b8c2d66f8ce8;hpb=b677bdd4ff60e9ac22d33c86d6250b106115df92;p=friendica.git diff --git a/include/conversation.php b/include/conversation.php index d6b6bd8eee..7b358d3dd6 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -3,12 +3,15 @@ * @file include/conversation.php */ use Friendica\App; +use Friendica\Content\ContactSelector; use Friendica\Content\Feature; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; +use Friendica\Model\Profile; use Friendica\Object\Thread; use Friendica\Object\Post; @@ -17,7 +20,7 @@ require_once "include/acl_selectors.php"; function item_extract_images($body) { - $saved_image = array(); + $saved_image = []; $orig_body = $body; $new_body = ''; @@ -55,7 +58,7 @@ function item_extract_images($body) { $new_body = $new_body . $orig_body; - return array('body' => $new_body, 'images' => $saved_image); + return ['body' => $new_body, 'images' => $saved_image]; } function item_redir_and_replace_images($body, $images, $cid) { @@ -143,7 +146,7 @@ function localize_item(&$item) { default: if ($obj['resource-id']) { $post_type = t('photo'); - $m = array(); + $m = []; preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); $rr['plink'] = $m[1]; } else { @@ -193,10 +196,10 @@ function localize_item(&$item) { } } - $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]'; - $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]'; + $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]'; + $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]'; if ($Bphoto != "") { - $Bphoto = '[url=' . zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]'; + $Bphoto = '[url=' . Profile::zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]'; } $item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto; @@ -230,10 +233,10 @@ function localize_item(&$item) { } } - $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]'; - $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]'; + $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]'; + $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]'; if ($Bphoto != "") { - $Bphoto = '[url=' . zrl($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]'; + $Bphoto = '[url=' . Profile::zrl($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]'; } /* @@ -265,8 +268,8 @@ function localize_item(&$item) { $obj = $r[0]; - $author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]'; - $objauthor = '[url=' . zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]'; + $author = '[url=' . Profile::zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]'; + $objauthor = '[url=' . Profile::zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]'; switch ($obj['verb']) { case ACTIVITY_POST: @@ -281,7 +284,7 @@ function localize_item(&$item) { default: if ($obj['resource-id']) { $post_type = t('photo'); - $m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); + $m=[]; preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); $rr['plink'] = $m[1]; } else { $post_type = t('status'); @@ -319,8 +322,8 @@ function localize_item(&$item) { $target = $r[0]; $Bname = $target['author-name']; $Blink = $target['author-link']; - $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]'; - $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]'; + $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]'; + $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]'; $P = '[url=' . $target['plink'] . ']' . t('post/item') . '[/url]'; $item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n"; } @@ -330,7 +333,7 @@ function localize_item(&$item) { if (preg_match_all('/@\[url=(.*?)\]/is', $item['body'], $matches, PREG_SET_ORDER)) { foreach ($matches as $mtch) { if (! strpos($mtch[1], 'zrl=')) { - $item['body'] = str_replace($mtch[0], '@[url=' . zrl($mtch[1]) . ']', $item['body']); + $item['body'] = str_replace($mtch[0], '@[url=' . Profile::zrl($mtch[1]) . ']', $item['body']); } } } @@ -338,7 +341,7 @@ function localize_item(&$item) { // add zrl's to public images $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is"; if (preg_match($photo_pattern, $item['body'])) { - $photo_replace = '[url=' . zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]'; + $photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]'; $item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']); } @@ -380,7 +383,7 @@ function visible_activity($item) { * likes (etc.) can apply to other things besides posts. Check if they are post children, * in which case we handle them specially */ - $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); + $hidden_activities = [ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE]; foreach ($hidden_activities as $act) { if (activity_match($item['verb'], $act)) { return false; @@ -428,7 +431,6 @@ These Fields are not added below (yet). They are here to for bug search. `item`.`deleted`, `item`.`origin`, `item`.`forum_mode`, -`item`.`last-child`, `item`.`mention`, `item`.`global`, `item`.`gcontact-id`, @@ -578,39 +580,33 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $items = community_add_items($items); } $profile_owner = 0; -// Currently deactivated. Will be activated when we can comment on the community page -// if (!$update) { -// $live_update_div = '
' . "\r\n" -// . "\r\n"; -// } + if (!$update) { + $live_update_div = '
' . "\r\n" + . "\r\n"; + } } elseif ($mode === 'search') { $live_update_div = '' . "\r\n"; } $page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false); - - if ($update) { - $return_url = $_SESSION['return_url']; - } else { - $return_url = $_SESSION['return_url'] = $a->query_string; + if (!$update) { + $_SESSION['return_url'] = $a->query_string; } - $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview); - call_hooks('conversation_start',$cb); + $cb = ['items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview]; + Addon::callHooks('conversation_start',$cb); $items = $cb['items']; - $cmnt_tpl = get_markup_template('comment_item.tpl'); - $hide_comments_tpl = get_markup_template('hide_comments.tpl'); - - $conv_responses = array( - 'like' => array('title' => t('Likes','title')), 'dislike' => array('title' => t('Dislikes','title')), - 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title')) - ); + $conv_responses = [ + 'like' => ['title' => t('Likes','title')], 'dislike' => ['title' => t('Dislikes','title')], + 'attendyes' => ['title' => t('Attending','title')], 'attendno' => ['title' => t('Not attending','title')], 'attendmaybe' => ['title' => t('Might attend','title')] + ]; // array with html for each thread (parent+comments) - $threads = array(); + $threads = []; $threadsid = -1; $page_template = get_markup_template("conversation.tpl"); @@ -624,7 +620,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $community_readonly = false; $writable = true; } else { - $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA)); + $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]); } } else { $writable = false; @@ -634,7 +630,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $writable = false; } - if ($mode === 'network-new' || $mode === 'search' || $community_readonly) { + if (in_array($mode, ['network-new', 'search', 'contact-posts']) || $community_readonly) { /* * "New Item View" on network page or search page results @@ -677,15 +673,15 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $profile_name = $item['author-link']; } - $tags = array(); - $hashtags = array(); - $mentions = array(); + $tags = []; + $hashtags = []; + $mentions = []; $searchpath = System::baseUrl()."/search?tag="; - $taglist = dba::select('term', array('type', 'term', 'url'), - array("`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION), - array('order' => array('tid'))); + $taglist = dba::select('term', ['type', 'term', 'url'], + ["`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION], + ['order' => ['tid']]); while ($tag = dba::fetch($taglist)) { if ($tag["url"] == "") { @@ -714,7 +710,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { if ($sp) { $sparkle = ' sparkle'; } else { - $profile_link = zrl($profile_link); + $profile_link = Profile::zrl($profile_link); } if (!x($item, 'author-thumb') || ($item['author-thumb'] == "")) { @@ -735,8 +731,8 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { } } - $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); - call_hooks('render_location',$locate); + $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => '']; + Addon::callHooks('render_location',$locate); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); @@ -747,19 +743,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $dropping = false; } - $drop = array( + $drop = [ 'dropping' => $dropping, 'pagedrop' => $page_dropping, 'select' => t('Select'), 'delete' => t('Delete'), - ); + ]; $star = false; $isstarred = "unstarred"; $lock = false; $likebuttons = false; - $shareable = false; $body = prepare_body($item, true, $preview); @@ -778,12 +773,12 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $item['item_network'] = $item['network']; } - $tmp_item = array( + $tmp_item = [ 'template' => $tpl, 'id' => (($preview) ? 'P0' : $item['item_id']), 'guid' => (($preview) ? 'Q0' : $item['guid']), 'network' => $item['item_network'], - 'network_name' => network_to_name($item['item_network'], $profile_link), + 'network_name' => ContactSelector::networkToName($item['item_network'], $profile_link), 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), @@ -819,18 +814,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { 'like' => '', 'dislike' => '', 'comment' => '', - 'conv' => (($preview) ? '' : array('href'=> 'display/'.$item['guid'], 'title'=> t('View in context'))), + 'conv' => (($preview) ? '' : ['href'=> 'display/'.$item['guid'], 'title'=> t('View in context')]), 'previewing' => $previewing, 'wait' => t('Please wait'), 'thread_level' => 1, - ); + ]; - $arr = array('item' => $item, 'output' => $tmp_item); - call_hooks('display_item', $arr); + $arr = ['item' => $item, 'output' => $tmp_item]; + Addon::callHooks('display_item', $arr); $threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['network'] = $item['item_network']; - $threads[$threadsid]['items'] = array($arr['output']); + $threads[$threadsid]['items'] = [$arr['output']]; } } else { @@ -844,9 +839,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { * this shouldn't be needed, as we should have only them in our array * But for now, this array respects the old style, just in case */ - $threads = array(); foreach ($items as $item) { - if ($arr_blocked) { $blocked = false; foreach ($arr_blocked as $b) { @@ -872,7 +865,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { continue; } - call_hooks('display_item', $arr); + Addon::callHooks('display_item', $arr); $item['pagedrop'] = $page_dropping; @@ -883,15 +876,14 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { } $threads = $conv->getTemplateData($conv_responses); - if (!$threads) { logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); - $threads = array(); + $threads = []; } } } - $o = replace_macros($page_template, array( + $o = replace_macros($page_template, [ '$baseurl' => System::baseUrl($ssl_state), '$return_path' => $a->query_string, '$live_update' => $live_update_div, @@ -900,7 +892,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { '$user' => $a->user, '$threads' => $threads, '$dropping' => ($page_dropping && Feature::isEnabled(local_user(), 'multi_delete') ? t('Delete Selected Items') : False), - )); + ]); return $o; } @@ -918,7 +910,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { function community_add_items($parents) { $max_comments = Config::get("system", "max_comments", 100); - $items = array(); + $items = []; foreach ($parents AS $parent) { $thread_items = dba::p(item_query()." AND `item`.`uid` = ? @@ -929,6 +921,21 @@ function community_add_items($parents) { ); $comments = dba::inArray($thread_items); + // Check if the original item is in the result. + // When commenting from the community page there can be incomplete threads + if (count($comments) > 0) { + $parent_found = false; + foreach ($comments as $comment) { + if ($comment['uri'] == $comment['parent-uri']) { + $parent_found = true; + break; + } + } + if (!$parent_found) { + $comments = []; + } + } + if (count($comments) == 0) { $thread_items = dba::p(item_query()." AND `item`.`uid` = 0 AND `item`.`parent-uri` = ? @@ -945,7 +952,7 @@ function community_add_items($parents) { foreach ($items as $index => $item) { if ($item['uid'] == 0) { - $items[$index]['writable'] = in_array($item['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS]); + $items[$index]['writable'] = in_array($item['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]); } } @@ -962,11 +969,15 @@ function best_link_url($item, &$sparkle, $url = '') { $clean_url = normalise_link($item['author-link']); if (local_user()) { - $r = dba::select('contact', array('id'), - array('network' => NETWORK_DFRN, 'uid' => local_user(), 'nurl' => normalise_link($clean_url), 'pending' => false), - array('limit' => 1)); - if (DBM::is_result($r)) { - $best_url = 'redir/' . $r['id']; + $condition = [ + 'network' => NETWORK_DFRN, + 'uid' => local_user(), + 'nurl' => normalise_link($clean_url), + 'pending' => false + ]; + $contact = dba::selectFirst('contact', ['id'], $condition); + if (DBM::is_result($contact)) { + $best_url = 'redir/' . $contact['id']; $sparkle = true; if ($url != '') { $hostname = get_app()->get_hostname(); @@ -1000,7 +1011,6 @@ function item_photo_menu($item) { $status_link = ''; $photos_link = ''; $posts_link = ''; - $network = ''; if ((local_user()) && local_user() == $item['uid'] && $item['parent'] == $item['id'] && (! $item['self'])) { $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; @@ -1015,20 +1025,20 @@ function item_photo_menu($item) { $cid = 0; $network = ''; $rel = 0; - $r = dba::select('contact', array('id', 'network', 'rel'), array('uid' => local_user(), 'nurl' => normalise_link($item['author-link'])), array('limit' => 1)); - if (DBM::is_result($r)) { - $cid = $r['id']; - $network = $r['network']; - $rel = $r['rel']; + $condition = ['uid' => local_user(), 'nurl' => normalise_link($item['author-link'])]; + $contact = dba::selectFirst('contact', ['id', 'network', 'rel'], $condition); + if (DBM::is_result($contact)) { + $cid = $contact['id']; + $network = $contact['network']; + $rel = $contact['rel']; } if ($sparkle) { $status_link = $profile_link . '?url=status'; $photos_link = $profile_link . '?url=photos'; $profile_link = $profile_link . '?url=profile'; - $zurl = ''; } else { - $profile_link = zrl($profile_link); + $profile_link = Profile::zrl($profile_link); } if ($cid && !$item['self']) { @@ -1036,13 +1046,13 @@ function item_photo_menu($item) { $contact_url = 'contacts/' . $cid; $posts_link = 'contacts/' . $cid . '/posts'; - if (in_array($network, array(NETWORK_DFRN, NETWORK_DIASPORA))) { + if (in_array($network, [NETWORK_DFRN, NETWORK_DIASPORA])) { $pm_url = 'message/new/' . $cid; } } if (local_user()) { - $menu = array( + $menu = [ t('Follow Thread') => $sub_link, t('View Status') => $status_link, t('View Profile') => $profile_link, @@ -1050,23 +1060,23 @@ function item_photo_menu($item) { t('Network Posts') => $posts_link, t('View Contact') => $contact_url, t('Send PM') => $pm_url - ); + ]; if ($network == NETWORK_DFRN) { $menu[t("Poke")] = $poke_link; } if ((($cid == 0) || ($rel == CONTACT_IS_FOLLOWER)) && - in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) { + in_array($item['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) { $menu[t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']); } } else { - $menu = array(t('View Profile') => $item['author-link']); + $menu = [t('View Profile') => $item['author-link']]; } - $args = array('item' => $item, 'menu' => $menu); + $args = ['item' => $item, 'menu' => $menu]; - call_hooks('item_photo_menu', $args); + Addon::callHooks('item_photo_menu', $args); $menu = $args['menu']; @@ -1113,7 +1123,6 @@ function builtin_activity_puller($item, &$conv_responses) { break; default: return; - break; } if ((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) { @@ -1122,7 +1131,7 @@ function builtin_activity_puller($item, &$conv_responses) { $url = 'redir/' . $item['contact-id']; $sparkle = ' class="sparkle" '; } else { - $url = zrl($url); + $url = Profile::zrl($url); } $url = '' . htmlentities($item['author-name']) . ''; @@ -1133,7 +1142,7 @@ function builtin_activity_puller($item, &$conv_responses) { if (! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l'])) && (is_array($conv_responses[$mode][$item['thr-parent'] . '-l'])))) { - $conv_responses[$mode][$item['thr-parent'] . '-l'] = array(); + $conv_responses[$mode][$item['thr-parent'] . '-l'] = []; } // only list each unique author once @@ -1241,11 +1250,11 @@ function format_like($cnt, array $arr, $type, $id) { } $phrase .= EOL ; - $o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array( + $o .= replace_macros(get_markup_template('voting_fakelink.tpl'), [ '$phrase' => $phrase, '$type' => $type, '$id' => $id - )); + ]); $o .= $expanded; return $o; @@ -1255,10 +1264,10 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) { $o = ''; - $geotag = x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : ''; + $geotag = x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), []) : ''; $tpl = get_markup_template('jot-header.tpl'); - $a->page['htmlhead'] .= replace_macros($tpl, array( + $a->page['htmlhead'] .= replace_macros($tpl, [ '$newpost' => 'true', '$baseurl' => System::baseUrl(true), '$geotag' => $geotag, @@ -1271,10 +1280,10 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) '$fileas' => t('Save to Folder:'), '$whereareu' => t('Where are you right now?'), '$delitems' => t('Delete item(s)?') - )); + ]); $tpl = get_markup_template('jot-end.tpl'); - $a->page['end'] .= replace_macros($tpl, array( + $a->page['end'] .= replace_macros($tpl, [ '$newpost' => 'true', '$baseurl' => System::baseUrl(true), '$geotag' => $geotag, @@ -1286,10 +1295,10 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) '$term' => t('Tag term:'), '$fileas' => t('Save to Folder:'), '$whereareu' => t('Where are you right now?') - )); + ]); $jotplugins = ''; - call_hooks('jot_tool', $jotplugins); + Addon::callHooks('jot_tool', $jotplugins); // Private/public post links for the non-JS ACL form $private_post = 1; @@ -1299,7 +1308,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) $query_str = $a->query_string; if (strpos($query_str, 'public=1') !== false) { - $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str); + $query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str); } /* @@ -1316,7 +1325,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) // $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); $tpl = get_markup_template("jot.tpl"); - $o .= replace_macros($tpl,array( + $o .= replace_macros($tpl,[ '$return_path' => $query_str, '$action' => 'item', '$share' => defaults($x, 'button', t('Share')), @@ -1361,7 +1370,6 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) // ACL permissions box '$acl' => $x['acl'], - '$acl_data' => $x['acl_data'], '$group_perms' => t('Post to Groups'), '$contact_perms' => t('Post to Contacts'), '$private' => t('Private post'), @@ -1371,7 +1379,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) //jot nav tab (used in some themes) '$message' => t('Message'), '$browser' => t('Browser'), - )); + ]); if ($popup == true) { @@ -1628,9 +1636,9 @@ function render_location_dummy($item) { /// @TODO Add type-hint function get_responses($conv_responses, $response_verbs, $ob, $item) { - $ret = array(); + $ret = []; foreach ($response_verbs as $v) { - $ret[$v] = array(); + $ret[$v] = []; $ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], ''); $ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', ''); $ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0'); @@ -1656,22 +1664,25 @@ function get_responses($conv_responses, $response_verbs, $ob, $item) { return $ret; } -function get_response_button_text($v, $count) { +function get_response_button_text($v, $count) +{ switch ($v) { case 'like': - return tt('Like', 'Likes', $count, 'noun'); + $return = tt('Like', 'Likes', $count); break; case 'dislike': - return tt('Dislike', 'Dislikes', $count, 'noun'); + $return = tt('Dislike', 'Dislikes', $count); break; case 'attendyes': - return tt('Attending', 'Attending', $count, 'noun'); + $return = tt('Attending', 'Attending', $count); break; case 'attendno': - return tt('Not Attending', 'Not Attending', $count, 'noun'); + $return = tt('Not Attending', 'Not Attending', $count); break; case 'attendmaybe': - return tt('Undecided', 'Undecided', $count, 'noun'); + $return = tt('Undecided', 'Undecided', $count); break; } + + return $return; }