Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/view/DiffusionBrowseTableView.php
12242 views
1
<?php
2
3
final class DiffusionBrowseTableView extends DiffusionView {
4
5
private $paths;
6
7
public function setPaths(array $paths) {
8
assert_instances_of($paths, 'DiffusionRepositoryPath');
9
$this->paths = $paths;
10
return $this;
11
}
12
13
public function render() {
14
$request = $this->getDiffusionRequest();
15
$repository = $request->getRepository();
16
require_celerity_resource('diffusion-css');
17
18
if ($request->getPath() !== null) {
19
$base_path = trim($request->getPath(), '/');
20
if ($base_path) {
21
$base_path = $base_path.'/';
22
}
23
} else {
24
$base_path = '';
25
}
26
27
$need_pull = array();
28
$rows = array();
29
foreach ($this->paths as $path) {
30
$full_path = $base_path.$path->getPath();
31
32
$dir_slash = null;
33
$file_type = $path->getFileType();
34
if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
35
$browse_text = $path->getPath().'/';
36
$dir_slash = '/';
37
38
$browse_link = phutil_tag('strong', array(), $this->linkBrowse(
39
$full_path.$dir_slash,
40
array(
41
'type' => $file_type,
42
'name' => $browse_text,
43
)));
44
45
$history_path = $full_path.'/';
46
} else if ($file_type == DifferentialChangeType::FILE_SUBMODULE) {
47
$browse_text = $path->getPath().'/';
48
$browse_link = phutil_tag('strong', array(), $this->linkBrowse(
49
null,
50
array(
51
'type' => $file_type,
52
'name' => $browse_text,
53
'hash' => $path->getHash(),
54
'external' => $path->getExternalURI(),
55
)));
56
57
$history_path = $full_path.'/';
58
} else {
59
$browse_text = $path->getPath();
60
$browse_link = $this->linkBrowse(
61
$full_path,
62
array(
63
'type' => $file_type,
64
'name' => $browse_text,
65
));
66
67
$history_path = $full_path;
68
}
69
70
$history_link = $this->linkHistory($history_path);
71
72
$dict = array(
73
'lint' => celerity_generate_unique_node_id(),
74
'date' => celerity_generate_unique_node_id(),
75
'details' => celerity_generate_unique_node_id(),
76
);
77
78
$need_pull[$full_path.$dir_slash] = $dict;
79
foreach ($dict as $k => $uniq) {
80
$dict[$k] = phutil_tag('span', array('id' => $uniq), '');
81
}
82
83
$rows[] = array(
84
$browse_link,
85
idx($dict, 'lint'),
86
$dict['details'],
87
$dict['date'],
88
$history_link,
89
);
90
91
}
92
93
if ($need_pull) {
94
Javelin::initBehavior(
95
'diffusion-pull-lastmodified',
96
array(
97
'uri' => (string)$request->generateURI(
98
array(
99
'action' => 'lastmodified',
100
'stable' => true,
101
)),
102
'map' => $need_pull,
103
));
104
}
105
106
$branch = $this->getDiffusionRequest()->loadBranch();
107
$show_lint = ($branch && $branch->getLintCommit());
108
$lint = $request->getLint();
109
110
$view = new AphrontTableView($rows);
111
$view->setColumnClasses(
112
array(
113
'',
114
'',
115
'wide commit-detail',
116
'right',
117
'right narrow',
118
));
119
$view->setColumnVisibility(
120
array(
121
true,
122
$show_lint,
123
true,
124
true,
125
true,
126
));
127
128
$view->setDeviceVisibility(
129
array(
130
true,
131
false,
132
false,
133
false,
134
false,
135
));
136
137
138
return phutil_tag_div('diffusion-browse-table', $view->render());
139
}
140
141
}
142
143