/** * Get common interests with the user you are watching * * @param $target_user_id:current user; $user_id:his id * @return array */ function getCommonInterest($user_id, $target_user_id) { global $wgUser; $user_id = $this->user_id; $target_user_id = $wgUser->getId(); $res = UserSiteFollow::getCommonInterest($user_id, $target_user_id); $us = new UserStatus($this->user); $gender = $us->getGender(); if ($gender == 'male') { $genderIcon = '他'; } elseif ($gender == 'female') { $genderIcon = '她'; } else { $genderIcon = 'TA'; } $output = '<div class="panel panel-default"><div class="user-section-heading panel-heading"> <div class="user-section-title">我和' . $genderIcon . '的共同兴趣: </div> <div class="user-section-actions"> <div class="action-right"> </div> <div class="action-left"> </div> <div class="cleared"></div> </div> </div> <div class="cleared"></div> <div class="common-interest-container panel-body">'; if (!empty($res)) { foreach ($res as $value) { $Iname = HuijiPrefix::prefixToSiteName($value); $Iurl = HuijiPrefix::prefixToUrl($value); $output .= '<span class="label label-primary"><a href="' . $Iurl . '">' . $Iname . ' </a></span>'; } } else { $output .= '<p> 您和' . $genderIcon . '还没有共同兴趣~</p>'; } $output .= '</div></div>'; return $output; }