本文整理汇总了PHP中Revision::isMinor方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::isMinor方法的具体用法?PHP Revision::isMinor怎么用?PHP Revision::isMinor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::isMinor方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showHeader
/**
* Render the header of a diff page including:
* Name with url to page
* Bytes added/removed
* Day and time of edit
* Edit Comment
*/
function showHeader()
{
$title = $this->targetTitle;
if ($this->prevRev) {
$bytesChanged = $this->rev->getSize() - $this->prevRev->getSize();
} else {
$bytesChanged = $this->rev->getSize();
}
if ($bytesChanged > 0) {
$changeMsg = 'mobile-frontend-diffview-bytesadded';
$sizeClass = MobileUI::iconClass('bytesadded', 'before', 'icon-12px meta mw-mf-bytesadded');
} elseif ($bytesChanged === 0) {
$changeMsg = 'mobile-frontend-diffview-bytesnochange';
$sizeClass = MobileUI::iconClass('bytesneutral', 'before', 'icon-12px meta mw-mf-bytesneutral');
} else {
$changeMsg = 'mobile-frontend-diffview-bytesremoved';
$sizeClass = MobileUI::iconClass('bytesremoved', 'before', 'icon-12px meta mw-mf-bytesremoved');
$bytesChanged = abs($bytesChanged);
}
if ($this->rev->isMinor()) {
$minor = ChangesList::flag('minor');
} else {
$minor = '';
}
if ($this->rev->getComment() !== '') {
$comment = Linker::formatComment($this->rev->getComment(), $title);
} else {
$comment = $this->msg('mobile-frontend-changeslist-nocomment')->escaped();
}
$ts = new MWTimestamp($this->rev->getTimestamp());
$this->getOutput()->addHtml(Html::openElement('div', array('id' => 'mw-mf-diff-info', 'class' => 'page-summary')) . Html::openElement('h2', array()) . Html::element('a', array('href' => $title->getLocalURL()), $title->getPrefixedText()) . Html::closeElement('h2') . $this->msg('mobile-frontend-diffview-comma')->rawParams(Html::element('span', array('class' => $sizeClass), $this->msg($changeMsg)->numParams($bytesChanged)->text()), Html::element('span', array('class' => 'mw-mf-diff-date meta'), $ts->getHumanTimestamp()))->text() . Html::closeElement('div') . $minor . Html::rawElement('div', array('id' => 'mw-mf-diff-comment'), $comment));
}
示例2: getMinorEdit
/**
* Returns true if last revision was marked as "minor edit"
*
* @return bool Minor edit indicator for the last article revision.
*/
public function getMinorEdit()
{
$this->loadLastEdit();
if ($this->mLastRevision) {
return $this->mLastRevision->isMinor();
} else {
return false;
}
}
示例3: doEditUpdates
/**
* Do standard deferred updates after page edit.
* Update links tables, site stats, search index and message cache.
* Purges pages that include this page if the text was changed here.
* Every 100th edit, prune the recent changes table.
*
* @param $revision Revision object
* @param $user User object that did the revision
* @param array $options of options, following indexes are used:
* - changed: boolean, whether the revision changed the content (default true)
* - created: boolean, whether the revision created the page (default false)
* - oldcountable: boolean or null (default null):
* - boolean: whether the page was counted as an article before that
* revision, only used in changed is true and created is false
* - null: don't change the article count
*/
public function doEditUpdates( Revision $revision, User $user, array $options = array() ) {
global $wgEnableParserCache;
wfProfileIn( __METHOD__ );
$options += array( 'changed' => true, 'created' => false, 'oldcountable' => null );
$content = $revision->getContent();
// Parse the text
// Be careful not to do pre-save transform twice: $text is usually
// already pre-save transformed once.
if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" );
$editInfo = $this->prepareContentForEdit( $content, $revision->getId(), $user );
} else {
wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" );
$editInfo = $this->mPreparedEdit;
}
// Save it to the parser cache
if ( $wgEnableParserCache ) {
$parserCache = ParserCache::singleton();
$parserCache->save( $editInfo->output, $this, $editInfo->popts );
}
// Update the links tables and other secondary data
if ( $content ) {
$recursive = $options['changed']; // bug 50785
$updates = $content->getSecondaryDataUpdates(
$this->getTitle(), null, $recursive, $editInfo->output );
DataUpdate::runUpdates( $updates );
}
wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) );
if ( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
if ( 0 == mt_rand( 0, 99 ) ) {
// Flush old entries from the `recentchanges` table; we do this on
// random requests so as to avoid an increase in writes for no good reason
RecentChange::purgeExpiredChanges();
}
}
if ( !$this->exists() ) {
wfProfileOut( __METHOD__ );
return;
}
$id = $this->getId();
$title = $this->mTitle->getPrefixedDBkey();
$shortTitle = $this->mTitle->getDBkey();
if ( !$options['changed'] ) {
$good = 0;
$total = 0;
} elseif ( $options['created'] ) {
$good = (int)$this->isCountable( $editInfo );
$total = 1;
} elseif ( $options['oldcountable'] !== null ) {
$good = (int)$this->isCountable( $editInfo ) - (int)$options['oldcountable'];
$total = 0;
} else {
$good = 0;
$total = 0;
}
DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content ) );
// If this is another user's talk page, update newtalk.
// Don't do this if $options['changed'] = false (null-edits) nor if
// it's a minor edit and the user doesn't want notifications for those.
if ( $options['changed']
&& $this->mTitle->getNamespace() == NS_USER_TALK
&& $shortTitle != $user->getTitleKey()
&& !( $revision->isMinor() && $user->isAllowed( 'nominornewtalk' ) )
) {
$recipient = User::newFromName( $shortTitle, false );
if ( !$recipient ) {
wfDebug( __METHOD__ . ": invalid username\n" );
} else {
// Allow extensions to prevent user notification when a new message is added to their talk page
if ( wfRunHooks( 'ArticleEditUpdateNewTalk', array( &$this, $recipient ) ) ) {
if ( User::isIP( $shortTitle ) ) {
//.........这里部分代码省略.........
示例4: showDiffPage
public function showDiffPage($diffOnly = false)
{
# Allow frames except in certain special cases
$out = $this->getOutput();
$out->allowClickjacking();
$out->setRobotPolicy('noindex,nofollow');
if (!$this->loadRevisionData()) {
$this->showMissingRevision();
return;
}
$user = $this->getUser();
$permErrors = $this->mNewPage->getUserPermissionsErrors('read', $user);
if ($this->mOldPage) {
# mOldPage might not be set, see below.
$permErrors = wfMergeErrorArrays($permErrors, $this->mOldPage->getUserPermissionsErrors('read', $user));
}
if (count($permErrors)) {
throw new PermissionsError('read', $permErrors);
}
$rollback = '';
$query = array();
# Carry over 'diffonly' param via navigation links
if ($diffOnly != $user->getBoolOption('diffonly')) {
$query['diffonly'] = $diffOnly;
}
# Cascade unhide param in links for easy deletion browsing
if ($this->unhide) {
$query['unhide'] = 1;
}
# Check if one of the revisions is deleted/suppressed
$deleted = $suppressed = false;
$allowed = $this->mNewRev->userCan(Revision::DELETED_TEXT, $user);
$revisionTools = array();
# mOldRev is false if the difference engine is called with a "vague" query for
# a diff between a version V and its previous version V' AND the version V
# is the first version of that article. In that case, V' does not exist.
if ($this->mOldRev === false) {
$out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText()));
$samePage = true;
$oldHeader = '';
} else {
Hooks::run('DiffViewHeader', array($this, $this->mOldRev, $this->mNewRev));
if ($this->mNewPage->equals($this->mOldPage)) {
$out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText()));
$samePage = true;
} else {
$out->setPageTitle($this->msg('difference-title-multipage', $this->mOldPage->getPrefixedText(), $this->mNewPage->getPrefixedText()));
$out->addSubtitle($this->msg('difference-multipage'));
$samePage = false;
}
if ($samePage && $this->mNewPage->quickUserCan('edit', $user)) {
if ($this->mNewRev->isCurrent() && $this->mNewPage->userCan('rollback', $user)) {
$rollbackLink = Linker::generateRollback($this->mNewRev, $this->getContext());
if ($rollbackLink) {
$out->preventClickjacking();
$rollback = '   ' . $rollbackLink;
}
}
if (!$this->mOldRev->isDeleted(Revision::DELETED_TEXT) && !$this->mNewRev->isDeleted(Revision::DELETED_TEXT)) {
$undoLink = Html::element('a', array('href' => $this->mNewPage->getLocalURL(array('action' => 'edit', 'undoafter' => $this->mOldid, 'undo' => $this->mNewid)), 'title' => Linker::titleAttrib('undo')), $this->msg('editundo')->text());
$revisionTools['mw-diff-undo'] = $undoLink;
}
}
# Make "previous revision link"
if ($samePage && $this->mOldRev->getPrevious()) {
$prevlink = Linker::linkKnown($this->mOldPage, $this->msg('previousdiff')->escaped(), array('id' => 'differences-prevlink'), array('diff' => 'prev', 'oldid' => $this->mOldid) + $query);
} else {
$prevlink = ' ';
}
if ($this->mOldRev->isMinor()) {
$oldminor = ChangesList::flag('minor');
} else {
$oldminor = '';
}
$ldel = $this->revisionDeleteLink($this->mOldRev);
$oldRevisionHeader = $this->getRevisionHeader($this->mOldRev, 'complete');
$oldChangeTags = ChangeTags::formatSummaryRow($this->mOldTags, 'diff');
$oldHeader = '<div id="mw-diff-otitle1"><strong>' . $oldRevisionHeader . '</strong></div>' . '<div id="mw-diff-otitle2">' . Linker::revUserTools($this->mOldRev, !$this->unhide) . '</div>' . '<div id="mw-diff-otitle3">' . $oldminor . Linker::revComment($this->mOldRev, !$diffOnly, !$this->unhide) . $ldel . '</div>' . '<div id="mw-diff-otitle5">' . $oldChangeTags[0] . '</div>' . '<div id="mw-diff-otitle4">' . $prevlink . '</div>';
if ($this->mOldRev->isDeleted(Revision::DELETED_TEXT)) {
$deleted = true;
// old revisions text is hidden
if ($this->mOldRev->isDeleted(Revision::DELETED_RESTRICTED)) {
$suppressed = true;
// also suppressed
}
}
# Check if this user can see the revisions
if (!$this->mOldRev->userCan(Revision::DELETED_TEXT, $user)) {
$allowed = false;
}
}
# Make "next revision link"
# Skip next link on the top revision
if ($samePage && !$this->mNewRev->isCurrent()) {
$nextlink = Linker::linkKnown($this->mNewPage, $this->msg('nextdiff')->escaped(), array('id' => 'differences-nextlink'), array('diff' => 'next', 'oldid' => $this->mNewid) + $query);
} else {
$nextlink = ' ';
}
if ($this->mNewRev->isMinor()) {
$newminor = ChangesList::flag('minor');
//.........这里部分代码省略.........
示例5: showContributionsRow
/**
* Render the contribution of the pagerevision (time, bytes added/deleted, pagename comment)
* @param Revision $rev
*/
protected function showContributionsRow(Revision $rev)
{
$user = $this->getUser();
$userId = $rev->getUser(Revision::FOR_THIS_USER, $user);
if ($userId === 0) {
$username = IP::prettifyIP($rev->getUserText(Revision::RAW));
$isAnon = true;
} else {
$username = $rev->getUserText(Revision::FOR_THIS_USER, $user);
$isAnon = false;
}
// FIXME: Style differently user comment when this is the case
if ($rev->userCan(Revision::DELETED_COMMENT, $user)) {
$comment = $rev->getComment(Revision::FOR_THIS_USER, $user);
$comment = $this->formatComment($comment, $this->title);
} else {
$comment = $this->msg('rev-deleted-comment')->plain();
}
$ts = $rev->getTimestamp();
$this->renderListHeaderWhereNeeded($this->getLanguage()->userDate($ts, $this->getUser()));
$ts = new MWTimestamp($ts);
if ($rev->userCan(Revision::DELETED_TEXT, $user)) {
$diffLink = SpecialPage::getTitleFor('MobileDiff', $rev->getId())->getLocalUrl();
} else {
$diffLink = false;
}
// FIXME: Style differently user comment when this is the case
if (!$rev->userCan(Revision::DELETED_USER, $user)) {
$username = $this->msg('rev-deleted-user')->plain();
}
$bytes = null;
if (isset($this->prevLengths[$rev->getParentId()])) {
$bytes = $rev->getSize() - $this->prevLengths[$rev->getParentId()];
}
$isMinor = $rev->isMinor();
$this->renderFeedItemHtml($ts, $diffLink, $username, $comment, $rev->getTitle(), $isAnon, $bytes, $isMinor);
}
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:41,代码来源:SpecialMobileContributions.php
示例6: showRow
/**
* Show a row in history, including:
* time of edit
* changed bytes
* name of editor
* comment of edit
* @param Revision $rev Revision id of the row wants to show
* @param Revision|null $prev Revision id of previous Revision to display the difference
*/
protected function showRow(Revision $rev, $prev)
{
$user = $this->getUser();
$userId = $rev->getUser(Revision::FOR_THIS_USER, $user);
if ($userId === 0) {
$username = IP::prettifyIP($rev->getUserText(Revision::RAW));
$isAnon = true;
} else {
$username = $rev->getUserText(Revision::FOR_THIS_USER, $user);
$isAnon = false;
}
// FIXME: Style differently user comment when this is the case
if ($rev->userCan(Revision::DELETED_COMMENT, $user)) {
$comment = $rev->getComment(Revision::FOR_THIS_USER, $user);
$comment = $this->formatComment($comment, $this->title);
} else {
$comment = $this->msg('rev-deleted-comment')->plain();
}
$ts = $rev->getTimestamp();
$this->renderListHeaderWhereNeeded($this->getLanguage()->userDate($ts, $this->getUser()));
$ts = new MWTimestamp($ts);
$canSeeText = $rev->userCan(Revision::DELETED_TEXT, $user);
if ($canSeeText && $prev && $prev->userCan(Revision::DELETED_TEXT, $user)) {
$diffLink = SpecialPage::getTitleFor('MobileDiff', $rev->getId())->getLocalUrl();
} elseif ($canSeeText && $rev->getTitle() !== null) {
$diffLink = $rev->getTitle()->getLocalUrl(array('oldid' => $rev->getId()));
} else {
$diffLink = false;
}
// FIXME: Style differently user comment when this is the case
if (!$rev->userCan(Revision::DELETED_USER, $user)) {
$username = $this->msg('rev-deleted-user')->plain();
}
// When the page is named there is no need to print it in output
if ($this->title) {
$title = null;
} else {
$title = $rev->getTitle();
}
$bytes = $rev->getSize();
if ($prev) {
$bytes -= $prev->getSize();
}
$isMinor = $rev->isMinor();
$this->renderFeedItemHtml($ts, $diffLink, $username, $comment, $title, $isAnon, $bytes, $isMinor);
}
示例7: extractRevisionInfo
/**
* Extract information from the Revision
*
* @param Revision $revision
* @param object $row Should have a field 'ts_tags' if $this->fld_tags is set
* @return array
*/
protected function extractRevisionInfo(Revision $revision, $row)
{
$title = $revision->getTitle();
$user = $this->getUser();
$vals = array();
$anyHidden = false;
if ($this->fld_ids) {
$vals['revid'] = intval($revision->getId());
if (!is_null($revision->getParentId())) {
$vals['parentid'] = intval($revision->getParentId());
}
}
if ($this->fld_flags) {
$vals['minor'] = $revision->isMinor();
}
if ($this->fld_user || $this->fld_userid) {
if ($revision->isDeleted(Revision::DELETED_USER)) {
$vals['userhidden'] = true;
$anyHidden = true;
}
if ($revision->userCan(Revision::DELETED_USER, $user)) {
if ($this->fld_user) {
$vals['user'] = $revision->getUserText(Revision::RAW);
}
$userid = $revision->getUser(Revision::RAW);
if (!$userid) {
$vals['anon'] = true;
}
if ($this->fld_userid) {
$vals['userid'] = $userid;
}
}
}
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $revision->getTimestamp());
}
if ($this->fld_size) {
if (!is_null($revision->getSize())) {
$vals['size'] = intval($revision->getSize());
} else {
$vals['size'] = 0;
}
}
if ($this->fld_sha1) {
if ($revision->isDeleted(Revision::DELETED_TEXT)) {
$vals['sha1hidden'] = true;
$anyHidden = true;
}
if ($revision->userCan(Revision::DELETED_TEXT, $user)) {
if ($revision->getSha1() != '') {
$vals['sha1'] = wfBaseConvert($revision->getSha1(), 36, 16, 40);
} else {
$vals['sha1'] = '';
}
}
}
if ($this->fld_contentmodel) {
$vals['contentmodel'] = $revision->getContentModel();
}
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($revision->isDeleted(Revision::DELETED_COMMENT)) {
$vals['commenthidden'] = true;
$anyHidden = true;
}
if ($revision->userCan(Revision::DELETED_COMMENT, $user)) {
$comment = $revision->getComment(Revision::RAW);
if ($this->fld_comment) {
$vals['comment'] = $comment;
}
if ($this->fld_parsedcomment) {
$vals['parsedcomment'] = Linker::formatComment($comment, $title);
}
}
}
if ($this->fld_tags) {
if ($row->ts_tags) {
$tags = explode(',', $row->ts_tags);
ApiResult::setIndexedTagName($tags, 'tag');
$vals['tags'] = $tags;
} else {
$vals['tags'] = array();
}
}
$content = null;
global $wgParser;
if ($this->fetchContent) {
$content = $revision->getContent(Revision::FOR_THIS_USER, $this->getUser());
// Expand templates after getting section content because
// template-added sections don't count and Parser::preprocess()
// will have less input
if ($content && $this->section !== false) {
$content = $content->getSection($this->section, false);
if (!$content) {
//.........这里部分代码省略.........
示例8: extractRowInfo
private function extractRowInfo($row)
{
$revision = new Revision($row);
$title = $revision->getTitle();
$vals = array();
if ($this->fld_ids) {
$vals['revid'] = intval($revision->getId());
// $vals['oldid'] = intval( $row->rev_text_id ); // todo: should this be exposed?
if (!is_null($revision->getParentId())) {
$vals['parentid'] = intval($revision->getParentId());
}
}
if ($this->fld_flags && $revision->isMinor()) {
$vals['minor'] = '';
}
if ($this->fld_user || $this->fld_userid) {
if ($revision->isDeleted(Revision::DELETED_USER)) {
$vals['userhidden'] = '';
} else {
if ($this->fld_user) {
$vals['user'] = $revision->getUserText();
}
$userid = $revision->getUser();
if (!$userid) {
$vals['anon'] = '';
}
if ($this->fld_userid) {
$vals['userid'] = $userid;
}
}
}
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $revision->getTimestamp());
}
if ($this->fld_size) {
if (!is_null($revision->getSize())) {
$vals['size'] = intval($revision->getSize());
} else {
$vals['size'] = 0;
}
}
if ($this->fld_sha1) {
if ($revision->getSha1() != '') {
$vals['sha1'] = wfBaseConvert($revision->getSha1(), 36, 16, 40);
} else {
$vals['sha1'] = '';
}
}
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($revision->isDeleted(Revision::DELETED_COMMENT)) {
$vals['commenthidden'] = '';
} else {
$comment = $revision->getComment();
if ($this->fld_comment) {
$vals['comment'] = $comment;
}
if ($this->fld_parsedcomment) {
$vals['parsedcomment'] = Linker::formatComment($comment, $title);
}
}
}
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], $title->getArticleID(), $title, $revision);
if ($val === false) {
$this->setWarning("Action '{$t}' is not allowed for the current user");
} else {
$vals[$t . 'token'] = $val;
}
}
}
$text = null;
global $wgParser;
if ($this->fld_content || !is_null($this->difftotext)) {
$text = $revision->getText();
// Expand templates after getting section content because
// template-added sections don't count and Parser::preprocess()
// will have less input
if ($this->section !== false) {
$text = $wgParser->getSection($text, $this->section, false);
if ($text === false) {
$this->dieUsage("There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection');
}
}
}
if ($this->fld_content && !$revision->isDeleted(Revision::DELETED_TEXT)) {
if ($this->generateXML) {
$wgParser->startExternalParse($title, ParserOptions::newFromContext($this->getContext()), OT_PREPROCESS);
$dom = $wgParser->preprocessToDom($text);
if (is_callable(array($dom, 'saveXML'))) {
//.........这里部分代码省略.........
示例9: doEditUpdates
/**
* Do standard deferred updates after page edit.
* Update links tables, site stats, search index and message cache.
* Purges pages that include this page if the text was changed here.
* Every 100th edit, prune the recent changes table.
*
* @param $revision Revision object
* @param $user User object that did the revision
* @param $options Array of options, following indexes are used:
* - changed: boolean, whether the revision changed the content (default true)
* - created: boolean, whether the revision created the page (default false)
* - oldcountable: boolean or null (default null):
* - boolean: whether the page was counted as an article before that
* revision, only used in changed is true and created is false
* - null: don't change the article count
*/
public function doEditUpdates(Revision $revision, User $user, array $options = array())
{
global $wgEnableParserCache;
wfProfileIn(__METHOD__);
$options += array('changed' => true, 'created' => false, 'oldcountable' => null);
$content = $revision->getContent();
# Parse the text
# Be careful not to double-PST: $text is usually already PST-ed once
if (!$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag('vary-revision')) {
wfDebug(__METHOD__ . ": No prepared edit or vary-revision is set...\n");
$editInfo = $this->prepareContentForEdit($content, $revision->getId(), $user);
} else {
wfDebug(__METHOD__ . ": No vary-revision, using prepared edit...\n");
$editInfo = $this->mPreparedEdit;
}
# Save it to the parser cache
if ($wgEnableParserCache) {
$parserCache = ParserCache::singleton();
$parserCache->save($editInfo->output, $this, $editInfo->popts);
}
# Update the links tables and other secondary data
$updates = $content->getSecondaryDataUpdates($this->getTitle(), null, true, $editInfo->output);
DataUpdate::runUpdates($updates);
wfRunHooks('ArticleEditUpdates', array(&$this, &$editInfo, $options['changed']));
if (wfRunHooks('ArticleEditUpdatesDeleteFromRecentchanges', array(&$this))) {
if (0 == mt_rand(0, 99)) {
// Flush old entries from the `recentchanges` table; we do this on
// random requests so as to avoid an increase in writes for no good reason
global $wgRCMaxAge;
$dbw = wfGetDB(DB_MASTER);
$cutoff = $dbw->timestamp(time() - $wgRCMaxAge);
$dbw->delete('recentchanges', array("rc_timestamp < '{$cutoff}'"), __METHOD__);
}
}
if (!$this->mTitle->exists()) {
wfProfileOut(__METHOD__);
return;
}
$id = $this->getId();
$title = $this->mTitle->getPrefixedDBkey();
$shortTitle = $this->mTitle->getDBkey();
if (!$options['changed']) {
$good = 0;
$total = 0;
} elseif ($options['created']) {
$good = (int) $this->isCountable($editInfo);
$total = 1;
} elseif ($options['oldcountable'] !== null) {
$good = (int) $this->isCountable($editInfo) - (int) $options['oldcountable'];
$total = 0;
} else {
$good = 0;
$total = 0;
}
DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 1, $good, $total));
DeferredUpdates::addUpdate(new SearchUpdate($id, $title, $content->getTextForSearchIndex()));
#@TODO: let the search engine decide what to do with the content object
# If this is another user's talk page, update newtalk.
# Don't do this if $options['changed'] = false (null-edits) nor if
# it's a minor edit and the user doesn't want notifications for those.
if ($options['changed'] && $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $user->getTitleKey() && !($revision->isMinor() && $user->isAllowed('nominornewtalk'))) {
if (wfRunHooks('ArticleEditUpdateNewTalk', array(&$this))) {
$other = User::newFromName($shortTitle, false);
if (!$other) {
wfDebug(__METHOD__ . ": invalid username\n");
} elseif (User::isIP($shortTitle)) {
// An anonymous user
$other->setNewtalk(true, $revision);
} elseif ($other->isLoggedIn()) {
$other->setNewtalk(true, $revision);
} else {
wfDebug(__METHOD__ . ": don't need to notify a nonexistent user\n");
}
}
}
if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
#XXX: could skip pseudo-messages like js/css here, based on content model.
$msgtext = $content->getWikitextForTransclusion();
if ($msgtext === false || $msgtext === null) {
$msgtext = '';
}
MessageCache::singleton()->replace($shortTitle, $msgtext);
}
if ($options['created']) {
//.........这里部分代码省略.........
示例10: createUpdates
/**
* Perform article updates on a special page creation.
*
* @param Revision $rev
*
* @fixme This is a shitty interface function. Kill it and replace the
* other shitty functions like editUpdates and such so it's not needed
* anymore.
*/
function createUpdates($rev)
{
$this->mGoodAdjustment = $this->isCountable($rev->getText());
$this->mTotalAdjustment = 1;
$this->editUpdates($rev->getText(), $rev->getComment(), $rev->isMinor(), wfTimestamp(), $rev->getId(), true);
}
示例11: extractRowInfo
private function extractRowInfo($row)
{
$revision = new Revision($row);
$title = $revision->getTitle();
$vals = array();
if ($this->fld_ids) {
$vals['revid'] = intval($revision->getId());
// $vals['oldid'] = intval( $row->rev_text_id ); // todo: should this be exposed?
if (!is_null($revision->getParentId())) {
$vals['parentid'] = intval($revision->getParentId());
}
}
if ($this->fld_flags && $revision->isMinor()) {
$vals['minor'] = '';
}
if ($this->fld_user || $this->fld_userid) {
if ($revision->isDeleted(Revision::DELETED_USER)) {
$vals['userhidden'] = '';
} else {
if ($this->fld_user) {
$vals['user'] = $revision->getUserText();
}
$userid = $revision->getUser();
if (!$userid) {
$vals['anon'] = '';
}
if ($this->fld_userid) {
$vals['userid'] = $userid;
}
}
}
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $revision->getTimestamp());
}
if ($this->fld_size) {
if (!is_null($revision->getSize())) {
$vals['size'] = intval($revision->getSize());
} else {
$vals['size'] = 0;
}
}
if ($this->fld_sha1) {
if ($revision->getSha1() != '') {
$vals['sha1'] = wfBaseConvert($revision->getSha1(), 36, 16, 40);
} else {
$vals['sha1'] = '';
}
}
if ($this->fld_contentmodel) {
$vals['contentmodel'] = $revision->getContentModel();
}
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($revision->isDeleted(Revision::DELETED_COMMENT)) {
$vals['commenthidden'] = '';
} else {
$comment = $revision->getComment();
if ($this->fld_comment) {
$vals['comment'] = $comment;
}
if ($this->fld_parsedcomment) {
$vals['parsedcomment'] = Linker::formatComment($comment, $title);
}
}
}
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], $title->getArticleID(), $title, $revision);
if ($val === false) {
$this->setWarning("Action '{$t}' is not allowed for the current user");
} else {
$vals[$t . 'token'] = $val;
}
}
}
$content = null;
global $wgParser;
if ($this->fld_content || !is_null($this->difftotext)) {
$content = $revision->getContent();
// Expand templates after getting section content because
// template-added sections don't count and Parser::preprocess()
// will have less input
if ($this->section !== false) {
$content = $content->getSection($this->section, false);
if (!$content) {
$this->dieUsage("There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection');
}
}
}
if ($this->fld_content && !$revision->isDeleted(Revision::DELETED_TEXT)) {
$text = null;
//.........这里部分代码省略.........