2012-11-09 01:13:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionLintDetailsController extends DiffusionController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$limit = 500;
|
|
|
|
$offset = $this->getRequest()->getInt('offset', 0);
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
2012-11-10 02:45:19 +01:00
|
|
|
$branch = $drequest->loadBranch();
|
|
|
|
$messages = $this->loadLintMessages($branch, $limit, $offset);
|
2012-11-09 01:13:21 +01:00
|
|
|
$is_dir = (substr('/'.$drequest->getPath(), -1) == '/');
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($messages as $message) {
|
|
|
|
$path = hsprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$drequest->generateURI(array(
|
|
|
|
'action' => 'lint',
|
|
|
|
'path' => $message['path'],
|
|
|
|
)),
|
|
|
|
substr($message['path'], strlen($drequest->getPath()) + 1));
|
|
|
|
|
|
|
|
$line = hsprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$drequest->generateURI(array(
|
|
|
|
'action' => 'browse',
|
|
|
|
'path' => $message['path'],
|
|
|
|
'line' => $message['line'],
|
2012-11-10 02:45:19 +01:00
|
|
|
'commit' => $branch->getLintCommit(),
|
2012-11-09 01:13:21 +01:00
|
|
|
)),
|
|
|
|
$message['line']);
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
$path,
|
|
|
|
$line,
|
|
|
|
phutil_escape_html(ArcanistLintSeverity::getStringForSeverity(
|
|
|
|
$message['severity'])),
|
|
|
|
phutil_escape_html($message['name']),
|
|
|
|
phutil_escape_html($message['description']),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setHeaders(array(
|
|
|
|
'Path',
|
|
|
|
'Line',
|
|
|
|
'Severity',
|
|
|
|
'Name',
|
2012-11-10 02:45:19 +01:00
|
|
|
'Description',
|
2012-11-09 01:13:21 +01:00
|
|
|
))
|
2012-11-10 02:45:19 +01:00
|
|
|
->setColumnClasses(array('', 'n', '', '', ''))
|
|
|
|
->setColumnVisibility(array($is_dir));
|
2012-11-09 01:13:21 +01:00
|
|
|
|
|
|
|
$content = array();
|
|
|
|
|
|
|
|
$content[] = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'lint',
|
|
|
|
));
|
|
|
|
|
|
|
|
$pager = id(new AphrontPagerView())
|
|
|
|
->setPageSize($limit)
|
|
|
|
->setOffset($offset)
|
|
|
|
->setHasMorePages(count($messages) >= $limit)
|
|
|
|
->setURI($this->getRequest()->getRequestURI(), 'offset');
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
$lint = $drequest->getLint();
|
|
|
|
$link = hsprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$drequest->generateURI(array(
|
|
|
|
'action' => 'lint',
|
|
|
|
'lint' => null,
|
|
|
|
)),
|
|
|
|
pht('Switch to Grouped View'));
|
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
$content[] = id(new AphrontPanelView())
|
2012-11-10 02:45:19 +01:00
|
|
|
->setHeader(
|
|
|
|
($lint != '' ? phutil_escape_html($lint)." \xC2\xB7 " : '').
|
|
|
|
pht('%d Lint Message(s)', count($messages)))
|
|
|
|
->setCaption($link)
|
2012-11-09 01:13:21 +01:00
|
|
|
->appendChild($table)
|
|
|
|
->appendChild($pager);
|
|
|
|
|
|
|
|
$nav = $this->buildSideNav('lint', false);
|
|
|
|
$nav->appendChild($content);
|
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
|
|
|
$nav,
|
|
|
|
array('title' => array(
|
|
|
|
'Lint',
|
|
|
|
$drequest->getRepository()->getCallsign(),
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
private function loadLintMessages(
|
|
|
|
PhabricatorRepositoryBranch $branch,
|
|
|
|
$limit,
|
|
|
|
$offset) {
|
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
if (!$branch) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$conn = $branch->establishConnection('r');
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
$where = array();
|
2012-11-09 01:13:21 +01:00
|
|
|
if ($drequest->getPath() != '') {
|
|
|
|
$is_dir = (substr($drequest->getPath(), -1) == '/');
|
2012-11-10 02:45:19 +01:00
|
|
|
$where[] = qsprintf(
|
2012-11-09 01:13:21 +01:00
|
|
|
$conn,
|
2012-11-10 02:45:19 +01:00
|
|
|
'path '.($is_dir ? 'LIKE %>' : '= %s'),
|
2012-11-09 01:13:21 +01:00
|
|
|
'/'.$drequest->getPath());
|
|
|
|
}
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
if ($drequest->getLint() != '') {
|
|
|
|
$where[] = qsprintf(
|
|
|
|
$conn,
|
|
|
|
'code = %s',
|
|
|
|
$drequest->getLint());
|
|
|
|
}
|
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
return queryfx_all(
|
|
|
|
$conn,
|
|
|
|
'SELECT *
|
|
|
|
FROM %T
|
|
|
|
WHERE branchID = %d
|
2012-11-10 02:45:19 +01:00
|
|
|
AND %Q
|
2012-11-10 00:40:18 +01:00
|
|
|
ORDER BY path, code, line
|
2012-11-09 01:13:21 +01:00
|
|
|
LIMIT %d OFFSET %d',
|
|
|
|
PhabricatorRepository::TABLE_LINTMESSAGE,
|
|
|
|
$branch->getID(),
|
2012-11-10 02:45:19 +01:00
|
|
|
implode(' AND ', $where),
|
2012-11-09 01:13:21 +01:00
|
|
|
$limit,
|
|
|
|
$offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|