Merge remote-tracking branch 'upstream/develop' into public-redir
authorMichael <heluecht@pirati.ca>
Fri, 1 Jun 2018 12:32:51 +0000 (12:32 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 1 Jun 2018 12:32:51 +0000 (12:32 +0000)
1  2 
include/conversation.php

diff --combined include/conversation.php
@@@ -116,7 -116,7 +116,7 @@@ function localize_item(&$item) 
                $item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
        }
  
-       /// @Separted ???
+       /// @TODO Separted ???
        $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
        if (activity_match($item['verb'], ACTIVITY_LIKE)
                || activity_match($item['verb'], ACTIVITY_DISLIKE)
  
                if (activity_match($item['verb'], ACTIVITY_LIKE)) {
                        $bodyverb = L10n::t('%1$s likes %2$s\'s %3$s');
-               }
-               elseif (activity_match($item['verb'], ACTIVITY_DISLIKE)) {
+               } elseif (activity_match($item['verb'], ACTIVITY_DISLIKE)) {
                        $bodyverb = L10n::t('%1$s doesn\'t like %2$s\'s %3$s');
-               }
-               elseif (activity_match($item['verb'], ACTIVITY_ATTEND)) {
+               } elseif (activity_match($item['verb'], ACTIVITY_ATTEND)) {
                        $bodyverb = L10n::t('%1$s attends %2$s\'s %3$s');
-               }
-               elseif (activity_match($item['verb'], ACTIVITY_ATTENDNO)) {
+               } elseif (activity_match($item['verb'], ACTIVITY_ATTENDNO)) {
                        $bodyverb = L10n::t('%1$s doesn\'t attend %2$s\'s %3$s');
-               }
-               elseif (activity_match($item['verb'], ACTIVITY_ATTENDMAYBE)) {
+               } elseif (activity_match($item['verb'], ACTIVITY_ATTENDMAYBE)) {
                        $bodyverb = L10n::t('%1$s attends maybe %2$s\'s %3$s');
                }
-               $item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
  
+               $item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
        }
        if (activity_match($item['verb'], ACTIVITY_FRIEND)) {
  
                if ($item['object-type']=="" || $item['object-type']!== ACTIVITY_OBJ_PERSON) return;
                $item['body'] = L10n::t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag );
  
        }
-       if (activity_match($item['verb'], ACTIVITY_FAVORITE)) {
  
+       if (activity_match($item['verb'], ACTIVITY_FAVORITE)) {
                if ($item['object-type'] == "") {
                        return;
                }
        }
  
        // add sparkle links to appropriate permalinks
 -
 -      $x = stristr($item['plink'],'/display/');
 -      if ($x) {
 -              $sparkle = false;
 -              $y = best_link_url($item, $sparkle);
 -
 -              if (strstr($y, '/redir/')) {
 -                      $item['plink'] = $y . '?f=&url=' . $item['plink'];
 -              }
 -      }
 +      $item['plink'] = Contact::magicLink($item['author-link'], $item['plink']);
  }
  
  /**
@@@ -385,10 -391,9 +382,9 @@@ function visible_activity($item) 
                }
        }
  
-       if (activity_match($item['verb'], ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE) {
-               if (!($item['self'] && ($item['uid'] == local_user()))) {
-                       return false;
-               }
+       // @TODO below if() block can be rewritten to a single line: $isVisible = allConditionsHere;
+       if (activity_match($item['verb'], ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE && empty($item['self']) && $item['uid'] == local_user()) {
+               return false;
        }
  
        return true;
@@@ -669,10 -674,16 +665,10 @@@ function conversation(App $a, $items, $
  
                                $tags = \Friendica\Model\Term::populateTagsFromItem($item);
  
 -                              $sp = false;
 -                              $profile_link = best_link_url($item, $sp);
 -                              if ($profile_link === 'mailbox') {
 -                                      $profile_link = '';
 -                              }
 +                              $profile_link = Contact::magicLink($item['author-link']);
  
 -                              if ($sp) {
 +                              if (strpos($profile_link, 'redir/') === 0) {
                                        $sparkle = ' sparkle';
 -                              } else {
 -                                      $profile_link = Profile::zrl($profile_link);
                                }
  
                                if (!x($item, 'author-thumb') || ($item['author-thumb'] == "")) {
@@@ -967,8 -978,11 +963,8 @@@ function item_photo_menu($item) 
                $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;';
        }
  
 -      $sparkle = false;
 -      $profile_link = best_link_url($item, $sparkle);
 -      if ($profile_link === 'mailbox') {
 -              $profile_link = '';
 -      }
 +      $profile_link = Contact::magicLink($item['author-link']);
 +      $sparkle = (strpos($profile_link, 'redir/') === 0);
  
        $cid = 0;
        $network = '';
@@@ -1074,14 -1088,17 +1070,14 @@@ function builtin_activity_puller($item
                }
  
                if (activity_match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
 -                      $url = $item['author-link'];
 -                      if (local_user() && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && !$item['self'] && link_compare($item['author-link'], $item['url'])) {
 -                              $url = 'redir/' . $item['contact-id'];
 +                      $url = Contact::MagicLink($item['author-link']);
 +                      if (strpos($url, 'redir/') === 0) {
                                $sparkle = ' class="sparkle" ';
 -                      } else {
 -                              $url = Profile::zrl($url);
                        }
  
                        $url = '<a href="'. $url . '"'. $sparkle .'>' . htmlentities($item['author-name']) . '</a>';
  
-                       if (!$item['thr-parent']) {
+                       if (!x($item, 'thr-parent')) {
                                $item['thr-parent'] = $item['parent-uri'];
                        }
  
@@@ -1569,19 -1586,17 +1565,17 @@@ function sort_thr_commented(array $a, a
        return strcmp($b['commented'], $a['commented']);
  }
  
- /// @TODO Add type-hint
- function render_location_dummy($item) {
-       if ($item['location'] != "") {
+ function render_location_dummy(array $item) {
+       if (x($item, 'location') && !empty($item['location'])) {
                return $item['location'];
        }
  
-       if ($item['coord'] != "") {
+       if (x($item, 'coord') && !empty($item['coord'])) {
                return $item['coord'];
        }
  }
  
- /// @TODO Add type-hint
- function get_responses($conv_responses, $response_verbs, $ob, $item) {
+ function get_responses(array $conv_responses, array $response_verbs, $ob, array $item) {
        $ret = [];
        foreach ($response_verbs as $v) {
                $ret[$v] = [];