public function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $out->addModuleStyles('mediawiki.special');
     $this->opts = array();
     $request = $this->getRequest();
     if ($par !== null) {
         $target = $par;
     } else {
         $target = $request->getVal('target');
     }
     // check for radiobox
     if ($request->getVal('contribs') == 'newbie') {
         $target = 'newbies';
         $this->opts['contribs'] = 'newbie';
     } elseif ($par === 'newbies') {
         // b/c for WMF
         $target = 'newbies';
         $this->opts['contribs'] = 'newbie';
     } else {
         $this->opts['contribs'] = 'user';
     }
     $this->opts['deletedOnly'] = $request->getBool('deletedOnly');
     if (!strlen($target)) {
         $out->addHTML($this->getForm());
         return;
     }
     $user = $this->getUser();
     $this->opts['limit'] = $request->getInt('limit', $user->getOption('rclimit'));
     $this->opts['target'] = $target;
     $this->opts['topOnly'] = $request->getBool('topOnly');
     $nt = Title::makeTitleSafe(NS_USER, $target);
     if (!$nt) {
         $out->addHTML($this->getForm());
         return;
     }
     $userObj = User::newFromName($nt->getText(), false);
     if (!$userObj) {
         $out->addHTML($this->getForm());
         return;
     }
     $id = $userObj->getID();
     if ($this->opts['contribs'] != 'newbie') {
         $target = $nt->getText();
         $out->addSubtitle($this->contributionsSub($userObj));
         $out->setHTMLTitle($this->msg('pagetitle', $this->msg('contributions-title', $target)->plain()));
         $this->getSkin()->setRelevantUser($userObj);
     } else {
         $out->addSubtitle($this->msg('sp-contributions-newbies-sub'));
         $out->setHTMLTitle($this->msg('pagetitle', $this->msg('sp-contributions-newbies-title')->plain()));
     }
     if (($ns = $request->getVal('namespace', null)) !== null && $ns !== '') {
         $this->opts['namespace'] = intval($ns);
     } else {
         $this->opts['namespace'] = '';
     }
     $this->opts['associated'] = $request->getBool('associated');
     $this->opts['nsInvert'] = (bool) $request->getVal('nsInvert');
     $this->opts['tagfilter'] = (string) $request->getVal('tagfilter');
     // Allows reverts to have the bot flag in recent changes. It is just here to
     // be passed in the form at the top of the page
     if ($user->isAllowed('markbotedits') && $request->getBool('bot')) {
         $this->opts['bot'] = '1';
     }
     $skip = $request->getText('offset') || $request->getText('dir') == 'prev';
     # Offset overrides year/month selection
     if ($skip) {
         $this->opts['year'] = '';
         $this->opts['month'] = '';
     } else {
         $this->opts['year'] = $request->getIntOrNull('year');
         $this->opts['month'] = $request->getIntOrNull('month');
     }
     $feedType = $request->getVal('feed');
     if ($feedType) {
         // Maintain some level of backwards compatability
         // If people request feeds using the old parameters, redirect to API
         $apiParams = array('action' => 'feedcontributions', 'feedformat' => $feedType, 'user' => $target);
         if ($this->opts['topOnly']) {
             $apiParams['toponly'] = true;
         }
         if ($this->opts['deletedOnly']) {
             $apiParams['deletedonly'] = true;
         }
         if ($this->opts['tagfilter'] !== '') {
             $apiParams['tagfilter'] = $this->opts['tagfilter'];
         }
         if ($this->opts['namespace'] !== '') {
             $apiParams['namespace'] = $this->opts['namespace'];
         }
         if ($this->opts['year'] !== null) {
             $apiParams['year'] = $this->opts['year'];
         }
         if ($this->opts['month'] !== null) {
             $apiParams['month'] = $this->opts['month'];
         }
         $url = wfScript('api') . '?' . wfArrayToCGI($apiParams);
         $out->redirect($url, '301');
         return;
     }
     // Add RSS/atom links
     $this->addFeedLinks(array('action' => 'feedcontributions', 'user' => $target));
     if (wfRunHooks('SpecialContributionsBeforeMainOutput', array($id))) {
         $out->addHTML($this->getForm());
         $pager = new ContribsPager($this->getContext(), array('target' => $target, 'contribs' => $this->opts['contribs'], 'namespace' => $this->opts['namespace'], 'year' => $this->opts['year'], 'month' => $this->opts['month'], 'deletedOnly' => $this->opts['deletedOnly'], 'topOnly' => $this->opts['topOnly'], 'nsInvert' => $this->opts['nsInvert'], 'associated' => $this->opts['associated']));
         if (!$pager->getNumRows()) {
             $out->addWikiMsg('nocontribs', $target);
         } else {
             # Show a message about slave lag, if applicable
             $lag = wfGetLB()->safeGetLag($pager->getDatabase());
             if ($lag > 0) {
                 $out->showLagWarning($lag);
             }
             $out->addHTML('<p>' . $pager->getNavigationBar() . '</p>' . $pager->getBody() . '<p>' . $pager->getNavigationBar() . '</p>');
         }
         $out->preventClickjacking($pager->getPreventClickjacking());
         # Show the appropriate "footer" message - WHOIS tools, etc.
         if ($this->opts['contribs'] == 'newbie') {
             $message = 'sp-contributions-footer-newbies';
         } elseif (IP::isIPAddress($target)) {
             $message = 'sp-contributions-footer-anon';
         } elseif ($userObj->isAnon()) {
             // No message for non-existing users
             $message = '';
         } else {
             $message = 'sp-contributions-footer';
         }
         if ($message) {
             if (!$this->msg($message, $target)->isDisabled()) {
                 $out->wrapWikiMsg("<div class='mw-contributions-footer'>\n\$1\n</div>", array($message, $target));
             }
         }
     }
 }
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgRequest;
     $this->setHeaders();
     $this->outputHeader();
     $this->opts = array();
     if ($par == 'newbies') {
         $target = 'newbies';
         $this->opts['contribs'] = 'newbie';
     } elseif (isset($par)) {
         $target = $par;
     } else {
         $target = $wgRequest->getVal('target');
     }
     // check for radiobox
     if ($wgRequest->getVal('contribs') == 'newbie') {
         $target = 'newbies';
         $this->opts['contribs'] = 'newbie';
     }
     if (!strlen($target)) {
         $wgOut->addHTML($this->getForm());
         return;
     }
     $this->opts['limit'] = $wgRequest->getInt('limit', $wgUser->getOption('rclimit'));
     $this->opts['target'] = $target;
     $nt = Title::makeTitleSafe(NS_USER, $target);
     if (!$nt) {
         $wgOut->addHTML($this->getForm());
         return;
     }
     $id = User::idFromName($nt->getText());
     if ($target != 'newbies') {
         $target = $nt->getText();
         $wgOut->setSubtitle($this->contributionsSub($nt, $id));
         $wgOut->setHTMLTitle(wfMsg('pagetitle', wfMsgExt('contributions-title', array('parsemag'), $target)));
     } else {
         $wgOut->setSubtitle(wfMsgHtml('sp-contributions-newbies-sub'));
         $wgOut->setHTMLTitle(wfMsg('pagetitle', wfMsg('sp-contributions-newbies-title')));
     }
     if (($ns = $wgRequest->getVal('namespace', null)) !== null && $ns !== '') {
         $this->opts['namespace'] = intval($ns);
     } else {
         $this->opts['namespace'] = '';
     }
     $this->opts['tagfilter'] = (string) $wgRequest->getVal('tagfilter');
     // Allows reverts to have the bot flag in recent changes. It is just here to
     // be passed in the form at the top of the page
     if ($wgUser->isAllowed('markbotedits') && $wgRequest->getBool('bot')) {
         $this->opts['bot'] = '1';
     }
     $skip = $wgRequest->getText('offset') || $wgRequest->getText('dir') == 'prev';
     # Offset overrides year/month selection
     if ($skip) {
         $this->opts['year'] = '';
         $this->opts['month'] = '';
     } else {
         $this->opts['year'] = $wgRequest->getIntOrNull('year');
         $this->opts['month'] = $wgRequest->getIntOrNull('month');
     }
     // Add RSS/atom links
     $this->setSyndicated();
     $feedType = $wgRequest->getVal('feed');
     if ($feedType) {
         return $this->feed($feedType);
     }
     if (wfRunHooks('SpecialContributionsBeforeMainOutput', array($id))) {
         $wgOut->addHTML($this->getForm());
         $pager = new ContribsPager($target, $this->opts['namespace'], $this->opts['year'], $this->opts['month']);
         if (!$pager->getNumRows()) {
             $wgOut->addWikiMsg('nocontribs', $target);
         } else {
             # Show a message about slave lag, if applicable
             if (($lag = $pager->getDatabase()->getLag()) > 0) {
                 $wgOut->showLagWarning($lag);
             }
             $wgOut->addHTML('<p>' . $pager->getNavigationBar() . '</p>' . $pager->getBody() . '<p>' . $pager->getNavigationBar() . '</p>');
         }
         $wgOut->preventClickjacking($pager->getPreventClickjacking());
         # Show the appropriate "footer" message - WHOIS tools, etc.
         if ($target != 'newbies') {
             $message = 'sp-contributions-footer';
             if (IP::isIPAddress($target)) {
                 $message = 'sp-contributions-footer-anon';
             } else {
                 $user = User::newFromName($target);
                 if (!$user || $user->isAnon()) {
                     // No message for non-existing users
                     return;
                 }
             }
             $text = wfMsgNoTrans($message, $target);
             if (!wfEmptyMsg($message, $text) && $text != '-') {
                 $wgOut->wrapWikiMsg("<div class='mw-contributions-footer'>\n\$1\n</div>", array($message, $target));
             }
         }
     }
 }