Changeset View
Changeset View
Standalone View
Standalone View
src/applications/macro/markup/PhabricatorMemeRemarkupRule.php
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if ($this->getEngine()->isTextMode()) { | ||||
'img', | 'img', | ||||
array( | array( | ||||
'src' => $uri, | 'src' => $uri, | ||||
'alt' => $alt_text, | 'alt' => $alt_text, | ||||
'class' => 'phabricator-remarkup-macro', | 'class' => 'phabricator-remarkup-macro', | ||||
)); | )); | ||||
} | } | ||||
return $this->getEngine()->storeText($img); | $engine = $this->getEngine(); | ||||
$macro_usage_key = PhabricatorImageMacroRemarkupRule::KEY_MACRO_USAGE; | |||||
$macro_usage = $engine->getTextMetadata($macro_usage_key, array()); | |||||
$viewer = $engine->getConfig('viewer'); | |||||
$macro = id(new PhabricatorMacroQuery()) | |||||
->setViewer($viewer) | |||||
->withNames(array($options['src'])) | |||||
->needFiles(false) | |||||
->executeOne(); | |||||
if ($macro) { | |||||
if (isset($macro_usage[$macro->getPHID()])) { | |||||
$macro_usage[$macro->getPHID()]++; | |||||
} else { | |||||
$macro_usage[$macro->getPHID()] = 1; | |||||
} | |||||
$engine->setTextMetadata($macro_usage_key, $macro_usage); | |||||
} | |||||
return $engine->storeText($img); | |||||
} | } | ||||
} | } |