Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112160954
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
Thu, May 8, 09:24
Size
1 KB
Mime Type
text/x-php
Expires
Sat, May 10, 09:24 (2 d)
Engine
blob
Format
Raw Data
Handle
26021821
Attached To
rPH Phabricator
PhabricatorRemarkupRuleMeme.php
View Options
<?php
/**
* @group markup
*/
final
class
PhabricatorRemarkupRuleMeme
extends
PhutilRemarkupRule
{
private
$images
;
public
function
getPriority
()
{
return
50.0
;
}
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'
]);
if
(
$this
->
getEngine
()->
isTextMode
())
{
$img
=
(
$options
[
'above'
]
!=
''
?
"
\"
{$options['above']}
\"\n
"
:
''
).
$options
[
'src'
].
' <'
.
PhabricatorEnv
::
getProductionURI
(
$uri
).
'>'
.
(
$options
[
'below'
]
!=
''
?
"
\n\"
{$options['below']}
\"
"
:
''
);
}
else
{
$alt_text
=
pht
(
'Macro %s: %s %s'
,
$options
[
'src'
],
$options
[
'above'
],
$options
[
'below'
]);
$img
=
$this
->
newTag
(
'img'
,
array
(
'src'
=>
$uri
,
'alt'
=>
$alt_text
,
));
}
return
$this
->
getEngine
()->
storeText
(
$img
);
}
}
Event Timeline
Log In to Comment