本文整理汇总了PHP中ChangesList::newFromContext方法的典型用法代码示例。如果您正苦于以下问题:PHP ChangesList::newFromContext方法的具体用法?PHP ChangesList::newFromContext怎么用?PHP ChangesList::newFromContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChangesList
的用法示例。
在下文中一共展示了ChangesList::newFromContext方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: outputChangesList
/**
* Build and output the actual changes list.
*
* @param array $rows Database rows
* @param FormOptions $opts
*/
public function outputChangesList($rows, $opts)
{
$limit = $opts['limit'];
$showWatcherCount = $this->getConfig()->get('RCShowWatchingUsers') && $this->getUser()->getOption('shownumberswatching');
$watcherCache = array();
$dbr = $this->getDB();
$counter = 1;
$list = ChangesList::newFromContext($this->getContext());
$list->initChangesListRows($rows);
$rclistOutput = $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 ($this->getConfig()->get('ShowUpdatedMarker') && !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) {
$rclistOutput .= $changeLine;
--$limit;
}
}
$rclistOutput .= $list->endRecentChangesList();
if ($rows->numRows() === 0) {
$this->getOutput()->addHtml('<div class="mw-changeslist-empty">' . $this->msg('recentchanges-noresult')->parse() . '</div>');
if (!$this->including()) {
$this->getOutput()->setStatusCode(404);
}
} else {
$this->getOutput()->addHTML($rclistOutput);
}
}
示例4: 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 );
}
示例5: outputChangesList
/**
* Build and output the actual changes list.
*
* @param ResultWrapper $rows Database rows
* @param FormOptions $opts
*/
public function outputChangesList($rows, $opts)
{
$limit = $opts['limit'];
$showWatcherCount = $this->getConfig()->get('RCShowWatchingUsers') && $this->getUser()->getOption('shownumberswatching');
$watcherCache = [];
$dbr = $this->getDB();
$counter = 1;
$list = ChangesList::newFromContext($this->getContext());
$list->initChangesListRows($rows);
$userShowHiddenCats = $this->getUser()->getBoolOption('showhiddencats');
$rclistOutput = $list->beginRecentChangesList();
foreach ($rows as $obj) {
if ($limit == 0) {
break;
}
$rc = RecentChange::newFromRow($obj);
# Skip CatWatch entries for hidden cats based on user preference
if ($rc->getAttribute('rc_type') == RC_CATEGORIZE && !$userShowHiddenCats && $rc->getParam('hidden-cat')) {
continue;
}
$rc->counter = $counter++;
# Check if the page has been updated since the last visit
if ($this->getConfig()->get('ShowUpdatedMarker') && !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] = MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchers(new TitleValue((int) $obj->rc_namespace, $obj->rc_title));
}
$rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
}
$changeLine = $list->recentChangesLine($rc, !empty($obj->wl_user), $counter);
if ($changeLine !== false) {
$rclistOutput .= $changeLine;
--$limit;
}
}
$rclistOutput .= $list->endRecentChangesList();
if ($rows->numRows() === 0) {
$this->getOutput()->addHTML('<div class="mw-changeslist-empty">' . $this->msg('recentchanges-noresult')->parse() . '</div>');
if (!$this->including()) {
$this->getOutput()->setStatusCode(404);
}
} else {
$this->getOutput()->addHTML($rclistOutput);
}
}
示例6: revisionInfo
function revisionInfo($row)
{
global $wgUser;
$changes = ChangesList::newFromContext(RequestContext::getMain());
$out = $changes->beginRecentChangesList();
$rc = RecentChange::newFromCurRow($row);
$rc->counter = 0;
// ???
$out .= $changes->recentChangesLine($rc);
$out .= $changes->endRecentChangesList();
return $out;
}
示例7: 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 replica DB 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);
if ($this->getConfig()->get('RCShowWatchingUsers') && $user->getOption('shownumberswatching')) {
$watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
}
$s = $list->beginRecentChangesList();
$userShowHiddenCats = $this->getUser()->getBoolOption('showhiddencats');
$counter = 1;
foreach ($rows as $obj) {
# Make RC entry
$rc = RecentChange::newFromRow($obj);
# Skip CatWatch entries for hidden cats based on user preference
if ($rc->getAttribute('rc_type') == RC_CATEGORIZE && !$userShowHiddenCats && $rc->getParam('hidden-cat')) {
continue;
}
$rc->counter = $counter++;
if ($this->getConfig()->get('ShowUpdatedMarker')) {
$updated = $obj->wl_notificationtimestamp;
} else {
$updated = false;
}
if (isset($watchedItemStore)) {
$rcTitleValue = new TitleValue((int) $obj->rc_namespace, $obj->rc_title);
$rc->numberofWatchingusers = $watchedItemStore->countWatchers($rcTitleValue);
} else {
$rc->numberofWatchingusers = 0;
}
$changeLine = $list->recentChangesLine($rc, $updated, $counter);
if ($changeLine !== false) {
$s .= $changeLine;
}
}
$s .= $list->endRecentChangesList();
$output->addHTML($s);
}
示例8: 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);
}
示例9: 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();
}
示例10: 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;
}