Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/markup/PhabricatorMarkupEngine.php
Show First 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | foreach ($blocks as $block) { | ||||
$block->setMarkupRules($rules); | $block->setMarkupRules($rules); | ||||
} | } | ||||
$engine->setBlockRules($blocks); | $engine->setBlockRules($blocks); | ||||
return $engine; | return $engine; | ||||
} | } | ||||
public static function extractPHIDsFromMentions(array $content_blocks) { | public static function extractPHIDsFromMentions( | ||||
PhabricatorUser $viewer, | |||||
array $content_blocks) { | |||||
$mentions = array(); | $mentions = array(); | ||||
$engine = self::newDifferentialMarkupEngine(); | $engine = self::newDifferentialMarkupEngine(); | ||||
$engine->setConfig('viewer', PhabricatorUser::getOmnipotentUser()); | $engine->setConfig('viewer', $viewer); | ||||
foreach ($content_blocks as $content_block) { | foreach ($content_blocks as $content_block) { | ||||
$engine->markupText($content_block); | $engine->markupText($content_block); | ||||
$phids = $engine->getTextMetadata( | $phids = $engine->getTextMetadata( | ||||
PhabricatorRemarkupRuleMention::KEY_MENTIONED, | PhabricatorRemarkupRuleMention::KEY_MENTIONED, | ||||
array()); | array()); | ||||
$mentions += $phids; | $mentions += $phids; | ||||
} | } | ||||
return $mentions; | return $mentions; | ||||
} | } | ||||
public static function extractFilePHIDsFromEmbeddedFiles( | public static function extractFilePHIDsFromEmbeddedFiles( | ||||
PhabricatorUser $viewer, | |||||
array $content_blocks) { | array $content_blocks) { | ||||
$files = array(); | $files = array(); | ||||
$engine = self::newDifferentialMarkupEngine(); | $engine = self::newDifferentialMarkupEngine(); | ||||
$engine->setConfig('viewer', PhabricatorUser::getOmnipotentUser()); | $engine->setConfig('viewer', $viewer); | ||||
foreach ($content_blocks as $content_block) { | foreach ($content_blocks as $content_block) { | ||||
$engine->markupText($content_block); | $engine->markupText($content_block); | ||||
$ids = $engine->getTextMetadata( | $ids = $engine->getTextMetadata( | ||||
PhabricatorRemarkupRuleEmbedFile::KEY_EMBED_FILE_PHIDS, | PhabricatorRemarkupRuleEmbedFile::KEY_EMBED_FILE_PHIDS, | ||||
array()); | array()); | ||||
$files += $ids; | $files += $ids; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |