2011-03-11 18:34:22 +01:00
|
|
|
<?php
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
final class DiffusionCommitChangeTableView extends DiffusionView {
|
2011-03-11 18:34:22 +01:00
|
|
|
|
|
|
|
private $pathChanges;
|
2012-07-17 00:00:32 +02:00
|
|
|
private $ownersPaths = array();
|
2012-08-07 08:01:23 +02:00
|
|
|
private $renderingReferences;
|
2011-03-11 18:34:22 +01:00
|
|
|
|
|
|
|
public function setPathChanges(array $path_changes) {
|
2012-04-04 01:22:31 +02:00
|
|
|
assert_instances_of($path_changes, 'DiffusionPathChange');
|
2011-03-11 18:34:22 +01:00
|
|
|
$this->pathChanges = $path_changes;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-07-17 00:00:32 +02:00
|
|
|
public function setOwnersPaths(array $owners_paths) {
|
|
|
|
assert_instances_of($owners_paths, 'PhabricatorOwnersPath');
|
|
|
|
$this->ownersPaths = $owners_paths;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-08-07 08:01:23 +02:00
|
|
|
public function setRenderingReferences(array $value) {
|
|
|
|
$this->renderingReferences = $value;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:34:22 +01:00
|
|
|
public function render() {
|
|
|
|
$rows = array();
|
2012-07-17 00:00:32 +02:00
|
|
|
$rowc = array();
|
2011-03-19 22:38:50 +01:00
|
|
|
|
|
|
|
// TODO: Experiment with path stack rendering.
|
|
|
|
|
|
|
|
// TODO: Copy Away and Move Away are rendered junkily still.
|
|
|
|
|
2012-08-07 08:01:23 +02:00
|
|
|
foreach ($this->pathChanges as $id => $change) {
|
2011-03-31 07:08:41 +02:00
|
|
|
$path = $change->getPath();
|
2012-01-21 06:40:17 +01:00
|
|
|
$hash = substr(md5($path), 0, 8);
|
2011-03-19 22:38:50 +01:00
|
|
|
if ($change->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
2012-01-21 06:40:17 +01:00
|
|
|
$path .= '/';
|
2011-03-31 07:08:41 +02:00
|
|
|
}
|
2011-03-19 22:38:50 +01:00
|
|
|
|
2012-10-09 01:51:50 +02:00
|
|
|
if (isset($this->renderingReferences[$id])) {
|
2013-01-25 21:57:17 +01:00
|
|
|
$path_column = javelin_tag(
|
2012-10-09 01:51:50 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#'.$hash,
|
|
|
|
'meta' => array(
|
|
|
|
'id' => 'diff-'.$hash,
|
|
|
|
'ref' => $this->renderingReferences[$id],
|
|
|
|
),
|
|
|
|
'sigil' => 'differential-load',
|
2012-08-07 08:01:23 +02:00
|
|
|
),
|
2013-01-25 21:57:17 +01:00
|
|
|
$path);
|
2012-10-09 01:51:50 +02:00
|
|
|
} else {
|
2013-02-13 23:50:15 +01:00
|
|
|
$path_column = $path;
|
2012-10-09 01:51:50 +02:00
|
|
|
}
|
2012-01-21 06:40:17 +01:00
|
|
|
|
2011-03-11 18:34:22 +01:00
|
|
|
$rows[] = array(
|
2011-03-14 00:19:39 +01:00
|
|
|
$this->linkHistory($change->getPath()),
|
|
|
|
$this->linkBrowse($change->getPath()),
|
2011-03-14 06:03:30 +01:00
|
|
|
$this->linkChange(
|
2011-03-19 22:38:50 +01:00
|
|
|
$change->getChangeType(),
|
2011-03-31 02:36:16 +02:00
|
|
|
$change->getFileType(),
|
|
|
|
$change->getPath()),
|
2011-03-31 07:08:41 +02:00
|
|
|
$path_column,
|
2011-03-11 18:34:22 +01:00
|
|
|
);
|
2012-07-17 00:00:32 +02:00
|
|
|
|
|
|
|
$row_class = null;
|
|
|
|
foreach ($this->ownersPaths as $owners_path) {
|
2012-12-07 02:23:56 +01:00
|
|
|
$excluded = $owners_path->getExcluded();
|
2012-07-17 00:00:32 +02:00
|
|
|
$owners_path = $owners_path->getPath();
|
|
|
|
if (strncmp('/'.$path, $owners_path, strlen($owners_path)) == 0) {
|
2012-12-07 02:23:56 +01:00
|
|
|
if ($excluded) {
|
|
|
|
$row_class = null;
|
|
|
|
break;
|
|
|
|
}
|
2012-07-17 00:00:32 +02:00
|
|
|
$row_class = 'highlighted';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$rowc[] = $row_class;
|
2011-03-11 18:34:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$view = new AphrontTableView($rows);
|
|
|
|
$view->setHeaders(
|
|
|
|
array(
|
|
|
|
'History',
|
2011-03-14 00:19:39 +01:00
|
|
|
'Browse',
|
2011-03-11 18:34:22 +01:00
|
|
|
'Change',
|
|
|
|
'Path',
|
|
|
|
));
|
|
|
|
$view->setColumnClasses(
|
|
|
|
array(
|
2011-03-14 00:19:39 +01:00
|
|
|
'',
|
2011-03-11 18:34:22 +01:00
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'wide',
|
|
|
|
));
|
2012-07-17 00:00:32 +02:00
|
|
|
$view->setRowClasses($rowc);
|
2011-03-11 18:34:22 +01:00
|
|
|
$view->setNoDataString('This change has not been fully parsed yet.');
|
|
|
|
|
|
|
|
return $view->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|