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