Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/files/document/PhabricatorRemarkupDocumentEngine.php
12241 views
1
<?php
2
3
final class PhabricatorRemarkupDocumentEngine
4
extends PhabricatorDocumentEngine {
5
6
const ENGINEKEY = 'remarkup';
7
8
public function getViewAsLabel(PhabricatorDocumentRef $ref) {
9
return pht('View as Remarkup');
10
}
11
12
protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {
13
return 'fa-file-text-o';
14
}
15
16
protected function getContentScore(PhabricatorDocumentRef $ref) {
17
$name = $ref->getName();
18
19
if ($name !== null) {
20
if (preg_match('/\\.remarkup\z/i', $name)) {
21
return 2000;
22
}
23
}
24
25
return 500;
26
}
27
28
protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {
29
return $ref->isProbablyText();
30
}
31
32
protected function newDocumentContent(PhabricatorDocumentRef $ref) {
33
$viewer = $this->getViewer();
34
35
$content = $ref->loadData();
36
$content = phutil_utf8ize($content);
37
38
$remarkup = new PHUIRemarkupView($viewer, $content);
39
40
$container = phutil_tag(
41
'div',
42
array(
43
'class' => 'document-engine-remarkup',
44
),
45
$remarkup);
46
47
return $container;
48
}
49
50
}
51
52