Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99000878
PhabricatorConfigRemarkupRule.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
Sat, Jan 18, 09:06
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jan 20, 09:06 (2 d)
Engine
blob
Format
Raw Data
Handle
23683650
Attached To
rPH Phabricator
PhabricatorConfigRemarkupRule.php
View Options
<?php
final
class
PhabricatorConfigRemarkupRule
extends
PhutilRemarkupRule
{
public
function
apply
(
$text
)
{
return
preg_replace_callback
(
'(@{config:([^}]+)})'
,
array
(
$this
,
'markupConfig'
),
$text
);
}
public
function
getPriority
()
{
// We're reusing the Diviner atom syntax, so make sure we evaluate before
// the Diviner rule evaluates.
return
id
(
new
DivinerSymbolRemarkupRule
())->
getPriority
()
-
1
;
}
public
function
markupConfig
(
array
$matches
)
{
if
(!
$this
->
isFlatText
(
$matches
[
0
]))
{
return
$matches
[
0
];
}
$config_key
=
$matches
[
1
];
try
{
$option
=
PhabricatorEnv
::
getEnvConfig
(
$config_key
);
}
catch
(
Exception
$ex
)
{
return
$matches
[
0
];
}
$is_text
=
$this
->
getEngine
()->
isTextMode
();
$is_html_mail
=
$this
->
getEngine
()->
isHTMLMailMode
();
if
(
$is_text
||
$is_html_mail
)
{
return
pht
(
'"%s"'
,
$config_key
);
}
$link
=
phutil_tag
(
'a'
,
array
(
'href'
=>
urisprintf
(
'/config/edit/%s/'
,
$config_key
),
'target'
=>
'_blank'
,
),
$config_key
);
return
$this
->
getEngine
()->
storeText
(
$link
);
}
}
Event Timeline
Log In to Comment