/** * This method is indirectly called by WP if one edits * an article in the WP clone. It starts and controls the * merge process and returns its result. * * @param $title * @param $newWPText * @param $currentUPText * @return unknown_type */ public function merge($title, $newWPText, $currentUPText) { wfProfileIn('WUMMergeController->merge'); if ($this->checkIgnoreNewWPVersion($currentUPText)) { return $currentUPText; } $overwrite = $this->checkOverwriteUPVersion($newWPText); if ($overwrite !== false) { return $overwrite; } //get the last WP version $originalWPText = $this->getOriginalWPText($title); $newWPText = $this->prepareText($newWPText); $originalWPText = $this->prepareText($originalWPText); $currentUPText = $this->prepareText($currentUPText); if (strlen($originalWPText) == 0) { return $newWPText . "\n" . $currentUPText; } //check whether to use the table based merger global $wumUseTableBasedMerger; if ($wumUseTableBasedMerger) { $tbm = WUMTableBasedMerger::getInstance(); list($newWPText, $currentUPText, $originalWPText) = $tbm->merge($title, $newWPText, $currentUPText, $originalWPText); //wfProfileOut('WUMMergeController->merge'); //return $currentUPText; } //do three way merge $twmResult = WUMThreeWayBasedMerger::getInstance()->merge($originalWPText, $newWPText, $currentUPText); //do section based merge if merge faults occured during three way merge if (count($twmResult['mergeFaults']) == 0) { $text = $twmResult['mergedText']; } else { $text = WUMSectionBasedMerger::getInstance()->merge($originalWPText, $newWPText, $currentUPText, $twmResult['mergedText'], $twmResult['mergeFaults']); } //finalize merge result, i.e. replace temporary characters $text = WUMThreeWayBasedMerger::getInstance()->finalizeMergeResult($text); wfProfileOut('WUMMergeController->merge'); return $text; }
/** * singleton * * @return WUMTableBasedMerger */ public static function getInstance() { if (self::$instance == null) { self::$instance = new self(); } return self::$instance; }