Path: blob/master/src/infrastructure/diff/view/PHUIDiffTwoUpInlineCommentRowScaffold.php
12242 views
<?php12/**3* Row scaffold for 2up (side-by-side) changeset views.4*5* Although this scaffold is normally straightforward, it may also accept6* two inline comments and display them adjacently.7*/8final class PHUIDiffTwoUpInlineCommentRowScaffold9extends PHUIDiffInlineCommentRowScaffold {1011public function render() {12$inlines = $this->getInlineViews();1314if (!$inlines) {15throw new Exception(16pht('Two-up inline row scaffold must have at least one inline view.'));17}1819if (count($inlines) > 2) {20throw new Exception(21pht('Two-up inline row scaffold must have at most two inline views.'));22}2324if (count($inlines) == 1) {25$inline = head($inlines);26if ($inline->getIsOnRight()) {27$left_side = null;28$right_side = $inline;2930$left_hidden = null;31$right_hidden = $inline->newHiddenIcon();32} else {33$left_side = $inline;34$right_side = null;3536$left_hidden = $inline->newHiddenIcon();37$right_hidden = null;38}39} else {40list($u, $v) = $inlines;4142if ($u->getIsOnRight() == $v->getIsOnRight()) {43throw new Exception(44pht(45'Two-up inline row scaffold must have one comment on the left and '.46'one comment on the right when showing two comments.'));47}4849if ($v->getIsOnRight()) {50$left_side = $u;51$right_side = $v;52} else {53$left_side = $v;54$right_side = $u;55}5657$left_hidden = null;58$right_hidden = null;59}6061$left_attrs = array(62'class' => 'left',63'id' => ($left_side ? $left_side->getScaffoldCellID() : null),64);6566$right_attrs = array(67'colspan' => 2,68'id' => ($right_side ? $right_side->getScaffoldCellID() : null),69);7071$cells = array(72phutil_tag('td', array('class' => 'n'), $left_hidden),73phutil_tag('td', $left_attrs, $left_side),74phutil_tag('td', array('class' => 'n'), $right_hidden),75phutil_tag('td', array('class' => 'copy')),76phutil_tag('td', $right_attrs, $right_side),77);7879return javelin_tag('tr', $this->getRowAttributes(), $cells);80}8182}838485