/**
  * Get array of tags that both User and Viewer following
  * and return parsed block 'You both follow'
  *
  * @param array $userTags
  * @param array $viewerTags
  *
  * @return string html block or empty String if there are
  * no common tags
  */
 protected static function getCommonTags(array $userTags, array $viewerTags)
 {
     $aCommon = \array_intersect($userTags, $viewerTags);
     if (empty($aCommon)) {
         return '';
     }
     $tags = \tplTagLink::loop(array_values($aCommon), false);
     /**
      * @todo translate string 'You both follow'
      *
      */
     $vals = array('count' => '@@You both follow@@', 'label' => 'tag', 'tags' => $tags);
     return \tplUserTags::parse($vals);
 }
Пример #2
0
 /**
  *
  * Renders block with user tags
  *
  * @todo get Viewer from Registry and if NOT
  * the same as User then get array intersection
  * and show you have these 'tags' in common
  *
  * @param object $Registry Registry object
  * @param object $User User object
  */
 public static function get(Registry $Registry, User $User)
 {
     $uid = $User->getUid();
     $aTags = $Registry->Mongo->USER_TAGS->findOne(array('_id' => $uid));
     if (empty($aTags) || empty($aTags['tags'])) {
         d('no tags for user: '******'';
     }
     $aUserTags = $aTags['tags'];
     d('$aUserTags: ' . print_r($aUserTags, 1));
     $count = count($aUserTags);
     /**
      * @todo Translate string
      */
     $blockTitle = "User's most active tags";
     if ($count > self::MAX_TO_SHOW) {
         $aUserTags = \array_slice($aUserTags, 0, self::MAX_TO_SHOW);
     }
     $tags = '';
     foreach ($aUserTags as $tag => $count) {
         $tags .= \tplUserTag::parse(array($tag, $count), false);
     }
     d('tags: ' . $tags);
     /**
      * @todo translate string
      */
     $vals = array('count' => $blockTitle, 'label' => 'tag', 'tags' => $tags);
     d('vals: ' . print_r($vals, 1));
     $ret = \tplUserTags::parse($vals);
     d('ret: ' . $ret);
     return $ret;
 }