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


PHP Revision类代码示例

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


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

示例1: executeNew

 public function executeNew(sfWebRequest $request)
 {
     $this->procedure = Doctrine::getTable('Procedure')->find($request->getParameter('procedure_id'));
     $this->last_state = $this->procedure->getLastRevision()->getRevisionStateId();
     if ($this->last_state != 4) {
         $revision = new Revision();
         $revision->setProcedureId($request->getParameter('procedure_id'));
         $this->form = new FrontRevisionForm($revision);
     }
 }
开发者ID:retrofox,项目名称:Huemul,代码行数:10,代码来源:actions.class.php

示例2: processRevision

 /**
  * Callback function for each revision, preprocessToObj()
  * @param Revision $rev
  */
 public function processRevision($rev)
 {
     $content = $rev->getContent(Revision::RAW);
     if ($content->getModel() !== CONTENT_MODEL_WIKITEXT) {
         return;
     }
     try {
         $this->mPreprocessor->preprocessToObj(strval($content->getNativeData()), 0);
     } catch (Exception $e) {
         $this->error("Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText());
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:16,代码来源:preprocessDump.php

示例3: execute

 public function execute()
 {
     $db = wfGetDB(DB_MASTER);
     if (!$db->tableExists('revision')) {
         $this->error("revision table does not exist", true);
     }
     $this->output("Populating rev_len column\n");
     $start = $db->selectField('revision', 'MIN(rev_id)', false, __FUNCTION__);
     $end = $db->selectField('revision', 'MAX(rev_id)', false, __FUNCTION__);
     if (is_null($start) || is_null($end)) {
         $this->output("...revision table seems to be empty.\n");
         $db->insert('updatelog', array('ul_key' => 'populate rev_len'), __METHOD__, 'IGNORE');
         return;
     }
     # Do remaining chunks
     $blockStart = intval($start);
     $blockEnd = intval($start) + $this->mBatchSize - 1;
     $count = 0;
     $missing = 0;
     while ($blockStart <= $end) {
         $this->output("...doing rev_id from {$blockStart} to {$blockEnd}\n");
         $res = $db->select('revision', Revision::selectFields(), array("rev_id >= {$blockStart}", "rev_id <= {$blockEnd}", "rev_len IS NULL"), __METHOD__);
         # Go through and update rev_len from these rows.
         foreach ($res as $row) {
             $rev = new Revision($row);
             $text = $rev->getRawText();
             if (!is_string($text)) {
                 # This should not happen, but sometimes does (bug 20757)
                 $this->output("Text of revision {$row->rev_id} unavailable!\n");
                 $missing++;
             } else {
                 # Update the row...
                 $db->update('revision', array('rev_len' => strlen($text)), array('rev_id' => $row->rev_id), __METHOD__);
                 $count++;
             }
         }
         $blockStart += $this->mBatchSize;
         $blockEnd += $this->mBatchSize;
         wfWaitForSlaves(5);
     }
     $logged = $db->insert('updatelog', array('ul_key' => 'populate rev_len'), __METHOD__, 'IGNORE');
     if ($logged) {
         $this->output("rev_len population complete ... {$count} rows changed ({$missing} missing)\n");
         return true;
     } else {
         $this->output("Could not insert rev_len population row.\n");
         return false;
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:49,代码来源:populateRevisionLength.php

示例4: runForTitleInternal

 /**
  * @param $title Title
  * @param $revision Revision
  * @param $fname string
  * @return void
  */
 public static function runForTitleInternal(Title $title, Revision $revision, $fname)
 {
     wfProfileIn($fname);
     $content = $revision->getContent(Revision::RAW);
     if (!$content) {
         // if there is no content, pretend the content is empty
         $content = $revision->getContentHandler()->makeEmptyContent();
     }
     // Revision ID must be passed to the parser output to get revision variables correct
     $parserOutput = $content->getParserOutput($title, $revision->getId(), null, false);
     $updates = $content->getSecondaryDataUpdates($title, null, false, $parserOutput);
     DataUpdate::runUpdates($updates);
     InfoAction::invalidateCache($title);
     wfProfileOut($fname);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:21,代码来源:RefreshLinksJob.php

示例5: doDBUpdates

 public function doDBUpdates()
 {
     $db = $this->getDB(DB_MASTER);
     if (!$db->tableExists('revision')) {
         $this->error("revision table does not exist", true);
     } else {
         if (!$db->fieldExists('revision', 'rev_sha1', __METHOD__)) {
             $this->output("rev_sha1 column does not exist\n\n", true);
             return false;
         }
     }
     $this->output("Populating rev_len column\n");
     $start = $db->selectField('revision', 'MIN(rev_id)', false, __METHOD__);
     $end = $db->selectField('revision', 'MAX(rev_id)', false, __METHOD__);
     if (!$start || !$end) {
         $this->output("...revision table seems to be empty.\n");
         return true;
     }
     # Do remaining chunks
     $blockStart = intval($start);
     $blockEnd = intval($start) + $this->mBatchSize - 1;
     $count = 0;
     $missing = 0;
     $fields = Revision::selectFields();
     while ($blockStart <= $end) {
         $this->output("...doing rev_id from {$blockStart} to {$blockEnd}\n");
         $res = $db->select('revision', $fields, array("rev_id >= {$blockStart}", "rev_id <= {$blockEnd}", "rev_len IS NULL"), __METHOD__);
         # Go through and update rev_len from these rows.
         foreach ($res as $row) {
             $rev = new Revision($row);
             $content = $rev->getContent();
             if (!$content) {
                 # This should not happen, but sometimes does (bug 20757)
                 $this->output("Content of revision {$row->rev_id} unavailable!\n");
                 $missing++;
             } else {
                 # Update the row...
                 $db->update('revision', array('rev_len' => $content->getSize()), array('rev_id' => $row->rev_id), __METHOD__);
                 $count++;
             }
         }
         $blockStart += $this->mBatchSize;
         $blockEnd += $this->mBatchSize;
         wfWaitForSlaves();
     }
     $this->output("rev_len population complete ... {$count} rows changed ({$missing} missing)\n");
     return true;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:48,代码来源:populateRevisionLength.php

示例6: 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

示例7: loadTable

 /**
  * Loads the mapping table.
  */
 private function loadTable()
 {
     // no need to load multiple times.
     if ($this->loaded) {
         return;
     }
     $this->loaded = true;
     $title = Title::newFromText(self::$tablePageName);
     if (!$title->exists()) {
         return;
     }
     $tablePageRev = Revision::newFromTitle($title);
     if (is_object($tablePageRev)) {
         $tablePage = $tablePageRev->getText();
         global $wgUser;
         $parser = new Parser();
         $parser->setFunctionHook('tag_to_template', array($this, 'mg_tag_to_template'));
         // this will populate the 'map' variable
         // assuming of course that the page was edited with
         // {{#tag_to_template| ... }} instructions.
         $this->initPhase = true;
         $parser->parse($tablePage, $title, new ParserOptions($wgUser));
         $this->initPhase = false;
     }
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:28,代码来源:TagToTemplate.body.php

示例8: doQuery

 /**
  * @param IDatabase $db
  * @return mixed
  */
 public function doQuery($db)
 {
     $ids = array_map('intval', $this->ids);
     $queryInfo = ['tables' => ['revision', 'user'], 'fields' => array_merge(Revision::selectFields(), Revision::selectUserFields()), 'conds' => ['rev_page' => $this->title->getArticleID(), 'rev_id' => $ids], 'options' => ['ORDER BY' => 'rev_id DESC'], 'join_conds' => ['page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()]];
     ChangeTags::modifyDisplayQuery($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], $queryInfo['join_conds'], $queryInfo['options'], '');
     $live = $db->select($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], __METHOD__, $queryInfo['options'], $queryInfo['join_conds']);
     if ($live->numRows() >= count($ids)) {
         // All requested revisions are live, keeps things simple!
         return $live;
     }
     $archiveQueryInfo = ['tables' => ['archive'], 'fields' => Revision::selectArchiveFields(), 'conds' => ['ar_rev_id' => $ids], 'options' => ['ORDER BY' => 'ar_rev_id DESC'], 'join_conds' => []];
     ChangeTags::modifyDisplayQuery($archiveQueryInfo['tables'], $archiveQueryInfo['fields'], $archiveQueryInfo['conds'], $archiveQueryInfo['join_conds'], $archiveQueryInfo['options'], '');
     // Check if any requested revisions are available fully deleted.
     $archived = $db->select($archiveQueryInfo['tables'], $archiveQueryInfo['fields'], $archiveQueryInfo['conds'], __METHOD__, $archiveQueryInfo['options'], $archiveQueryInfo['join_conds']);
     if ($archived->numRows() == 0) {
         return $live;
     } elseif ($live->numRows() == 0) {
         return $archived;
     } else {
         // Combine the two! Whee
         $rows = [];
         foreach ($live as $row) {
             $rows[$row->rev_id] = $row;
         }
         foreach ($archived as $row) {
             $rows[$row->ar_rev_id] = $row;
         }
         krsort($rows);
         return new FakeResultWrapper(array_values($rows));
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:35,代码来源:RevDelRevisionList.php

示例9: wfSpecialCheckmylinks

function wfSpecialCheckmylinks($par)
{
    global $wgRequest, $wgSitename, $wgLanguageCode;
    global $wgDeferredUpdateList, $wgOut, $wgUser, $wgServer, $wgParser, $wgTitle;
    $fname = "wfCheckmylinks";
    $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_summary'));
    if ($wgUser->getID() > 0) {
        $t = Title::makeTitle(NS_USER, $wgUser->getName() . "/Mylinks");
        if ($t->getArticleID() > 0) {
            $r = Revision::newFromTitle($t);
            $text = $r->getText();
            if ($text != "") {
                $ret = "<h3>" . wfMsg('mylinks') . "</h3>";
                $options = new ParserOptions();
                $output = $wgParser->parse($text, $wgTitle, $options);
                $ret .= $output->getText();
            }
            $size = strlen($ret);
            if ($size > 3000) {
                $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_size_bad', number_format($size, 0, "", ",")));
            } else {
                $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_size_good', number_format($size, 0, "", ",")));
            }
        } else {
            $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_error'));
        }
    } else {
        $wgOut->addHTML(wfMsgWikiHtml('checkmylinks_notloggedin'));
    }
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:30,代码来源:Checkmylinks.php

示例10: doQuery

 /**
  * @param IDatabase $db
  * @return mixed
  */
 public function doQuery($db)
 {
     $ids = array_map('intval', $this->ids);
     $live = $db->select(array('revision', 'page', 'user'), array_merge(Revision::selectFields(), Revision::selectUserFields()), array('rev_page' => $this->title->getArticleID(), 'rev_id' => $ids), __METHOD__, array('ORDER BY' => 'rev_id DESC'), array('page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()));
     if ($live->numRows() >= count($ids)) {
         // All requested revisions are live, keeps things simple!
         return $live;
     }
     // Check if any requested revisions are available fully deleted.
     $archived = $db->select(array('archive'), Revision::selectArchiveFields(), array('ar_rev_id' => $ids), __METHOD__, array('ORDER BY' => 'ar_rev_id DESC'));
     if ($archived->numRows() == 0) {
         return $live;
     } elseif ($live->numRows() == 0) {
         return $archived;
     } else {
         // Combine the two! Whee
         $rows = array();
         foreach ($live as $row) {
             $rows[$row->rev_id] = $row;
         }
         foreach ($archived as $row) {
             $rows[$row->ar_rev_id] = $row;
         }
         krsort($rows);
         return new FakeResultWrapper(array_values($rows));
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:31,代码来源:RevDelRevisionList.php

示例11: copyCheck

 /**
  * check for plagiarism with copyscape
  * return true if there's an issue
  */
 private static function copyCheck($t)
 {
     $threshold = 0.05;
     $result = '';
     $r = Revision::newFromTitle($t);
     if (!$r) {
         return 'No such article';
     }
     $text = Wikitext::flatten($r->getText());
     $res = copyscape_api_text_search_internet($text, 'ISO-8859-1', 2);
     if ($res['count']) {
         $words = $res['querywords'];
         foreach ($res['result'] as $r) {
             if (!preg_match("@^http://[a-z0-9]*.(wikihow|whstatic|youtube).com@i", $r['url'])) {
                 //if ($r['minwordsmatched'] / $words > $threshold) {
                 //we got one!
                 $result .= '<b>Plagiarized:</b> <a href="' . $r['url'] . '">' . $r['url'] . '</a><br />';
                 //}
             }
         }
     } else {
         $result = '';
     }
     return $result;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:29,代码来源:AdminCopyCheck.body.php

示例12: 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

示例13: formatResult

 function formatResult($skin, $result)
 {
     global $wgContLang;
     # Make a link to the redirect itself
     $rd_title = Title::makeTitle($result->namespace, $result->title);
     $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
     $rd_link = $skin->makeKnownLinkObj($rd_title, '', 'redirect=no');
     # Find out where the redirect leads
     $revision = Revision::newFromTitle($rd_title);
     if ($revision) {
         # Make a link to the destination page
         $target = Title::newFromRedirect($revision->getText());
         if ($target) {
             $targetLink = $skin->makeLinkObj($target);
         } else {
             /** @todo Put in some decent error display here */
             $targetLink = '*';
         }
     } else {
         /** @todo Put in some decent error display here */
         $targetLink = '*';
     }
     # Format the whole thing and return it
     return "{$rd_link} {$arr} {$targetLink}";
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:25,代码来源:SpecialListredirects.php

示例14: renderSubpageToC

 /**
  * ToC rendering for non-hubs
  * @param $title Title of hub the ToC is generated off
  * @return string html
  */
 public function renderSubpageToC(Title $title)
 {
     $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
     // We assume $title is sane. This is supposed to be called with a $title gotten from CollaborationHubContent::getParentHub, which already checks if it is.
     $rev = Revision::newFromTitle($title);
     $content = $rev->getContent();
     $colour = $content->getThemeColour();
     $image = $content->getImage();
     $html = Html::openElement('div', ['class' => "mw-ck-theme-{$colour}"]);
     $html .= Html::openElement('div', ['class' => "mw-ck-subpage-toc"]);
     // ToC label
     $html .= Html::rawElement('div', ['class' => 'mw-ck-toc-label'], Html::rawElement('span', [], wfMessage('collaborationkit-subpage-toc-label')->inContentLanguage()->text()));
     // hubpage
     $name = $content->getDisplayName() == '' ? $title->getText() : $content->getDisplayName();
     $link = $this->renderItem($title, $name, $image, 16);
     $html .= Html::rawElement('div', ['class' => 'mw-ck-toc-subpage-hub'], $link);
     // Contents
     $html .= Html::openElement('ul', ['class' => 'mw-ck-toc-contents']);
     foreach ($content->getContent() as $item) {
         $itemTitle = Title::newFromText($item['title']);
         if (isset($item['display_title'])) {
             $itemDisplayTitle = $item['display_title'];
         } else {
             $itemDisplayTitle = $itemTitle->getSubpageText();
         }
         $itemImage = isset($item['image']) ? $item['image'] : $itemDisplayTitle;
         $itemLink = $this->renderItem($itemTitle, $itemDisplayTitle, $itemImage, $colour, 16);
         $html .= Html::rawElement('li', ['class' => 'mw-ck-toc-item'], $itemLink);
     }
     $html .= Html::closeElement('ul');
     $html .= Html::closeElement('div');
     $html .= Html::closeElement('div');
     return $html;
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-CollaborationKit,代码行数:39,代码来源:CollaborationHubTOC.php

示例15: removeImagesFromArticle

 private function removeImagesFromArticle($articleId)
 {
     $title = Title::newFromID($articleId);
     if ($title) {
         $revision = Revision::newFromTitle($title);
         $text = $revision->getText();
         //regular expressions copied out of maintenance/wikiphotoProcessImages.php
         //but modified to remove the leading BR tags if they exist
         //In the callback we keep track of each image name that we remove
         $text = preg_replace_callback('@(<\\s*br\\s*[\\/]?>)*\\s*\\[\\[Image:([^\\]]*)\\]\\]@im', function ($matches) {
             $image = $matches[2];
             $pipeLoc = strpos($image, "|");
             if ($pipeLoc !== false) {
                 $image = substr($image, 0, $pipeLoc);
             }
             AdminImageRemoval::$imagesRemoved[] = $image;
             return '';
         }, $text);
         $text = preg_replace_callback('@(<\\s*br\\s*[\\/]?>)*\\s*\\{\\{largeimage\\|([^\\}]*)\\}\\}@im', function ($matches) {
             $image = $matches[2];
             AdminImageRemoval::$imagesRemoved[] = $image;
             return '';
         }, $text);
         $text = preg_replace('@(<\\s*br\\s*[\\/]?>)*\\s*\\{\\{largeimage\\|[^\\}]*\\}\\}@im', '', $text);
         $article = new Article($title);
         $saved = $article->doEdit($text, 'Removing all images from article.');
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:28,代码来源:AdminImageRemoval.body.php


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