2011-03-07 15:13:36 -08:00
|
|
|
<?php
|
|
|
|
|
|
2012-03-09 15:46:25 -08:00
|
|
|
final class DiffusionHomeController extends DiffusionController {
|
2011-03-07 15:13:36 -08:00
|
|
|
|
|
|
|
|
public function processRequest() {
|
2011-06-18 13:07:02 -07:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$user = $request->getUser();
|
2011-03-07 15:13:36 -08:00
|
|
|
|
2011-03-31 00:33:44 -07:00
|
|
|
$shortcuts = id(new PhabricatorRepositoryShortcut())->loadAll();
|
|
|
|
|
if ($shortcuts) {
|
|
|
|
|
$shortcuts = msort($shortcuts, 'getSequence');
|
|
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
|
foreach ($shortcuts as $shortcut) {
|
|
|
|
|
$rows[] = array(
|
2013-05-11 08:23:19 -07:00
|
|
|
$shortcut->getName(),
|
|
|
|
|
$shortcut->getHref(),
|
2013-02-13 14:50:15 -08:00
|
|
|
$shortcut->getDescription(),
|
2011-03-31 00:33:44 -07:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 14:14:34 -07:00
|
|
|
$list = new PHUIObjectItemListView();
|
2013-05-11 08:23:19 -07:00
|
|
|
$list->setCards(true);
|
|
|
|
|
$list->setFlush(true);
|
|
|
|
|
foreach ($rows as $row) {
|
2013-09-09 14:14:34 -07:00
|
|
|
$item = id(new PHUIObjectItemView())
|
2013-05-11 08:23:19 -07:00
|
|
|
->setHeader($row[0])
|
|
|
|
|
->setHref($row[1])
|
|
|
|
|
->setSubhead(($row[2] ? $row[2] : pht('No Description')));
|
|
|
|
|
$list->addItem($item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$shortcut_panel = id(new AphrontPanelView())
|
|
|
|
|
->setNoBackground(true)
|
|
|
|
|
->setHeader(pht('Shortcuts'))
|
|
|
|
|
->appendChild($list);
|
|
|
|
|
|
2011-03-31 00:33:44 -07:00
|
|
|
} else {
|
|
|
|
|
$shortcut_panel = null;
|
|
|
|
|
}
|
2011-03-07 15:13:36 -08:00
|
|
|
|
2012-12-19 11:07:06 -08:00
|
|
|
$repositories = id(new PhabricatorRepositoryQuery())
|
|
|
|
|
->setViewer($user)
|
2013-09-10 15:22:41 -07:00
|
|
|
->needCommitCounts(true)
|
|
|
|
|
->needMostRecentCommits(true)
|
2012-12-19 11:07:06 -08:00
|
|
|
->execute();
|
2011-03-20 17:46:02 -07:00
|
|
|
|
2012-03-29 13:24:06 -07:00
|
|
|
foreach ($repositories as $key => $repo) {
|
|
|
|
|
if (!$repo->isTracked()) {
|
2012-04-03 13:54:01 -07:00
|
|
|
unset($repositories[$key]);
|
2011-03-15 13:38:14 -07:00
|
|
|
}
|
|
|
|
|
}
|
2013-01-16 10:51:08 -08:00
|
|
|
$repositories = msort($repositories, 'getName');
|
2011-03-07 15:13:36 -08:00
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
|
foreach ($repositories as $repository) {
|
2011-03-12 22:51:40 -08:00
|
|
|
$id = $repository->getID();
|
2011-03-20 17:46:02 -07:00
|
|
|
|
2013-09-10 15:22:41 -07:00
|
|
|
$size = $repository->getCommitCount();
|
|
|
|
|
if ($size) {
|
2012-11-08 13:45:21 -08:00
|
|
|
$size = hsprintf(
|
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
|
DiffusionRequest::generateDiffusionURI(array(
|
|
|
|
|
'callsign' => $repository->getCallsign(),
|
|
|
|
|
'action' => 'history',
|
|
|
|
|
)),
|
2013-05-13 08:09:08 -07:00
|
|
|
pht('%s Commits', new PhutilNumber($size)));
|
2012-11-08 13:45:21 -08:00
|
|
|
}
|
2011-03-20 17:46:02 -07:00
|
|
|
|
2013-05-11 08:23:19 -07:00
|
|
|
$datetime = '';
|
2013-09-10 15:22:41 -07:00
|
|
|
$most_recent_commit = $repository->getMostRecentCommit();
|
|
|
|
|
if ($most_recent_commit) {
|
|
|
|
|
$date = phabricator_date($most_recent_commit->getEpoch(), $user);
|
|
|
|
|
$time = phabricator_time($most_recent_commit->getEpoch(), $user);
|
2013-05-11 08:23:19 -07:00
|
|
|
$datetime = $date.' '.$time;
|
2011-03-12 22:51:40 -08:00
|
|
|
}
|
|
|
|
|
|
2011-03-07 15:13:36 -08:00
|
|
|
$rows[] = array(
|
2013-05-11 08:23:19 -07:00
|
|
|
$repository->getName(),
|
|
|
|
|
('/diffusion/'.$repository->getCallsign().'/'),
|
2011-03-15 13:38:14 -07:00
|
|
|
PhabricatorRepositoryType::getNameForRepositoryType(
|
|
|
|
|
$repository->getVersionControlSystem()),
|
2013-09-10 15:22:41 -07:00
|
|
|
$size ? $size : null,
|
|
|
|
|
$most_recent_commit
|
2011-03-12 22:51:40 -08:00
|
|
|
? DiffusionView::linkCommit(
|
|
|
|
|
$repository,
|
2013-09-10 15:22:41 -07:00
|
|
|
$most_recent_commit->getCommitIdentifier(),
|
|
|
|
|
$most_recent_commit->getSummary())
|
2013-05-11 08:23:19 -07:00
|
|
|
: pht('No Commits'),
|
|
|
|
|
$datetime
|
2011-03-07 15:13:36 -08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-30 09:09:40 -07:00
|
|
|
$repository_tool_uri = PhabricatorEnv::getProductionURI('/repository/');
|
2013-01-17 18:57:09 -08:00
|
|
|
$repository_tool = phutil_tag('a',
|
2013-02-28 08:47:51 -08:00
|
|
|
array(
|
|
|
|
|
'href' => $repository_tool_uri,
|
|
|
|
|
),
|
|
|
|
|
'repository tool');
|
|
|
|
|
$preface = pht('This instance of Phabricator does not have any '.
|
|
|
|
|
'configured repositories.');
|
2012-07-30 09:09:40 -07:00
|
|
|
if ($user->getIsAdmin()) {
|
2013-02-28 08:47:51 -08:00
|
|
|
$no_repositories_txt = hsprintf(
|
|
|
|
|
'%s %s',
|
|
|
|
|
$preface,
|
|
|
|
|
pht(
|
|
|
|
|
'To setup one or more repositories, visit the %s.',
|
|
|
|
|
$repository_tool));
|
2012-07-30 09:09:40 -07:00
|
|
|
} else {
|
2013-02-28 08:47:51 -08:00
|
|
|
$no_repositories_txt = hsprintf(
|
|
|
|
|
'%s %s',
|
|
|
|
|
$preface,
|
|
|
|
|
pht(
|
|
|
|
|
'Ask an administrator to setup one or more repositories '.
|
|
|
|
|
'via the %s.',
|
|
|
|
|
$repository_tool));
|
2012-07-30 09:09:40 -07:00
|
|
|
}
|
|
|
|
|
|
2013-09-09 14:14:34 -07:00
|
|
|
$list = new PHUIObjectItemListView();
|
2013-05-11 08:23:19 -07:00
|
|
|
$list->setCards(true);
|
|
|
|
|
$list->setFlush(true);
|
|
|
|
|
foreach ($rows as $row) {
|
2013-09-09 14:14:34 -07:00
|
|
|
$item = id(new PHUIObjectItemView())
|
2013-05-11 08:23:19 -07:00
|
|
|
->setHeader($row[0])
|
2013-09-10 15:24:28 -07:00
|
|
|
->setSubHead($row[4])
|
2013-05-11 08:23:19 -07:00
|
|
|
->setHref($row[1])
|
|
|
|
|
->addAttribute(($row[2] ? $row[2] : pht('No Information')))
|
|
|
|
|
->addAttribute(($row[3] ? $row[3] : pht('0 Commits')))
|
2013-09-10 15:24:28 -07:00
|
|
|
->addIcon('none', $row[5]);
|
2013-05-11 08:23:19 -07:00
|
|
|
$list->addItem($item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list = id(new AphrontPanelView())
|
|
|
|
|
->setNoBackground(true)
|
|
|
|
|
->setHeader(pht('Repositories'))
|
|
|
|
|
->appendChild($list);
|
2011-03-07 15:13:36 -08:00
|
|
|
|
|
|
|
|
|
2011-03-12 16:17:34 -08:00
|
|
|
$crumbs = $this->buildCrumbs();
|
2012-12-12 18:40:18 -08:00
|
|
|
$crumbs->addCrumb(
|
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
|
->setName(pht('All Repositories'))
|
|
|
|
|
->setHref($this->getApplicationURI()));
|
2011-03-12 16:17:34 -08:00
|
|
|
|
2013-05-11 08:23:19 -07:00
|
|
|
return $this->buildApplicationPage(
|
2011-03-12 16:17:34 -08:00
|
|
|
array(
|
|
|
|
|
$crumbs,
|
2011-03-31 00:33:44 -07:00
|
|
|
$shortcut_panel,
|
2013-05-11 08:23:19 -07:00
|
|
|
$list,
|
2011-03-12 16:17:34 -08:00
|
|
|
),
|
2011-03-07 15:13:36 -08:00
|
|
|
array(
|
2013-05-11 08:23:19 -07:00
|
|
|
'title' => pht('Diffusion'),
|
|
|
|
|
'device' => true,
|
2011-03-07 15:13:36 -08:00
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|