Changeset View
Changeset View
Standalone View
Standalone View
src/applications/macro/markup/PhabricatorEmojiRemarkupRule.php
<?php | <?php | ||||
final class PhabricatorEmojiRemarkupRule extends PhutilRemarkupRule { | final class PhabricatorEmojiRemarkupRule extends PhutilRemarkupRule { | ||||
public function getPriority() { | public function getPriority() { | ||||
return 200.0; | return 200.0; | ||||
} | } | ||||
public function apply($text) { | public function apply($text) { | ||||
return preg_replace_callback( | return preg_replace_callback( | ||||
'(\B:(\S+):\B)', | '(\B:(\S+):\B)', | ||||
array($this, 'markupEmoji'), | array($this, 'markupEmoji'), | ||||
$text); | $text); | ||||
} | } | ||||
public function markupEmojiJSON() { | public function getEmojiManifest() { | ||||
$root = dirname(phutil_get_library_root('phabricator')); | $root = dirname(phutil_get_library_root('phabricator')); | ||||
$json = Filesystem::readFile( | $json = Filesystem::readFile($root.'/resources/emoji/manifest.json'); | ||||
$root.'/resources/emoji/manifest.json'); | $manifest = phutil_json_decode($json); | ||||
return $json; | |||||
foreach ($manifest as $key => $emoji) { | |||||
if (is_array($emoji)) { | |||||
continue; | |||||
} | |||||
$manifest[$key] = array( | |||||
'emoji' => $emoji, | |||||
); | |||||
} | |||||
return $manifest; | |||||
} | } | ||||
public function markupEmoji(array $matches) { | public function markupEmoji(array $matches) { | ||||
if (!$this->isFlatText($matches[0])) { | if (!$this->isFlatText($matches[0])) { | ||||
return $matches[0]; | return $matches[0]; | ||||
} | } | ||||
static $map = array( | static $map = array( | ||||
▲ Show 20 Lines • Show All 882 Lines • Show Last 20 Lines |