mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 11:12:42 +01:00
6270114767
Summary: - Removed trailing newlines. - Added newline at EOF. - Removed leading newlines. - Trimmed trailing whitespace. - Spelling fix. - Added newline at EOF Test Plan: N/A Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: hach-que, chad, Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D8344
56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?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.
|
|
|
|
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";
|
|
}
|
|
|
|
try {
|
|
$engine = new PhabricatorDifferenceEngine();
|
|
$changeset = $engine->generateChangesetFromFileContent($old, $new);
|
|
|
|
$whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
|
|
|
|
$markup_engine = new PhabricatorMarkupEngine();
|
|
$markup_engine->setViewer($this->getUser());
|
|
|
|
$parser = new DifferentialChangesetParser();
|
|
$parser->setChangeset($changeset);
|
|
$parser->setMarkupEngine($markup_engine);
|
|
$parser->setWhitespaceMode($whitespace_mode);
|
|
|
|
return $parser->render(0, PHP_INT_MAX, array());
|
|
} catch (Exception $ex) {
|
|
return $ex->getMessage();
|
|
}
|
|
}
|
|
|
|
}
|