Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99852860
PhabricatorSourceCodeView.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
Sun, Jan 26, 23:27
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jan 28, 23:27 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23835339
Attached To
rPH Phabricator
PhabricatorSourceCodeView.php
View Options
<?php
final
class
PhabricatorSourceCodeView
extends
AphrontView
{
private
$lines
;
private
$limit
;
public
function
setLimit
(
$limit
)
{
$this
->
limit
=
$limit
;
return
$this
;
}
public
function
setLines
(
array
$lines
)
{
$this
->
lines
=
$lines
;
return
$this
;
}
public
function
render
()
{
require_celerity_resource
(
'phabricator-source-code-view-css'
);
require_celerity_resource
(
'syntax-highlighting-css'
);
Javelin
::
initBehavior
(
'phabricator-oncopy'
,
array
());
$line_number
=
1
;
$rows
=
array
();
foreach
(
$this
->
lines
as
$line
)
{
$hit_limit
=
$this
->
limit
&&
(
$line_number
==
$this
->
limit
)
&&
(
count
(
$this
->
lines
)
!=
$this
->
limit
);
if
(
$hit_limit
)
{
$content_number
=
''
;
$content_line
=
phutil_tag
(
'span'
,
array
(
'class'
=>
'c'
,
),
pht
(
'...'
));
}
else
{
$content_number
=
phutil_escape_html
(
$line_number
);
$content_line
=
"
\x
E2
\x
80
\x
8B"
.
$line
;
}
// TODO: Provide nice links.
$rows
[]
=
'<tr>'
.
'<th class="phabricator-source-line">'
.
$content_number
.
'</th>'
.
'<td class="phabricator-source-code">'
.
$content_line
.
'</td>'
.
'</tr>'
;
if
(
$hit_limit
)
{
break
;
}
$line_number
++;
}
$classes
=
array
();
$classes
[]
=
'phabricator-source-code-view'
;
$classes
[]
=
'remarkup-code'
;
$classes
[]
=
'PhabricatorMonospaced'
;
return
phutil_tag
(
'div'
,
array
(
'class'
=>
'phabricator-source-code-container'
,
),
phutil_tag
(
'table'
,
array
(
'class'
=>
implode
(
' '
,
$classes
),
),
new
PhutilSafeHTML
(
implode
(
''
,
$rows
))));
}
}
Event Timeline
Log In to Comment