Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96151684
PhabricatorSourceDocumentEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 23, 04:54
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 04:54 (2 d)
Engine
blob
Format
Raw Data
Handle
23133791
Attached To
rPH Phabricator
PhabricatorSourceDocumentEngine.php
View Options
<?php
final
class
PhabricatorSourceDocumentEngine
extends
PhabricatorTextDocumentEngine
{
const
ENGINEKEY
=
'source'
;
public
function
getViewAsLabel
(
PhabricatorDocumentRef
$ref
)
{
return
pht
(
'View as Source'
);
}
public
function
canConfigureHighlighting
(
PhabricatorDocumentRef
$ref
)
{
return
true
;
}
public
function
canBlame
(
PhabricatorDocumentRef
$ref
)
{
return
true
;
}
protected
function
getDocumentIconIcon
(
PhabricatorDocumentRef
$ref
)
{
return
'fa-code'
;
}
protected
function
getContentScore
(
PhabricatorDocumentRef
$ref
)
{
return
1500
;
}
protected
function
newDocumentContent
(
PhabricatorDocumentRef
$ref
)
{
$content
=
$this
->
loadTextData
(
$ref
);
$messages
=
array
();
$highlighting
=
$this
->
getHighlightingConfiguration
();
if
(
$highlighting
!==
null
)
{
$content
=
PhabricatorSyntaxHighlighter
::
highlightWithLanguage
(
$highlighting
,
$content
);
}
else
{
$highlight_limit
=
DifferentialChangesetParser
::
HIGHLIGHT_BYTE_LIMIT
;
if
(
strlen
(
$content
)
>
$highlight_limit
)
{
$messages
[]
=
$this
->
newMessage
(
pht
(
'This file is larger than %s, so syntax highlighting was skipped.'
,
phutil_format_bytes
(
$highlight_limit
)));
}
else
{
$content
=
PhabricatorSyntaxHighlighter
::
highlightWithFilename
(
$ref
->
getName
(),
$content
);
}
}
$options
=
array
();
if
(
$ref
->
getBlameURI
()
&&
$this
->
getBlameEnabled
())
{
$content
=
phutil_split_lines
(
$content
);
$blame
=
range
(
1
,
count
(
$content
));
$blame
=
array_fuse
(
$blame
);
$options
[
'blame'
]
=
$blame
;
}
if
(
$ref
->
getCoverage
())
{
$options
[
'coverage'
]
=
$ref
->
getCoverage
();
}
return
array
(
$messages
,
$this
->
newTextDocumentContent
(
$ref
,
$content
,
$options
),
);
}
}
Event Timeline
Log In to Comment