本文整理汇总了PHP中RecentChange::newFromRow方法的典型用法代码示例。如果您正苦于以下问题:PHP RecentChange::newFromRow方法的具体用法?PHP RecentChange::newFromRow怎么用?PHP RecentChange::newFromRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecentChange
的用法示例。
在下文中一共展示了RecentChange::newFromRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNewFromRow
/**
* @covers RecentChange::newFromRow
* @covers RecentChange::loadFromRow
*/
public function testNewFromRow()
{
$row = new stdClass();
$row->rc_foo = 'AAA';
$row->rc_timestamp = '20150921134808';
$row->rc_deleted = 'bar';
$rc = RecentChange::newFromRow($row);
$expected = array('rc_foo' => 'AAA', 'rc_timestamp' => '20150921134808', 'rc_deleted' => 'bar');
$this->assertEquals($expected, $rc->getAttributes());
}
示例2: doTest
function doTest()
{
// Quick syntax check.
$out = $this->getOutput();
$result = AbuseFilter::checkSyntax($this->mFilter);
if ($result !== true) {
$out->addWikiMsg('abusefilter-test-syntaxerr');
return;
}
$dbr = wfGetDB(DB_SLAVE);
$conds = array('rc_user_text' => $this->mTestUser, 'rc_type != ' . RC_EXTERNAL);
if ($this->mTestPeriodStart) {
$conds[] = 'rc_timestamp >= ' . $dbr->addQuotes($dbr->timestamp(strtotime($this->mTestPeriodStart)));
}
if ($this->mTestPeriodEnd) {
$conds[] = 'rc_timestamp <= ' . $dbr->addQuotes($dbr->timestamp(strtotime($this->mTestPeriodEnd)));
}
if ($this->mTestPage) {
$title = Title::newFromText($this->mTestPage);
if ($title instanceof Title) {
$conds['rc_namespace'] = $title->getNamespace();
$conds['rc_title'] = $title->getDBkey();
} else {
$out->addWikiMsg('abusefilter-test-badtitle');
return;
}
}
// Get our ChangesList
$changesList = new AbuseFilterChangesList($this->getSkin());
$output = $changesList->beginRecentChangesList();
$res = $dbr->select('recentchanges', '*', array_filter($conds), __METHOD__, array('LIMIT' => self::$mChangeLimit, 'ORDER BY' => 'rc_timestamp desc'));
$counter = 1;
foreach ($res as $row) {
$vars = AbuseFilter::getVarsFromRCRow($row);
if (!$vars) {
continue;
}
$result = AbuseFilter::checkConditions($this->mFilter, $vars);
if ($result || $this->mShowNegative) {
// Stash result in RC item
$rc = RecentChange::newFromRow($row);
$rc->examineParams['testfilter'] = $this->mFilter;
$rc->filterResult = $result;
$rc->counter = $counter++;
$output .= $changesList->recentChangesLine($rc, false);
}
}
$output .= $changesList->endRecentChangesList();
$out->addHTML($output);
}
示例3: buildQuickWatchlist
private function buildQuickWatchlist()
{
global $wgShowUpdatedMarker, $wgRCShowWatchingUsers;
$user = $this->getUser();
// Building the request
$dbr = wfGetDB(DB_SLAVE, 'watchlist');
$tables = array('recentchanges', 'watchlist');
$fields = array($dbr->tableName('recentchanges') . '.*');
if ($wgShowUpdatedMarker) {
$fields[] = 'wl_notificationtimestamp';
}
$conds = array();
$conds[] = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG;
$limitWatchlist = 0;
$usePage = true;
$join_conds = array('watchlist' => array('INNER JOIN', "wl_user='{$user->getId()}' AND wl_namespace=rc_namespace AND wl_title=rc_title"));
$options = array('LIMIT' => 5, 'ORDER BY' => 'rc_timestamp DESC');
$rollbacker = $user->isAllowed('rollback');
if ($usePage || $rollbacker) {
$tables[] = 'page';
$join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
if ($rollbacker) {
$fields[] = 'page_latest';
}
}
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, '');
$res = $dbr->select($tables, $fields, $conds, __METHOD__, $options, $join_conds);
$numRows = $dbr->numRows($res);
$s = '<div class="ms-info-wl">' . wfMessage('ms-watchlist')->parse() . '</div>';
if ($numRows == 0) {
$s .= '<p class="ms-wl-empty">' . wfMessage('watchnochange')->parse() . '</p>';
} else {
/* Do link batch query */
$linkBatch = new LinkBatch();
foreach ($res as $row) {
$userNameUnderscored = str_replace(' ', '_', $row->rc_user_text);
if ($row->rc_user != 0) {
$linkBatch->add(NS_USER, $userNameUnderscored);
}
$linkBatch->add(NS_USER_TALK, $userNameUnderscored);
$linkBatch->add($row->rc_namespace, $row->rc_title);
}
$linkBatch->execute();
$dbr->dataSeek($res, 0);
$list = ChangesList::newFromContext($this->getContext());
$list->setWatchlistDivs();
$s .= $list->beginRecentChangesList();
$counter = 1;
foreach ($res as $obj) {
# Make RC entry
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
// Updated markers are always shown
$updated = $obj->wl_notificationtimestamp;
// We don't display the count of watching users
$rc->numberofWatchingusers = 0;
$s .= $list->recentChangesLine($rc, $updated, $counter);
}
$s .= $list->endRecentChangesList();
}
return $s;
}
示例4: outputChangesList
/**
* Build and output the actual changes list.
*
* @param ResultWrapper $rows Database rows
* @param FormOptions $opts
*/
public function outputChangesList($rows, $opts)
{
$dbr = $this->getDB();
$user = $this->getUser();
$output = $this->getOutput();
# Show a message about slave lag, if applicable
$lag = wfGetLB()->safeGetLag($dbr);
if ($lag > 0) {
$output->showLagWarning($lag);
}
# If no rows to display, show message before try to render the list
if ($rows->numRows() == 0) {
$output->wrapWikiMsg("<div class='mw-changeslist-empty'>\n\$1\n</div>", 'recentchanges-noresult');
return;
}
$dbr->dataSeek($rows, 0);
$list = ChangesList::newFromContext($this->getContext());
$list->setWatchlistDivs();
$list->initChangesListRows($rows);
$dbr->dataSeek($rows, 0);
$s = $list->beginRecentChangesList();
$counter = 1;
foreach ($rows as $obj) {
# Make RC entry
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
if ($this->getConfig()->get('ShowUpdatedMarker')) {
$updated = $obj->wl_notificationtimestamp;
} else {
$updated = false;
}
if ($this->getConfig()->get('RCShowWatchingUsers') && $user->getOption('shownumberswatching')) {
$rc->numberofWatchingusers = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__);
} else {
$rc->numberofWatchingusers = 0;
}
$changeLine = $list->recentChangesLine($rc, $updated, $counter);
if ($changeLine !== false) {
$s .= $changeLine;
}
}
$s .= $list->endRecentChangesList();
$output->addHTML($s);
}
示例5: extractRowInfo
//.........这里部分代码省略.........
case RC_MOVE_OVER_REDIRECT:
$vals['type'] = 'move over redirect';
break;
default:
$vals['type'] = $type;
}
/* Create a new entry in the result for the title. */
if ($this->fld_title) {
ApiQueryBase::addTitleInfo($vals, $title);
if ($movedToTitle) {
ApiQueryBase::addTitleInfo($vals, $movedToTitle, 'new_');
}
}
/* Add ids, such as rcid, pageid, revid, and oldid to the change's info. */
if ($this->fld_ids) {
$vals['rcid'] = intval($row->rc_id);
$vals['pageid'] = intval($row->rc_cur_id);
$vals['revid'] = intval($row->rc_this_oldid);
$vals['old_revid'] = intval($row->rc_last_oldid);
}
/* Add user data and 'anon' flag, if use is anonymous. */
if ($this->fld_user || $this->fld_userid) {
if ($this->fld_user) {
$vals['user'] = $row->rc_user_text;
}
if ($this->fld_userid) {
$vals['userid'] = $row->rc_user;
}
if (!$row->rc_user) {
$vals['anon'] = '';
}
}
/* Add flags, such as new, minor, bot. */
if ($this->fld_flags) {
if ($row->rc_bot) {
$vals['bot'] = '';
}
if ($row->rc_new) {
$vals['new'] = '';
}
if ($row->rc_minor) {
$vals['minor'] = '';
}
}
/* Add sizes of each revision. (Only available on 1.10+) */
if ($this->fld_sizes) {
$vals['oldlen'] = intval($row->rc_old_len);
$vals['newlen'] = intval($row->rc_new_len);
}
/* Add the timestamp. */
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
}
/* Add edit summary / log summary. */
if ($this->fld_comment && isset($row->rc_comment)) {
$vals['comment'] = $row->rc_comment;
}
if ($this->fld_parsedcomment && isset($row->rc_comment)) {
$vals['parsedcomment'] = Linker::formatComment($row->rc_comment, $title);
}
if ($this->fld_redirect) {
if ($row->page_is_redirect) {
$vals['redirect'] = '';
}
}
/* Add the patrolled flag */
if ($this->fld_patrolled && $row->rc_patrolled == 1) {
$vals['patrolled'] = '';
}
if ($this->fld_loginfo && $row->rc_type == RC_LOG) {
$vals['logid'] = intval($row->rc_logid);
$vals['logtype'] = $row->rc_log_type;
$vals['logaction'] = $row->rc_log_action;
ApiQueryLogEvents::addLogParams($this->getResult(), $vals, $row->rc_params, $row->rc_log_action, $row->rc_log_type, $row->rc_timestamp);
}
if ($this->fld_tags) {
if ($row->ts_tags) {
$tags = explode(',', $row->ts_tags);
$this->getResult()->setIndexedTagName($tags, 'tag');
$vals['tags'] = $tags;
} else {
$vals['tags'] = array();
}
}
if (!is_null($this->token)) {
$tokenFunctions = $this->getTokenFunctions();
foreach ($this->token as $t) {
$val = call_user_func($tokenFunctions[$t], $row->rc_cur_id, $title, RecentChange::newFromRow($row));
if ($val === false) {
$this->setWarning("Action '{$t}' is not allowed for the current user");
} else {
$vals[$t . 'token'] = $val;
}
}
}
if ($this->fld_wikiamode) {
$vals['rc_params'] = $row->rc_params;
}
return $vals;
}
示例6: webOutput
/**
* Send output to the OutputPage object, only called if not used feeds
*
* @param array $rows Database rows
* @param FormOptions $opts
*/
public function webOutput($rows, $opts)
{
global $wgRCShowWatchingUsers, $wgShowUpdatedMarker, $wgAllowCategorizedRecentChanges;
$limit = $opts['limit'];
if (!$this->including()) {
// Output options box
$this->doHeader($opts);
}
// And now for the content
$feedQuery = $this->getFeedQuery();
if ($feedQuery !== '') {
$this->getOutput()->setFeedAppendQuery($feedQuery);
} else {
$this->getOutput()->setFeedAppendQuery(false);
}
if ($wgAllowCategorizedRecentChanges) {
$this->filterByCategories($rows, $opts);
}
$showNumsWachting = $this->getUser()->getOption('shownumberswatching');
$showWatcherCount = $wgRCShowWatchingUsers && $showNumsWachting;
$watcherCache = array();
$dbr = wfGetDB(DB_SLAVE);
$counter = 1;
$list = ChangesList::newFromContext($this->getContext());
$s = $list->beginRecentChangesList();
foreach ($rows as $obj) {
if ($limit == 0) {
break;
}
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
# Check if the page has been updated since the last visit
if ($wgShowUpdatedMarker && !empty($obj->wl_notificationtimestamp)) {
$rc->notificationtimestamp = $obj->rc_timestamp >= $obj->wl_notificationtimestamp;
} else {
$rc->notificationtimestamp = false;
// Default
}
# Check the number of users watching the page
$rc->numberofWatchingusers = 0;
// Default
if ($showWatcherCount && $obj->rc_namespace >= 0) {
if (!isset($watcherCache[$obj->rc_namespace][$obj->rc_title])) {
$watcherCache[$obj->rc_namespace][$obj->rc_title] = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__ . '-watchers');
}
$rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
}
$changeLine = $list->recentChangesLine($rc, !empty($obj->wl_user), $counter);
if ($changeLine !== false) {
$s .= $changeLine;
--$limit;
}
}
$s .= $list->endRecentChangesList();
$this->getOutput()->addHTML($s);
}
示例7: execute
//.........这里部分代码省略.........
# Namespace filter and put the whole form together.
$form .= $wlInfo;
$form .= $cutofflinks;
$form .= $lang->pipeList( $links ) . "\n";
$form .= "<hr />\n<p>";
$form .= Html::namespaceSelector(
array(
'selected' => $nameSpace,
'all' => '',
'label' => $this->msg( 'namespace' )->text()
), array(
'name' => 'namespace',
'id' => 'namespace',
'class' => 'namespaceselector',
)
) . ' ';
$form .= Xml::checkLabel(
$this->msg( 'invert' )->text(),
'invert',
'nsinvert',
$invert,
array( 'title' => $this->msg( 'tooltip-invert' )->text() )
) . ' ';
$form .= Xml::checkLabel(
$this->msg( 'namespace_association' )->text(),
'associated',
'associated',
$associated,
array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
) . ' ';
$form .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "</p>\n";
foreach ( $hiddenFields as $key => $value ) {
$form .= Html::hidden( $key, $value ) . "\n";
}
$form .= Xml::closeElement( 'fieldset' ) . "\n";
$form .= Xml::closeElement( 'form' ) . "\n";
$output->addHTML( $form );
# If there's nothing to show, stop here
if ( $numRows == 0 ) {
$output->wrapWikiMsg(
"<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
);
return;
}
/* End bottom header */
/* Do link batch query */
$linkBatch = new LinkBatch;
foreach ( $res as $row ) {
$userNameUnderscored = str_replace( ' ', '_', $row->rc_user_text );
if ( $row->rc_user != 0 ) {
$linkBatch->add( NS_USER, $userNameUnderscored );
}
$linkBatch->add( NS_USER_TALK, $userNameUnderscored );
$linkBatch->add( $row->rc_namespace, $row->rc_title );
}
$linkBatch->execute();
$dbr->dataSeek( $res, 0 );
$list = ChangesList::newFromContext( $this->getContext() );
$list->setWatchlistDivs();
$s = $list->beginRecentChangesList();
$counter = 1;
foreach ( $res as $obj ) {
# Make RC entry
$rc = RecentChange::newFromRow( $obj );
$rc->counter = $counter++;
if ( $wgShowUpdatedMarker ) {
$updated = $obj->wl_notificationtimestamp;
} else {
$updated = false;
}
if ( $wgRCShowWatchingUsers && $user->getOption( 'shownumberswatching' ) ) {
$rc->numberofWatchingusers = $dbr->selectField( 'watchlist',
'COUNT(*)',
array(
'wl_namespace' => $obj->rc_namespace,
'wl_title' => $obj->rc_title,
),
__METHOD__ );
} else {
$rc->numberofWatchingusers = 0;
}
$changeLine = $list->recentChangesLine( $rc, $updated, $counter );
if ( $changeLine !== false ) {
$s .= $changeLine;
}
}
$s .= $list->endRecentChangesList();
$output->addHTML( $s );
}
示例8: wfSpecialWatchlist
//.........这里部分代码省略.........
# Spit out some control panel links
$thisTitle = SpecialPage::getTitleFor('Watchlist');
$skin = $wgUser->getSkin();
$showLinktext = wfMsgHtml('show');
$hideLinktext = wfMsgHtml('hide');
# Hide/show minor edits
$label = $hideMinor ? $showLinktext : $hideLinktext;
$linkBits = wfArrayToCGI(array('hideMinor' => 1 - (int) $hideMinor), $nondefaults);
$links[] = wfMsgHtml('rcshowhideminor', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
# Hide/show bot edits
$label = $hideBots ? $showLinktext : $hideLinktext;
$linkBits = wfArrayToCGI(array('hideBots' => 1 - (int) $hideBots), $nondefaults);
$links[] = wfMsgHtml('rcshowhidebots', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
# Hide/show anonymous edits
$label = $hideAnons ? $showLinktext : $hideLinktext;
$linkBits = wfArrayToCGI(array('hideAnons' => 1 - (int) $hideAnons), $nondefaults);
$links[] = wfMsgHtml('rcshowhideanons', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
# Hide/show logged in edits
$label = $hideLiu ? $showLinktext : $hideLinktext;
$linkBits = wfArrayToCGI(array('hideLiu' => 1 - (int) $hideLiu), $nondefaults);
$links[] = wfMsgHtml('rcshowhideliu', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
# Hide/show own edits
$label = $hideOwn ? $showLinktext : $hideLinktext;
$linkBits = wfArrayToCGI(array('hideOwn' => 1 - (int) $hideOwn), $nondefaults);
$links[] = wfMsgHtml('rcshowhidemine', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
# Hide/show patrolled edits
if ($wgUser->useRCPatrol()) {
$label = $hidePatrolled ? $showLinktext : $hideLinktext;
$linkBits = wfArrayToCGI(array('hidePatrolled' => 1 - (int) $hidePatrolled), $nondefaults);
$links[] = wfMsgHtml('rcshowhidepatr', $skin->makeKnownLinkObj($thisTitle, $label, $linkBits));
}
# Namespace filter and put the whole form together.
$form .= $wlInfo;
$form .= $cutofflinks;
$form .= implode(' | ', $links);
$form .= Xml::openElement('form', array('method' => 'post', 'action' => $thisTitle->getLocalUrl()));
$form .= '<hr /><p>';
$form .= Xml::label(wfMsg('namespace'), 'namespace') . ' ';
$form .= Xml::namespaceSelector($nameSpace, '') . ' ';
$form .= Xml::checkLabel(wfMsg('invert'), 'invert', 'nsinvert', $invert) . ' ';
$form .= Xml::submitButton(wfMsg('allpagessubmit')) . '</p>';
$form .= Xml::hidden('days', $days);
if ($hideMinor) {
$form .= Xml::hidden('hideMinor', 1);
}
if ($hideBots) {
$form .= Xml::hidden('hideBots', 1);
}
if ($hideAnons) {
$form .= Xml::hidden('hideAnons', 1);
}
if ($hideLiu) {
$form .= Xml::hidden('hideLiu', 1);
}
if ($hideOwn) {
$form .= Xml::hidden('hideOwn', 1);
}
$form .= Xml::closeElement('form');
$form .= Xml::closeElement('fieldset');
$wgOut->addHTML($form);
# If there's nothing to show, stop here
if ($numRows == 0) {
$wgOut->addWikiMsg('watchnochange');
return;
}
/* End bottom header */
/* Do link batch query */
$linkBatch = new LinkBatch();
while ($row = $dbr->fetchObject($res)) {
$userNameUnderscored = str_replace(' ', '_', $row->rc_user_text);
if ($row->rc_user != 0) {
$linkBatch->add(NS_USER, $userNameUnderscored);
}
$linkBatch->add(NS_USER_TALK, $userNameUnderscored);
}
$linkBatch->execute();
$dbr->dataSeek($res, 0);
$list = ChangesList::newFromUser($wgUser);
$s = $list->beginRecentChangesList();
$counter = 1;
while ($obj = $dbr->fetchObject($res)) {
# Make RC entry
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
if ($wgShowUpdatedMarker) {
$updated = $obj->wl_notificationtimestamp;
} else {
$updated = false;
}
if ($wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
$rc->numberofWatchingusers = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__);
} else {
$rc->numberofWatchingusers = 0;
}
$s .= $list->recentChangesLine($rc, $updated);
}
$s .= $list->endRecentChangesList();
$dbr->freeResult($res);
$wgOut->addHTML($s);
}
示例9: wfSpecialWatchlist
//.........这里部分代码省略.........
$limitWatchlist = '';
}
$header .= wfMsgExt('watchlist-details', array('parsemag'), $wgLang->formatNum($nitems));
$wgOut->addWikiText($header);
# Show a message about slave lag, if applicable
if (($lag = $dbr->getLag()) > 0) {
$wgOut->showLagWarning($lag);
}
if ($wgEnotifWatchlist && $wgShowUpdatedMarker) {
$wgOut->addHTML('<form action="' . $specialTitle->escapeLocalUrl() . '" method="post"><input type="submit" name="dummy" value="' . htmlspecialchars(wfMsg('enotif_reset')) . '" /><input type="hidden" name="reset" value="all" /></form>' . "\n\n");
}
$sql = "SELECT *\r\n\t FROM {$watchlist},{$recentchanges},{$page}\r\n\t WHERE wl_user={$uid}\r\n\t AND wl_namespace=rc_namespace\r\n\t AND wl_title=rc_title\r\n\t AND rc_cur_id=page_id\r\n\t {$andcutoff}\r\n\t {$andLatest}\r\n\t {$andHideOwn}\r\n\t {$andHideBots}\r\n\t {$andHideMinor}\r\n\t {$nameSpaceClause}\r\n\t ORDER BY rc_timestamp DESC\r\n\t {$limitWatchlist}";
$res = $dbr->query($sql, $fname);
$numRows = $dbr->numRows($res);
/* Start bottom header */
$wgOut->addHTML("<hr />\n");
if ($days >= 1) {
$wgOut->addWikiText(wfMsgExt('rcnote', array('parseinline'), $wgLang->formatNum($numRows), $wgLang->formatNum($days), $wgLang->timeAndDate(wfTimestampNow(), true)) . '<br />', false);
} elseif ($days > 0) {
$wgOut->addWikiText(wfMsgExt('wlnote', array('parseinline'), $wgLang->formatNum($numRows), $wgLang->formatNum(round($days * 24))) . '<br />', false);
}
$wgOut->addHTML("\n" . wlCutoffLinks($days, 'Watchlist', $nondefaults) . "<br />\n");
# Spit out some control panel links
$thisTitle = SpecialPage::getTitleFor('Watchlist');
$skin = $wgUser->getSkin();
# Hide/show bot edits
$label = $hideBots ? wfMsgHtml('watchlist-show-bots') : wfMsgHtml('watchlist-hide-bots');
$linkBits = wfArrayToCGI(array('hideBots' => 1 - (int) $hideBots), $nondefaults);
$links[] = $skin->makeKnownLinkObj($thisTitle, $label, $linkBits);
# Hide/show own edits
$label = $hideOwn ? wfMsgHtml('watchlist-show-own') : wfMsgHtml('watchlist-hide-own');
$linkBits = wfArrayToCGI(array('hideOwn' => 1 - (int) $hideOwn), $nondefaults);
$links[] = $skin->makeKnownLinkObj($thisTitle, $label, $linkBits);
# Hide/show minor edits
$label = $hideMinor ? wfMsgHtml('watchlist-show-minor') : wfMsgHtml('watchlist-hide-minor');
$linkBits = wfArrayToCGI(array('hideMinor' => 1 - (int) $hideMinor), $nondefaults);
$links[] = $skin->makeKnownLinkObj($thisTitle, $label, $linkBits);
$wgOut->addHTML(implode(' | ', $links));
# Form for namespace filtering
$form = Xml::openElement('form', array('method' => 'post', 'action' => $thisTitle->getLocalUrl()));
$form .= '<p>';
$form .= Xml::label(wfMsg('namespace'), 'namespace') . ' ';
$form .= Xml::namespaceSelector($nameSpace, '') . ' ';
$form .= Xml::submitButton(wfMsg('allpagessubmit')) . '</p>';
$form .= Xml::hidden('days', $days);
if ($hideOwn) {
$form .= Xml::hidden('hideOwn', 1);
}
if ($hideBots) {
$form .= Xml::hidden('hideBots', 1);
}
if ($hideMinor) {
$form .= Xml::hidden('hideMinor', 1);
}
$form .= Xml::closeElement('form');
$wgOut->addHtml($form);
# If there's nothing to show, stop here
if ($numRows == 0) {
$wgOut->addWikiText(wfMsgNoTrans('watchnochange'));
return;
}
/* End bottom header */
/* Do link batch query */
$linkBatch = new LinkBatch();
while ($row = $dbr->fetchObject($res)) {
$userNameUnderscored = str_replace(' ', '_', $row->rc_user_text);
if ($row->rc_user != 0) {
$linkBatch->add(NS_USER, $userNameUnderscored);
}
$linkBatch->add(NS_USER_TALK, $userNameUnderscored);
}
$linkBatch->execute();
$dbr->dataSeek($res, 0);
$list = ChangesList::newFromUser($wgUser);
$s = $list->beginRecentChangesList();
$counter = 1;
while ($obj = $dbr->fetchObject($res)) {
# Make RC entry
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
if ($wgShowUpdatedMarker) {
$updated = $obj->wl_notificationtimestamp;
} else {
// Same visual appearance as MW 1.4
$updated = true;
}
if ($wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
$sql3 = "SELECT COUNT(*) AS n FROM {$watchlist} WHERE wl_title='" . $dbr->strencode($obj->page_title) . "' AND wl_namespace='{$obj->page_namespace}'";
$res3 = $dbr->query($sql3, $fname);
$x = $dbr->fetchObject($res3);
$rc->numberofWatchingusers = $x->n;
} else {
$rc->numberofWatchingusers = 0;
}
$s .= $list->recentChangesLine($rc, $updated);
}
$s .= $list->endRecentChangesList();
$dbr->freeResult($res);
$wgOut->addHTML($s);
}
示例10: execute
//.........这里部分代码省略.........
$options = array('ORDER BY' => 'rc_timestamp DESC');
if ($wgShowUpdatedMarker) {
$fields[] = 'wl_notificationtimestamp';
}
if ($limitWatchlist) {
$options['LIMIT'] = $limitWatchlist;
}
$rollbacker = $user->isAllowed('rollback');
if ($usePage || $rollbacker) {
$tables[] = 'page';
$join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
if ($rollbacker) {
$fields[] = 'page_latest';
}
}
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, '');
wfRunHooks('SpecialWatchlistQuery', array(&$conds, &$tables, &$join_conds, &$fields));
$res = $dbr->select($tables, $fields, $conds, __METHOD__, $options, $join_conds);
$numRows = $res->numRows();
/* Start bottom header */
$lang = $this->getLanguage();
$wlInfo = '';
if ($values['days'] > 0) {
$timestamp = wfTimestampNow();
$wlInfo = $this->msg('wlnote')->numParams($numRows, round($values['days'] * 24))->params($lang->userDate($timestamp, $user), $lang->userTime($timestamp, $user))->parse() . '<br />';
}
$cutofflinks = "\n" . $this->cutoffLinks($values['days'], $nondefaults) . "<br />\n";
# Spit out some control panel links
$filters = array('hideMinor' => 'rcshowhideminor', 'hideBots' => 'rcshowhidebots', 'hideAnons' => 'rcshowhideanons', 'hideLiu' => 'rcshowhideliu', 'hideOwn' => 'rcshowhidemine', 'hidePatrolled' => 'rcshowhidepatr');
foreach ($this->customFilters as $key => $params) {
$filters[$key] = $params['msg'];
}
// Disable some if needed
if (!$user->useNPPatrol()) {
unset($filters['hidePatrolled']);
}
$links = array();
foreach ($filters as $name => $msg) {
$links[] = $this->showHideLink($nondefaults, $msg, $name, $values[$name]);
}
# Namespace filter and put the whole form together.
$form .= $wlInfo;
$form .= $cutofflinks;
$form .= $lang->pipeList($links);
$form .= Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'mw-watchlist-form-namespaceselector'));
$form .= '<hr /><p>';
$form .= Html::namespaceSelector(array('selected' => $nameSpace, 'all' => '', 'label' => $this->msg('namespace')->text()), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector')) . ' ';
$form .= Xml::checkLabel($this->msg('invert')->text(), 'invert', 'nsinvert', $invert, array('title' => $this->msg('tooltip-invert')->text())) . ' ';
$form .= Xml::checkLabel($this->msg('namespace_association')->text(), 'associated', 'associated', $associated, array('title' => $this->msg('tooltip-namespace_association')->text())) . ' ';
$form .= Xml::submitButton($this->msg('allpagessubmit')->text()) . '</p>';
$form .= Html::hidden('days', $values['days']);
foreach ($filters as $key => $msg) {
if ($values[$key]) {
$form .= Html::hidden($key, 1);
}
}
$form .= Xml::closeElement('form');
$form .= Xml::closeElement('fieldset');
$output->addHTML($form);
# If there's nothing to show, stop here
if ($numRows == 0) {
$output->addWikiMsg('watchnochange');
return;
}
/* End bottom header */
/* Do link batch query */
$linkBatch = new LinkBatch();
foreach ($res as $row) {
$userNameUnderscored = str_replace(' ', '_', $row->rc_user_text);
if ($row->rc_user != 0) {
$linkBatch->add(NS_USER, $userNameUnderscored);
}
$linkBatch->add(NS_USER_TALK, $userNameUnderscored);
$linkBatch->add($row->rc_namespace, $row->rc_title);
}
$linkBatch->execute();
$dbr->dataSeek($res, 0);
$list = ChangesList::newFromContext($this->getContext());
$list->setWatchlistDivs();
$s = $list->beginRecentChangesList();
$counter = 1;
foreach ($res as $obj) {
# Make RC entry
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
if ($wgShowUpdatedMarker) {
$updated = $obj->wl_notificationtimestamp;
} else {
$updated = false;
}
if ($wgRCShowWatchingUsers && $user->getOption('shownumberswatching')) {
$rc->numberofWatchingusers = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__);
} else {
$rc->numberofWatchingusers = 0;
}
$s .= $list->recentChangesLine($rc, $updated, $counter);
}
$s .= $list->endRecentChangesList();
$output->addHTML($s);
}
示例11: buildRssWatch
//.........这里部分代码省略.........
$hookSql = "";
if (!wfRunHooks('BeforeWatchlist', array($nondefaults, $user, &$hookSql))) {
return;
}
/*if ( $nitems == 0 ) {
$wgOut->addWikiMsg( 'nowatchlist' );
return;
}*/
if ($days <= 0) {
$andcutoff = '';
} else {
$andcutoff = "AND rc_timestamp > '" . $dbr->timestamp(time() - intval($days * 86400)) . "'";
}
# If the watchlist is relatively short, it's simplest to zip
# down its entirety and then sort the results.
# If it's relatively long, it may be worth our while to zip
# through the time-sorted page list checking for watched items.
# Up estimate of watched items by 15% to compensate for talk pages...
# Toggles
$andHideOwn = $hideOwn ? "AND (rc_user <> {$uid})" : '';
$andHideBots = $hideBots ? "AND (rc_bot = 0)" : '';
$andHideMinor = $hideMinor ? 'AND rc_minor = 0' : '';
# Toggle watchlist content (all recent edits or just the latest)
if ($user->getOption('extendwatchlist')) {
$andLatest = '';
$limitWatchlist = 'LIMIT ' . intval($user->getOption('wllimit'));
} else {
# Top log Ids for a page are not stored
$andLatest = 'AND (rc_this_oldid=page_latest OR rc_type=' . RC_LOG . ') ';
$limitWatchlist = '';
}
if ($wgShowUpdatedMarker) {
$wltsfield = ", {$watchlist}.wl_notificationtimestamp ";
} else {
$wltsfield = '';
}
$sql = "SELECT {$recentchanges}.* {$wltsfield}\n\t FROM {$watchlist},{$recentchanges}\n\t LEFT JOIN {$page} ON rc_cur_id=page_id\n\t WHERE wl_user={$uid}\n\t AND wl_namespace=rc_namespace\n\t AND wl_title=rc_title\n\t\t\t{$andcutoff}\n\t\t\t{$andLatest}\n\t\t\t{$andHideOwn}\n\t\t\t{$andHideBots}\n\t\t\t{$andHideMinor}\n\t\t\t{$nameSpaceClause}\n\t\t\t{$hookSql}\n\t ORDER BY rc_timestamp DESC\n\t\t\t{$limitWatchlist}";
$res = $dbr->query($sql, __METHOD__);
$numRows = $dbr->numRows($res);
/*# If there's nothing to show, stop here
if( $numRows == 0 ) {
$wgOut->addWikiMsg( 'watchnochange' );
return;
}*/
/* End bottom header */
if ($numRows > 0) {
/* Do link batch query */
$linkBatch = new LinkBatch();
while ($row = $dbr->fetchObject($res)) {
$userNameUnderscored = str_replace(' ', '_', $row->rc_user_text);
if ($row->rc_user != 0) {
$linkBatch->add(NS_USER, $userNameUnderscored);
}
$linkBatch->add(NS_USER_TALK, $userNameUnderscored);
}
$linkBatch->execute();
$dbr->dataSeek($res, 0);
}
$list = ChangesList::newFromContext($skin->getContext());
//Thanks to Bartosz Dziewoński (https://gerrit.wikimedia.org/r/#/c/94082/)
$channel = RSSCreator::createChannel(SpecialPage::getTitleFor('Watchlist') . ' (' . $user->getName() . ')', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'], wfMessage('bs-rssstandards-desc-watch')->plain());
$html = $list->beginRecentChangesList();
$counter = 1;
$items = array();
while ($obj = $dbr->fetchObject($res)) {
$title = Title::newFromText($obj->rc_title, $obj->rc_namespace);
$items[] = array('title' => $title->getPrefixedText(), 'link' => $title->getFullURL(), 'date' => wfTimestamp(TS_UNIX, $obj->rc_timestamp), 'comments' => $title->getTalkPage()->getFullURL());
# Make RC entry
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
if ($wgShowUpdatedMarker) {
$updated = $obj->wl_notificationtimestamp;
} else {
$updated = false;
}
if ($wgRCShowWatchingUsers && $user->getOption('shownumberswatching')) {
$rc->numberofWatchingusers = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__);
} else {
$rc->numberofWatchingusers = 0;
}
$rc->mAttribs['rc_timestamp'] = 0;
$html .= $list->recentChangesLine($rc, false);
}
$html .= $list->endRecentChangesList();
$lines = array();
preg_match_all('%<li.*?>(.*?)</li>%', $html, $lines, PREG_SET_ORDER);
foreach ($lines as $key => $line) {
$item = $items[$key];
$entry = RSSItemCreator::createItem($item['title'], $item['link'], RSSCreator::xmlEncode($line[1]));
if ($entry == false) {
wfDebugLog('BS::RSSStandards::buildRssWatch', 'Invalid item: ' . var_export($item, true));
continue;
}
$entry->setPubDate($item['date']);
$entry->setComments($item['comments']);
$channel->addItem($entry);
}
$dbr->freeResult($res);
return $channel->buildOutput();
}
示例12: extractRowInfo
//.........这里部分代码省略.........
}
}
/* Add flags, such as new, minor, bot. */
if ( $this->fld_flags ) {
if ( $row->rc_bot ) {
$vals['bot'] = '';
}
if ( $row->rc_type == RC_NEW ) {
$vals['new'] = '';
}
if ( $row->rc_minor ) {
$vals['minor'] = '';
}
}
/* Add sizes of each revision. (Only available on 1.10+) */
if ( $this->fld_sizes ) {
$vals['oldlen'] = intval( $row->rc_old_len );
$vals['newlen'] = intval( $row->rc_new_len );
}
/* Add the timestamp. */
if ( $this->fld_timestamp ) {
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->rc_timestamp );
}
/* Add edit summary / log summary. */
if ( $this->fld_comment && isset( $row->rc_comment ) ) {
$vals['comment'] = $row->rc_comment;
}
if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
$vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title );
}
if ( $this->fld_redirect ) {
if ( $row->page_is_redirect ) {
$vals['redirect'] = '';
}
}
/* Add the patrolled flag */
if ( $this->fld_patrolled && $row->rc_patrolled == 1 ) {
$vals['patrolled'] = '';
}
if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
$vals['logid'] = intval( $row->rc_logid );
$vals['logtype'] = $row->rc_log_type;
$vals['logaction'] = $row->rc_log_action;
$logEntry = DatabaseLogEntry::newFromRow( (array)$row );
ApiQueryLogEvents::addLogParams(
$this->getResult(),
$vals,
$logEntry->getParameters(),
$logEntry->getType(),
$logEntry->getSubtype(),
$logEntry->getTimestamp()
);
}
if ( $this->fld_tags ) {
if ( $row->ts_tags ) {
$tags = explode( ',', $row->ts_tags );
$this->getResult()->setIndexedTagName( $tags, 'tag' );
$vals['tags'] = $tags;
} else {
$vals['tags'] = array();
}
}
if ( $this->fld_sha1 && $row->rev_sha1 !== null ) {
// The RevDel check should currently never pass due to the
// rc_deleted = 0 condition in the WHERE clause, but in case that
// ever changes we check it here too.
if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
$vals['sha1hidden'] = '';
} elseif ( $row->rev_sha1 !== '' ) {
$vals['sha1'] = wfBaseConvert( $row->rev_sha1, 36, 16, 40 );
} else {
$vals['sha1'] = '';
}
}
if ( !is_null( $this->token ) ) {
$tokenFunctions = $this->getTokenFunctions();
foreach ( $this->token as $t ) {
$val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id,
$title, RecentChange::newFromRow( $row ) );
if ( $val === false ) {
$this->setWarning( "Action '$t' is not allowed for the current user" );
} else {
$vals[$t . 'token'] = $val;
}
}
}
return $vals;
}
示例13: wfSpecialRecentchangeslinked
/**
* Entrypoint
* @param string $par parent page we will look at
*/
function wfSpecialRecentchangeslinked($par = NULL)
{
global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest;
$fname = 'wfSpecialRecentchangeslinked';
$days = $wgRequest->getInt('days');
$target = isset($par) ? $par : $wgRequest->getText('target');
$hideminor = $wgRequest->getBool('hideminor') ? 1 : 0;
$wgOut->setPagetitle(wfMsg('recentchangeslinked'));
$sk = $wgUser->getSkin();
# Validate the title
$nt = Title::newFromURL($target);
if (!is_object($nt)) {
$wgOut->errorPage('notargettitle', 'notargettext');
return;
}
# Check for existence
# Do a quiet redirect back to the page itself if it doesn't
if (!$nt->exists()) {
$wgOut->redirect($nt->getLocalUrl());
return;
}
$id = $nt->getArticleId();
$wgOut->setSubtitle(htmlspecialchars(wfMsg('rclsub', $nt->getPrefixedText())));
if (!$days) {
$days = $wgUser->getOption('rcdays');
if (!$days) {
$days = 7;
}
}
$days = (int) $days;
list($limit, $offset) = wfCheckLimits(100, 'rclimit');
$dbr =& wfGetDB(DB_SLAVE);
$cutoff = $dbr->timestamp(time() - $days * 86400);
$hideminor = $hideminor ? 1 : 0;
if ($hideminor) {
$mlink = $sk->makeKnownLink($wgContLang->specialPage('Recentchangeslinked'), wfMsg('show'), 'target=' . htmlspecialchars($nt->getPrefixedURL()) . "&days={$days}&limit={$limit}&hideminor=0");
} else {
$mlink = $sk->makeKnownLink($wgContLang->specialPage("Recentchangeslinked"), wfMsg("hide"), "target=" . htmlspecialchars($nt->getPrefixedURL()) . "&days={$days}&limit={$limit}&hideminor=1");
}
if ($hideminor) {
$cmq = 'AND rc_minor=0';
} else {
$cmq = '';
}
extract($dbr->tableNames('recentchanges', 'categorylinks', 'pagelinks', 'revision', 'page', "watchlist"));
$uid = $wgUser->getID();
// If target is a Category, use categorylinks and invert from and to
if ($nt->getNamespace() == NS_CATEGORY) {
$catkey = $dbr->addQuotes($nt->getDBKey());
$sql = "SELECT /* wfSpecialRecentchangeslinked */\n\t\t\t\trc_id,\n\t\t\t\trc_cur_id,\n\t\t\t\trc_namespace,\n\t\t\t\trc_title,\n\t\t\t\trc_this_oldid,\n\t\t\t\trc_last_oldid,\n\t\t\t\trc_user,\n\t\t\t\trc_comment,\n\t\t\t\trc_user_text,\n\t\t\t\trc_timestamp,\n\t\t\t\trc_minor,\n\t\t\t\trc_bot,\n\t\t\t\trc_new,\n\t\t\t\trc_patrolled,\n\t\t\t\trc_type\n" . ($uid ? ",wl_user" : "") . "\n\t FROM {$categorylinks}, {$recentchanges}\n" . ($uid ? "LEFT OUTER JOIN {$watchlist} ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "\n\t WHERE rc_timestamp > '{$cutoff}'\n\t {$cmq}\n\t AND cl_from=rc_cur_id\n\t AND cl_to={$catkey}\n\tGROUP BY rc_cur_id,rc_namespace,rc_title,\n\t \trc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,\n\t \trc_new\n\t\tORDER BY rc_timestamp DESC\n\tLIMIT {$limit};\n ";
} else {
$sql = "SELECT /* wfSpecialRecentchangeslinked */\n\t\t\trc_id,\n\t\t\trc_cur_id,\n\t\t\trc_namespace,\n\t\t\trc_title,\n\t\t\trc_user,\n\t\t\trc_comment,\n\t\t\trc_user_text,\n\t\t\trc_this_oldid,\n\t\t\trc_last_oldid,\n\t\t\trc_timestamp,\n\t\t\trc_minor,\n\t\t\trc_bot,\n\t\t\trc_new,\n\t\t\trc_patrolled,\n\t\t\trc_type\n" . ($uid ? ",wl_user" : "") . "\n FROM {$pagelinks}, {$recentchanges}\n" . ($uid ? " LEFT OUTER JOIN {$watchlist} ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "\n WHERE rc_timestamp > '{$cutoff}'\n\t{$cmq}\n AND pl_namespace=rc_namespace\n AND pl_title=rc_title\n AND pl_from={$id}\nGROUP BY rc_cur_id,rc_namespace,rc_title,\n\t rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,\n\t rc_new\nORDER BY rc_timestamp DESC\n LIMIT {$limit}";
}
$res = $dbr->query($sql, $fname);
$wgOut->addHTML("< " . $sk->makeKnownLinkObj($nt, "", "redirect=no") . "<br />\n");
$note = wfMsg("rcnote", $limit, $days, $wgLang->timeAndDate(wfTimestampNow(), true));
$wgOut->addHTML("<hr />\n{$note}\n<br />");
$note = rcDayLimitlinks($days, $limit, "Recentchangeslinked", "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}", false, $mlink);
$wgOut->addHTML($note . "\n");
$list = ChangesList::newFromUser($wgUser);
$s = $list->beginRecentChangesList();
$count = $dbr->numRows($res);
$counter = 1;
while ($limit) {
if (0 == $count) {
break;
}
$obj = $dbr->fetchObject($res);
--$count;
# print_r ( $obj ) ;
# print "<br/>\n" ;
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
$s .= $list->recentChangesLine($rc, !empty($obj->wl_user));
--$limit;
}
$s .= $list->endRecentChangesList();
$dbr->freeResult($res);
$wgOut->addHTML($s);
}
示例14: getRevisionFromLog
private function getRevisionFromLog()
{
wfProfileIn(__METHOD__);
$this->addTables('logging');
$this->addFields('recentchanges.*');
$this->addTables('recentchanges');
$this->addWhere('log_id = rc_logid');
$this->addWhere('log_title = rc_title');
$this->addWhere('log_namespace = rc_namespace');
$this->addWhereFld('log_id', $this->mLogid);
$res = $this->select(__METHOD__);
$count = 0;
$oRC = false;
$db = $this->getDB();
if ($row = $db->fetchObject($res)) {
$oRC = RecentChange::newFromRow($row);
}
$db->freeResult($res);
$res = is_object($oRC) ? $this->getArchivePage($oRC) : false;
if (empty($res) && is_object($oRC)) {
$res = $this->getRecentchangePage($oRC);
}
if (empty($res) && !is_object($oRC)) {
$res = $this->getLoggingArchivePage();
}
wfProfileOut(__METHOD__);
return $res;
}
示例15: newFromRow
public function newFromRow($obj)
{
$rc = \RecentChange::newFromRow($obj);
$rc->setExtra(array('pageStatus' => 'update'));
return $rc;
}