-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAvivUtilController.php
66 lines (54 loc) · 1.42 KB
/
AvivUtilController.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
<?php
abstract class AvivUtilController extends PhabricatorController{
function build($result) {
return self::buildFor($this, $result);
}
function buildHumanReadableResponse(
$result) {
return self::buildFor($this, $result);
}
public static function buildFor($controller, array $data) {
$result = $data;
$param_rows = array();
$param_table = new AphrontTableView($param_rows);
$param_table->setDeviceReadyTable(true);
$param_table->setColumnClasses(
array(
'header',
'wide',
));
$result_rows = array();
foreach ($result as $key => $value) {
$result_rows[] = array(
$key,
self::renderAPIValue($value),
);
}
$result_table = new AphrontTableView($result_rows);
$result_table->setDeviceReadyTable(true);
$result_table->setColumnClasses(
array(
'header',
'wide',
));
$result_head = id(new PHUIHeaderView())
->setHeader(pht('demagicking'));
return $controller->buildApplicationPage(
array(
$result_head,
$result_table,
),
array(
'title' => 'magic',
'device' => true,
));
}
static function renderAPIValue($value) {
$json = new PhutilJSON();
if (is_array($value)) {
$value = $json->encodeFormatted($value);
}
$value = hsprintf('<pre style="white-space: pre-wrap;">%s</pre>', $value);
return $value;
}
}