Implement basic transaction detail blocks

Summary:
Some transactions (like editing configuration values, task descriptions, or Conpherence images) can't be simply explained and need an additional larger element to show them fully (like a text diff).

Support change details like this in ApplicationTransactions. Implements the element in Config, so you can see changes.

Test Plan: {F32974}

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T2213

Differential Revision: https://secure.phabricator.com/D4984
This commit is contained in:
epriestley
2013-02-17 06:37:02 -08:00
parent 5fb56f859c
commit 2231e5200a
13 changed files with 250 additions and 95 deletions

View File

@@ -0,0 +1,45 @@
<?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.
// TODO: This should be utf8-aware, but we don't currently have a plain-text
// utf8 hard-wrap function. See T2554.
$old = wordwrap($old, 80);
$new = wordwrap($new, 80);
$engine = new PhabricatorDifferenceEngine();
$changeset = $engine->generateChangesetFromFileContent($old, $new);
$whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
$parser = new DifferentialChangesetParser();
$parser->setChangeset($changeset);
$parser->setMarkupEngine(new PhabricatorMarkupEngine());
$parser->setWhitespaceMode($whitespace_mode);
return $parser->render(0, PHP_INT_MAX, array());
}
}