public function handle() { global $ID; global $INPUT; $this->file = Projects_file::file($ID); $old_text = $INPUT->post->str($this->old_input_name(), ''); $old = $this->split($old_text); $new_text = $INPUT->post->str($this->new_input_name(), ''); $new = $this->split($new_text); $diff = new Diff($old, $new); $now = $this->now(); if ($new == $now) { return "show"; } if ($old != $now) { $check = new Diff($old, $now); $merged = merge3($diff->edits, $check->edits); if ($merged['conflict']) { global $MERGED_DIFF; $MERGED_DIFF = $merged['merged']; return $this->action(); } $diff->edits = $merged['merged']; $new = $diff->closing(); } lock($ID); $text = $this->update($this->merge($new)); if ($text === FALSE) { msg('file has been changed, cannot save!', -1); } else { saveWikiText($ID, $text, ""); } unlock($ID); return "show"; }