2011-03-08 02:25:47 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DiffusionBrowseController extends DiffusionController {
|
2011-03-08 02:25:47 +01:00
|
|
|
|
|
|
|
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',
|
|
|
|
));
|
|
|
|
|
2012-04-24 03:36:25 +02:00
|
|
|
if ($drequest->getTagContent()) {
|
|
|
|
$title = 'Tag: '.$drequest->getSymbolicCommit();
|
|
|
|
|
|
|
|
$tag_view = new AphrontPanelView();
|
|
|
|
$tag_view->setHeader(phutil_escape_html($title));
|
|
|
|
$tag_view->appendChild(
|
|
|
|
$this->markupText($drequest->getTagContent()));
|
|
|
|
|
|
|
|
$content[] = $tag_view;
|
|
|
|
}
|
|
|
|
|
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);
|
2012-04-02 20:12:42 +02:00
|
|
|
$empty_result->setView($this->getRequest()->getStr('view'));
|
2012-02-01 19:59:20 +01:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-26 21:21:39 +02:00
|
|
|
$phids = array_keys($phids);
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2011-04-03 01:44:19 +02:00
|
|
|
|
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);
|
2012-08-02 21:22:50 +02:00
|
|
|
$browse_table->setUser($this->getRequest()->getUser());
|
2011-03-08 02:25:47 +01:00
|
|
|
|
|
|
|
$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();
|
|
|
|
|
2012-04-30 16:47:41 +02:00
|
|
|
$readme_content = $browse_query->renderReadme($results);
|
|
|
|
if ($readme_content) {
|
|
|
|
$readme_panel = new AphrontPanelView();
|
|
|
|
$readme_panel->setHeader('README');
|
|
|
|
$readme_panel->appendChild($readme_content);
|
|
|
|
|
|
|
|
$content[] = $readme_panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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(
|
2012-04-24 03:36:25 +02:00
|
|
|
'title' => array(
|
|
|
|
nonempty(basename($drequest->getPath()), '/'),
|
|
|
|
$drequest->getRepository()->getCallsign().' Repository',
|
|
|
|
),
|
2011-03-08 02:25:47 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-04-24 03:36:25 +02:00
|
|
|
private function markupText($text) {
|
|
|
|
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
|
|
|
|
$text = $engine->markupText($text);
|
|
|
|
|
|
|
|
$text = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-remarkup',
|
|
|
|
),
|
|
|
|
$text);
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
2011-03-08 02:25:47 +01:00
|
|
|
}
|