2011-03-08 02:25:47 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-02-01 19:59:20 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-03-08 02:25:47 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class DiffusionBrowseController extends DiffusionController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
2011-03-08 23:29:02 +01:00
|
|
|
$drequest = $this->diffusionRequest;
|
2011-03-08 02:25:47 +01:00
|
|
|
|
2011-03-08 23:29:02 +01:00
|
|
|
$browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
|
|
|
|
$results = $browse_query->loadPaths();
|
2011-03-08 02:25:47 +01:00
|
|
|
|
2011-03-08 03:21:43 +01:00
|
|
|
$content = array();
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
$content[] = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'browse',
|
|
|
|
));
|
|
|
|
|
2011-03-08 02:25:47 +01:00
|
|
|
if (!$results) {
|
2011-03-08 03:21:43 +01:00
|
|
|
|
2012-02-01 19:59:20 +01:00
|
|
|
if ($browse_query->getReasonForEmptyResultSet() ==
|
|
|
|
DiffusionBrowseQuery::REASON_IS_FILE) {
|
|
|
|
$controller = new DiffusionBrowseFileController($this->getRequest());
|
|
|
|
$controller->setDiffusionRequest($drequest);
|
|
|
|
return $this->delegateToController($controller);
|
2011-03-19 22:38:50 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 19:59:20 +01:00
|
|
|
$empty_result = new DiffusionEmptyResultView();
|
|
|
|
$empty_result->setDiffusionRequest($drequest);
|
|
|
|
$empty_result->setBrowseQuery($browse_query);
|
|
|
|
$content[] = $empty_result;
|
2011-03-08 03:21:43 +01:00
|
|
|
|
2011-03-08 02:25:47 +01:00
|
|
|
} else {
|
2011-04-03 01:44:19 +02:00
|
|
|
|
|
|
|
$phids = array();
|
|
|
|
foreach ($results as $result) {
|
|
|
|
$data = $result->getLastCommitData();
|
|
|
|
if ($data) {
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$phids = array_keys($phids);
|
|
|
|
|
|
|
|
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
|
|
|
|
2011-03-08 02:25:47 +01:00
|
|
|
$browse_table = new DiffusionBrowseTableView();
|
2011-03-08 23:29:02 +01:00
|
|
|
$browse_table->setDiffusionRequest($drequest);
|
2011-04-03 01:44:19 +02:00
|
|
|
$browse_table->setHandles($handles);
|
2011-03-08 02:25:47 +01:00
|
|
|
$browse_table->setPaths($results);
|
|
|
|
|
|
|
|
$browse_panel = new AphrontPanelView();
|
|
|
|
$browse_panel->appendChild($browse_table);
|
|
|
|
|
2011-03-08 03:21:43 +01:00
|
|
|
$content[] = $browse_panel;
|
2011-03-08 02:25:47 +01:00
|
|
|
}
|
|
|
|
|
2011-10-02 21:52:54 +02:00
|
|
|
$content[] = $this->buildOpenRevisions();
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
$nav = $this->buildSideNav('browse', false);
|
|
|
|
$nav->appendChild($content);
|
2011-03-08 02:25:47 +01:00
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
2011-03-13 01:17:34 +01:00
|
|
|
$nav,
|
2011-03-08 02:25:47 +01:00
|
|
|
array(
|
2011-03-08 23:29:02 +01:00
|
|
|
'title' => basename($drequest->getPath()),
|
2011-03-08 02:25:47 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|