Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79242904
PhrictionRemarkupRule.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
Sun, Aug 25, 11:09
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Aug 27, 11:09 (2 d)
Engine
blob
Format
Raw Data
Handle
20166690
Attached To
rPH Phabricator
PhrictionRemarkupRule.php
View Options
<?php
final
class
PhrictionRemarkupRule
extends
PhutilRemarkupRule
{
public
function
getPriority
()
{
return
175.0
;
}
public
function
apply
(
$text
)
{
return
preg_replace_callback
(
'@
\B\\
[
\\
[([^|
\\
]]+)(?:
\\
|([^
\\
]]+))?
\\
]
\\
]
\B
@U'
,
array
(
$this
,
'markupDocumentLink'
),
$text
);
}
public
function
markupDocumentLink
(
array
$matches
)
{
$link
=
trim
(
$matches
[
1
]);
$name
=
trim
(
idx
(
$matches
,
2
,
$link
));
if
(
empty
(
$matches
[
2
]))
{
$name
=
explode
(
'/'
,
trim
(
$name
,
'/'
));
$name
=
end
(
$name
);
}
$uri
=
new
PhutilURI
(
$link
);
$slug
=
$uri
->
getPath
();
$fragment
=
$uri
->
getFragment
();
$slug
=
PhabricatorSlug
::
normalize
(
$slug
);
$slug
=
PhrictionDocument
::
getSlugURI
(
$slug
);
$href
=
(
string
)
id
(
new
PhutilURI
(
$slug
))->
setFragment
(
$fragment
);
$text_mode
=
$this
->
getEngine
()->
isTextMode
();
$mail_mode
=
$this
->
getEngine
()->
isHTMLMailMode
();
if
(
$this
->
getEngine
()->
getState
(
'toc'
))
{
$text
=
$name
;
}
else
if
(
$text_mode
||
$mail_mode
)
{
return
PhabricatorEnv
::
getProductionURI
(
$href
);
}
else
{
$text
=
$this
->
newTag
(
'a'
,
array
(
'href'
=>
$href
,
'class'
=>
'phriction-link'
,
),
$name
);
}
return
$this
->
getEngine
()->
storeText
(
$text
);
}
}
Event Timeline
Log In to Comment