private function getBadgesData() { global $wgContLang; // get achievement lists $rankingService = new AchRankingService(); $userProfileService = new AchUserProfileService(); $userProfileService->getHTML(); // have to call this because it creates our data as a side effect $this->ownerName = $userProfileService->mUserOwner->getName(); $this->ownerBadges = $userProfileService->mOwnerBadgesSimple; $this->ownerCounters = $userProfileService->mOwnerCounters; $this->ownerRank = $rankingService->getUserRankingPosition($userProfileService->mUserOwner); $this->ownerScore = $wgContLang->formatNum($rankingService->getUserScore($userProfileService->mUserOwner->getId())); if($userProfileService->mUserViewer && $userProfileService->mUserViewer->isLoggedIn() && $userProfileService->mUserViewer->getId() == $userProfileService->mUserOwner->getId()) { $this->viewer_is_owner = true; $challengesBadges = $userProfileService->mChallengesBadges; // Let's prune the challengesBadges list to the correct length before passing it to the template if ($this->max_challenges != "all") { while (count($challengesBadges) > $this->max_challenges) array_pop($challengesBadges); } $this->challengesBadges = $challengesBadges; } // UI elements $this->leaderboard_url = Skin::makeSpecialUrl("Leaderboard"); if($userProfileService->mUserViewer && $userProfileService->mUserViewer->isAllowed('editinterface')) { $this->customize_url = Skin::makeSpecialUrl("AchievementsCustomize"); } }
public function executeIndex() { global $wgContLang; wfProfileIn(__METHOD__); $userProfileService = new AchUserProfileService(); if (!$userProfileService->isVisible()) { $this->skipRendering(); wfProfileOut(__METHOD__); return; } // add CSS and JS for this module $this->response->addAsset('achievements_css'); $this->response->addAsset('achievements_js'); $rankingService = new AchRankingService(); // get achievement lists $this->ownerName = $userProfileService->getOwnerUser()->getName(); $this->ownerBadgesCount = $userProfileService->getBadgesCount(); $this->ownerBadges = $userProfileService->getBadgesAnnotated(0); $this->ownerCounters = $userProfileService->getCounters(); $this->ownerRank = $rankingService->getUserRankingPosition($userProfileService->getOwnerUser()); $this->ownerScore = $wgContLang->formatNum($rankingService->getUserScore($userProfileService->getOwnerUser()->getId())); // if user is viewing their own page if ($userProfileService->getViewerUser() && !$userProfileService->getViewerUser()->isAnon() && $userProfileService->getViewerUser()->getId() == $userProfileService->getOwnerUser()->getId()) { $this->viewer_is_owner = true; $challengesBadges = $userProfileService->getChallengesAnnotated(); // Let's prune the challengesBadges list to the correct length before passing it to the template if ($this->max_challenges != "all") { $challengesBadges = array_slice($challengesBadges, 0, $this->max_challenges); } $this->challengesBadges = $challengesBadges; } // UI elements $this->leaderboard_url = Skin::makeSpecialUrl("Leaderboard"); if ($userProfileService->getViewerUser() && $userProfileService->getViewerUser()->isAllowed('editinterface')) { $this->customize_url = Skin::makeSpecialUrl("AchievementsCustomize"); } wfProfileOut(__METHOD__); }