本文整理汇总了PHP中ChangesList::newFromUser方法的典型用法代码示例。如果您正苦于以下问题:PHP ChangesList::newFromUser方法的具体用法?PHP ChangesList::newFromUser怎么用?PHP ChangesList::newFromUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChangesList
的用法示例。
在下文中一共展示了ChangesList::newFromUser方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfSpecialRecentchanges
//.........这里部分代码省略.........
$hidem .= $hideliu ? ' AND rc_user = 0' : '';
$hidem .= $wgUseRCPatrol && $hidepatrolled ? ' AND rc_patrolled = 0' : '';
$hidem .= $hideanons ? ' AND rc_user != 0' : '';
if ($hidemyself) {
if ($wgUser->getID()) {
$hidem .= ' AND rc_user != ' . $wgUser->getID();
} else {
$hidem .= ' AND rc_user_text != ' . $dbr->addQuotes($wgUser->getName());
}
}
# Namespace filtering
$hidem .= is_null($namespace) ? '' : ' AND rc_namespace' . ($invert ? '!=' : '=') . $namespace;
// This is the big thing!
$uid = $wgUser->getID();
// Perform query
$forceclause = $dbr->useIndexClause("rc_timestamp");
$sql2 = "SELECT * FROM {$recentchanges} {$forceclause}" . ($uid ? "LEFT OUTER JOIN {$watchlist} ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "WHERE rc_timestamp >= '{$cutoff}' {$hidem} " . "ORDER BY rc_timestamp DESC";
$sql2 = $dbr->limitResult($sql2, $limit, 0);
$res = $dbr->query($sql2, $fname);
// Fetch results, prepare a batch link existence check query
$rows = array();
$batch = new LinkBatch();
while ($row = $dbr->fetchObject($res)) {
$rows[] = $row;
if (!$feedFormat) {
// User page link
$title = Title::makeTitleSafe(NS_USER, $row->rc_user_text);
$batch->addObj($title);
// User talk
$title = Title::makeTitleSafe(NS_USER_TALK, $row->rc_user_text);
$batch->addObj($title);
}
}
$dbr->freeResult($res);
if ($feedFormat) {
rcOutputFeed($rows, $feedFormat, $limit, $hideminor, $lastmod);
} else {
# Web output...
// Run existence checks
$batch->execute();
$any = $wgRequest->getBool('categories_any', $defaults['categories_any']);
// Output header
if (!$specialPage->including()) {
$wgOut->addWikiText(wfMsgForContentNoTrans("recentchangestext"));
// Dump everything here
$nondefaults = array();
wfAppendToArrayIfNotDefault('days', $days, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('limit', $limit, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hideminor', $hideminor, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hidebots', $hidebots, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hideanons', $hideanons, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hideliu', $hideliu, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hidepatrolled', $hidepatrolled, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hidemyself', $hidemyself, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('from', $from, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('namespace', $namespace, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('invert', $invert, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('categories_any', $any, $defaults, $nondefaults);
// Add end of the texts
$wgOut->addHTML('<div class="rcoptions">' . rcOptionsPanel($defaults, $nondefaults) . "\n");
$wgOut->addHTML(rcNamespaceForm($namespace, $invert, $nondefaults, $any) . '</div>' . "\n");
}
// And now for the content
$list = ChangesList::newFromUser($wgUser);
if ($wgAllowCategorizedRecentChanges) {
$categories = trim($wgRequest->getVal('categories', ""));
$categories = str_replace("|", "\n", $categories);
$categories = explode("\n", $categories);
rcFilterByCategories($rows, $categories, $any);
}
$s = $list->beginRecentChangesList();
$counter = 1;
foreach ($rows as $obj) {
if ($limit == 0) {
break;
}
if (!($hideminor && $obj->rc_minor) && !($hidepatrolled && $obj->rc_patrolled)) {
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
if ($wgShowUpdatedMarker && !empty($obj->wl_notificationtimestamp) && $obj->rc_timestamp >= $obj->wl_notificationtimestamp) {
$rc->notificationtimestamp = true;
} else {
$rc->notificationtimestamp = false;
}
if ($wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
$sql3 = "SELECT COUNT(*) AS n FROM {$watchlist} WHERE wl_title='" . $dbr->strencode($obj->rc_title) . "' AND wl_namespace={$obj->rc_namespace}";
$res3 = $dbr->query($sql3, 'wfSpecialRecentChanges');
$x = $dbr->fetchObject($res3);
$rc->numberofWatchingusers = $x->n;
} else {
$rc->numberofWatchingusers = 0;
}
$s .= $list->recentChangesLine($rc, !empty($obj->wl_user));
--$limit;
}
}
$s .= $list->endRecentChangesList();
$wgOut->addHTML($s);
}
}
示例2: wfSpecialRecentchanges
//.........这里部分代码省略.........
$batch->add(NS_USER, $row->rc_user_text);
$batch->add(NS_USER_TALK, $row->rc_user_text);
}
}
$dbr->freeResult($res);
if ($feedFormat) {
rcOutputFeed($rows, $feedFormat, $limit, $hideminor, $lastmod);
} else {
# Web output...
// Run existence checks
$batch->execute();
$any = $wgRequest->getBool('categories_any', $defaults['categories_any']);
// Output header
if (!$specialPage->including()) {
$wgOut->addWikiText('<div class="minor_text">' . wfMsgForContentNoTrans("recentchangestext") . '<br /></div>');
// Dump everything here
$nondefaults = array();
wfAppendToArrayIfNotDefault('days', $days, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('limit', $limit, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hideminor', $hideminor, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hidebots', $hidebots, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hideanons', $hideanons, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hideliu', $hideliu, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hidepatrolled', $hidepatrolled, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('hidemyself', $hidemyself, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('from', $from, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('namespace', $namespace, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('invert', $invert, $defaults, $nondefaults);
wfAppendToArrayIfNotDefault('categories_any', $any, $defaults, $nondefaults);
// Add end of the texts
$wgOut->addHTML('<div class="rcoptions">' . rcOptionsPanel($defaults, $nondefaults) . "\n");
//XXCHANGED
$wgOut->addHTML(rcNamespaceForm($namespace, $invert, $reverse, $featured, $nondefaults, $any) . '</div>' . "\n");
//XXADDED
global $wgLanguageCode;
if ($wgUser->getID() > 0 && $wgLanguageCode == 'en') {
$sk = $wgUser->getSkin();
$url = $wgRequest->getRequestURL();
if ($wgRequest->getVal('refresh', null) != null) {
$url = str_replace("&refresh=1", "", $url);
$url = str_replace("?refresh=1", "", $url);
$wgOut->addHTML("<a href='{$url}' class='button secondary'>" . wfMsg('rc_turn_refresh_off') . "</a>");
} else {
if (strpos($url, "?") !== false) {
$url .= "&refresh=1";
} else {
$url .= "?refresh=1";
}
$wgOut->addHTML("<a href='{$url}' class='button secondary'>" . wfMsg('rc_turn_refresh_on') . "</a>");
}
$wgOut->addHTML(" <a class='button secondary' href='#' onclick=\"open('/index.php?title=Special:RCBuddy&hidepatrolled=1&limit=200&featured=1', '', 'scrollbars=no,status=no,width=570,height=200,resizable=yes,titlebar=no');\">RC Buddy</a>");
}
}
// And now for the content
$wgOut->setSyndicated(true);
$list = ChangesList::newFromUser($wgUser);
if ($wgAllowCategorizedRecentChanges) {
$categories = trim($wgRequest->getVal('categories', ""));
$categories = str_replace("|", "\n", $categories);
$categories = explode("\n", $categories);
rcFilterByCategories($rows, $categories, $any);
}
$s = $list->beginRecentChangesList();
$s .= "<div id='recentchanges'>\n";
$counter = 1;
$showWatcherCount = $wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching');
$watcherCache = array();
foreach ($rows as $obj) {
if ($limit == 0) {
break;
}
if (!($hideminor && $obj->rc_minor) && !($hidepatrolled && $obj->rc_patrolled)) {
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
if ($wgShowUpdatedMarker && !empty($obj->wl_notificationtimestamp) && $obj->rc_timestamp >= $obj->wl_notificationtimestamp) {
$rc->notificationtimestamp = true;
} else {
$rc->notificationtimestamp = false;
}
$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];
}
$rc->show_namespace = $namespace;
$rc->invert = $invert;
$rc->reverse = $reverse;
$rc->featured = $featured;
$s .= $list->recentChangesLine($rc, !empty($obj->wl_user));
--$limit;
}
}
$s .= $list->endRecentChangesList();
$s .= "</div>\n";
$wgOut->addHTML($s);
}
}
示例3: wfSpecialWatchlist
//.........这里部分代码省略.........
$limitWatchlist = '';
}
# TODO: Consider removing the third parameter
$header .= wfMsg('watchdetails', $wgLang->formatNum($nitems), $wgLang->formatNum($npages), '', $specialTitle->getFullUrl('edit=yes'));
$wgOut->addWikiText($header);
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");
}
// WERELATE - handle changed view
if ($wgRequest->getBool('changed') || $par == 'changed') {
$wgOut->addHTML('<hr /><h2>All pages changed since last visited</h2><ul><li><a href="' . $specialTitle->getFullUrl() . '">Show recently-changed pages</a></li></ul>');
$sql = 'select wl_namespace, wl_title from watchlist where wl_user=' . $wgUser->getID() . ' and wl_notificationtimestamp > \'0\'';
$res = $dbr->query($sql, $fname);
$sk = $wgUser->getSkin();
$changed = '';
$count = 0;
while ($obj = $dbr->fetchObject($res)) {
$t = Title::makeTitle($obj->wl_namespace, $obj->wl_title);
$historylink = $sk->makeKnownLinkObj($t, 'hist', wfArrayToCGI(array('action' => 'history')));
$articlelink = $sk->makeKnownLinkObj($t);
$changed .= "<li> ( {$historylink} ) . . {$articlelink}</li>\n";
$count += 1;
}
$dbr->freeResult($res);
$wgOut->addHTML("<h3>{$count} page(s)</h3>\n<ul>" . $changed . '</ul>');
return;
}
// WERELATE - remove join with page table
$sql = "SELECT\n\t rc_namespace AS page_namespace, rc_title AS page_title,\n\t rc_comment AS rev_comment, rc_cur_id AS page_id,\n\t rc_user AS rev_user, rc_user_text AS rev_user_text,\n\t rc_timestamp AS rev_timestamp, rc_minor AS rev_minor_edit,\n\t rc_this_oldid AS rev_id,\n\t rc_last_oldid, rc_id, rc_patrolled,\n\t rc_new AS page_is_new,wl_notificationtimestamp\n\t FROM {$watchlist},{$recentchanges}\n\t WHERE wl_user={$uid}\n\t AND wl_namespace=rc_namespace\n\t AND wl_title=rc_title\n\t AND rc_timestamp > '{$cutoff}'\n\t {$andHideOwn}\n\t {$andHideBots}\n\t {$nameSpaceClause}\n\t ORDER BY rc_timestamp DESC\n\t {$limitWatchlist}";
$res = $dbr->query($sql, $fname);
// WERELATE - moved up from below so we can calculate $numRows inside the loop
// $numRows = $dbr->numRows( $res );
$numRows = 0;
$list = ChangesList::newFromUser($wgUser);
$rcs = $list->beginRecentChangesList();
$counter = 1;
// WERELATE - added array of seen pagetitles
$seen = array();
while ($obj = $dbr->fetchObject($res)) {
$nsTitle = "{$obj->page_namespace}:{$obj->page_title}";
if (!$andLatest || !isset($seen[$nsTitle])) {
$seen[$nsTitle] = 1;
$numRows++;
# Make fake RC entry
$rc = RecentChange::newFromCurRow($obj, $obj->rc_last_oldid);
$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='" . wfStrencode($obj->page_title) . "' AND wl_namespace='{$obj->page_namespace}'";
$res3 = $dbr->query($sql3, DB_READ, $fname);
$x = $dbr->fetchObject($res3);
$rc->numberofWatchingusers = $x->n;
} else {
$rc->numberofWatchingusers = 0;
}
$rcs .= $list->recentChangesLine($rc, $updated);
}
}
$rcs .= $list->endRecentChangesList();
$dbr->freeResult($res);
/* Start bottom header */
示例4: webOutput
/**
* Send output to $wgOut, only called if not used feeds
*
* @param $rows array of database rows
* @param $opts FormOptions
*/
public function webOutput($rows, $opts)
{
global $wgOut, $wgUser, $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
global $wgAllowCategorizedRecentChanges;
$limit = $opts['limit'];
if (!$this->including()) {
// Output options box
$this->doHeader($opts);
}
// And now for the content
$wgOut->setFeedAppendQuery($this->getFeedQuery());
if ($wgAllowCategorizedRecentChanges) {
$this->filterByCategories($rows, $opts);
}
$showWatcherCount = $wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching');
$watcherCache = array();
$dbr = wfGetDB(DB_SLAVE);
$counter = 1;
$list = ChangesList::newFromUser($wgUser);
$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];
}
$s .= $list->recentChangesLine($rc, !empty($obj->wl_user), $counter);
--$limit;
}
$s .= $list->endRecentChangesList();
$wgOut->addHTML($s);
}
示例5: 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);
}
示例6: wfSpecialRecentchangeslinked
/**
* Entrypoint
* @param string $par parent page we will look at
*/
function wfSpecialRecentchangeslinked($par = NULL)
{
global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgTitle;
$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();
if (is_null($target)) {
$wgOut->errorpage('notargettitle', 'notargettext');
return;
}
$nt = Title::newFromURL($target);
if (!$nt) {
$wgOut->errorpage('notargettitle', 'notargettext');
return;
}
$id = $nt->getArticleId();
$wgOut->setPageTitle(wfMsg('recentchangeslinked-title', $nt->getPrefixedText()));
$wgOut->setSyndicated();
$wgOut->setFeedAppendQuery("target=" . urlencode($target));
if (!$days) {
$days = (int) $wgUser->getOption('rcdays', 7);
}
list($limit, ) = wfCheckLimits(100, 'rclimit');
$dbr = wfGetDB(DB_SLAVE, 'recentchangeslinked');
$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 = '';
}
list($recentchanges, $categorylinks, $pagelinks, $watchlist) = $dbr->tableNamesN('recentchanges', 'categorylinks', 'pagelinks', "watchlist");
$uid = $wgUser->getID();
$GROUPBY = "\n\tGROUP BY rc_cur_id,rc_namespace,rc_title,\n\t\trc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_deleted,\n\t\trc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type, rc_old_len, rc_new_len\n" . ($uid ? ",wl_user" : "") . "\n\t\tORDER BY rc_timestamp DESC\n\tLIMIT {$limit}";
// 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\t\t\t\trc_old_len,\n\t\t\t\trc_new_len,\n\t\t\t\trc_deleted\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{$GROUPBY}\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\t\t\trc_old_len,\n\t\t\trc_new_len,\n\t\t\trc_deleted\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}\n{$GROUPBY}\n";
}
$res = $dbr->query($sql, $fname);
$wgOut->addHTML("< " . $sk->makeLinkObj($nt, "", "redirect=no") . "<br />\n");
$note = wfMsgExt("rcnote", array('parseinline'), $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);
$rchanges = array();
if ($count) {
$counter = 1;
while ($limit) {
if (0 == $count) {
break;
}
$obj = $dbr->fetchObject($res);
--$count;
$rc = RecentChange::newFromRow($obj);
$rc->counter = $counter++;
$s .= $list->recentChangesLine($rc, !empty($obj->wl_user));
--$limit;
$rchanges[] = $obj;
}
} else {
$wgOut->addWikiMsg('recentchangeslinked-noresult');
}
$s .= $list->endRecentChangesList();
$dbr->freeResult($res);
$wgOut->addHTML($s);
global $wgSitename, $wgFeedClasses, $wgContLanguageCode;
$feedFormat = $wgRequest->getVal('feed');
if ($feedFormat && isset($wgFeedClasses[$feedFormat])) {
$feedTitle = $wgSitename . ' - ' . wfMsgForContent('recentchangeslinked-title', $nt->getPrefixedText()) . ' [' . $wgContLanguageCode . ']';
$feed = new $wgFeedClasses[$feedFormat]($feedTitle, htmlspecialchars(wfMsgForContent('recentchangeslinked')), $wgTitle->getFullUrl());
require_once "SpecialRecentchanges.php";
$wgOut->disable();
rcDoOutputFeed($rchanges, $feed);
}
}
示例7: showDiffDetails
/**
* Produce a stub recent changes listing for a single diff.
*
* @param $edit Diff. to show the listing for
*/
private function showDiffDetails( &$edit ) {
global $wgUser, $wgOut;
$edit->counter = 1;
$edit->mAttribs['rc_patrolled'] = 1;
$list = ChangesList::newFromUser( $wgUser );
$wgOut->addHTML( $list->beginRecentChangesList() .
$list->recentChangesLine( $edit ) .
$list->endRecentChangesList() );
}
示例8: revisionInfo
/**
* @param $row
* @return String
*/
function revisionInfo( $row ) {
global $wgUser;
$changes = ChangesList::newFromUser( $wgUser );
$out = $changes->beginRecentChangesList();
$rc = RecentChange::newFromCurRow( $row );
$rc->counter = 0; // ???
$out .= $changes->recentChangesLine( $rc );
$out .= $changes->endRecentChangesList();
return $out;
}
示例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: 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);
}