2013-02-17 15:37:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorApplicationTransactionTextDiffDetailView
|
|
|
|
extends AphrontView {
|
|
|
|
|
|
|
|
private $oldText;
|
|
|
|
private $newText;
|
|
|
|
|
|
|
|
public function setNewText($new_text) {
|
|
|
|
$this->newText = $new_text;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOldText($old_text) {
|
|
|
|
$this->oldText = $old_text;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$old = $this->oldText;
|
|
|
|
$new = $this->newText;
|
|
|
|
|
|
|
|
// TODO: On mobile, or perhaps by default, we should switch to 1-up once
|
|
|
|
// that is built.
|
|
|
|
|
2013-03-05 03:07:47 +01:00
|
|
|
if (strlen($old)) {
|
|
|
|
$old = phutil_utf8_hard_wrap($old, 80);
|
|
|
|
$old = implode("\n", $old)."\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen($new)) {
|
|
|
|
$new = phutil_utf8_hard_wrap($new, 80);
|
|
|
|
$new = implode("\n", $new)."\n";
|
|
|
|
}
|
2013-02-17 15:37:02 +01:00
|
|
|
|
2013-04-16 17:41:36 +02:00
|
|
|
try {
|
|
|
|
$engine = new PhabricatorDifferenceEngine();
|
|
|
|
$changeset = $engine->generateChangesetFromFileContent($old, $new);
|
2013-02-17 15:37:02 +01:00
|
|
|
|
2013-04-16 17:41:36 +02:00
|
|
|
$whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
|
2013-02-17 15:37:02 +01:00
|
|
|
|
2013-04-16 17:41:36 +02:00
|
|
|
$markup_engine = new PhabricatorMarkupEngine();
|
|
|
|
$markup_engine->setViewer($this->getUser());
|
2013-03-04 21:33:05 +01:00
|
|
|
|
2013-04-16 17:41:36 +02:00
|
|
|
$parser = new DifferentialChangesetParser();
|
|
|
|
$parser->setChangeset($changeset);
|
|
|
|
$parser->setMarkupEngine($markup_engine);
|
|
|
|
$parser->setWhitespaceMode($whitespace_mode);
|
2013-02-17 15:37:02 +01:00
|
|
|
|
2013-04-16 17:41:36 +02:00
|
|
|
return $parser->render(0, PHP_INT_MAX, array());
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
return $ex->getMessage();
|
|
|
|
}
|
2013-02-17 15:37:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|