[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorMemeRemarkupRule extends PhutilRemarkupRule { 4 5 private $images; 6 7 public function getPriority() { 8 return 200.0; 9 } 10 11 public function apply($text) { 12 return preg_replace_callback( 13 '@{meme,((?:[^}\\\\]+|\\\\.)+)}$@m', 14 array($this, 'markupMeme'), 15 $text); 16 } 17 18 public function markupMeme($matches) { 19 if (!$this->isFlatText($matches[0])) { 20 return $matches[0]; 21 } 22 23 $options = array( 24 'src' => null, 25 'above' => null, 26 'below' => null, 27 ); 28 29 $parser = new PhutilSimpleOptions(); 30 $options = $parser->parse($matches[1]) + $options; 31 32 $uri = id(new PhutilURI('/macro/meme/')) 33 ->alter('macro', $options['src']) 34 ->alter('uppertext', $options['above']) 35 ->alter('lowertext', $options['below']); 36 37 if ($this->getEngine()->isHTMLMailMode()) { 38 $uri = PhabricatorEnv::getProductionURI($uri); 39 } 40 41 if ($this->getEngine()->isTextMode()) { 42 $img = 43 ($options['above'] != '' ? "\"{$options['above']}\"\n" : ''). 44 $options['src'].' <'.PhabricatorEnv::getProductionURI($uri).'>'. 45 ($options['below'] != '' ? "\n\"{$options['below']}\"" : ''); 46 } else { 47 $alt_text = pht( 48 'Macro %s: %s %s', 49 $options['src'], 50 $options['above'], 51 $options['below']); 52 53 $img = $this->newTag( 54 'img', 55 array( 56 'src' => $uri, 57 'alt' => $alt_text, 58 )); 59 } 60 61 return $this->getEngine()->storeText($img); 62 } 63 64 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |