2013-01-25 02:23:05 +01: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 23:03:52 +01:00
|
|
|
->needHeaderPics(true)
|
2013-01-25 02:23:05 +01:00
|
|
|
->executeOne();
|
|
|
|
$this->setConpherence($conpherence);
|
|
|
|
|
|
|
|
$participant = $conpherence->getParticipant($user->getPHID());
|
2013-01-27 03:53:30 +01:00
|
|
|
$transactions = $conpherence->getTransactions();
|
|
|
|
$latest_transaction = end($transactions);
|
2013-01-25 02:23:05 +01:00
|
|
|
$write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
|
2013-01-27 03:53:30 +01:00
|
|
|
$participant->markUpToDate($latest_transaction);
|
2013-01-25 02:23:05 +01:00
|
|
|
unset($write_guard);
|
|
|
|
|
|
|
|
$header = $this->renderHeaderPaneContent();
|
|
|
|
$messages = $this->renderMessagePaneContent();
|
2013-02-15 23:01:27 +01:00
|
|
|
$content = $header + $messages;
|
2013-01-25 02:23:05 +01:00
|
|
|
return id(new AphrontAjaxResponse())->setContent($content);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderHeaderPaneContent() {
|
|
|
|
require_celerity_resource('conpherence-header-pane-css');
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
$conpherence = $this->getConpherence();
|
2013-02-06 23:03:52 +01:00
|
|
|
$display_data = $conpherence->getDisplayData(
|
|
|
|
$user,
|
|
|
|
ConpherenceImageData::SIZE_HEAD
|
|
|
|
);
|
2013-01-25 02:23:05 +01:00
|
|
|
$edit_href = $this->getApplicationURI('update/'.$conpherence->getID().'/');
|
2013-02-06 23:03:52 +01:00
|
|
|
$class_mod = $display_data['image_class'];
|
2013-01-25 02:23:05 +01:00
|
|
|
|
|
|
|
$header =
|
2013-02-06 23:03:52 +01:00
|
|
|
phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'upload-photo'
|
|
|
|
),
|
|
|
|
pht('Drop photo here to change this Conpherence photo.')
|
|
|
|
).
|
2013-02-05 04:01:46 +01:00
|
|
|
javelin_tag(
|
2013-01-25 02:23:05 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'class' => 'edit',
|
|
|
|
'href' => $edit_href,
|
2013-02-06 23:03:52 +01:00
|
|
|
'sigil' => 'workflow edit-action',
|
2013-01-25 02:23:05 +01:00
|
|
|
),
|
2013-01-26 00:48:04 +01:00
|
|
|
''
|
2013-01-25 02:23:05 +01:00
|
|
|
).
|
2013-02-05 04:01:46 +01:00
|
|
|
phutil_tag(
|
2013-01-25 02:23:05 +01:00
|
|
|
'div',
|
|
|
|
array(
|
2013-02-06 23:03:52 +01:00
|
|
|
'class' => $class_mod.'header-image',
|
2013-01-25 02:23:05 +01:00
|
|
|
'style' => 'background-image: url('.$display_data['image'].');'
|
|
|
|
),
|
|
|
|
''
|
|
|
|
).
|
2013-02-05 04:01:46 +01:00
|
|
|
phutil_tag(
|
2013-01-25 02:23:05 +01:00
|
|
|
'div',
|
|
|
|
array(
|
2013-02-06 23:03:52 +01:00
|
|
|
'class' => $class_mod.'title',
|
2013-01-25 02:23:05 +01:00
|
|
|
),
|
2013-02-05 04:01:46 +01:00
|
|
|
$display_data['title']
|
2013-01-25 02:23:05 +01:00
|
|
|
).
|
2013-02-05 04:01:46 +01:00
|
|
|
phutil_tag(
|
2013-01-25 02:23:05 +01:00
|
|
|
'div',
|
|
|
|
array(
|
2013-02-06 23:03:52 +01:00
|
|
|
'class' => $class_mod.'subtitle',
|
2013-01-25 02:23:05 +01:00
|
|
|
),
|
2013-02-05 04:01:46 +01:00
|
|
|
$display_data['subtitle']
|
2013-01-25 02:23:05 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return array('header' => $header);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderMessagePaneContent() {
|
|
|
|
require_celerity_resource('conpherence-message-pane-css');
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
$conpherence = $this->getConpherence();
|
|
|
|
$handles = $conpherence->getHandles();
|
|
|
|
$rendered_transactions = array();
|
|
|
|
|
2013-02-15 23:01:27 +01:00
|
|
|
|
|
|
|
$transactions = $conpherence->getTransactionsFrom(0, 100);
|
2013-02-07 02:53:51 +01:00
|
|
|
|
|
|
|
$engine = id(new PhabricatorMarkupEngine())
|
|
|
|
->setViewer($user);
|
|
|
|
foreach ($transactions as $transaction) {
|
|
|
|
if ($transaction->getComment()) {
|
|
|
|
$engine->addObject(
|
|
|
|
$transaction->getComment(),
|
|
|
|
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$engine->process();
|
2013-01-25 02:23:05 +01:00
|
|
|
foreach ($transactions as $transaction) {
|
2013-01-25 22:04:40 +01:00
|
|
|
if ($transaction->shouldHide()) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-01-25 02:23:05 +01:00
|
|
|
$rendered_transactions[] = id(new ConpherenceTransactionView())
|
|
|
|
->setUser($user)
|
|
|
|
->setConpherenceTransaction($transaction)
|
|
|
|
->setHandles($handles)
|
2013-02-07 02:53:51 +01:00
|
|
|
->setMarkupEngine($engine)
|
2013-01-25 02:23:05 +01:00
|
|
|
->render();
|
|
|
|
}
|
2013-02-13 23:50:15 +01:00
|
|
|
$transactions = phutil_implode_html(' ', $rendered_transactions);
|
2013-01-25 02:23:05 +01:00
|
|
|
|
|
|
|
$form =
|
|
|
|
id(new AphrontFormView())
|
2013-01-30 01:53:57 +01:00
|
|
|
->setWorkflow(true)
|
2013-01-25 02:23:05 +01:00
|
|
|
->setAction($this->getApplicationURI('update/'.$conpherence->getID().'/'))
|
|
|
|
->setFlexible(true)
|
|
|
|
->setUser($user)
|
|
|
|
->addHiddenInput('action', 'message')
|
|
|
|
->appendChild(
|
|
|
|
id(new PhabricatorRemarkupControl())
|
|
|
|
->setUser($user)
|
|
|
|
->setName('text')
|
|
|
|
)
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue(pht('Pontificate'))
|
|
|
|
)->render();
|
|
|
|
|
2013-02-15 23:01:27 +01:00
|
|
|
$scrollbutton = javelin_tag(
|
|
|
|
'a',
|
2013-01-25 02:23:05 +01:00
|
|
|
array(
|
2013-02-15 23:01:27 +01:00
|
|
|
'href' => '#',
|
|
|
|
'mustcapture' => true,
|
|
|
|
'sigil' => 'show-older-messages',
|
|
|
|
'class' => 'conpherence-show-older-messages',
|
2013-01-25 02:23:05 +01:00
|
|
|
),
|
2013-02-15 23:01:27 +01:00
|
|
|
pht('Show Older Messages'));
|
2013-02-05 04:01:46 +01:00
|
|
|
|
2013-02-15 23:01:27 +01:00
|
|
|
return array(
|
|
|
|
'messages' => $scrollbutton.$transactions,
|
|
|
|
'form' => $form
|
|
|
|
);
|
2013-02-05 04:01:46 +01:00
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|