Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96193742
PhabricatorPasteRemarkupRule.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, 15:40
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 15:40 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23142096
Attached To
rPH Phabricator
PhabricatorPasteRemarkupRule.php
View Options
<?php
/**
* @group markup
*/
final
class
PhabricatorPasteRemarkupRule
extends
PhabricatorRemarkupRuleObject
{
protected
function
getObjectNamePrefix
()
{
return
'P'
;
}
protected
function
loadObjects
(
array
$ids
)
{
$viewer
=
$this
->
getEngine
()->
getConfig
(
'viewer'
);
return
id
(
new
PhabricatorPasteQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
$ids
)
->
needContent
(
true
)
->
execute
();
}
protected
function
renderObjectEmbed
(
$object
,
$handle
,
$options
)
{
$embed_paste
=
id
(
new
PasteEmbedView
())
->
setPaste
(
$object
)
->
setHandle
(
$handle
);
if
(
strlen
(
$options
))
{
$parser
=
new
PhutilSimpleOptions
();
$opts
=
$parser
->
parse
(
substr
(
$options
,
1
));
foreach
(
$opts
as
$key
=>
$value
)
{
if
(
$key
==
'lines'
)
{
$embed_paste
->
setLines
(
preg_replace
(
'/[^0-9]/'
,
''
,
$value
));
}
else
if
(
$key
==
'highlight'
)
{
$highlights
=
preg_split
(
'/,|&/'
,
preg_replace
(
'/
\s
+/'
,
''
,
$value
));
$to_highlight
=
array
();
foreach
(
$highlights
as
$highlight
)
{
$highlight
=
explode
(
'-'
,
$highlight
);
if
(!
empty
(
$highlight
))
{
sort
(
$highlight
);
$to_highlight
=
array_merge
(
$to_highlight
,
range
(
head
(
$highlight
),
last
(
$highlight
)));
}
}
$embed_paste
->
setHighlights
(
array_unique
(
$to_highlight
));
}
}
}
return
$embed_paste
->
render
();
}
}
Event Timeline
Log In to Comment