/** * Get URL to default avatar */ public static function getDefaultAvatar($avatarSize) { wfProfileIn(__METHOD__); global $wgStylePath; if (class_exists('Masthead')) { $avatarUrl = Masthead::newFromUserId(0)->getThumbnail($avatarSize); } else { $randomInt = rand(1, 3); $avatarUrl = "{$wgStylePath}/oasis/images/generic_avatar{$randomInt}.png"; } wfProfileOut(__METHOD__); return $avatarUrl; }
public function getTopUsers($tag_id, $lang, $limit = 5, $force_reload = false) { global $wgMemc; wfProfileIn(__METHOD__); $mcKey = wfSharedMemcKey("auto_hubs", "users", $tag_id, $lang, $limit, __METHOD__); if (!$force_reload) { $out = $wgMemc->get($mcKey); if (!empty($out)) { wfProfileOut(__METHOD__); return $out; } } if (empty($this->dbEnabled)) { wfProfileOut(__METHOD__); return array("value" => array(), "age" => time()); } $tag_id = (int) $tag_id; $res = $this->dbs->select(array('specials.summary_tags_top_users'), array('user_id, tag_id, username, groups, all_count'), array('tag_id' => $tag_id, 'city_lang' => $lang, 'user_id <> 0'), __METHOD__, array('ORDER BY' => 'all_count desc', 'LIMIT' => 100)); $out = array(); $count = 0; while ($row = $this->dbs->fetchRow($res)) { if ($this->filterBanUsers($row)) { $out[] = $row; $count++; } if ($count == $limit) { break; } } // get avatars and fix usernames for the users foreach ($out as $key => $val) { $u = User::newFromId($val['user_id']); $out[$key]['username'] = $u->getName(); $userWiki = $this->getUserWiki($val['user_id']); if ($userWiki !== false) { list($wikiUrl, $pageUrl) = array_values($userWiki); $avatar = Masthead::newFromUserId($val['user_id']); $avatar->setUserPageUrl($pageUrl); $out[$key]['avatar'] = $avatar->display(30, 30); $out[$key]['userpage'] = $pageUrl; } } $out = array("value" => $out, "age" => time()); $wgMemc->set($mcKey, $out, 60 * 60); wfProfileOut(__METHOD__); return $out; }