2011-03-08 17:31:44 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2011 Facebook, Inc.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class DiffusionHistoryController extends DiffusionController {
|
|
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
$drequest = $this->diffusionRequest;
|
2011-03-31 18:46:53 -07:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
|
|
$page_size = $request->getInt('pagesize', 100);
|
|
|
|
|
$offset = $request->getInt('page', 0);
|
2011-03-08 17:31:44 -08:00
|
|
|
|
|
|
|
|
$history_query = DiffusionHistoryQuery::newFromDiffusionRequest(
|
|
|
|
|
$drequest);
|
2011-03-31 18:46:53 -07:00
|
|
|
$history_query->setOffset($offset);
|
|
|
|
|
$history_query->setLimit($page_size + 1);
|
2011-03-08 17:31:44 -08:00
|
|
|
$history = $history_query->loadHistory();
|
|
|
|
|
|
2011-04-02 16:39:23 -07:00
|
|
|
$phids = array();
|
|
|
|
|
foreach ($history as $item) {
|
|
|
|
|
$data = $item->getCommitData();
|
|
|
|
|
if ($data) {
|
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
2011-04-03 14:48:36 -07:00
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
2011-04-02 16:39:23 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-03 14:48:36 -07:00
|
|
|
$phids = array_keys($phids);
|
2011-04-02 16:39:23 -07:00
|
|
|
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
|
|
|
|
|
2011-03-31 18:46:53 -07:00
|
|
|
$pager = new AphrontPagerView();
|
|
|
|
|
$pager->setPageSize($page_size);
|
|
|
|
|
$pager->setOffset($offset);
|
|
|
|
|
if (count($history) == $page_size + 1) {
|
|
|
|
|
array_pop($history);
|
|
|
|
|
$pager->setHasMorePages(true);
|
|
|
|
|
} else {
|
|
|
|
|
$pager->setHasMorePages(false);
|
|
|
|
|
}
|
|
|
|
|
$pager->setURI($request->getRequestURI(), 'page');
|
|
|
|
|
|
2011-03-08 17:31:44 -08:00
|
|
|
$content = array();
|
|
|
|
|
|
2011-03-12 16:17:34 -08:00
|
|
|
$content[] = $this->buildCrumbs(
|
|
|
|
|
array(
|
|
|
|
|
'branch' => true,
|
|
|
|
|
'path' => true,
|
|
|
|
|
'view' => 'history',
|
|
|
|
|
));
|
|
|
|
|
|
2011-03-08 17:31:44 -08:00
|
|
|
$history_table = new DiffusionHistoryTableView();
|
|
|
|
|
$history_table->setDiffusionRequest($drequest);
|
2011-04-02 16:39:23 -07:00
|
|
|
$history_table->setHandles($handles);
|
2011-03-08 17:31:44 -08:00
|
|
|
$history_table->setHistory($history);
|
|
|
|
|
|
|
|
|
|
$history_panel = new AphrontPanelView();
|
|
|
|
|
$history_panel->appendChild($history_table);
|
2011-03-31 18:46:53 -07:00
|
|
|
$history_panel->appendChild($pager);
|
2011-03-08 17:31:44 -08:00
|
|
|
|
|
|
|
|
$content[] = $history_panel;
|
|
|
|
|
|
2011-03-12 16:17:34 -08:00
|
|
|
// TODO: Sometimes we do have a change view, we need to look at the most
|
|
|
|
|
// recent history entry to figure it out.
|
|
|
|
|
|
|
|
|
|
$nav = $this->buildSideNav('history', false);
|
|
|
|
|
$nav->appendChild($content);
|
2011-03-08 17:31:44 -08:00
|
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
2011-03-12 16:17:34 -08:00
|
|
|
$nav,
|
2011-03-08 17:31:44 -08:00
|
|
|
array(
|
|
|
|
|
'title' => 'history',
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|