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));
             }
         }
     }
 }
/**
 * Special page "user contributions".
 * Shows a list of the contributions of a user.
 *
 * @return	none
 * @param	$par	String: (optional) user name of the user for which to show the contributions
 */
function wfSpecialContributions($par = null)
{
    global $wgUser, $wgOut, $wgLang, $wgRequest;
    $options = array();
    if (isset($par) && $par == 'newbies') {
        $target = 'newbies';
        $options['contribs'] = 'newbie';
    } elseif (isset($par)) {
        $target = $par;
    } else {
        $target = $wgRequest->getVal('target');
    }
    // check for radiobox
    if ($wgRequest->getVal('contribs') == 'newbie') {
        $target = 'newbies';
        $options['contribs'] = 'newbie';
    }
    $wgOut->addHTML("<div class='section_text' style='font-size: .9em;'>");
    if (!strlen($target)) {
        $wgOut->addHTML(contributionsForm(''));
        return;
    }
    $options['limit'] = $wgRequest->getInt('limit', 50);
    $options['target'] = $target;
    $nt = Title::makeTitleSafe(NS_USER, $target);
    if (!$nt) {
        $wgOut->addHTML(contributionsForm(''));
        return;
    }
    $id = User::idFromName($nt->getText());
    if ($target != 'newbies') {
        $target = $nt->getText();
        $wgOut->setSubtitle(contributionsSub($nt, $id));
    } else {
        $wgOut->setSubtitle(wfMsgHtml('sp-contributions-newbies-sub'));
    }
    if (($ns = $wgRequest->getVal('namespace', null)) !== null && $ns !== '') {
        $options['namespace'] = intval($ns);
    } else {
        $options['namespace'] = '';
    }
    if ($wgUser->isAllowed('markbotedit') && $wgRequest->getBool('bot')) {
        $options['bot'] = '1';
    }
    $skip = $wgRequest->getText('offset') || $wgRequest->getText('dir') == 'prev';
    # Offset overrides year/month selection
    if (($month = $wgRequest->getIntOrNull('month')) !== null && $month !== -1) {
        $options['month'] = intval($month);
    } else {
        $options['month'] = '';
    }
    if (($year = $wgRequest->getIntOrNull('year')) !== null) {
        $options['year'] = intval($year);
    } else {
        if ($options['month']) {
            $thisMonth = intval(gmdate('n'));
            $thisYear = intval(gmdate('Y'));
            if (intval($options['month']) > $thisMonth) {
                $thisYear--;
            }
            $options['year'] = $thisYear;
        } else {
            $options['year'] = '';
        }
    }
    wfRunHooks('SpecialContributionsBeforeMainOutput', array($id));
    $wgOut->addHTML(contributionsForm($options));
    $wgOut->addHTML("<div style='font-size:95%; margin-bottom:10px;'>" . contributionsSub($nt, $id) . "</div>");
    # Show original selected options, don't apply them so as to allow paging
    $_GET['year'] = '';
    // hack for Pager
    $_GET['month'] = '';
    // hack for Pager
    if ($skip) {
        $options['year'] = '';
        $options['month'] = '';
    }
    $pager = new ContribsPager($target, $options['namespace'], $options['year'], $options['month']);
    if (!$pager->getNumRows()) {
        $wgOut->addWikiMsg('nocontribs');
        return;
    }
    # 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>');
    # If there were contributions, and it was a valid user or IP, show
    # the appropriate "footer" message - WHOIS tools, etc.
    if ($target != 'newbies') {
        $message = IP::isIPAddress($target) ? 'sp-contributions-footer-anon' : 'sp-contributions-footer';
        $text = wfMsgNoTrans($message, $target);
        if (!wfEmptyMsg($message, $text) && $text != '-') {
            $wgOut->addHtml('<div class="mw-contributions-footer">');
            $wgOut->addWikiText($text);
            $wgOut->addHtml('</div>');
        }
    }
    $wgOut->addHTML("</div>");
}
 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', 50);
     $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', wfMsg('contributions-title', $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'] = '';
     }
     // 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 (($month = $wgRequest->getIntOrNull('month')) !== null && $month !== -1) {
         $this->opts['month'] = intval($month);
     } else {
         $this->opts['month'] = '';
     }
     if (($year = $wgRequest->getIntOrNull('year')) !== null) {
         $this->opts['year'] = intval($year);
     } else {
         if ($this->opts['month']) {
             $thisMonth = intval(gmdate('n'));
             $thisYear = intval(gmdate('Y'));
             if (intval($this->opts['month']) > $thisMonth) {
                 $thisYear--;
             }
             $this->opts['year'] = $thisYear;
         } else {
             $this->opts['year'] = '';
         }
     }
     if ($skip) {
         $this->opts['year'] = '';
         $this->opts['month'] = '';
     }
     // Add RSS/atom links
     $this->setSyndicated();
     $feedType = $wgRequest->getVal('feed');
     if ($feedType) {
         return $this->feed($feedType);
     }
     wfRunHooks('SpecialContributionsBeforeMainOutput', $id);
     $wgOut->addHTML($this->getForm($this->opts));
     $pager = new ContribsPager($target, $this->opts['namespace'], $this->opts['year'], $this->opts['month']);
     if (!$pager->getNumRows()) {
         $wgOut->addWikiMsg('nocontribs');
         return;
     }
     # 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>');
     # If there were contributions, and it was a valid user or IP, show
     # the appropriate "footer" message - WHOIS tools, etc.
     if ($target != 'newbies') {
         $message = IP::isIPAddress($target) ? 'sp-contributions-footer-anon' : 'sp-contributions-footer';
         $text = wfMsgNoTrans($message, $target);
         if (!wfEmptyMsg($message, $text) && $text != '-') {
             $wgOut->addHTML('<div class="mw-contributions-footer">');
             $wgOut->addWikiText($text);
             $wgOut->addHTML('</div>');
         }
     }
 }
 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));
             }
         }
     }
 }
/**
 * Special page "user contributions".
 * Shows a list of the contributions of a user.
 *
 * @return	none
 * @param	$par	String: (optional) user name of the user for which to show the contributions
 */
function wfSpecialContributions($par = null)
{
    global $wgUser, $wgOut, $wgLang, $wgRequest;
    $options = array();
    if (isset($par) && $par == 'newbies') {
        $target = 'newbies';
        $options['contribs'] = 'newbie';
    } elseif (isset($par)) {
        $target = $par;
    } else {
        $target = $wgRequest->getVal('target');
    }
    // check for radiobox
    if ($wgRequest->getVal('contribs') == 'newbie') {
        $target = 'newbies';
        $options['contribs'] = 'newbie';
    }
    if (!strlen($target)) {
        $wgOut->addHTML(contributionsForm(''));
        return;
    }
    $options['limit'] = $wgRequest->getInt('limit', 50);
    $options['target'] = $target;
    $nt = Title::makeTitleSafe(NS_USER, $target);
    if (!$nt) {
        $wgOut->addHTML(contributionsForm(''));
        return;
    }
    $id = User::idFromName($nt->getText());
    if ($target != 'newbies') {
        $target = $nt->getText();
        $wgOut->setSubtitle(contributionsSub($nt, $id));
    } else {
        $wgOut->setSubtitle(wfMsgHtml('sp-contributions-newbies-sub'));
    }
    if (($ns = $wgRequest->getVal('namespace', null)) !== null && $ns !== '') {
        $options['namespace'] = intval($ns);
    } else {
        $options['namespace'] = '';
    }
    /* BizzWiki */
    if ($ns == null || $ns == "") {
        $ns = 0;
    }
    if ($wgUser->isAllowed('rollback', $ns) && $wgRequest->getBool('bot')) {
        $options['bot'] = '1';
    }
    wfRunHooks('SpecialContributionsBeforeMainOutput', $id);
    $wgOut->addHTML(contributionsForm($options));
    $pager = new ContribsPager($target, $options['namespace']);
    if (!$pager->getNumRows()) {
        $wgOut->addWikiText(wfMsg('nocontribs'));
        return;
    }
    $wgOut->addHTML('<p>' . $pager->getNavigationBar() . '</p>' . $pager->getBody() . '<p>' . $pager->getNavigationBar() . '</p>');
    # If there were contributions, and it was a valid user or IP, show
    # the appropriate "footer" message - WHOIS tools, etc.
    if ($target != 'newbies') {
        $message = IP::isIPAddress($target) ? 'sp-contributions-footer-anon' : 'sp-contributions-footer';
        $text = wfMsg($message, $target);
        if (!wfEmptyMsg($message, $text) && $text != '-') {
            $wgOut->addHtml('<div class="mw-contributions-footer">');
            $wgOut->addWikiText($text);
            $wgOut->addHtml('</div>');
        }
    }
}