[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorApplicationTransactionNoEffectResponse 4 extends AphrontProxyResponse { 5 6 private $viewer; 7 private $exception; 8 private $cancelURI; 9 10 public function setCancelURI($cancel_uri) { 11 $this->cancelURI = $cancel_uri; 12 return $this; 13 } 14 15 public function setException( 16 PhabricatorApplicationTransactionNoEffectException $exception) { 17 $this->exception = $exception; 18 return $this; 19 } 20 21 protected function buildProxy() { 22 return new AphrontDialogResponse(); 23 } 24 25 public function reduceProxyResponse() { 26 $request = $this->getRequest(); 27 28 $ex = $this->exception; 29 $xactions = $ex->getTransactions(); 30 31 $type_comment = PhabricatorTransactions::TYPE_COMMENT; 32 $only_empty_comment = (count($xactions) == 1) && 33 (head($xactions)->getTransactionType() == $type_comment); 34 35 $count = new PhutilNumber(count($xactions)); 36 37 if ($ex->hasAnyEffect()) { 38 $title = pht('%d Action(s) With No Effect', $count); 39 $head = pht('Some of your %d action(s) have no effect:', $count); 40 $tail = pht('Apply remaining actions?'); 41 $continue = pht('Apply Remaining Actions'); 42 } else if ($ex->hasComment()) { 43 $title = pht('Post as Comment'); 44 $head = pht('The %d action(s) you are taking have no effect:', $count); 45 $tail = pht('Do you want to post your comment anyway?'); 46 $continue = pht('Post Comment'); 47 } else if ($only_empty_comment) { 48 // Special case this since it's common and we can give the user a nicer 49 // dialog than "Action Has No Effect". 50 $title = pht('Empty Comment'); 51 $head = null; 52 $tail = null; 53 $continue = null; 54 } else { 55 $title = pht('%d Action(s) Have No Effect', $count); 56 $head = pht('The %d action(s) you are taking have no effect:', $count); 57 $tail = null; 58 $continue = null; 59 } 60 61 $dialog = id(new AphrontDialogView()) 62 ->setUser($request->getUser()) 63 ->setTitle($title); 64 65 $dialog->appendChild($head); 66 67 $list = array(); 68 foreach ($xactions as $xaction) { 69 $list[] = phutil_tag( 70 'li', 71 array(), 72 $xaction->getNoEffectDescription()); 73 } 74 75 $dialog->appendChild(phutil_tag('ul', array(), $list)); 76 $dialog->appendChild($tail); 77 78 if ($continue) { 79 $passthrough = $request->getPassthroughRequestParameters(); 80 foreach ($passthrough as $key => $value) { 81 $dialog->addHiddenInput($key, $value); 82 } 83 $dialog->addHiddenInput('__continue__', 1); 84 $dialog->addSubmitButton($continue); 85 } 86 87 $dialog->addCancelButton($this->cancelURI); 88 89 return $this->getProxy()->setDialog($dialog); 90 } 91 92 }
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 |