Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F982346
PhabricatorMemeRemarkupRule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorMemeRemarkupRule.php
View Options
<?php
final
class
PhabricatorMemeRemarkupRule
extends
PhutilRemarkupRule
{
private
$images
;
public
function
getPriority
()
{
return
200.0
;
}
public
function
apply
(
$text
)
{
return
preg_replace_callback
(
'@{meme,((?:[^}
\\\\
]+|
\\\\
.)+)}@m'
,
array
(
$this
,
'markupMeme'
),
$text
);
}
public
function
markupMeme
(
array
$matches
)
{
if
(!
$this
->
isFlatText
(
$matches
[
0
]))
{
return
$matches
[
0
];
}
$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
()->
isHTMLMailMode
())
{
$uri
=
PhabricatorEnv
::
getProductionURI
(
$uri
);
}
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
,
'class'
=>
'phabricator-remarkup-macro'
,
));
}
return
$this
->
getEngine
()->
storeText
(
$img
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Jun 18, 1:48 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
221440
Default Alt Text
PhabricatorMemeRemarkupRule.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment