本文整理汇总了PHP中RecentChange类的典型用法代码示例。如果您正苦于以下问题:PHP RecentChange类的具体用法?PHP RecentChange怎么用?PHP RecentChange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RecentChange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeRecentChange
private function makeRecentChange($attribs, $counter, $watchingUsers)
{
$change = new RecentChange();
$change->setAttribs($attribs);
$change->counter = $counter;
$change->numberofWatchingusers = $watchingUsers;
return $change;
}
示例2: getLine
/**
* Generates a notification that can be easily interpreted by a machine.
* @see RCFeedFormatter::getLine
*/
public function getLine(array $feed, RecentChange $rc, $actionComment)
{
global $wgCanonicalServer, $wgScriptPath;
$attrib = $rc->getAttributes();
$packet = array('id' => $attrib['rc_id'], 'type' => $attrib['rc_type'], 'namespace' => $rc->getTitle()->getNamespace(), 'title' => $rc->getTitle()->getPrefixedText(), 'comment' => $attrib['rc_comment'], 'timestamp' => (int) wfTimestamp(TS_UNIX, $attrib['rc_timestamp']), 'user' => $attrib['rc_user_text'], 'bot' => (bool) $attrib['rc_bot']);
if (isset($feed['channel'])) {
$packet['channel'] = $feed['channel'];
}
$type = $attrib['rc_type'];
if ($type == RC_EDIT || $type == RC_NEW) {
global $wgUseRCPatrol, $wgUseNPPatrol;
$packet['minor'] = $attrib['rc_minor'];
if ($wgUseRCPatrol || $type == RC_NEW && $wgUseNPPatrol) {
$packet['patrolled'] = $attrib['rc_patrolled'];
}
}
switch ($type) {
case RC_EDIT:
$packet['length'] = array('old' => $attrib['rc_old_len'], 'new' => $attrib['rc_new_len']);
$packet['revision'] = array('old' => $attrib['rc_last_oldid'], 'new' => $attrib['rc_this_oldid']);
break;
case RC_NEW:
$packet['length'] = array('old' => null, 'new' => $attrib['rc_new_len']);
$packet['revision'] = array('old' => null, 'new' => $attrib['rc_this_oldid']);
break;
case RC_LOG:
$packet['log_type'] = $attrib['rc_log_type'];
$packet['log_action'] = $attrib['rc_log_action'];
if ($attrib['rc_params']) {
wfSuppressWarnings();
$params = unserialize($attrib['rc_params']);
wfRestoreWarnings();
if ($attrib['rc_params'] == serialize(false) || $params !== false) {
// From ApiQueryLogEvents::addLogParams
$logParams = array();
// Keys like "4::paramname" can't be used for output so we change them to "paramname"
foreach ($params as $key => $value) {
if (strpos($key, ':') === false) {
$logParams[$key] = $value;
continue;
}
$logParam = explode(':', $key, 3);
$logParams[$logParam[2]] = $value;
}
$packet['log_params'] = $logParams;
} else {
$packet['log_params'] = explode("\n", $attrib['rc_params']);
}
}
$packet['log_action_comment'] = $actionComment;
break;
}
$packet['server_url'] = $wgCanonicalServer;
$packet['server_script_path'] = $wgScriptPath ?: '/';
$packet['wiki'] = wfWikiID();
return $this->formatArray($packet);
}
示例3: formatChangeLine
/**
* @param RecentChange $rc
* @param string[] &$classes
* @param bool $watched
*
* @return string
*/
private function formatChangeLine(RecentChange $rc, array &$classes, $watched)
{
$html = '';
if ($rc->mAttribs['rc_log_type']) {
$logtitle = SpecialPage::getTitleFor('Log', $rc->mAttribs['rc_log_type']);
$this->insertLog($html, $logtitle, $rc->mAttribs['rc_log_type']);
// Log entries (old format) or log targets, and special pages
} elseif ($rc->mAttribs['rc_namespace'] == NS_SPECIAL) {
list($name, $htmlubpage) = SpecialPageFactory::resolveAlias($rc->mAttribs['rc_title']);
if ($name == 'Log') {
$this->insertLog($html, $rc->getTitle(), $htmlubpage);
}
// Regular entries
} else {
$unpatrolled = $this->showAsUnpatrolled($rc);
$this->insertDiffHist($html, $rc, $unpatrolled);
# M, N, b and ! (minor, new, bot and unpatrolled)
$html .= $this->recentChangesFlags(array('newpage' => $rc->mAttribs['rc_type'] == RC_NEW, 'minor' => $rc->mAttribs['rc_minor'], 'unpatrolled' => $unpatrolled, 'bot' => $rc->mAttribs['rc_bot']), '');
$this->insertArticleLink($html, $rc, $unpatrolled, $watched);
}
# Edit/log timestamp
$this->insertTimestamp($html, $rc);
# Bytes added or removed
if ($this->getConfig()->get('RCShowChangedSize')) {
$cd = $this->formatCharacterDifference($rc);
if ($cd !== '') {
$html .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
}
}
if ($rc->mAttribs['rc_type'] == RC_LOG) {
$html .= $this->insertLogEntry($rc);
} elseif ($this->isCategorizationWithoutRevision($rc)) {
$html .= $this->insertComment($rc);
} else {
# User tool links
$this->insertUserRelatedLinks($html, $rc);
# LTR/RTL direction mark
$html .= $this->getLanguage()->getDirMark();
$html .= $this->insertComment($rc);
}
# Tags
$this->insertTags($html, $rc, $classes);
# Rollback
$this->insertRollback($html, $rc);
# For subclasses
$this->insertExtra($html, $rc, $classes);
# How many users watch this page
if ($rc->numberofWatchingusers > 0) {
$html .= ' ' . $this->numberofWatchingusers($rc->numberofWatchingusers);
}
return $html;
}
示例4: saveContent
protected function saveContent()
{
global $wgLogRestrictions;
$dbw = wfGetDB(DB_MASTER);
$log_id = $dbw->nextSequenceValue('logging_log_id_seq');
$this->timestamp = $now = wfTimestampNow();
$data = array('log_id' => $log_id, 'log_type' => $this->type, 'log_action' => $this->action, 'log_timestamp' => $dbw->timestamp($now), 'log_user' => $this->doer->getId(), 'log_user_text' => $this->doer->getName(), 'log_namespace' => $this->target->getNamespace(), 'log_title' => $this->target->getDBkey(), 'log_page' => $this->target->getArticleId(), 'log_comment' => $this->comment, 'log_params' => $this->params);
$dbw->insert('logging', $data, __METHOD__);
$newId = !is_null($log_id) ? $log_id : $dbw->insertId();
# And update recentchanges
if ($this->updateRecentChanges) {
$titleObj = SpecialPage::getTitleFor('Log', $this->type);
RecentChange::notifyLog($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
} else {
if ($this->sendToUDP) {
# Don't send private logs to UDP
if (isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] != '*') {
return true;
}
# Notify external application via UDP.
# We send this to IRC but do not want to add it the RC table.
$titleObj = SpecialPage::getTitleFor('Log', $this->type);
$rc = RecentChange::newLogEntry($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
$rc->notifyRC2UDP();
}
}
return $newId;
}
示例5: saveContent
function saveContent()
{
if (wfReadOnly()) {
return false;
}
global $wgUser;
$fname = 'LogPage::saveContent';
$dbw =& wfGetDB(DB_MASTER);
$uid = $wgUser->getID();
$this->timestamp = $now = wfTimestampNow();
$dbw->insert('logging', array('log_type' => $this->type, 'log_action' => $this->action, 'log_timestamp' => $dbw->timestamp($now), 'log_user' => $uid, 'log_namespace' => $this->target->getNamespace(), 'log_title' => $this->target->getDBkey(), 'log_comment' => $this->comment, 'log_params' => $this->params), $fname);
# And update recentchanges
if ($this->updateRecentChanges) {
$titleObj = Title::makeTitle(NS_SPECIAL, 'Log/' . $this->type);
$rcComment = $this->actionText;
if ('' != $this->comment) {
if ($rcComment == '') {
$rcComment = $this->comment;
} else {
$rcComment .= ': ' . $this->comment;
}
}
RecentChange::notifyLog($now, $titleObj, $wgUser, $rcComment, '', $this->type, $this->action, $this->target, $this->comment, $this->params);
}
return true;
}
示例6: execute
/**
* Patrols the article or provides the reason the patrol failed.
*/
public function execute()
{
global $wgUser, $wgUseRCPatrol, $wgUseNPPatrol;
$this->getMain()->requestWriteMode();
$params = $this->extractRequestParams();
if (!isset($params['token'])) {
$this->dieUsageMsg(array('missingparam', 'token'));
}
if (!isset($params['rcid'])) {
$this->dieUsageMsg(array('missingparam', 'rcid'));
}
if (!$wgUser->matchEditToken($params['token'])) {
$this->dieUsageMsg(array('sessionfailure'));
}
$rc = RecentChange::newFromID($params['rcid']);
if (!$rc instanceof RecentChange) {
$this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
}
$retval = RecentChange::markPatrolled($params['rcid']);
if ($retval) {
$this->dieUsageMsg(current($retval));
}
$result = array('rcid' => $rc->getAttribute('rc_id'));
ApiQueryBase::addTitleInfo($result, $rc->getTitle());
$this->getResult()->addValue(null, $this->getModuleName(), $result);
}
示例7: record
/**
* Record a log event for a change being patrolled
*
* @param $rc Mixed: change identifier or RecentChange object
* @param $auto Boolean: was this patrol event automatic?
* @param $user User: user performing the action or null to use $wgUser
*
* @return bool
*/
public static function record( $rc, $auto = false, User $user = null ) {
global $wgLogAutopatrol;
// do not log autopatrolled edits if setting disables it
if ( $auto && !$wgLogAutopatrol ) {
return false;
}
if ( !$rc instanceof RecentChange ) {
$rc = RecentChange::newFromId( $rc );
if ( !is_object( $rc ) ) {
return false;
}
}
if ( !$user ) {
global $wgUser;
$user = $wgUser;
}
$entry = new ManualLogEntry( 'patrol', 'patrol' );
$entry->setTarget( $rc->getTitle() );
$entry->setParameters( self::buildParams( $rc, $auto ) );
$entry->setPerformer( $user );
$logid = $entry->insert();
if ( !$auto ) {
$entry->publish( $logid, 'udp' );
}
return true;
}
示例8: execute
/**
* Patrols the article or provides the reason the patrol failed.
*/
public function execute()
{
$params = $this->extractRequestParams();
$this->requireOnlyOneParameter($params, 'rcid', 'revid');
if (isset($params['rcid'])) {
$rc = RecentChange::newFromID($params['rcid']);
if (!$rc) {
$this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
}
} else {
$rev = Revision::newFromId($params['revid']);
if (!$rev) {
$this->dieUsageMsg(array('nosuchrevid', $params['revid']));
}
$rc = $rev->getRecentChange();
if (!$rc) {
$this->dieUsage('The revision ' . $params['revid'] . " can't be patrolled as it's too old", 'notpatrollable');
}
}
$retval = $rc->doMarkPatrolled($this->getUser());
if ($retval) {
$this->dieUsageMsg(reset($retval));
}
$result = array('rcid' => intval($rc->getAttribute('rc_id')));
ApiQueryBase::addTitleInfo($result, $rc->getTitle());
$this->getResult()->addValue(null, $this->getModuleName(), $result);
}
示例9: saveContent
function saveContent()
{
if (wfReadOnly()) {
return false;
}
global $wgUser;
$fname = 'LogPage::saveContent';
$dbw = wfGetDB(DB_MASTER);
$uid = $wgUser->getID();
$log_id = $dbw->nextSequenceValue('log_log_id_seq');
$this->timestamp = $now = wfTimestampNow();
$data = array('log_type' => $this->type, 'log_action' => $this->action, 'log_timestamp' => $dbw->timestamp($now), 'log_user' => $uid, 'log_namespace' => $this->target->getNamespace(), 'log_title' => $this->target->getDBkey(), 'log_comment' => $this->comment, 'log_params' => $this->params);
# log_id doesn't exist on Wikimedia servers yet, and it's a tricky
# schema update to do. Hack it for now to ignore the field on MySQL.
if (!is_null($log_id)) {
$data['log_id'] = $log_id;
}
$dbw->insert('logging', $data, $fname);
# And update recentchanges
if ($this->updateRecentChanges) {
$titleObj = SpecialPage::getTitleFor('Log', $this->type);
$rcComment = $this->getRcComment();
RecentChange::notifyLog($now, $titleObj, $wgUser, $rcComment, '', $this->type, $this->action, $this->target, $this->comment, $this->params);
}
return true;
}
示例10: onView
public function onView()
{
$rc = RecentChange::newFromId($this->getRequest()->getInt('rcid'));
if (is_null($rc)) {
throw new ErrorPageError('markedaspatrollederror', 'markedaspatrollederrortext');
}
$errors = $rc->doMarkPatrolled($this->getUser());
if (in_array(array('rcpatroldisabled'), $errors)) {
throw new ErrorPageError('rcpatroldisabled', 'rcpatroldisabledtext');
}
if (in_array(array('hookaborted'), $errors)) {
// The hook itself has handled any output
return;
}
# It would be nice to see where the user had actually come from, but for now just guess
$returnto = $rc->getAttribute('rc_type') == RC_NEW ? 'Newpages' : 'Recentchanges';
$return = SpecialPage::getTitleFor($returnto);
if (in_array(array('markedaspatrollederror-noautopatrol'), $errors)) {
$this->getOutput()->setPageTitle(wfMsg('markedaspatrollederror'));
$this->getOutput()->addWikiMsg('markedaspatrollederror-noautopatrol');
$this->getOutput()->returnToMain(null, $return);
return;
}
if (!empty($errors)) {
$this->getOutput()->showPermissionsErrorPage($errors);
return;
}
# Inform the user
$this->getOutput()->setPageTitle(wfMsg('markedaspatrolled'));
$this->getOutput()->addWikiMsg('markedaspatrolledtext', $rc->getTitle()->getPrefixedText());
$this->getOutput()->returnToMain(null, $return);
}
示例11: getLine
/**
* @see RCFeedFormatter::getLine
*/
public function getLine(array $feed, RecentChange $rc, $actionComment)
{
global $wgWWRCFeedHideLogs, $wgWWRCFeedHideNamespaces;
$attribs = $rc->getAttributes();
if ($attribs['rc_type'] == RC_LOG) {
$title = Title::newFromText('Log/' . $attribs['rc_log_type'], NS_SPECIAL);
} else {
$title =& $rc->getTitle();
}
if ($attribs['rc_type'] == RC_LOG && in_array($attribs['rc_log_type'], $wgWWRCFeedHideLogs)) {
return null;
} elseif (in_array($title->getNamespace(), $wgWWRCFeedHideNamespaces)) {
return null;
}
// if we aren't hiding it, let the core class do all the heavy lifting
return parent::getLine($feed, $rc, $actionComment);
}
示例12: wfMarkUndoneEditAsPatrolled
function wfMarkUndoneEditAsPatrolled()
{
global $wgRequest;
if ($wgRequest->getVal('wpUndoEdit', null) != null) {
$oldid = $wgRequest->getVal('wpUndoEdit');
// using db master to avoid db replication lag
$dbr = wfGetDB(DB_MASTER);
$rcid = $dbr->selectField('recentchanges', 'rc_id', array('rc_this_oldid' => $oldid));
RecentChange::markPatrolled($rcid);
PatrolLog::record($rcid, false);
}
return true;
}
示例13: 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);
}
示例14: execute
/**
* Patrols the article or provides the reason the patrol failed.
*/
public function execute()
{
$params = $this->extractRequestParams();
$rc = RecentChange::newFromID($params['rcid']);
if (!$rc instanceof RecentChange) {
$this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
}
$retval = $rc->doMarkPatrolled($this->getUser());
if ($retval) {
$this->dieUsageMsg(reset($retval));
}
$result = array('rcid' => intval($rc->getAttribute('rc_id')));
ApiQueryBase::addTitleInfo($result, $rc->getTitle());
$this->getResult()->addValue(null, $this->getModuleName(), $result);
}
示例15: doEdit
function doEdit($edit)
{
// create "fake" EditPage
$editor = (object) array('textbox1' => isset($edit['text']) ? $edit['text'] : '');
// try to get section name
MyHome::getSectionName($editor, '', !empty($edit['section']) ? $edit['section'] : false, $errno);
// create "fake" RecentChange object
$row = (object) array('rev_timestamp' => time(), 'rev_user' => 1, 'rev_user_text' => 'test', 'page_namespace' => NS_MAIN, 'page_title' => 'Test', 'rev_comment' => isset($edit['comment']) ? $edit['comment'] : '', 'rev_minor_edit' => true, 'page_is_new' => !empty($edit['is_new']), 'page_id' => 1, 'rev_id' => 1, 'rc_id' => 1, 'rc_patrolled' => 1, 'rc_old_len' => 1, 'rc_new_len' => 1, 'rc_deleted' => 1, 'rc_timestamp' => time());
$rc = RecentChange::newFromCurRow($row);
// call MyHome to add its data to rc object and Wikia vars
MyHome::storeInRecentChanges($rc);
$data = Wikia::getVar('rc_data');
unset($data['articleComment']);
return $data;
}