[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ConpherenceViewController extends 4 ConpherenceController { 5 6 private $conpherenceID; 7 private $conpherence; 8 9 public function setConpherence(ConpherenceThread $conpherence) { 10 $this->conpherence = $conpherence; 11 return $this; 12 } 13 public function getConpherence() { 14 return $this->conpherence; 15 } 16 17 public function setConpherenceID($conpherence_id) { 18 $this->conpherenceID = $conpherence_id; 19 return $this; 20 } 21 public function getConpherenceID() { 22 return $this->conpherenceID; 23 } 24 25 public function willProcessRequest(array $data) { 26 $this->setConpherenceID(idx($data, 'id')); 27 } 28 29 public function processRequest() { 30 $request = $this->getRequest(); 31 $user = $request->getUser(); 32 33 $conpherence_id = $this->getConpherenceID(); 34 if (!$conpherence_id) { 35 return new Aphront404Response(); 36 } 37 $query = id(new ConpherenceThreadQuery()) 38 ->setViewer($user) 39 ->withIDs(array($conpherence_id)) 40 ->needParticipantCache(true) 41 ->needTransactions(true) 42 ->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT); 43 $before_transaction_id = $request->getInt('oldest_transaction_id'); 44 if ($before_transaction_id) { 45 $query 46 ->setBeforeTransactionID($before_transaction_id); 47 } 48 $conpherence = $query->executeOne(); 49 if (!$conpherence) { 50 return new Aphront404Response(); 51 } 52 $this->setConpherence($conpherence); 53 54 $participant = $conpherence->getParticipant($user->getPHID()); 55 $transactions = $conpherence->getTransactions(); 56 $latest_transaction = end($transactions); 57 $write_guard = AphrontWriteGuard::beginScopedUnguardedWrites(); 58 $participant->markUpToDate($conpherence, $latest_transaction); 59 unset($write_guard); 60 61 $data = $this->renderConpherenceTransactions($conpherence); 62 $messages = $this->renderMessagePaneContent( 63 $data['transactions'], 64 $data['oldest_transaction_id']); 65 if ($before_transaction_id) { 66 $header = null; 67 $form = null; 68 $content = array('messages' => $messages); 69 } else { 70 $header = $this->buildHeaderPaneContent($conpherence); 71 $form = $this->renderFormContent($data['latest_transaction_id']); 72 $content = array( 73 'header' => $header, 74 'messages' => $messages, 75 'form' => $form, 76 ); 77 } 78 79 if ($request->isAjax()) { 80 return id(new AphrontAjaxResponse())->setContent($content); 81 } 82 83 $layout = id(new ConpherenceLayoutView()) 84 ->setBaseURI($this->getApplicationURI()) 85 ->setThread($conpherence) 86 ->setHeader($header) 87 ->setMessages($messages) 88 ->setReplyForm($form) 89 ->setRole('thread'); 90 91 $title = $conpherence->getTitle(); 92 if (!$title) { 93 $title = pht('[No Title]'); 94 } 95 return $this->buildApplicationPage( 96 $layout, 97 array( 98 'title' => $title, 99 'pageObjects' => array($conpherence->getPHID()), 100 )); 101 } 102 103 private function renderMessagePaneContent( 104 array $transactions, 105 $oldest_transaction_id) { 106 107 $scrollbutton = ''; 108 if ($oldest_transaction_id) { 109 $scrollbutton = javelin_tag( 110 'a', 111 array( 112 'href' => '#', 113 'mustcapture' => true, 114 'sigil' => 'show-older-messages', 115 'class' => 'conpherence-show-older-messages', 116 'meta' => array( 117 'oldest_transaction_id' => $oldest_transaction_id, 118 ), 119 ), 120 pht('Show Older Messages')); 121 } 122 123 return hsprintf('%s%s', $scrollbutton, $transactions); 124 } 125 126 private function renderFormContent($latest_transaction_id) { 127 128 $conpherence = $this->getConpherence(); 129 $user = $this->getRequest()->getUser(); 130 $draft = PhabricatorDraft::newFromUserAndKey( 131 $user, 132 $conpherence->getPHID()); 133 $update_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/'); 134 135 $this->initBehavior('conpherence-pontificate'); 136 137 $form = 138 id(new AphrontFormView()) 139 ->setAction($update_uri) 140 ->addSigil('conpherence-pontificate') 141 ->setWorkflow(true) 142 ->setUser($user) 143 ->addHiddenInput('action', 'message') 144 ->appendChild( 145 id(new PhabricatorRemarkupControl()) 146 ->setUser($user) 147 ->setName('text') 148 ->setValue($draft->getDraft())) 149 ->appendChild( 150 id(new AphrontFormSubmitControl()) 151 ->setValue(pht('Send Message'))) 152 ->appendChild( 153 javelin_tag( 154 'input', 155 array( 156 'type' => 'hidden', 157 'name' => 'latest_transaction_id', 158 'value' => $latest_transaction_id, 159 'sigil' => 'latest-transaction-id', 160 'meta' => array( 161 'threadPHID' => $conpherence->getPHID(), 162 'threadID' => $conpherence->getID(), 163 ), 164 ), 165 '')) 166 ->render(); 167 168 return $form; 169 } 170 171 }
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 |