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


PHP wfMerge函数代码示例

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


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

示例1: getUndoContent

 protected function getUndoContent($startContent, $stopContent, $currentContent)
 {
     if ($currentContent === $stopContent) {
         return $startContent;
     } else {
         // 3-way merge
         $ok = wfMerge($stopContent, $startContent, $currentContent, $result);
         if ($ok) {
             return $result;
         } else {
             return false;
         }
     }
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:14,代码来源:RevisionUndoViewFormatter.php

示例2: merge3

 /**
  * Attempts to merge differences between three versions. Returns a new
  * Content object for a clean merge and false for failure or a conflict.
  *
  * All three Content objects passed as parameters must have the same
  * content model.
  *
  * This text-based implementation uses wfMerge().
  *
  * @param Content $oldContent The page's previous content.
  * @param Content $myContent One of the page's conflicting contents.
  * @param Content $yourContent One of the page's conflicting contents.
  *
  * @return Content|bool
  */
 public function merge3(Content $oldContent, Content $myContent, Content $yourContent)
 {
     $this->checkModelID($oldContent->getModel());
     $this->checkModelID($myContent->getModel());
     $this->checkModelID($yourContent->getModel());
     $format = $this->getDefaultFormat();
     $old = $this->serializeContent($oldContent, $format);
     $mine = $this->serializeContent($myContent, $format);
     $yours = $this->serializeContent($yourContent, $format);
     $ok = wfMerge($old, $mine, $yours, $result);
     if (!$ok) {
         return false;
     }
     if (!$result) {
         return $this->makeEmptyContent();
     }
     $mergedContent = $this->unserializeContent($result, $format);
     return $mergedContent;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:34,代码来源:TextContentHandler.php

示例3: mergeChangesInto

 /**
  * @access private
  * @todo document
  */
 function mergeChangesInto(&$editText)
 {
     $fname = 'EditPage::mergeChangesInto';
     wfProfileIn($fname);
     $db =& wfGetDB(DB_MASTER);
     // This is the revision the editor started from
     $baseRevision = Revision::loadFromTimestamp($db, $this->mArticle->mTitle, $this->edittime);
     if (is_null($baseRevision)) {
         wfProfileOut($fname);
         return false;
     }
     $baseText = $baseRevision->getText();
     // The current state, we want to merge updates into it
     $currentRevision = Revision::loadFromTitle($db, $this->mArticle->mTitle);
     if (is_null($currentRevision)) {
         wfProfileOut($fname);
         return false;
     }
     $currentText = $currentRevision->getText();
     if (wfMerge($baseText, $editText, $currentText, $result)) {
         $editText = $result;
         wfProfileOut($fname);
         return true;
     } else {
         wfProfileOut($fname);
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:enotifwiki,代码行数:32,代码来源:EditPage.php

示例4: testMerge

 /**
  * @param string $old Text as it was in the database
  * @param string $mine Text submitted while user was editing
  * @param string $yours Text submitted by the user
  * @param bool $expectedMergeResult Whether the merge should be a success
  * @param string $expectedText Text after merge has been completed
  *
  * @dataProvider provideMerge()
  * @group medium
  * @covers ::wfMerge
  */
 public function testMerge($old, $mine, $yours, $expectedMergeResult, $expectedText)
 {
     $this->checkHasDiff3();
     $mergedText = null;
     $isMerged = wfMerge($old, $mine, $yours, $mergedText);
     $msg = 'Merge should be a ';
     $msg .= $expectedMergeResult ? 'success' : 'failure';
     $this->assertEquals($expectedMergeResult, $isMerged, $msg);
     if ($isMerged) {
         // Verify the merged text
         $this->assertEquals($expectedText, $mergedText, 'is merged text as expected?');
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:24,代码来源:GlobalTest.php

示例5: getUndoText

 /**
  * Get the text that needs to be saved in order to undo all revisions
  * between $undo and $undoafter. Revisions must belong to the same page,
  * must exist and must not be deleted
  * @param $undo Revision
  * @param $undoafter Revision Must be an earlier revision than $undo
  * @return mixed string on success, false on failure
  */
 public function getUndoText(Revision $undo, Revision $undoafter = null)
 {
     $currentRev = Revision::newFromTitle($this->mTitle);
     if (!$currentRev) {
         return false;
         // no page
     }
     $undo_text = $undo->getText();
     $undoafter_text = $undoafter->getText();
     $cur_text = $currentRev->getText();
     if ($cur_text == $undo_text) {
         # No use doing a merge if it's just a straight revert.
         return $undoafter_text;
     }
     $undone_text = '';
     if (!wfMerge($undo_text, $undoafter_text, $cur_text, $undone_text)) {
         return false;
     }
     return $undone_text;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:28,代码来源:Article.php

示例6: mergeChangesInto

 /**
  * @private
  * @todo document
  *
  * @parma $editText string
  *
  * @return bool
  */
 function mergeChangesInto(&$editText)
 {
     wfProfileIn(__METHOD__);
     $db = wfGetDB(DB_MASTER);
     // This is the revision the editor started from
     $baseRevision = $this->getBaseRevision();
     if (is_null($baseRevision)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $baseText = $baseRevision->getText();
     // The current state, we want to merge updates into it
     $currentRevision = Revision::loadFromTitle($db, $this->mTitle);
     if (is_null($currentRevision)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $currentText = $currentRevision->getText();
     $result = '';
     if (wfMerge($baseText, $editText, $currentText, $result)) {
         $editText = $result;
         wfProfileOut(__METHOD__);
         return true;
     } else {
         wfProfileOut(__METHOD__);
         return false;
     }
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:36,代码来源:EditPage.php

示例7: getUndoText

 /**
  * Get the text that needs to be saved in order to undo all revisions
  * between $undo and $undoafter. Revisions must belong to the same page,
  * must exist and must not be deleted
  * @param $undo Revision
  * @param $undoafter Revision Must be an earlier revision than $undo
  * @return mixed string on success, false on failure
  */
 public function getUndoText(Revision $undo, Revision $undoafter = null)
 {
     $cur_text = $this->getRawText();
     if ($cur_text === false) {
         return false;
         // no page
     }
     $undo_text = $undo->getText();
     $undoafter_text = $undoafter->getText();
     if ($cur_text == $undo_text) {
         # No use doing a merge if it's just a straight revert.
         return $undoafter_text;
     }
     $undone_text = '';
     if (!wfMerge($undo_text, $undoafter_text, $cur_text, $undone_text)) {
         return false;
     }
     return $undone_text;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:27,代码来源:WikiPage.php

示例8: saveCssFileContent

 /**
  * @desc Saving CSS content
  * If there is more recent edit it will try to merge text and save.
  * Returns false when conflict is found and cannot be resolved
  *
  * @param string $content
  * @param string $summary
  * @param bool $isMinor
  * @param int $editTime timestamp
  * @param User $user
  * @return Status|bool
  */
 public function saveCssFileContent($content, $summary, $isMinor, $editTime, $user)
 {
     $cssTitle = $this->getCssFileTitle();
     $flags = 0;
     if ($cssTitle instanceof Title) {
         $aid = $cssTitle->getArticleID(Title::GAID_FOR_UPDATE);
         $flags |= $aid == 0 ? EDIT_NEW : EDIT_UPDATE;
         if ($isMinor) {
             $flags |= EDIT_MINOR;
         }
         $db = wfGetDB(DB_MASTER);
         $currentRevision = Revision::loadFromTitle($db, $cssTitle);
         // we handle both - edit and creation conflicts below
         if (!empty($currentRevision) && $editTime != $currentRevision->getTimestamp()) {
             $result = '';
             $currentText = $currentRevision->getText();
             if (!$editTime) {
                 // the css did not exist when the editor was started, so the base revision for
                 // parallel edits is an empty file
                 $baseText = '';
             } else {
                 $baseText = Revision::loadFromTimestamp($db, $this->getCssFileTitle(), $editTime)->getText();
             }
             // remove windows endlines from input before merging texts
             $content = str_replace("\r", "", $content);
             if (wfMerge($baseText, $content, $currentText, $result)) {
                 // This conflict can be resolved
                 $content = $result;
             } else {
                 // We have real conflict here
                 return false;
             }
         }
         $page = new WikiPage($cssTitle);
         $status = $page->doEdit($content, $summary, $flags, false, $user);
         return $status;
     }
     return Status::newFatal('special-css-saving-internal-error');
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:51,代码来源:SpecialCssModel.class.php


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