当前位置: 首页>>代码示例>>PHP>>正文


PHP Revision::newFromId方法代码示例

本文整理汇总了PHP中Revision::newFromId方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::newFromId方法的具体用法?PHP Revision::newFromId怎么用?PHP Revision::newFromId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Revision的用法示例。


在下文中一共展示了Revision::newFromId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testHidingRevisions

 public function testHidingRevisions()
 {
     $user = self::$users['sysop']->getUser();
     $revid = array_shift($this->revs);
     $out = $this->doApiRequest(array('action' => 'revisiondelete', 'type' => 'revision', 'target' => self::$page, 'ids' => $revid, 'hide' => 'content|user|comment', 'token' => $user->getEditToken()));
     // Check the output
     $out = $out[0]['revisiondelete'];
     $this->assertEquals($out['status'], 'Success');
     $this->assertArrayHasKey('items', $out);
     $item = $out['items'][0];
     $this->assertArrayHasKey('userhidden', $item);
     $this->assertArrayHasKey('commenthidden', $item);
     $this->assertArrayHasKey('texthidden', $item);
     $this->assertEquals($item['id'], $revid);
     // Now check that that revision was actually hidden
     $rev = Revision::newFromId($revid);
     $this->assertEquals($rev->getContent(Revision::FOR_PUBLIC), null);
     $this->assertEquals($rev->getComment(Revision::FOR_PUBLIC), '');
     $this->assertEquals($rev->getUser(Revision::FOR_PUBLIC), 0);
     // Now test unhiding!
     $out2 = $this->doApiRequest(array('action' => 'revisiondelete', 'type' => 'revision', 'target' => self::$page, 'ids' => $revid, 'show' => 'content|user|comment', 'token' => $user->getEditToken()));
     // Check the output
     $out2 = $out2[0]['revisiondelete'];
     $this->assertEquals($out2['status'], 'Success');
     $this->assertArrayHasKey('items', $out2);
     $item = $out2['items'][0];
     $this->assertArrayNotHasKey('userhidden', $item);
     $this->assertArrayNotHasKey('commenthidden', $item);
     $this->assertArrayNotHasKey('texthidden', $item);
     $this->assertEquals($item['id'], $revid);
     $rev = Revision::newFromId($revid);
     $this->assertNotEquals($rev->getContent(Revision::FOR_PUBLIC), null);
     $this->assertNotEquals($rev->getComment(Revision::FOR_PUBLIC), '');
     $this->assertNotEquals($rev->getUser(Revision::FOR_PUBLIC), 0);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:35,代码来源:ApiRevisionDeleteTest.php

示例2: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $rev1 = $this->revisionOrTitleOrId($params['fromrev'], $params['fromtitle'], $params['fromid']);
     $rev2 = $this->revisionOrTitleOrId($params['torev'], $params['totitle'], $params['toid']);
     $revision = Revision::newFromId($rev1);
     if (!$revision) {
         $this->dieUsage('The diff cannot be retrieved, ' . 'one revision does not exist or you do not have permission to view it.', 'baddiff');
     }
     $contentHandler = $revision->getContentHandler();
     $de = $contentHandler->createDifferenceEngine($this->getContext(), $rev1, $rev2, null, true, false);
     $vals = array();
     if (isset($params['fromtitle'])) {
         $vals['fromtitle'] = $params['fromtitle'];
     }
     if (isset($params['fromid'])) {
         $vals['fromid'] = $params['fromid'];
     }
     $vals['fromrevid'] = $rev1;
     if (isset($params['totitle'])) {
         $vals['totitle'] = $params['totitle'];
     }
     if (isset($params['toid'])) {
         $vals['toid'] = $params['toid'];
     }
     $vals['torevid'] = $rev2;
     $difftext = $de->getDiffBody();
     if ($difftext === false) {
         $this->dieUsage('The diff cannot be retrieved. Maybe one or both revisions do ' . 'not exist or you do not have permission to view them.', 'baddiff');
     }
     ApiResult::setContentValue($vals, 'body', $difftext);
     $this->getResult()->addValue(null, $this->getModuleName(), $vals);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:33,代码来源:ApiComparePages.php

示例3: articleCountWordDiff

 public static function articleCountWordDiff(&$article, &$user, $newText, $summary, $flag, $fake1, $fake2, &$flags, $revision, &$status, $baseRevId)
 {
     global $wgContentNamespaces, $wgSitename;
     wfProfileIn(__METHOD__);
     if (is_null($revision)) {
         // nothing's changed, quit early
         wfProfileOut(__METHOD__);
         return true;
     }
     if (!in_array($article->getTitle()->getNamespace(), $wgContentNamespaces)) {
         wfProfileOut(__METHOD__);
         return true;
     }
     // do not push reverts
     $baseRevision = Revision::newFromId($baseRevId);
     if ($baseRevision && $revision->getTextId() == $baseRevision->getTextId()) {
         wfProfileOut(__METHOD__);
         return true;
     }
     $diff = 0;
     $wNewCount = strlen($newText);
     $wOldCount = strlen($article->getRawText());
     $countDiff = $wNewCount - $wOldCount;
     if ($countDiff > self::$MIN_CHARS_TO_PUSH) {
         $params = array('$ARTICLENAME' => $article->getTitle()->getText(), '$WIKINAME' => $wgSitename, '$ARTICLE_URL' => $article->getTitle()->getFullURL("ref=fbfeed&fbtype=largeedit"), '$EVENTIMG' => self::$eventImage, '$SUMMART' => $summary, '$TEXT' => self::shortenText(self::parseArticle($article, $newText)));
         self::pushEvent(self::$messageName, $params, __CLASS__);
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:30,代码来源:FBPush_OnLargeEdit.php

示例4: parseWikitext

 protected function parseWikitext($title, $newRevId)
 {
     $apiParams = array('action' => 'parse', 'page' => $title->getPrefixedDBkey(), 'oldid' => $newRevId, 'prop' => 'text|revid|categorieshtml|displaytitle|modules|jsconfigvars');
     $api = new ApiMain(new DerivativeRequest($this->getRequest(), $apiParams, false), true);
     $api->execute();
     if (defined('ApiResult::META_CONTENT')) {
         $result = $api->getResult()->getResultData(null, array('BC' => array(), 'Types' => array(), 'Strip' => 'all'));
     } else {
         $result = $api->getResultData();
     }
     $content = isset($result['parse']['text']['*']) ? $result['parse']['text']['*'] : false;
     $categorieshtml = isset($result['parse']['categorieshtml']['*']) ? $result['parse']['categorieshtml']['*'] : false;
     $links = isset($result['parse']['links']) ? $result['parse']['links'] : array();
     $revision = Revision::newFromId($result['parse']['revid']);
     $timestamp = $revision ? $revision->getTimestamp() : wfTimestampNow();
     $displaytitle = isset($result['parse']['displaytitle']) ? $result['parse']['displaytitle'] : false;
     $modules = isset($result['parse']['modules']) ? $result['parse']['modules'] : array();
     $jsconfigvars = isset($result['parse']['jsconfigvars']) ? $result['parse']['jsconfigvars'] : array();
     if ($content === false || strlen($content) && $revision === null) {
         return false;
     }
     if ($displaytitle !== false) {
         // Escape entities as in OutputPage::setPageTitle()
         $displaytitle = Sanitizer::normalizeCharReferences(Sanitizer::removeHTMLtags($displaytitle));
     }
     return array('content' => $content, 'categorieshtml' => $categorieshtml, 'basetimestamp' => $timestamp, 'starttimestamp' => wfTimestampNow(), 'displayTitleHtml' => $displaytitle, 'modules' => $modules, 'jsconfigvars' => $jsconfigvars);
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:27,代码来源:ApiVisualEditorEdit.php

示例5: 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);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:30,代码来源:ApiPatrol.php

示例6: logTagAdded

 protected function logTagAdded($tags, $revId, $user, $reason)
 {
     // log it
     $logEntry = new ManualLogEntry('tag', 'update');
     $logEntry->setPerformer($user);
     $logEntry->setComment($reason);
     // find the appropriate target page
     if ($revId) {
         $rev = Revision::newFromId($revId);
         if ($rev) {
             $logEntry->setTarget($rev->getTitle());
         }
     }
     if (!$logEntry->getTarget()) {
         // target is required, so we have to set something
         $logEntry->setTarget(SpecialPage::getTitleFor('Tags'));
     }
     $logParams = array('4::revid' => $revId, '6:list:tagsAdded' => $tags, '7:number:tagsAddedCount' => count($tags));
     $logEntry->setParameters($logParams);
     $logEntry->setRelations(array('Tag' => $tags));
     $dbw = wfGetDB(DB_MASTER);
     $logId = $logEntry->insert($dbw);
     // Only send this to UDP, not RC, similar to patrol events
     $logEntry->publish($logId, 'udp');
     //$logEntry->publish( $logId );
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-MarkMajorChanges,代码行数:26,代码来源:MarkMajorChangeAction.php

示例7: getBoardInfo

 /**
  * get board info: the number of threads, the number of posts, the username and timestamp of the last post
  * @return array $info
  */
 public function getBoardInfo($db = DB_SLAVE)
 {
     wfProfileIn(__METHOD__);
     $memKey = wfMemcKey('forum_board_info', $this->getId());
     if ($db == DB_SLAVE) {
         $info = $this->wg->Memc->get($memKey);
     }
     if (empty($info)) {
         $db = wfGetDB($db);
         $row = $db->selectRow(array('comments_index'), array('count(if(parent_comment_id=0,1,null)) threads, count(*) posts, max(first_rev_id) rev_id'), array('parent_page_id' => $this->getId(), 'archived' => 0, 'deleted' => 0, 'removed' => 0), __METHOD__);
         $info = array('postCount' => 0, 'threadCount' => 0);
         if ($row) {
             $info = array('postCount' => $row->posts, 'threadCount' => $row->threads);
             // get last post info
             $revision = Revision::newFromId($row->rev_id);
             if ($revision instanceof Revision) {
                 if ($revision->getRawUser() == 0) {
                     $username = wfMsg('oasis-anon-user');
                 } else {
                     $username = $revision->getRawUserText();
                 }
                 $userprofile = Title::makeTitle($this->wg->EnableWallExt ? NS_USER_WALL : NS_USER_TALK, $username)->getFullURL();
                 $info['lastPost'] = array('username' => $username, 'userprofile' => $userprofile, 'timestamp' => $revision->getTimestamp());
             }
         }
         $this->wg->Memc->set($memKey, $info, 60 * 60 * 12);
     }
     wfProfileOut(__METHOD__);
     return $info;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:ForumBoard.class.php

示例8: moddate

 /**
  * @param Parser $parser
  * @return string
  */
 public static function moddate($parser)
 {
     $title = $parser->getTitle();
     if (!$title || !$title->exists()) {
         return '';
     }
     $lastRev = Revision::newFromId($title->getLatestRevID());
     return date("j M Y", wfTimestamp(TS_UNIX, $lastRev->getTimestamp()));
 }
开发者ID:vedmaka,项目名称:SettleInSkin,代码行数:13,代码来源:stools.class.php

示例9: feedItemDesc

 function feedItemDesc($row)
 {
     if (isset($row->rev_id)) {
         $revision = Revision::newFromId($row->rev_id);
         if ($revision) {
             return '<p>' . htmlspecialchars(wfMsg('summary')) . ': ' . $text . "</p>\n<hr />\n<div>" . nl2br(htmlspecialchars($revision->getText())) . "</div>";
         }
     }
     return parent::feedItemDesc($row);
 }
开发者ID:BackupTheBerlios,项目名称:enotifwiki,代码行数:10,代码来源:SpecialNewpages.php

示例10: getResultParams

 public function getResultParams()
 {
     $testInfo = $this->getTestInfo();
     $r = Revision::newFromId($testInfo['rq_rev_new']);
     if (!$r) {
         throw new Exception("Unable to create revision from testInfo['rq_rev_new'] = {$testInfo['rq_rev_new']}");
     }
     $params['title'] = $r->getTitle();
     $params['old'] = $testInfo['rq_rev_old'];
     $params['new'] = $testInfo['rq_rev_new'];
     return $params;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:12,代码来源:RCTest.class.php

示例11: execute

	public function execute() {
		global $wgUser;
		if ( !$wgUser->isallowed( self::$right ) ) {
			$this->dieUsage( 'Permission denied', 'permissiondenied' );
		}

		$params = $this->extractRequestParams();

		$revision = Revision::newFromId( $params['revision'] );
		if ( !$revision ) {
			$this->dieUsage( 'Invalid revision', 'invalidrevision' );
		}

		$title = $revision->getTitle();
		$handle = new MessageHandle( $title );
		if ( !$handle->isValid() ) {
			$this->dieUsage( 'Unknown message', 'unknownmessage' );
		}

		if ( $handle->isFuzzy() ) {
			$this->dieUsage( 'Cannot review fuzzy translations', 'fuzzymessage' );
		}

		if ( $revision->getUser() == $wgUser->getId() ) {
			$this->dieUsage( 'Cannot review own translations', 'owntranslation' );
		}

		$dbw = wfGetDB( DB_MASTER );
		$table = 'translate_reviews';
		$row = array(
			'trr_user' => $wgUser->getId(),
			'trr_page' => $revision->getPage(),
			'trr_revision' => $revision->getId(),
		);
		$options = array( 'IGNORE' );
		$res = $dbw->insert( $table, $row, __METHOD__, $options );
		if ( !$dbw->affectedRows() ) {
			$this->setWarning( 'Already marked as reviewed by you' );
		} else {
			$logger = new LogPage( 'translationreview' );
			$params = array( $revision->getId() );
			$logger->addEntry( 'message', $title, null, $params, $wgUser );
		}

		$output = array( 'review' => array(
			'title' => $title->getPrefixedText(),
			'pageid' => $revision->getPage(),
			'revision' => $revision->getId()
		) );

		$this->getResult()->addValue( null, $this->getModuleName(), $output );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:52,代码来源:ApiTranslationReview.php

示例12: revertTips

 public static function revertTips($user, $cutoff, $cutoff2, $unpatrol_limit)
 {
     global $wgLang, $wgOut;
     //max number of possible unpatrols
     $limit = array();
     if (!empty($unpatrol_limit)) {
         $limit = array('LIMIT' => $unpatrol_limit);
     }
     $dbw = wfGetDB(DB_MASTER);
     $options = array('tw_user' => $user->getID(), "tw_timestamp > '{$cutoff}'");
     if ($cutoff2) {
         $options[] = "tw_timestamp < '{$cutoff2}'";
     }
     $res = $dbw->select('tipsandwarnings_log', array('tw_id', 'tw_rev_this'), $options, __METHOD__, $limit);
     $tipIds = array();
     while ($row = $dbw->fetchObject($res)) {
         $tipIds[$row->tw_id] = $row->tw_rev_this;
     }
     wfRunHooks('UnpatrolTips', array(&$tipIds));
     $count = sizeof($tipIds);
     foreach ($tipIds as $tipId => $revId) {
         // undo the tip
         $success = TipsPatrol::undoTip($tipId);
         if ($revId) {
             $revision = Revision::newFromId($revId);
             $title = $revision->getTitle();
             if (!$success) {
                 $wgOut->addHTML("failed to undo tip: {$tipId} with revId: {$revId} with Title: {$title}<br>");
                 continue;
             }
             $wgOut->addHTML("undid approved tip: {$tipId} with revId: {$revId} with Title: {$title}<br>");
         } else {
             $wgOut->addHTML("undid rejected tip: {$tipId} <br>");
         }
     }
     //log the change
     $logTitle = Title::newFromText('Special:UnpatrolTips');
     $logPage = new LogPage('undotips', false);
     $logData = array();
     $logMessage = "[[User:" . $user->getName() . "]]: {$count} tip patrols undone";
     $logPage->addEntry('unpatrol', $logTitle, $logMessage, $logData);
     // set the original logs to be deleted
     unset($options);
     $options = array('log_user' => $user->getID(), 'log_type' => 'newtips', "log_timestamp > '{$cutoff}'", 'log_deleted' => 0);
     if ($cutoff2) {
         $options[] = "tw_timestamp < '{$cutoff2}'";
     }
     $res = $dbw->update('logging', array('log_deleted' => 1), $options, __METHOD__, $limit);
     return $count;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:50,代码来源:Unpatrol.body.php

示例13: execute

 public function execute()
 {
     if (!$this->getUser()->isAllowed(self::$right)) {
         $this->dieUsage('Permission denied', 'permissiondenied');
     }
     $params = $this->extractRequestParams();
     $revision = Revision::newFromId($params['revision']);
     if (!$revision) {
         $this->dieUsage('Invalid revision', 'invalidrevision');
     }
     $error = self::getReviewBlockers($this->getUser(), $revision);
     switch ($error) {
         case '':
             // Everything is okay
             break;
         case 'permissiondenied':
             $this->dieUsage('Permission denied', $error);
             break;
             // Unreachable, but throws off code analyzer.
         // Unreachable, but throws off code analyzer.
         case 'blocked':
             $this->dieUsage('You have been blocked', $error);
             break;
             // Unreachable, but throws off code analyzer.
         // Unreachable, but throws off code analyzer.
         case 'unknownmessage':
             $this->dieUsage('Unknown message', $error);
             break;
             // Unreachable, but throws off code analyzer.
         // Unreachable, but throws off code analyzer.
         case 'owntranslation':
             $this->dieUsage('Cannot review own translations', $error);
             break;
             // Unreachable, but throws off code analyzer.
         // Unreachable, but throws off code analyzer.
         case 'fuzzymessage':
             $this->dieUsage('Cannot review fuzzy translations', $error);
             break;
             // Unreachable, but throws off code analyzer.
         // Unreachable, but throws off code analyzer.
         default:
             $this->dieUsage('Unknown error', $error);
     }
     $ok = self::doReview($this->getUser(), $revision);
     if (!$ok) {
         $this->setWarning('Already marked as reviewed by you');
     }
     $output = array('review' => array('title' => $revision->getTitle()->getPrefixedText(), 'pageid' => $revision->getPage(), 'revision' => $revision->getId()));
     $this->getResult()->addValue(null, $this->getModuleName(), $output);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:50,代码来源:ApiTranslationReview.php

示例14: execute

 /**
  * This function does essentially the same as RevisionReview::AjaxReview,
  * except that it generates the template and image parameters itself.
  */
 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     // Check basic permissions
     if (!$wgUser->isAllowed('review')) {
         $this->dieUsage("You don't have the right to review revisions.", 'permissiondenied');
     } elseif ($wgUser->isBlocked(false)) {
         $this->dieUsageMsg(array('blockedtext'));
     }
     $newRev = Revision::newFromId($params['oldid']);
     if (!$newRev || !$newRev->getTitle()) {
         $this->dieUsage("Cannot find a revision with the specified ID.", 'notarget');
     }
     $title = $newRev->getTitle();
     $fa = FlaggableWikiPage::getTitleInstance($title);
     if (!$fa->isReviewable()) {
         $this->dieUsage("Provided page is not reviewable.", 'notreviewable');
     }
     $status = false;
     if ($params['previd']) {
         // changes
         $oldRev = Revision::newFromId($params['previd']);
         if (!$oldRev || $oldRev->getPage() != $newRev->getPage()) {
             $this->dieUsage("Revisions do not belong to the same page.", 'notarget');
         }
         // Mark as reviewing...
         if ($params['reviewing']) {
             $status = FRUserActivity::setUserReviewingDiff($wgUser, $params['previd'], $params['oldid']);
             // Unmark as reviewing...
         } else {
             $status = FRUserActivity::clearUserReviewingDiff($wgUser, $params['previd'], $params['oldid']);
         }
     } else {
         // Mark as reviewing...
         if ($params['reviewing']) {
             $status = FRUserActivity::setUserReviewingPage($wgUser, $newRev->getPage());
             // Unmark as reviewing...
         } else {
             $status = FRUserActivity::clearUserReviewingPage($wgUser, $newRev->getPage());
         }
     }
     # Success in setting flag...
     if ($status === true) {
         $this->getResult()->addValue(null, $this->getModuleName(), array('result' => 'Success'));
         # Failure...
     } else {
         $this->getResult()->addValue(null, $this->getModuleName(), array('result' => 'Failure'));
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:54,代码来源:ApiReviewActivity.php

示例15: getLastEdit

 /**
  * Returns the last edit of the user
  *
  * @return Revision|false
  */
 public function getLastEdit()
 {
     $conds = array('rev_user' => $this->user->getId());
     $options = array('LIMIT' => 1, 'ORDER BY' => 'rev_timestamp DESC');
     $dbr = wfGetDB(DB_SLAVE, 'revision');
     $res = $dbr->select('revision', 'rev_id', $conds, __METHOD__, $options);
     $row = $res->fetchObject();
     if ($row) {
         $rev = Revision::newFromId($row->rev_id);
     } else {
         $rev = false;
     }
     return $rev;
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:19,代码来源:MobileUserInfo.php


注:本文中的Revision::newFromId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。