2013-01-24 17:23:05 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group conpherence
|
|
|
|
*/
|
|
|
|
final class ConpherenceViewController extends
|
|
|
|
ConpherenceController {
|
|
|
|
|
|
|
|
private $conpherenceID;
|
|
|
|
private $conpherence;
|
|
|
|
|
|
|
|
public function setConpherence(ConpherenceThread $conpherence) {
|
|
|
|
$this->conpherence = $conpherence;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getConpherence() {
|
|
|
|
return $this->conpherence;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setConpherenceID($conpherence_id) {
|
|
|
|
$this->conpherenceID = $conpherence_id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getConpherenceID() {
|
|
|
|
return $this->conpherenceID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->setConpherenceID(idx($data, 'id'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$conpherence_id = $this->getConpherenceID();
|
|
|
|
if (!$conpherence_id) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
$conpherence = id(new ConpherenceThreadQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($conpherence_id))
|
2013-02-06 14:03:52 -08:00
|
|
|
->needHeaderPics(true)
|
2013-04-02 06:44:55 -07:00
|
|
|
->needAllTransactions(true)
|
2013-01-24 17:23:05 -08:00
|
|
|
->executeOne();
|
|
|
|
$this->setConpherence($conpherence);
|
|
|
|
|
|
|
|
$participant = $conpherence->getParticipant($user->getPHID());
|
2013-01-26 18:53:30 -08:00
|
|
|
$transactions = $conpherence->getTransactions();
|
|
|
|
$latest_transaction = end($transactions);
|
2013-01-24 17:23:05 -08:00
|
|
|
$write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
|
2013-04-04 16:57:38 -07:00
|
|
|
$participant->markUpToDate($conpherence, $latest_transaction);
|
2013-01-24 17:23:05 -08:00
|
|
|
unset($write_guard);
|
|
|
|
|
|
|
|
$header = $this->renderHeaderPaneContent();
|
|
|
|
$messages = $this->renderMessagePaneContent();
|
2013-02-15 14:01:27 -08:00
|
|
|
$content = $header + $messages;
|
2013-04-01 12:52:30 -07:00
|
|
|
|
|
|
|
if ($request->isAjax()) {
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($content);
|
|
|
|
}
|
|
|
|
|
|
|
|
$layout = id(new ConpherenceLayoutView())
|
|
|
|
->setBaseURI($this->getApplicationURI())
|
|
|
|
->setThread($conpherence)
|
|
|
|
->setHeader($header)
|
|
|
|
->setMessages($messages['messages'])
|
|
|
|
->setReplyForm($messages['form'])
|
|
|
|
->setRole('thread');
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
$layout,
|
|
|
|
array(
|
|
|
|
'title' => $conpherence->getTitle(),
|
|
|
|
'device' => true,
|
|
|
|
));
|
2013-01-24 17:23:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private function renderHeaderPaneContent() {
|
|
|
|
require_celerity_resource('conpherence-header-pane-css');
|
|
|
|
$conpherence = $this->getConpherence();
|
2013-03-05 15:45:36 -08:00
|
|
|
$header = $this->buildHeaderPaneContent($conpherence);
|
2013-04-01 12:52:30 -07:00
|
|
|
return array('header' => hsprintf('%s', $header));
|
2013-01-24 17:23:05 -08:00
|
|
|
}
|
|
|
|
|
2013-03-05 15:45:36 -08:00
|
|
|
|
2013-01-24 17:23:05 -08:00
|
|
|
private function renderMessagePaneContent() {
|
|
|
|
require_celerity_resource('conpherence-message-pane-css');
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
$conpherence = $this->getConpherence();
|
|
|
|
|
2013-03-05 15:45:36 -08:00
|
|
|
$data = $this->renderConpherenceTransactions($conpherence);
|
|
|
|
$latest_transaction_id = $data['latest_transaction_id'];
|
|
|
|
$transactions = $data['transactions'];
|
2013-02-15 14:01:27 -08:00
|
|
|
|
2013-03-05 15:45:36 -08:00
|
|
|
$update_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
|
2013-04-01 12:43:07 -07:00
|
|
|
|
|
|
|
Javelin::initBehavior('conpherence-pontificate');
|
2013-01-24 17:23:05 -08:00
|
|
|
|
|
|
|
$form =
|
|
|
|
id(new AphrontFormView())
|
2013-03-05 15:45:36 -08:00
|
|
|
->setAction($update_uri)
|
2013-01-24 17:23:05 -08:00
|
|
|
->setFlexible(true)
|
2013-03-31 14:41:33 -07:00
|
|
|
->addSigil('conpherence-pontificate')
|
|
|
|
->setWorkflow(true)
|
2013-01-24 17:23:05 -08:00
|
|
|
->setUser($user)
|
|
|
|
->addHiddenInput('action', 'message')
|
2013-03-05 15:45:36 -08:00
|
|
|
->addHiddenInput('latest_transaction_id', $latest_transaction_id)
|
2013-01-24 17:23:05 -08:00
|
|
|
->appendChild(
|
|
|
|
id(new PhabricatorRemarkupControl())
|
|
|
|
->setUser($user)
|
2013-02-19 13:33:10 -08:00
|
|
|
->setName('text'))
|
2013-01-24 17:23:05 -08:00
|
|
|
->appendChild(
|
2013-03-31 14:41:33 -07:00
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue(pht('Pontificate')))
|
2013-03-05 15:45:36 -08:00
|
|
|
->render();
|
2013-01-24 17:23:05 -08:00
|
|
|
|
2013-02-15 14:01:27 -08:00
|
|
|
$scrollbutton = javelin_tag(
|
|
|
|
'a',
|
2013-01-24 17:23:05 -08:00
|
|
|
array(
|
2013-02-15 14:01:27 -08:00
|
|
|
'href' => '#',
|
|
|
|
'mustcapture' => true,
|
|
|
|
'sigil' => 'show-older-messages',
|
|
|
|
'class' => 'conpherence-show-older-messages',
|
2013-01-24 17:23:05 -08:00
|
|
|
),
|
2013-02-15 14:01:27 -08:00
|
|
|
pht('Show Older Messages'));
|
2013-02-04 19:01:46 -08:00
|
|
|
|
2013-02-15 14:01:27 -08:00
|
|
|
return array(
|
2013-04-01 12:52:30 -07:00
|
|
|
'messages' => hsprintf('%s%s', $scrollbutton, $transactions),
|
2013-02-15 14:01:27 -08:00
|
|
|
'form' => $form
|
|
|
|
);
|
2013-02-04 19:01:46 -08:00
|
|
|
|
2013-01-24 17:23:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|