本文整理汇总了PHP中Revision::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::getId方法的具体用法?PHP Revision::getId怎么用?PHP Revision::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hrDiffViewHeaderHook
/**
* Hook for diff view, giving us a chance to insert a removal
* tab on old version views.
*
* @param $diff
* @param $oldRev
* @param Revision $newRev
*/
function hrDiffViewHeaderHook($diff, $oldRev, $newRev)
{
if (!empty($newRev) && $newRev->getId()) {
hrInstallTab($newRev->getId());
}
return true;
}
示例2: getRevIncludes
/**
* Get template and image versions from parsing a revision
* @param Page $article
* @param Revision $rev
* @param User $user
* @param string $regen use 'regen' to force regeneration
* @return array( templateIds, fileSHA1Keys )
* templateIds like ParserOutput->mTemplateIds
* fileSHA1Keys like ParserOutput->mImageTimeKeys
*/
public static function getRevIncludes(Page $article, Revision $rev, User $user, $regen = '')
{
global $wgParser, $wgMemc;
wfProfileIn(__METHOD__);
$versions = false;
$key = self::getCacheKey($article->getTitle(), $rev->getId());
if ($regen !== 'regen') {
// check cache
$versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article, 'allowStale');
}
if (!is_array($versions)) {
// cache miss
$pOut = false;
if ($rev->isCurrent()) {
$parserCache = ParserCache::singleton();
# Try current version parser cache (as anon)...
$pOut = $parserCache->get($article, $article->makeParserOptions($user));
if ($pOut == false && $rev->getUser()) {
// try the user who saved the change
$author = User::newFromId($rev->getUser());
$pOut = $parserCache->get($article, $article->makeParserOptions($author));
}
}
// ParserOutput::mImageTimeKeys wasn't always there
if ($pOut == false || !FlaggedRevs::parserOutputIsVersioned($pOut)) {
$title = $article->getTitle();
$pOpts = ParserOptions::newFromUser($user);
// Note: tidy off
$pOut = $wgParser->parse($rev->getText(), $title, $pOpts, true, true, $rev->getId());
}
# Get the template/file versions used...
$versions = array($pOut->getTemplateIds(), $pOut->getFileSearchOptions());
# Save to cache (check cache expiry for dynamic elements)...
$data = FlaggedRevs::makeMemcObj($versions);
$wgMemc->set($key, $data, $pOut->getCacheExpiry());
} else {
$tVersions =& $versions[0];
// templates
# Do a link batch query for page_latest...
$lb = new LinkBatch();
foreach ($tVersions as $ns => $tmps) {
foreach ($tmps as $dbKey => $revIdDraft) {
$lb->add($ns, $dbKey);
}
}
$lb->execute();
# Update array with the current page_latest values.
# This kludge is there since $newTemplates (thus $revIdDraft) is cached.
foreach ($tVersions as $ns => &$tmps) {
foreach ($tmps as $dbKey => &$revIdDraft) {
$title = Title::makeTitle($ns, $dbKey);
$revIdDraft = (int) $title->getLatestRevID();
}
}
}
wfProfileOut(__METHOD__);
return $versions;
}
示例3: getRevIncludes
/**
* Get template and image versions from parsing a revision
* @param Page $article
* @param Revision $rev
* @param User $user
* @param string $regen use 'regen' to force regeneration
* @return array( templateIds, fileSHA1Keys )
* templateIds like ParserOutput->mTemplateIds
* fileSHA1Keys like ParserOutput->mImageTimeKeys
*/
public static function getRevIncludes(Page $article, Revision $rev, User $user, $regen = '')
{
global $wgMemc;
wfProfileIn(__METHOD__);
$key = self::getCacheKey($article->getTitle(), $rev->getId());
if ($regen === 'regen') {
$versions = false;
// skip cache
} elseif ($rev->isCurrent()) {
// Check cache entry against page_touched
$versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article);
} else {
// Old revs won't always be invalidated with template/file changes.
// Also, we don't care if page_touched changed due to a direct edit.
$versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article, 'allowStale');
if (is_array($versions)) {
// entry exists
// Sanity check that the cache is reasonably up to date
list($templates, $files) = $versions;
if (self::templatesStale($templates) || self::filesStale($files)) {
$versions = false;
// no good
}
}
}
if (!is_array($versions)) {
// cache miss
$pOut = false;
if ($rev->isCurrent()) {
$parserCache = ParserCache::singleton();
# Try current version parser cache for this user...
$pOut = $parserCache->get($article, $article->makeParserOptions($user));
if ($pOut == false) {
# Try current version parser cache for the revision author...
$optsUser = $rev->getUser() ? User::newFromId($rev->getUser()) : 'canonical';
$pOut = $parserCache->get($article, $article->makeParserOptions($optsUser));
}
}
// ParserOutput::mImageTimeKeys wasn't always there
if ($pOut == false || !FlaggedRevs::parserOutputIsVersioned($pOut)) {
$content = $rev->getContent(Revision::RAW);
if (!$content) {
// Just for extra sanity
$pOut = new ParserOutput();
} else {
$pOut = $content->getParserOutput($article->getTitle(), $rev->getId(), ParserOptions::newFromUser($user));
}
}
# Get the template/file versions used...
$versions = array($pOut->getTemplateIds(), $pOut->getFileSearchOptions());
# Save to cache (check cache expiry for dynamic elements)...
$data = FlaggedRevs::makeMemcObj($versions);
$wgMemc->set($key, $data, $pOut->getCacheExpiry());
}
wfProfileOut(__METHOD__);
return $versions;
}
示例4: getDiffLink
/**
* Get the HTML link to the diff.
* Overridden by RevDelArchiveItem
* @return string
*/
protected function getDiffLink()
{
if ($this->isDeleted() && !$this->canViewContent()) {
return $this->list->msg('diff')->escaped();
} else {
return Linker::linkKnown($this->list->title, $this->list->msg('diff')->escaped(), array(), array('diff' => $this->revision->getId(), 'oldid' => 'prev', 'unhide' => 1));
}
}
示例5: assertRevEquals
protected function assertRevEquals(Revision $orig, Revision $rev = null)
{
$this->assertNotNull($rev, 'missing revision');
$this->assertEquals($orig->getId(), $rev->getId());
$this->assertEquals($orig->getPage(), $rev->getPage());
$this->assertEquals($orig->getTimestamp(), $rev->getTimestamp());
$this->assertEquals($orig->getUser(), $rev->getUser());
$this->assertEquals($orig->getSha1(), $rev->getSha1());
}
示例6: runForTitleInternal
public static function runForTitleInternal(Title $title, Revision $revision, $fname)
{
global $wgParser, $wgContLang;
wfProfileIn($fname . '-parse');
$options = ParserOptions::newFromUserAndLang(new User(), $wgContLang);
$parserOutput = $wgParser->parse($revision->getText(), $title, $options, true, true, $revision->getId());
wfProfileOut($fname . '-parse');
wfProfileIn($fname . '-update');
$updates = $parserOutput->getSecondaryDataUpdates($title, false);
DataUpdate::runUpdates($updates);
wfProfileOut($fname . '-update');
}
示例7: loadRevisionData
/**
* Load revision metadata for the specified articles. If newid is 0, then compare
* the old article in oldid to the current article; if oldid is 0, then
* compare the current article to the immediately previous one (ignoring the
* value of newid).
*
* If oldid is false, leave the corresponding revision object set
* to false. This is impossible via ordinary user input, and is provided for
* API convenience.
*
* @return bool
*/
public function loadRevisionData()
{
if ($this->mRevisionsLoaded) {
return true;
}
// Whether it succeeds or fails, we don't want to try again
$this->mRevisionsLoaded = true;
$this->loadRevisionIds();
// Load the new revision object
if ($this->mNewid) {
$this->mNewRev = Revision::newFromId($this->mNewid);
} else {
$this->mNewRev = Revision::newFromTitle($this->getTitle(), false, Revision::READ_NORMAL);
}
if (!$this->mNewRev instanceof Revision) {
return false;
}
// Update the new revision ID in case it was 0 (makes life easier doing UI stuff)
$this->mNewid = $this->mNewRev->getId();
$this->mNewPage = $this->mNewRev->getTitle();
// Load the old revision object
$this->mOldRev = false;
if ($this->mOldid) {
$this->mOldRev = Revision::newFromId($this->mOldid);
} elseif ($this->mOldid === 0) {
$rev = $this->mNewRev->getPrevious();
if ($rev) {
$this->mOldid = $rev->getId();
$this->mOldRev = $rev;
} else {
// No previous revision; mark to show as first-version only.
$this->mOldid = false;
$this->mOldRev = false;
}
}
/* elseif ( $this->mOldid === false ) leave mOldRev false; */
if (is_null($this->mOldRev)) {
return false;
}
if ($this->mOldRev) {
$this->mOldPage = $this->mOldRev->getTitle();
}
// Load tags information for both revisions
$dbr = wfGetDB(DB_SLAVE);
if ($this->mOldid !== false) {
$this->mOldTags = $dbr->selectField('tag_summary', 'ts_tags', array('ts_rev_id' => $this->mOldid), __METHOD__);
} else {
$this->mOldTags = false;
}
$this->mNewTags = $dbr->selectField('tag_summary', 'ts_tags', array('ts_rev_id' => $this->mNewid), __METHOD__);
return true;
}
示例8: fetchContent
/**
* Get text of an article from database
* Does *NOT* follow redirects.
*
* @return mixed string containing article contents, or false if null
*/
function fetchContent()
{
if ($this->mContentLoaded) {
return $this->mContent;
}
wfProfileIn(__METHOD__);
$this->mContentLoaded = true;
$oldid = $this->getOldID();
# Pre-fill content with error message so that if something
# fails we'll have something telling us what we intended.
$t = $this->getTitle()->getPrefixedText();
$d = $oldid ? wfMsgExt('missingarticle-rev', array('escape'), $oldid) : '';
$this->mContent = wfMsgNoTrans('missing-article', $t, $d);
if ($oldid) {
# $this->mRevision might already be fetched by getOldIDFromRequest()
if (!$this->mRevision) {
$this->mRevision = Revision::newFromId($oldid);
if (!$this->mRevision) {
wfDebug(__METHOD__ . " failed to retrieve specified revision, id {$oldid}\n");
Wikia::log(__METHOD__, 1, "failed to retrieve specified revision, title '{$t}', id {$oldid}", true);
# Wikia change - @author macbre
wfProfileOut(__METHOD__);
return false;
}
}
} else {
if (!$this->mPage->getLatest()) {
wfDebug(__METHOD__ . " failed to find page data for title " . $this->getTitle()->getPrefixedText() . "\n");
wfProfileOut(__METHOD__);
return false;
}
$this->mRevision = $this->mPage->getRevision();
if (!$this->mRevision) {
wfDebug(__METHOD__ . " failed to retrieve current page, rev_id " . $this->mPage->getLatest() . "\n");
Wikia::log(__METHOD__, 3, "failed to retrieve current page, title '{$t}', rev_id " . $this->mPage->getLatest(), true);
# Wikia change - @author macbre
wfProfileOut(__METHOD__);
return false;
}
}
// @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
// We should instead work with the Revision object when we need it...
$this->mContent = $this->mRevision->getText(Revision::FOR_THIS_USER);
// Loads if user is allowed
$this->mRevIdFetched = $this->mRevision->getId();
wfRunHooks('ArticleAfterFetchContent', array(&$this, &$this->mContent));
wfProfileOut(__METHOD__);
return $this->mContent;
}
示例9: cleanupArticle
/**
* Find the latest revision of the article that does not contain spam and revert to it
*/
function cleanupArticle(Revision $rev, $regexes, $match)
{
$title = $rev->getTitle();
$revId = $rev->getId();
while ($rev) {
$matches = false;
foreach ($regexes as $regex) {
$matches = $matches || preg_match($regex, $rev->getText());
}
if (!$matches) {
// Didn't find any spam
break;
}
# Revision::getPrevious can't be used in this way before MW 1.6 (Revision.php 1.26)
#$rev = $rev->getPrevious();
$revId = $title->getPreviousRevisionID($revId);
if ($revId) {
$rev = Revision::newFromTitle($title, $revId);
} else {
$rev = false;
}
}
$dbw = wfGetDB(DB_MASTER);
$dbw->begin();
if (!$rev) {
// Didn't find a non-spammy revision, delete the page
/*
print "All revisions are spam, deleting...\n";
$article = new Article( $title );
$article->doDeleteArticle( "All revisions matched the spam blacklist" );
*/
// Too scary, blank instead
print "All revisions are spam, blanking...\n";
$text = '';
$comment = "All revisions matched the spam blacklist ({$match}), blanking";
} else {
// Revert to this revision
$text = $rev->getText();
$comment = "Cleaning up links to {$match}";
}
$wikiPage = new WikiPage($title);
$wikiPage->doEdit($text, $comment);
$dbw->commit();
}
示例10: showDiff
/**
* Render the inline difference between two revisions
* using InlineDiffEngine
*/
function showDiff()
{
$ctx = MobileContext::singleton();
$prevId = $this->prevRev ? $this->prevRev->getId() : 0;
$unhide = (bool) $this->getRequest()->getVal('unhide');
$contentHandler = $this->rev->getContentHandler();
$de = $contentHandler->createDifferenceEngine($this->getContext(), $prevId, $this->revId);
// HACK:
if (get_class($de) == 'DifferenceEngine') {
$de = new $this->diffClass($this->getContext(), $prevId, $this->revId, 0, false, $unhide);
} else {
$de->showDiffPage();
return;
}
$this->mDiffEngine = $de;
$diff = $de->getDiffBody();
if (!$prevId) {
$audience = $unhide ? Revision::FOR_THIS_USER : Revision::FOR_PUBLIC;
$diff = '<ins>' . nl2br(htmlspecialchars($this->rev->getText($audience))) . '</ins>';
}
$warnings = $de->getWarningMessageText();
if ($warnings) {
$warnings = MobileUI::warningBox($warnings);
}
$this->getOutput()->addHtml($warnings . '<div id="mw-mf-minidiff">' . $diff . '</div>');
$prev = $this->rev->getPrevious();
$next = $this->rev->getNext();
if ($prev || $next) {
$history = Html::openElement('ul', array('class' => 'hlist revision-history-links'));
if ($prev) {
$history .= Html::openElement('li') . Html::element('a', array('href' => SpecialPage::getTitleFor('MobileDiff', $prev->getId())->getLocalUrl()), $this->msg('previousdiff')) . Html::closeElement('li');
}
if ($next) {
$history .= Html::openElement('li') . Html::element('a', array('href' => SpecialPage::getTitleFor('MobileDiff', $next->getId())->getLocalUrl()), $this->msg('nextdiff')) . Html::closeElement('li');
}
$history .= Html::closeElement('ul');
$this->getOutput()->addHtml($history);
}
}
示例11: doReview
/**
* Executes the real stuff. No checks done!
* @param User $user
* @param Revision $revision
* @param null|string $comment
* @return Bool, whether the action was recorded.
*/
public static function doReview(User $user, Revision $revision, $comment = null)
{
$dbw = wfGetDB(DB_MASTER);
$table = 'translate_reviews';
$row = array('trr_user' => $user->getId(), 'trr_page' => $revision->getPage(), 'trr_revision' => $revision->getId());
$options = array('IGNORE');
$dbw->insert($table, $row, __METHOD__, $options);
if (!$dbw->affectedRows()) {
return false;
}
$title = $revision->getTitle();
$entry = new ManualLogEntry('translationreview', 'message');
$entry->setPerformer($user);
$entry->setTarget($title);
$entry->setComment($comment);
$entry->setParameters(array('4::revision' => $revision->getId()));
$logid = $entry->insert();
$entry->publish($logid);
$handle = new MessageHandle($title);
Hooks::run('TranslateEventTranslationReview', array($handle));
return true;
}
示例12: diffHeader
/**
* @param Revision $rev
* @param string $prefix
* @return string
*/
private function diffHeader($rev, $prefix)
{
$isDeleted = !($rev->getId() && $rev->getTitle());
if ($isDeleted) {
/// @todo FIXME: $rev->getTitle() is null for deleted revs...?
$targetPage = $this->getPageTitle();
$targetQuery = array('target' => $this->mTargetObj->getPrefixedText(), 'timestamp' => wfTimestamp(TS_MW, $rev->getTimestamp()));
} else {
/// @todo FIXME: getId() may return non-zero for deleted revs...
$targetPage = $rev->getTitle();
$targetQuery = array('oldid' => $rev->getId());
}
// Add show/hide deletion links if available
$user = $this->getUser();
$lang = $this->getLanguage();
$rdel = Linker::getRevDeleteLink($user, $rev, $this->mTargetObj);
if ($rdel) {
$rdel = " {$rdel}";
}
$minor = $rev->isMinor() ? ChangesList::flag('minor') : '';
$tags = wfGetDB(DB_SLAVE)->selectField('tag_summary', 'ts_tags', array('ts_rev_id' => $rev->getId()), __METHOD__);
$tagSummary = ChangeTags::formatSummaryRow($tags, 'deleteddiff');
// FIXME This is reimplementing DifferenceEngine#getRevisionHeader
// and partially #showDiffPage, but worse
return '<div id="mw-diff-' . $prefix . 'title1"><strong>' . Linker::link($targetPage, $this->msg('revisionasof', $lang->userTimeAndDate($rev->getTimestamp(), $user), $lang->userDate($rev->getTimestamp(), $user), $lang->userTime($rev->getTimestamp(), $user))->escaped(), array(), $targetQuery) . '</strong></div>' . '<div id="mw-diff-' . $prefix . 'title2">' . Linker::revUserTools($rev) . '<br />' . '</div>' . '<div id="mw-diff-' . $prefix . 'title3">' . $minor . Linker::revComment($rev) . $rdel . '<br />' . '</div>' . '<div id="mw-diff-' . $prefix . 'title5">' . $tagSummary[0] . '<br />' . '</div>';
}
示例13: 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
示例14: saveComplete
/**
* saveComplete -- hook
*
* @static
* @access public
*
* @param WikiPage $oArticle,
* @param User $User
*
* @author Piotr Molski (MoLi)
* @return true
*/
public static function saveComplete(&$oArticle, &$oUser, $text, $summary, $minor, $undef1, $undef2, &$flags, Revision $oRevision, &$status, $baseRevId)
{
global $wgCityId;
wfProfileIn(__METHOD__);
$revId = $pageId = 0;
if (is_object($oArticle) && $oUser instanceof User) {
# revision
if ($oRevision instanceof Revision) {
$revId = $oRevision->getId();
$pageId = $oRevision->getPage();
}
if (empty($revId)) {
$revId = $oArticle->getTitle()->getLatestRevID(Title::GAID_FOR_UPDATE);
}
# article
if (empty($pageId) || $pageId < 0) {
$pageId = $oArticle->getID();
}
if ($revId > 0 && $pageId > 0) {
$key = isset($status->value['new']) && $status->value['new'] == 1 ? 'create' : 'edit';
$oScribeProducer = new ScribeProducer($key, $pageId, $revId, 0, !empty($undef1) ? 1 : 0);
if (is_object($oScribeProducer)) {
$oScribeProducer->send_log();
}
} else {
Wikia::log(__METHOD__, "error", "Cannot send log via scribe ({$wgCityId}): revision not found for page: {$pageId}");
}
} else {
$isArticle = is_object($oArticle);
$isUser = is_object($oUser);
Wikia::log(__METHOD__, "error", "Cannot send log via scribe ({$wgCityId}): invalid user: {$isUser}, invalid article: {$isArticle}");
}
wfProfileOut(__METHOD__);
return true;
}
示例15: getParserOutput
protected function getParserOutput(WikiPage $page, Revision $rev)
{
$parserOptions = $page->makeParserOptions($this->getContext());
if (!$rev->isCurrent() || !$rev->getTitle()->quickUserCan("edit")) {
$parserOptions->setEditSection(false);
}
$parserOutput = $page->getParserOutput($parserOptions, $rev->getId());
return $parserOutput;
}