forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorFilesApplicationStorageEnginePanel.php
91 lines (75 loc) · 2.08 KB
/
PhabricatorFilesApplicationStorageEnginePanel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
final class PhabricatorFilesApplicationStorageEnginePanel
extends PhabricatorApplicationConfigurationPanel {
public function getPanelKey() {
return 'storage';
}
public function shouldShowForApplication(
PhabricatorApplication $application) {
return ($application instanceof PhabricatorFilesApplication);
}
public function buildConfigurationPagePanel() {
$viewer = $this->getViewer();
$application = $this->getApplication();
$engines = PhabricatorFileStorageEngine::loadAllEngines();
$writable_engines = PhabricatorFileStorageEngine::loadWritableEngines();
$chunk_engines = PhabricatorFileStorageEngine::loadWritableChunkEngines();
$yes = pht('Yes');
$no = pht('No');
$rows = array();
$rowc = array();
foreach ($engines as $key => $engine) {
if ($engine->isTestEngine()) {
continue;
}
$limit = null;
if ($engine->hasFilesizeLimit()) {
$limit = phutil_format_bytes($engine->getFilesizeLimit());
} else {
$limit = pht('Unlimited');
}
if ($engine->canWriteFiles()) {
$writable = $yes;
} else {
$writable = $no;
}
if (isset($writable_engines[$key]) || isset($chunk_engines[$key])) {
$rowc[] = 'highlighted';
} else {
$rowc[] = null;
}
$rows[] = array(
$key,
get_class($engine),
$writable,
$limit,
);
}
$table = id(new AphrontTableView($rows))
->setNoDataString(pht('No storage engines available.'))
->setHeaders(
array(
pht('Key'),
pht('Class'),
pht('Writable'),
pht('Limit'),
))
->setRowClasses($rowc)
->setColumnClasses(
array(
'',
'wide',
'',
'n',
));
$box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Storage Engines'))
->setTable($table);
return $box;
}
public function handlePanelRequest(
AphrontRequest $request,
PhabricatorController $controller) {
return new Aphront404Response();
}
}