[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorPasteRemarkupRule extends PhabricatorObjectRemarkupRule { 4 5 protected function getObjectNamePrefix() { 6 return 'P'; 7 } 8 9 protected function loadObjects(array $ids) { 10 $viewer = $this->getEngine()->getConfig('viewer'); 11 12 return id(new PhabricatorPasteQuery()) 13 ->setViewer($viewer) 14 ->withIDs($ids) 15 ->needContent(true) 16 ->execute(); 17 18 } 19 20 protected function renderObjectEmbed($object, $handle, $options) { 21 $embed_paste = id(new PasteEmbedView()) 22 ->setPaste($object) 23 ->setHandle($handle); 24 25 if (strlen($options)) { 26 $parser = new PhutilSimpleOptions(); 27 $opts = $parser->parse(substr($options, 1)); 28 29 foreach ($opts as $key => $value) { 30 if ($key == 'lines') { 31 $embed_paste->setLines(preg_replace('/[^0-9]/', '', $value)); 32 } else if ($key == 'highlight') { 33 $highlights = preg_split('/,|&/', preg_replace('/\s+/', '', $value)); 34 35 $to_highlight = array(); 36 foreach ($highlights as $highlight) { 37 $highlight = explode('-', $highlight); 38 39 if (!empty($highlight)) { 40 sort($highlight); 41 $to_highlight = array_merge( 42 $to_highlight, 43 range(head($highlight), last($highlight))); 44 } 45 } 46 47 $embed_paste->setHighlights(array_unique($to_highlight)); 48 } 49 } 50 51 } 52 53 return $embed_paste; 54 } 55 56 }
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 |