Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/document/DiffusionDocumentRenderingEngine.php
12241 views
1
<?php
2
3
final class DiffusionDocumentRenderingEngine
4
extends PhabricatorDocumentRenderingEngine {
5
6
private $diffusionRequest;
7
8
public function setDiffusionRequest(DiffusionRequest $drequest) {
9
$this->diffusionRequest = $drequest;
10
return $this;
11
}
12
13
public function getDiffusionRequest() {
14
return $this->diffusionRequest;
15
}
16
17
protected function newRefViewURI(
18
PhabricatorDocumentRef $ref,
19
PhabricatorDocumentEngine $engine) {
20
21
$file = $ref->getFile();
22
$engine_key = $engine->getDocumentEngineKey();
23
$drequest = $this->getDiffusionRequest();
24
25
return (string)$drequest->generateURI(
26
array(
27
'action' => 'browse',
28
'stable' => true,
29
'params' => array(
30
'as' => $engine_key,
31
),
32
));
33
}
34
35
protected function newRefRenderURI(
36
PhabricatorDocumentRef $ref,
37
PhabricatorDocumentEngine $engine) {
38
39
$engine_key = $engine->getDocumentEngineKey();
40
41
$file = $ref->getFile();
42
$file_phid = $file->getPHID();
43
44
$drequest = $this->getDiffusionRequest();
45
46
return (string)$drequest->generateURI(
47
array(
48
'action' => 'document',
49
'stable' => true,
50
'params' => array(
51
'as' => $engine_key,
52
'filePHID' => $file_phid,
53
),
54
));
55
}
56
57
protected function getSelectedDocumentEngineKey() {
58
return $this->getRequest()->getStr('as');
59
}
60
61
protected function getSelectedLineRange() {
62
$range = $this->getDiffusionRequest()->getLine();
63
return AphrontRequest::parseURILineRange($range, 1000);
64
}
65
66
protected function addApplicationCrumbs(
67
PHUICrumbsView $crumbs,
68
PhabricatorDocumentRef $ref = null) {
69
return;
70
}
71
72
protected function willStageRef(PhabricatorDocumentRef $ref) {
73
$drequest = $this->getDiffusionRequest();
74
75
$blame_uri = (string)$drequest->generateURI(
76
array(
77
'action' => 'blame',
78
'stable' => true,
79
));
80
81
$ref->setBlameURI($blame_uri);
82
}
83
84
protected function willRenderRef(PhabricatorDocumentRef $ref) {
85
$drequest = $this->getDiffusionRequest();
86
87
$ref->setSymbolMetadata($this->getSymbolMetadata());
88
89
$coverage = $drequest->loadCoverage();
90
if ($coverage !== null && strlen($coverage)) {
91
$ref->addCoverage($coverage);
92
}
93
}
94
95
private function getSymbolMetadata() {
96
$drequest = $this->getDiffusionRequest();
97
98
$repo = $drequest->getRepository();
99
$symbol_repos = nonempty($repo->getSymbolSources(), array());
100
$symbol_repos[] = $repo->getPHID();
101
102
$lang = last(explode('.', $drequest->getPath()));
103
104
return array(
105
'repositories' => $symbol_repos,
106
'lang' => $lang,
107
'path' => $drequest->getPath(),
108
);
109
}
110
111
}
112
113