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


PHP Revision::loadFromId方法代码示例

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


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

示例1: execute

 /**
  * EXECUTE
  **/
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang, $wgParser, $wgHooks, $wgTitle, $wgStarterPages;
     $wgHooks['ShowBreadCrumbs'][] = array($this, 'removeBreadCrumbsCallback');
     //$wgHooks['WrapBodyWithArticleInner'][] = array($this, 'wrapBodyWithArticleInner');
     wfLoadExtensionMessages('StarterTool');
     self::setTemplatePath();
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     $referral = $wgRequest->getVal('ref');
     //get contents
     if ($wgRequest->getVal('edit')) {
         $wgOut->setArticleBodyOnly(true);
         $sentenceNum = $wgRequest->getVal('starter_title');
         $sentence = $this->getSentence($sentenceNum);
         $sentence = preg_replace('@<[/]?(span|[ovwxp]:\\w+)[^>]*?>@', '', $sentence);
         $vars = array('sentence' => $sentence);
         $html = EasyTemplate::html('edit', $vars);
         $wgOut->addHTML($html);
         return;
     } elseif ($wgRequest->getVal('finish')) {
         $finishNum = "Finish-" . $wgRequest->getVal('finish');
         self::logInfo($finishNum);
     } elseif ($wgRequest->getVal('editNum')) {
         $editNum = "Edit-" . $wgRequest->getVal('editNum');
         self::logInfo($editNum);
         if ($wgRequest->getVal('getsome')) {
             $wgOut->setArticleBodyOnly(true);
             $sentence = self::getSentence();
             $wgOut->addHTML($sentence);
             return;
         }
     } elseif ($wgRequest->getVal('getsome')) {
         $wgOut->setArticleBodyOnly(true);
         $sentence = self::getSentence();
         $wgOut->addHTML($sentence);
         return;
     } elseif ($wgRequest->getVal('action') == 'submit') {
         $wgOut->setArticleBodyOnly(true);
         $t = Title::newFromText($wgRequest->getVal('starter-title'));
         $a = new Article($t);
         //internal log
         if ($referral != "") {
             self::logInfo("submit");
         }
         //log it
         $params = array();
         $log = new LogPage('Starter_Tool', false);
         // false - dont show in recentchanges
         $log->addEntry('', $t, 'Fixed a sentence with the Starter Tool.', $params);
         $text = $wgRequest->getVal('wpTextbox1');
         $sum = $wgRequest->getVal('wpSummary');
         //save the edit
         if ($a->doEdit($text, $sum, EDIT_SUPPRESS_RC)) {
             //revert the edit for the next user
             $minRev = self::getFirstArticleRevision($t->getArticleId());
             //don't log rollback for the user
             $oldglobal = $wgUser;
             $wgUser = User::newFromName("MasterSockPuppet421");
             $dbr = wfGetDB(DB_SLAVE);
             $r = Revision::loadFromId($dbr, $minRev);
             $a->doEdit($r->getText(), 'Auto-rollback from Starter Tool.', EDIT_SUPPRESS_RC);
             // reset the wguser var
             $wgUser = $oldglobal;
             wfRunHooks("StarterToolSaveComplete", array($a, $text, $sum, $wgUser, $efType));
         }
         return;
     } else {
         //default; get a sentence
         if ($referral != "") {
             //log that they came in from the specific ad
             self::logInfo("Ad-" . $referral);
             setcookie(StarterTool::COOKIE_NAME, 1, 0);
         }
         $wgOut->addScript(HtmlSnips::makeUrlTags('css', array('starter.css'), 'extensions/wikihow/starter', false));
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('starter.js'), 'extensions/wikihow/starter', false));
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('clientscript.js'), 'skins/common/', false));
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('jquery.cookie.js'), 'extensions/wikihow/common', false));
         $sk = $wgUser->getSkin();
         $wgOut->setArticleBodyOnly(false);
         $vars = array('pagetitle' => wfMsg('app-name'), 'question' => wfMsg('fix-this'), 'yep' => wfMsg('yep'), 'nope' => wfMsg('nope'));
         $html = EasyTemplate::html('starter', $vars);
         $wgOut->addHTML($html);
     }
     $wgOut->setHTMLTitle(wfMsg('pagetitle', wfMsg('app-name')));
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:91,代码来源:StarterTool.body.php

示例2: util_ResolveRevSpec

 static function util_ResolveRevSpec($page_title, $page_id = 0, $rev_id = 0)
 {
     global $wgTitle;
     $dbr =& wfGetDB(DB_SLAVE);
     if ($rev_id && !$page_id) {
         $rev = Revision::loadFromId($dbr, $rev_id);
         if ($rev) {
             $page_id = $rev->getPage();
         }
     }
     if ($page_id && !$page_title) {
         $wgTitle = Title::newFromID($page_id);
     }
     if ($page_title) {
         $wgTitle = Title::newFromDBkey($page_title);
     }
     $article = new Article($wgTitle);
     $title_db = $wgTitle->getDBkey();
     $page_id_db = $wgTitle->getArticleID();
     $rev_id_db = $article->getLatest();
     if (!$page_id) {
         $page_id = $page_id_db;
     }
     if (!$rev_id) {
         $rev_id = $rev_id_db;
     }
     if (!$page_title) {
         $page_title = $title_db;
     }
     if ($page_id != $page_id_db) {
         wfWikiTrustWarn(__FILE__ . ":" . __LINE__ . ": mismatched pageId: {$page_id} != {$page_id_db}");
     }
     if ($page_title != $title_db) {
         wfWikiTrustWarn(__FILE__ . ":" . __LINE__ . ": mismatched title: {$page_title} != {$title_db}");
     }
     return array($page_title, $page_id, $rev_id);
 }
开发者ID:xzhao314,项目名称:WikiTrust,代码行数:37,代码来源:WikiTrustBase.php

示例3: loadText

	/**
	 * Load current revision of comment wikitext.
	 */
	public function loadText() {
		$dbr = wfGetDB( DB_SLAVE );
		$rev = Revision::loadFromId( $dbr, $this->mCommentRev );
		if ( $rev ) {
			$this->mText = $rev->getText();
			$this->mTextChanged = false;
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:11,代码来源:WikilogComment.php

示例4: replaceSectionAtRev

 /**
  * @param string|number|null|bool $sectionId Section identifier as a number or string
  * (e.g. 0, 1 or 'T-1'), null/false or an empty string for the whole page
  * or 'new' for a new section.
  * @param Content $sectionContent New content of the section.
  * @param string $sectionTitle New section's subject, only if $section is "new".
  * @param int|null $baseRevId
  *
  * @throws MWException
  * @return Content New complete article content, or null if error.
  *
  * @since 1.24
  */
 public function replaceSectionAtRev($sectionId, Content $sectionContent, $sectionTitle = '', $baseRevId = null)
 {
     wfProfileIn(__METHOD__);
     if (strval($sectionId) === '') {
         // Whole-page edit; let the whole text through
         $newContent = $sectionContent;
     } else {
         if (!$this->supportsSections()) {
             wfProfileOut(__METHOD__);
             throw new MWException("sections not supported for content model " . $this->getContentHandler()->getModelID());
         }
         // Bug 30711: always use current version when adding a new section
         if (is_null($baseRevId) || $sectionId === 'new') {
             $oldContent = $this->getContent();
         } else {
             // TODO: try DB_SLAVE first
             $dbw = wfGetDB(DB_MASTER);
             $rev = Revision::loadFromId($dbw, $baseRevId);
             if (!$rev) {
                 wfDebug(__METHOD__ . " asked for bogus section (page: " . $this->getId() . "; section: {$sectionId})\n");
                 wfProfileOut(__METHOD__);
                 return null;
             }
             $oldContent = $rev->getContent();
         }
         if (!$oldContent) {
             wfDebug(__METHOD__ . ": no page text\n");
             wfProfileOut(__METHOD__);
             return null;
         }
         $newContent = $oldContent->replaceSection($sectionId, $sectionContent, $sectionTitle);
     }
     wfProfileOut(__METHOD__);
     return $newContent;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:48,代码来源:WikiPage.php

示例5: fopen

<?php

require_once 'commandLine.inc';
# Export list of alternative methods for a list of articles to CSV file
$filename = $argv[0];
$f = fopen($filename, 'r');
$contents = fread($f, filesize($filename));
fclose($f);
$pages = preg_split('@[\\r\\n]+@', $contents);
foreach ($pages as $page) {
    $t = Title::newFromText($page);
    $gr = GoodRevision::newFromTitle($t);
    if ($gr) {
        $dbr = wfGetDB(DB_SLAVE);
        $lr = $gr->latestGood();
        $r = Revision::loadFromId($dbr, $lr);
        if ($r) {
            $text = Wikitext::getStepsSection($r->getText(), true);
            if (preg_match_all("@===([^=]+)===@", $text[0], $matches)) {
                print $page;
                foreach ($matches[1] as $m) {
                    if (!preg_match("@\r\n@", $m)) {
                        print ',' . $m;
                    }
                }
                print "\n";
            }
        }
    }
}
开发者ID:ErdemA,项目名称:wikihow,代码行数:30,代码来源:getAltMethodNames.php

示例6: calcPageStats

 public function calcPageStats(&$statsToCalc, &$row)
 {
     $dbr = $this->getWikiDB();
     $t = Title::newFromId($row->page_id);
     $goodRevision = GoodRevision::newFromTitle($t, $row->page_id);
     $revId = 0;
     if ($goodRevision) {
         $revId = $goodRevision->latestGood();
     }
     $r = $revId > 0 ? Revision::loadFromId($dbr, $revId) : Revision::loadFromPageId($dbr, $row->page_id);
     $fields = array();
     if ($r && $t && $t->exists()) {
         foreach ($statsToCalc as $stat => $isOn) {
             if ($isOn) {
                 $statCalculator = $this->getStatClass($stat);
                 $fields = array_merge($fields, $statCalculator->calc($dbr, $r, $t, $row));
             }
         }
     }
     return $fields;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:21,代码来源:Titus.class.php


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