2011-03-11 18:34:22 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-01-21 06:40:17 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-03-11 18:34:22 +01:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
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();
|
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;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
|
2011-03-11 18:34:22 +01:00
|
|
|
foreach ($this->pathChanges as $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-01-21 06:40:17 +01:00
|
|
|
$path_column = phutil_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#'.$hash,
|
|
|
|
),
|
|
|
|
phutil_escape_html($path));
|
|
|
|
|
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) {
|
|
|
|
$owners_path = $owners_path->getPath();
|
|
|
|
if (strncmp('/'.$path, $owners_path, strlen($owners_path)) == 0) {
|
|
|
|
$row_class = 'highlighted';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$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();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|