コード例 #1
0
 public function execute()
 {
     $params = $this->extractRequestParams();
     global $wgFeed, $wgFeedClasses, $wgSitename, $wgLanguageCode;
     if (!$wgFeed) {
         $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
     }
     if (!isset($wgFeedClasses[$params['feedformat']])) {
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     global $wgMiserMode;
     if ($params['showsizediff'] && $wgMiserMode) {
         $this->dieUsage('Size difference is disabled in Miser Mode', 'sizediffdisabled');
     }
     $msg = wfMessage('Contributions')->inContentLanguage()->text();
     $feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']';
     $feedUrl = SpecialPage::getTitleFor('Contributions', $params['user'])->getFullURL();
     $target = $params['user'] == 'newbies' ? 'newbies' : Title::makeTitleSafe(NS_USER, $params['user'])->getText();
     $feed = new $wgFeedClasses[$params['feedformat']]($feedTitle, htmlspecialchars($msg), $feedUrl);
     $pager = new ContribsPager($this->getContext(), array('target' => $target, 'namespace' => $params['namespace'], 'year' => $params['year'], 'month' => $params['month'], 'tagFilter' => $params['tagfilter'], 'deletedOnly' => $params['deletedonly'], 'topOnly' => $params['toponly'], 'showSizeDiff' => $params['showsizediff']));
     $feedItems = array();
     if ($pager->getNumRows() > 0) {
         foreach ($pager->mResult as $row) {
             $feedItems[] = $this->feedItem($row);
         }
     }
     ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
 }
コード例 #2
0
 public function execute()
 {
     $params = $this->extractRequestParams();
     $config = $this->getConfig();
     if (!$config->get('Feed')) {
         $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
     }
     $feedClasses = $config->get('FeedClasses');
     if (!isset($feedClasses[$params['feedformat']])) {
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     if ($params['showsizediff'] && $this->getConfig()->get('MiserMode')) {
         $this->dieUsage('Size difference is disabled in Miser Mode', 'sizediffdisabled');
     }
     $msg = wfMessage('Contributions')->inContentLanguage()->text();
     $feedTitle = $config->get('Sitename') . ' - ' . $msg . ' [' . $config->get('LanguageCode') . ']';
     $feedUrl = SpecialPage::getTitleFor('Contributions', $params['user'])->getFullURL();
     $target = $params['user'] == 'newbies' ? 'newbies' : Title::makeTitleSafe(NS_USER, $params['user'])->getText();
     $feed = new $feedClasses[$params['feedformat']]($feedTitle, htmlspecialchars($msg), $feedUrl);
     $pager = new ContribsPager($this->getContext(), array('target' => $target, 'namespace' => $params['namespace'], 'year' => $params['year'], 'month' => $params['month'], 'tagFilter' => $params['tagfilter'], 'deletedOnly' => $params['deletedonly'], 'topOnly' => $params['toponly'], 'newOnly' => $params['newonly'], 'showSizeDiff' => $params['showsizediff']));
     $feedLimit = $this->getConfig()->get('FeedLimit');
     if ($pager->getLimit() > $feedLimit) {
         $pager->setLimit($feedLimit);
     }
     $feedItems = array();
     if ($pager->getNumRows() > 0) {
         $count = 0;
         $limit = $pager->getLimit();
         foreach ($pager->mResult as $row) {
             // ContribsPager selects one more row for navigation, skip that row
             if (++$count > $limit) {
                 break;
             }
             $item = $this->feedItem($row);
             if ($item !== null) {
                 $feedItems[] = $item;
             }
         }
     }
     ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
 }
コード例 #3
0
 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));
             }
         }
     }
 }
コード例 #4
0
/**
 * 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>");
}
コード例 #5
0
 /**
  * Output a subscription feed listing recent edits to this page.
  * @param string $type
  */
 protected function feed($type)
 {
     global $wgRequest, $wgFeed, $wgFeedClasses, $wgFeedLimit;
     if (!$wgFeed) {
         global $wgOut;
         $wgOut->addWikiMsg('feed-unavailable');
         return;
     }
     if (!isset($wgFeedClasses[$type])) {
         global $wgOut;
         $wgOut->addWikiMsg('feed-invalid');
         return;
     }
     $feed = new $wgFeedClasses[$type]($this->feedTitle(), wfMsgExt('tagline', 'parsemag'), $this->getTitle()->getFullUrl() . "/" . urlencode($this->opts['target']));
     // Already valid title
     $nt = Title::makeTitleSafe(NS_USER, $this->opts['target']);
     $target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText();
     $pager = new ContribsPager($target, $this->opts['namespace'], $this->opts['year'], $this->opts['month'], $this->opts['tagfilter']);
     $pager->mLimit = min($this->opts['limit'], $wgFeedLimit);
     $feed->outHeader();
     if ($pager->getNumRows() > 0) {
         while ($row = $pager->mResult->fetchObject()) {
             $feed->outItem($this->feedItem($row));
         }
     }
     $feed->outFooter();
 }
コード例 #6
0
 public static function contributionsLineEndingProcess(ContribsPager &$contribsPager, &$ret, $row)
 {
     wfProfileIn(__METHOD__);
     $rev = new Revision($row);
     $page = $rev->getTitle();
     $page->resetArticleId($row->rev_page);
     $wfMsgOptsBase = self::getMessageOptions(null, $row);
     $isThread = $wfMsgOptsBase['isThread'];
     $isNew = $wfMsgOptsBase['isNew'];
     // Don't show useless link to people who cannot hide revisions
     $del = Linker::getRevDeleteLink($contribsPager->getUser(), $rev, $page);
     if ($del !== '') {
         $del .= ' ';
     } else {
         $del = '';
     }
     // VOLDEV-40: remove html messages
     $ret = $del;
     $ret .= Linker::linkKnown($page, $contribsPager->getLanguage()->userTimeAndDate($row->rev_timestamp, $contribsPager->getUser()), [], ['oldid' => $row->rev_id]) . ' (';
     if ($isNew) {
         $ret .= $contribsPager->msg('diff')->escaped();
     } else {
         $ret .= Linker::linkKnown($page, $contribsPager->msg('diff')->escaped(), [], ['diff' => 'prev', 'oldid' => $row->rev_id]);
     }
     $wallMessage = new WallMessage($page);
     $threadId = $wallMessage->getMessagePageId();
     $threadTitle = Title::newFromText($threadId, NS_USER_WALL_MESSAGE);
     $ret .= ' | ' . Linker::linkKnown($threadTitle, $contribsPager->msg('hist')->escaped(), [], ['action' => 'history']) . ') ';
     if ($isThread && $isNew) {
         $ret .= ChangesList::flag('newpage') . ' ';
     }
     if (MWNamespace::getSubject($row->page_namespace) === NS_WIKIA_FORUM_BOARD && empty($wfMsgOptsBase['articleTitleVal'])) {
         $wfMsgOptsBase['articleTitleTxt'] = $contribsPager->msg('forum-recentchanges-deleted-reply-title')->text();
     }
     $prefix = MWNamespace::getSubject($row->page_namespace) === NS_WIKIA_FORUM_BOARD ? 'forum' : 'wall';
     $ret .= $contribsPager->msg($prefix . '-contributions-line')->params($wfMsgOptsBase['articleTitle'])->rawParams(htmlspecialchars($wfMsgOptsBase['articleTitleTxt']))->params($wfMsgOptsBase['wallTitleTxt'], $wfMsgOptsBase['wallPageName'])->parse();
     if (!$isNew) {
         $summary = $rev->getComment();
         if (empty($summary)) {
             $msg = Linker::commentBlock($contribsPager->msg(static::getMessagePrefix($row->page_namespace) . '-edit')->inContentLanguage()->text());
         } else {
             $msg = Linker::revComment($rev, false, true);
         }
         $ret .= ' ' . $contribsPager->getLanguage()->getDirMark() . $msg;
     }
     wfProfileOut(__METHOD__);
     return true;
 }
コード例 #7
0
 /**
  *
  * Returns the html for the box at the
  * top of NFD Guardian which contains
  * information about the current
  * article being voted on.
  *
  */
 function getArticleInfoBox()
 {
     global $wgOut;
     //first find out who the author was
     $articleInfo = $this->getArticleInfo();
     if (intval($articleInfo->fe_user) > 0) {
         $u = User::newFromId($articleInfo->fe_user);
         $userLink = $u->getUserPage()->getInternalURL();
         $userName = $u->getName();
         $cp = new ContribsPager(ContextSource::getContext(), array($userName));
         $uEdits = $cp->getNumRows();
     } else {
         $u = User::newFromName($articleInfo->fe_user_text);
         $userLink = "/User:"******"") {
         $t = Title::newFromText($nfdReason['article']);
         if ($t) {
             $nfdLongReason .= " with [[" . $t->getText() . "]]";
         }
     }
     //finally check the number of discussion items for this
     //article. We ask for confirmation for articles
     //with a lot of discussion items.
     $t = Title::newFromID($this->mResult->nfd_page);
     if ($t) {
         $a = new Article($t);
         // $pageHistory = new PageHistory($a);
         // $pager = new PageHistoryPager( $pageHistory );
         // $edits = $pager->getNumRows();
         $pageHistory = new HistoryPage($a);
         $items = $pageHistory->fetchRevisions(100000, 0, 1);
         $edits = $items->numRows();
         $discussionTitle = Title::newFromText($t->getText(), NS_TALK);
         if ($discussionTitle) {
             $discussionArticle = new Article($discussionTitle);
             // $pageHistory = new PageHistory($discussionArticle);
             // $pager = new PageHistoryPager( $pageHistory );
             // $discussion = $pager->getNumRows();
             $pageHistory = new HistoryPage($discussionArticle);
             $items = $pageHistory->fetchRevisions(100000, 0, 1);
             $discussion = $items->numRows();
         } else {
             $discussion = 0;
         }
     }
     $articleInfo = $this->getArticleInfo();
     $tmpl = new EasyTemplate(dirname(__FILE__));
     $tmpl->set_vars(array('age' => wfTimeAgo($this->mResult->nfd_fe_timestamp), 'authorUrl' => $userLink, 'authorName' => $userName, 'views' => $articleInfo->page_counter, 'nfd' => $wgOut->parse($nfdLongReason), 'edits' => $edits, 'userEdits' => $uEdits, 'nfdVotes' => $this->getTotalVotes($this->mResult->nfd_id), 'discussion' => $discussion));
     $html = $tmpl->execute('NFDinfo.tmpl.php');
     return $html;
 }
コード例 #8
0
/**
 * 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>');
        }
    }
}