Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/markup/markuprule/PhutilRemarkupHyperlinkRule.php
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | protected function renderHyperlink($link, $is_embed) { | ||||
// If the URI is "{uri}" and no handler picked it up, we just render it | // If the URI is "{uri}" and no handler picked it up, we just render it | ||||
// as plain text. | // as plain text. | ||||
if ($is_embed) { | if ($is_embed) { | ||||
return $this->renderRawLink($link, $is_embed); | return $this->renderRawLink($link, $is_embed); | ||||
} | } | ||||
$engine = $this->getEngine(); | $engine = $this->getEngine(); | ||||
$same_window = $engine->getConfig('uri.same-window', false); | $uri = new PhutilURIHelper($link); | ||||
valerio.bozzolan: Here I just changed the `false` to `$is_internal` | |||||
$is_self = $uri->isSelf(); | |||||
$same_window = $engine->getConfig('uri.same-window', $is_self); | |||||
if ($same_window) { | if ($same_window) { | ||||
Done Inline Actions✅ This is just a better default. Note that if uri.same-window is already set, we also never call our extra logic. valerio.bozzolan: ✅ This is just a better default. Note that if `uri.same-window` is already set, we also never… | |||||
$target = null; | $target = null; | ||||
} else { | } else { | ||||
$target = '_blank'; | $target = '_blank'; | ||||
} | } | ||||
return phutil_tag( | return phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => $link, | 'href' => $link, | ||||
'class' => 'remarkup-link', | 'class' => $this->getRemarkupLinkClass($is_self), | ||||
'target' => $target, | 'target' => $target, | ||||
Done Inline ActionsIf you know a better way to concatenate two CSS classes, feel free to propose. valerio.bozzolan: If you know a better way to concatenate two CSS classes, feel free to propose. | |||||
Done Inline ActionsThis is the right way, but you don't need so many variables. Feel free to reuse $classes. avivey: This is the right way, but you don't need so many variables. Feel free to reuse `$classes`. | |||||
'rel' => 'noreferrer', | 'rel' => 'noreferrer', | ||||
), | ), | ||||
$link); | $link); | ||||
} | } | ||||
private function renderRawLink($link, $is_embed) { | private function renderRawLink($link, $is_embed) { | ||||
if ($is_embed) { | if ($is_embed) { | ||||
return '{'.$link.'}'; | return '{'.$link.'}'; | ||||
▲ Show 20 Lines • Show All 128 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
Here I just changed the false to $is_internal