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 executeBadges()
 {
     $userName = trim($this->getVal('user', ''));
     $page = $this->request->getInt('page', 0);
     $userProfileService = new AchUserProfileService(User::newFromName($userName));
     $this->ownerBadges = $userProfileService->getBadgesAnnotated($page);
 }
 function execute($user_id)
 {
     wfProfileIn(__METHOD__);
     global $wgOut, $wgExtensionsPath, $wgStylePath, $wgSupressPageSubtitle, $wgUser, $wgResourceBasePath, $wgJsMimeType;
     $wgSupressPageSubtitle = true;
     $rankingService = new AchRankingService();
     $this->setHeaders();
     $wgOut->setPageTitle(wfMsg('achievements-title'));
     $skinName = get_class($this->getSkin());
     if ($skinName == 'SkinOasis') {
         $assetsManager = F::build('AssetsManager', array(), 'getInstance');
         $scssPackage = 'special_leaderboard_oasis_css';
         $jsPackage = 'special_leaderboard_oasis_js';
         foreach ($assetsManager->getURL($scssPackage) as $url) {
             $wgOut->addStyle($url);
         }
         foreach ($assetsManager->getURL($jsPackage) as $url) {
             $wgOut->addScript("<script src=\"{$url}\"></script>");
         }
     } else {
         // FIXME: use AM group here
         $wgOut->addStyle("common/article_sidebar.css");
         $wgOut->addExtensionStyle("{$wgExtensionsPath}/wikia/AchievementsII/css/achievements_sidebar.css");
         $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgExtensionsPath}/wikia/AchievementsII/js/achievements.js\"></script>\n");
         if ($skinName == 'SkinMonoBook') {
             $wgOut->addExtensionStyle("{$wgExtensionsPath}/wikia/AchievementsII/css/leaderboard_monobook.css");
         }
     }
     // ranking
     $ranking = $rankingService->getUsersRanking(20, true);
     //make array of latest badges, per user
     $topUserIDs = array();
     foreach ($ranking as $rankedUser) {
         $topUserIDs[] = $rankedUser->getID();
     }
     $userService = new AchUserProfileService();
     $topUserBadges = $userService->getMostRecentUserBadge($topUserIDs);
     $template = new EasyTemplate(dirname(__FILE__) . '/templates');
     $template->set_vars(array('ranking' => $ranking, 'topUserBadges' => $topUserBadges, 'userpage' => $wgUser->getUserPage()->getPrefixedURL()));
     $wgOut->addHTML($template->render('SpecialLeaderboard'));
     wfProfileOut(__METHOD__);
 }
예제 #4
0
function Ach_AddToUserProfile(&$out)
{
    global $wgOut, $wgScriptPath;
    $userProfileService = new AchUserProfileService();
    $html = $userProfileService->getHTML();
    if ($html) {
        $out['achievementsII'] = $html;
        // TODO: use CDN path
        $wgOut->addStyle('../..' . $wgScriptPath . '/extensions/wikia/AchievementsII/css/achievements_sidebar.css');
    }
    return true;
}