2011-03-08 17:31:44 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-23 15:32:26 -07:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-03-08 17:31:44 -08: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-12 16:17:34 -08:00
|
|
|
final class DiffusionHistoryTableView extends DiffusionView {
|
2011-03-08 17:31:44 -08:00
|
|
|
|
|
|
|
|
private $history;
|
2011-04-02 16:39:23 -07:00
|
|
|
private $handles = array();
|
2011-03-08 17:31:44 -08:00
|
|
|
|
|
|
|
|
public function setHistory(array $history) {
|
|
|
|
|
$this->history = $history;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-02 16:39:23 -07:00
|
|
|
public function setHandles(array $handles) {
|
|
|
|
|
$this->handles = $handles;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-23 15:32:26 -07:00
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
|
$phids = array();
|
|
|
|
|
foreach ($this->history as $item) {
|
|
|
|
|
$data = $item->getCommitData();
|
|
|
|
|
if ($data) {
|
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
|
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return array_keys($phids);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-08 17:31:44 -08:00
|
|
|
public function render() {
|
2011-03-12 16:17:34 -08:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
2011-04-02 16:39:23 -07:00
|
|
|
$handles = $this->handles;
|
|
|
|
|
|
2011-03-08 17:31:44 -08:00
|
|
|
$rows = array();
|
|
|
|
|
foreach ($this->history as $history) {
|
2011-03-12 22:51:40 -08:00
|
|
|
$epoch = $history->getEpoch();
|
|
|
|
|
|
|
|
|
|
if ($epoch) {
|
|
|
|
|
$date = date('M j, Y', $epoch);
|
|
|
|
|
$time = date('g:i A', $epoch);
|
|
|
|
|
} else {
|
|
|
|
|
$date = null;
|
|
|
|
|
$time = null;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-02 16:39:23 -07:00
|
|
|
$data = $history->getCommitData();
|
|
|
|
|
$author_phid = null;
|
|
|
|
|
if ($data) {
|
|
|
|
|
$author_phid = $data->getCommitDetail('authorPHID');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($author_phid && isset($handles[$author_phid])) {
|
|
|
|
|
$author = $handles[$author_phid]->renderLink();
|
|
|
|
|
} else {
|
|
|
|
|
$author = phutil_escape_html($history->getAuthorName());
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-08 17:31:44 -08:00
|
|
|
$rows[] = array(
|
2011-03-12 16:17:34 -08:00
|
|
|
$this->linkBrowse(
|
|
|
|
|
$drequest->getPath(),
|
|
|
|
|
array(
|
|
|
|
|
'commit' => $history->getCommitIdentifier(),
|
|
|
|
|
)),
|
|
|
|
|
self::linkCommit(
|
|
|
|
|
$drequest->getRepository(),
|
|
|
|
|
$history->getCommitIdentifier()),
|
2011-03-13 22:03:30 -07:00
|
|
|
$this->linkChange(
|
|
|
|
|
$history->getChangeType(),
|
2011-05-09 16:42:39 -07:00
|
|
|
$history->getFileType(),
|
|
|
|
|
null,
|
|
|
|
|
$history->getCommitIdentifier()),
|
2011-03-12 22:51:40 -08:00
|
|
|
$date,
|
|
|
|
|
$time,
|
2011-04-02 16:39:23 -07:00
|
|
|
$author,
|
2011-07-31 08:38:06 -07:00
|
|
|
AphrontTableView::renderSingleDisplayLine(
|
|
|
|
|
phutil_escape_html($history->getSummary())),
|
2011-03-08 17:31:44 -08:00
|
|
|
// TODO: etc etc
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$view = new AphrontTableView($rows);
|
|
|
|
|
$view->setHeaders(
|
|
|
|
|
array(
|
2011-03-12 16:17:34 -08:00
|
|
|
'Browse',
|
2011-03-08 17:31:44 -08:00
|
|
|
'Commit',
|
2011-03-12 16:17:34 -08:00
|
|
|
'Change',
|
|
|
|
|
'Date',
|
2011-03-12 22:51:40 -08:00
|
|
|
'Time',
|
2011-03-12 16:17:34 -08:00
|
|
|
'Author',
|
|
|
|
|
'Details',
|
|
|
|
|
));
|
|
|
|
|
$view->setColumnClasses(
|
|
|
|
|
array(
|
|
|
|
|
'',
|
|
|
|
|
'n',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
2011-03-12 22:51:40 -08:00
|
|
|
'right',
|
2011-03-12 16:17:34 -08:00
|
|
|
'',
|
2011-07-31 08:38:06 -07:00
|
|
|
'wide',
|
2011-03-08 17:31:44 -08:00
|
|
|
));
|
|
|
|
|
return $view->render();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|