當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。