Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100940973
PhabricatorRemarkupRuleMeme.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
Tue, Feb 4, 03:55
Size
847 B
Mime Type
text/x-php
Expires
Thu, Feb 6, 03:55 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
24058025
Attached To
rPH Phabricator
PhabricatorRemarkupRuleMeme.php
View Options
<?php
/**
* @group markup
*/
final
class
PhabricatorRemarkupRuleMeme
extends
PhutilRemarkupRule
{
private
$images
;
public
function
apply
(
$text
)
{
return
preg_replace_callback
(
'@{meme,((?:[^}
\\\\
]+|
\\\\
.)+)}$@m'
,
array
(
$this
,
'markupMeme'
),
$text
);
}
public
function
markupMeme
(
$matches
)
{
$options
=
array
(
'src'
=>
null
,
'above'
=>
null
,
'below'
=>
null
,
);
$parser
=
new
PhutilSimpleOptions
();
$options
=
$parser
->
parse
(
$matches
[
1
])
+
$options
;
$uri
=
id
(
new
PhutilURI
(
'/macro/meme/'
))
->
alter
(
'macro'
,
$options
[
'src'
])
->
alter
(
'uppertext'
,
$options
[
'above'
])
->
alter
(
'lowertext'
,
$options
[
'below'
]);
$img
=
phutil_tag
(
'img'
,
array
(
'src'
=>
(
string
)
$uri
,
));
return
$this
->
getEngine
()->
storeText
(
$img
);
}
}
Event Timeline
Log In to Comment