Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15400699
D18222.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D18222.diff
View Options
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 @@
+<?php
+
+final class SecureSupportRemarkupRule
+ extends PhabricatorRemarkupCustomInlineRule {
+
+ public function apply($text) {
+ return preg_replace_callback(
+ '((?<![#@-])\bPHI([1-9]\d*)(?:#([-\w\d]+))?(?!\w))u',
+ array($this, 'markupSupportIssue'),
+ $text);
+ }
+
+ public function markupSupportIssue($matches) {
+ if (!$this->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);
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 18, 1:28 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7709887
Default Alt Text
D18222.diff (1 KB)
Attached To
Mode
D18222: Automatically link PHIxxx on "secure" to Support on Admin
Attached
Detach File
Event Timeline
Log In to Comment