diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -11,10 +11,12 @@ 'class' => array( 'SecureShieldsUpAction' => 'abuse/SecureShieldsUpAction.php', 'SecureShieldsUpTestCase' => 'abuse/__tests__/SecureSheldsUpTestCase.php', + 'SecureSupportRemarkupRule' => 'support/SecureSupportRemarkupRule.php', ), 'function' => array(), 'xmap' => array( 'SecureShieldsUpAction' => 'HeraldAction', 'SecureShieldsUpTestCase' => 'PhabricatorTestCase', + 'SecureSupportRemarkupRule' => 'PhabricatorRemarkupCustomInlineRule', ), )); diff --git a/src/support/SecureSupportRemarkupRule.php b/src/support/SecureSupportRemarkupRule.php new file mode 100644 --- /dev/null +++ b/src/support/SecureSupportRemarkupRule.php @@ -0,0 +1,44 @@ +isFlatText($matches[0])) { + return $matches[0]; + } + + $engine = $this->getEngine(); + if ($engine->isTextMode()) { + return $matches[0]; + } + + $id = $matches[1]; + $anchor = idx($matches, 2); + + $monogram = "PHI{$id}"; + $uri = "https://admin.phacility.com/{$monogram}"; + if ($anchor) { + $uri = new PhutilURI($uri); + $uri->setAnchor($anchor); + $uri = (string)$uri; + } + + $tag = id(new PHUITagView()) + ->setName($monogram) + ->setHref($uri) + ->setType(PHUITagView::TYPE_SHADE) + ->setColor(PHUITagView::COLOR_VIOLET) + ->render(); + + return $engine->storeText($tag); + } + +}