[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorApplicationTransactionCommentQuoteController 4 extends PhabricatorApplicationTransactionController { 5 6 private $phid; 7 8 public function willProcessRequest(array $data) { 9 $this->phid = $data['phid']; 10 } 11 12 public function processRequest() { 13 $request = $this->getRequest(); 14 $viewer = $request->getUser(); 15 16 $xaction = id(new PhabricatorObjectQuery()) 17 ->withPHIDs(array($this->phid)) 18 ->setViewer($viewer) 19 ->executeOne(); 20 if (!$xaction) { 21 return new Aphront404Response(); 22 } 23 24 if (!$xaction->getComment()) { 25 return new Aphront404Response(); 26 } 27 28 if ($xaction->getComment()->getIsRemoved()) { 29 return new Aphront400Response(); 30 } 31 32 if (!$xaction->hasComment()) { 33 return new Aphront404Response(); 34 } 35 36 $content = $xaction->getComment()->getContent(); 37 $content = rtrim($content, "\r\n"); 38 $content = phutil_split_lines($content, true); 39 foreach ($content as $key => $line) { 40 if (strlen($line) && ($line[0] != '>')) { 41 $content[$key] = '> '.$line; 42 } else { 43 $content[$key] = '>'.$line; 44 } 45 } 46 $content = implode('', $content); 47 48 $author = id(new PhabricatorHandleQuery()) 49 ->setViewer($viewer) 50 ->withPHIDs(array($xaction->getComment()->getAuthorPHID())) 51 ->executeOne(); 52 53 $ref = $request->getStr('ref'); 54 if (strlen($ref)) { 55 $quote = pht('In %s, %s wrote:', $ref, '@'.$author->getName()); 56 } else { 57 $quote = pht('%s wrote:', '@'.$author->getName()); 58 } 59 60 $content = ">>! {$quote}\n{$content}"; 61 62 return id(new AphrontAjaxResponse())->setContent( 63 array( 64 'quoteText' => $content, 65 )); 66 } 67 68 }
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 |