Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php
index 59da519834..2cd555204c 100644
--- a/src/applications/ponder/controller/PonderQuestionViewController.php
+++ b/src/applications/ponder/controller/PonderQuestionViewController.php
@@ -1,276 +1,276 @@
<?php
final class PonderQuestionViewController extends PonderController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$question = id(new PonderQuestionQuery())
->setViewer($viewer)
->withIDs(array($id))
->needAnswers(true)
->needProjectPHIDs(true)
->executeOne();
if (!$question) {
return new Aphront404Response();
}
$answers = $this->buildAnswers($question);
$answer_add_panel = id(new PonderAddAnswerView())
->setQuestion($question)
->setUser($viewer)
->setActionURI('/ponder/answer/add/');
$header = new PHUIHeaderView();
$header->setHeader($question->getTitle());
$header->setUser($viewer);
$header->setPolicyObject($question);
$header->setHeaderIcon('fa-university');
if ($question->getStatus() == PonderQuestionStatus::STATUS_OPEN) {
$header->setStatus('fa-square-o', 'bluegrey', pht('Open'));
} else {
$text = PonderQuestionStatus::getQuestionStatusFullName(
$question->getStatus());
$icon = PonderQuestionStatus::getQuestionStatusIcon(
$question->getStatus());
$header->setStatus($icon, 'dark', $text);
}
$curtain = $this->buildCurtain($question);
$details = $this->buildPropertySectionView($question);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$question,
PhabricatorPolicyCapability::CAN_EDIT);
$content_id = celerity_generate_unique_node_id();
$timeline = $this->buildTransactionTimeline(
$question,
id(new PonderQuestionTransactionQuery())
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT)));
$xactions = $timeline->getTransactions();
$add_comment = id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
->setObjectPHID($question->getPHID())
->setShowPreview(false)
->setAction($this->getApplicationURI("/question/comment/{$id}/"))
->setSubmitButtonName(pht('Comment'));
$add_comment = phutil_tag_div(
'ponder-question-add-comment-view', $add_comment);
$comment_view = phutil_tag(
'div',
array(
'id' => $content_id,
'style' => 'display: none;',
),
array(
$timeline,
$add_comment,
));
$footer = id(new PonderFooterView())
->setContentID($content_id)
->setCount(count($xactions));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb('Q'.$id, '/Q'.$id);
$crumbs->setBorder(true);
$subheader = $this->buildSubheaderView($question);
$answer_wiki = null;
if ($question->getAnswerWiki()) {
$wiki = new PHUIRemarkupView($viewer, $question->getAnswerWiki());
$answer_wiki = id(new PHUIObjectBoxView())
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
- ->setHeaderText(pht('ANSWER SUMMARY'))
+ ->setHeaderText(pht('Answer Summary'))
->appendChild($wiki)
->addClass('ponder-answer-wiki');
}
require_celerity_resource('ponder-view-css');
$ponder_content = phutil_tag(
'div',
array(
'class' => 'ponder-question-content',
),
array(
$answer_wiki,
$footer,
$comment_view,
$answers,
$answer_add_panel,
));
$ponder_view = id(new PHUITwoColumnView())
->setHeader($header)
->setSubheader($subheader)
->setCurtain($curtain)
->setMainColumn($ponder_content)
->addPropertySection(pht('Details'), $details)
->addClass('ponder-question-view');
$page_objects = array_merge(
array($question->getPHID()),
mpull($question->getAnswers(), 'getPHID'));
return $this->newPage()
->setTitle('Q'.$question->getID().' '.$question->getTitle())
->setCrumbs($crumbs)
->setPageObjectPHIDs($page_objects)
->appendChild($ponder_view);
}
private function buildCurtain(PonderQuestion $question) {
$viewer = $this->getViewer();
$id = $question->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$question,
PhabricatorPolicyCapability::CAN_EDIT);
$curtain = $this->newCurtainView($question);
if ($question->getStatus() == PonderQuestionStatus::STATUS_OPEN) {
$name = pht('Close Question');
$icon = 'fa-check-square-o';
} else {
$name = pht('Reopen Question');
$icon = 'fa-square-o';
}
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
->setName(pht('Edit Question'))
->setHref($this->getApplicationURI("/question/edit/{$id}/"))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$curtain->addAction(
id(new PhabricatorActionView())
->setName($name)
->setIcon($icon)
->setWorkflow(true)
->setDisabled(!$can_edit)
->setHref($this->getApplicationURI("/question/status/{$id}/")));
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-list')
->setName(pht('View History'))
->setHref($this->getApplicationURI("/question/history/{$id}/")));
return $curtain;
}
private function buildSubheaderView(
PonderQuestion $question) {
$viewer = $this->getViewer();
$asker = $viewer->renderHandle($question->getAuthorPHID())->render();
$date = phabricator_datetime($question->getDateCreated(), $viewer);
$asker = phutil_tag('strong', array(), $asker);
$author = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withPHIDs(array($question->getAuthorPHID()))
->needProfileImage(true)
->executeOne();
$image_uri = $author->getProfileImageURI();
$image_href = '/p/'.$author->getUsername();
$content = pht('Asked by %s on %s.', $asker, $date);
return id(new PHUIHeadThingView())
->setImage($image_uri)
->setImageHref($image_href)
->setContent($content);
}
private function buildPropertySectionView(
PonderQuestion $question) {
$viewer = $this->getViewer();
$question_details = PhabricatorMarkupEngine::renderOneObject(
$question,
$question->getMarkupField(),
$viewer);
if (!$question_details) {
$question_details = phutil_tag(
'em',
array(),
pht('No further details for this question.'));
}
$question_details = phutil_tag_div(
'phabricator-remarkup ml', $question_details);
return $question_details;
}
/**
* This is fairly non-standard; building N timelines at once (N = number of
* answers) is tricky business.
*
* TODO - re-factor this to ajax in one answer panel at a time in a more
* standard fashion. This is necessary to scale this application.
*/
private function buildAnswers(PonderQuestion $question) {
$viewer = $this->getViewer();
$answers = $question->getAnswers();
if ($answers) {
$author_phids = mpull($answers, 'getAuthorPHID');
$handles = $this->loadViewerHandles($author_phids);
$view = array();
foreach ($answers as $answer) {
$id = $answer->getID();
$handle = $handles[$answer->getAuthorPHID()];
$timeline = $this->buildTransactionTimeline(
$answer,
id(new PonderAnswerTransactionQuery())
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT)));
$xactions = $timeline->getTransactions();
$view[] = id(new PonderAnswerView())
->setUser($viewer)
->setAnswer($answer)
->setTransactions($xactions)
->setTimeline($timeline)
->setHandle($handle);
}
$header = id(new PHUIHeaderView())
->setHeader('Answers');
return id(new PHUIBoxView())
->addClass('ponder-answer-section')
->appendChild($header)
->appendChild($view);
}
return null;
}
}
diff --git a/src/applications/ponder/editor/PonderQuestionEditor.php b/src/applications/ponder/editor/PonderQuestionEditor.php
index a17aebecf8..0720f436b9 100644
--- a/src/applications/ponder/editor/PonderQuestionEditor.php
+++ b/src/applications/ponder/editor/PonderQuestionEditor.php
@@ -1,197 +1,197 @@
<?php
final class PonderQuestionEditor
extends PonderEditor {
private $answer;
public function getEditorObjectsDescription() {
return pht('Ponder Questions');
}
public function getCreateObjectTitle($author, $object) {
- return pht('%s created this question.', $author);
+ return pht('%s asked this question.', $author);
}
public function getCreateObjectTitleForFeed($author, $object) {
- return pht('%s created %s.', $author, $object);
+ return pht('%s asked %s.', $author, $object);
}
/**
* This is used internally on @{method:applyInitialEffects} if a transaction
* of type PonderQuestionTransaction::TYPE_ANSWERS is in the mix. The value
* is set to the //last// answer in the transactions. Practically, one
* answer is given at a time in the application, though theoretically
* this is buggy.
*
* The answer is used in emails to generate proper links.
*/
private function setAnswer(PonderAnswer $answer) {
$this->answer = $answer;
return $this;
}
private function getAnswer() {
return $this->answer;
}
protected function shouldApplyInitialEffects(
PhabricatorLiskDAO $object,
array $xactions) {
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case PonderQuestionAnswerTransaction::TRANSACTIONTYPE:
return true;
}
}
return false;
}
protected function applyInitialEffects(
PhabricatorLiskDAO $object,
array $xactions) {
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case PonderQuestionAnswerTransaction::TRANSACTIONTYPE:
$new_value = $xaction->getNewValue();
$new = idx($new_value, '+', array());
foreach ($new as $new_answer) {
$answer = idx($new_answer, 'answer');
if (!$answer) {
continue;
}
$answer->save();
$this->setAnswer($answer);
}
break;
}
}
}
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
$types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
return $types;
}
protected function supportsSearch() {
return true;
}
protected function shouldImplyCC(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PonderQuestionAnswerTransaction::TRANSACTIONTYPE:
return false;
}
return parent::shouldImplyCC($object, $xaction);
}
protected function shouldSendMail(
PhabricatorLiskDAO $object,
array $xactions) {
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case PonderQuestionAnswerTransaction::TRANSACTIONTYPE:
return false;
}
}
return true;
}
protected function getMailTo(PhabricatorLiskDAO $object) {
return array(
$object->getAuthorPHID(),
$this->requireActor()->getPHID(),
);
}
protected function shouldPublishFeedStory(
PhabricatorLiskDAO $object,
array $xactions) {
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case PonderQuestionAnswerTransaction::TRANSACTIONTYPE:
return false;
}
}
return true;
}
public function getMailTagsMap() {
return array(
PonderQuestionTransaction::MAILTAG_DETAILS =>
pht('Someone changes the questions details.'),
PonderQuestionTransaction::MAILTAG_ANSWERS =>
pht('Someone adds a new answer.'),
PonderQuestionTransaction::MAILTAG_COMMENT =>
pht('Someone comments on the question.'),
PonderQuestionTransaction::MAILTAG_OTHER =>
pht('Other question activity not listed above occurs.'),
);
}
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
return id(new PonderQuestionReplyHandler())
->setMailReceiver($object);
}
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
$id = $object->getID();
$title = $object->getTitle();
$original_title = $object->getOriginalTitle();
return id(new PhabricatorMetaMTAMail())
->setSubject("Q{$id}: {$title}")
->addHeader('Thread-Topic', "Q{$id}: {$original_title}");
}
protected function buildMailBody(
PhabricatorLiskDAO $object,
array $xactions) {
$body = parent::buildMailBody($object, $xactions);
$header = pht('QUESTION DETAIL');
$uri = '/Q'.$object->getID();
foreach ($xactions as $xaction) {
$type = $xaction->getTransactionType();
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
// If the user just asked the question, add the question text.
if ($type == PonderQuestionContentTransaction::TRANSACTIONTYPE) {
if ($old === null) {
$body->addRawSection($new);
}
}
}
$body->addLinkSection(
$header,
PhabricatorEnv::getProductionURI($uri));
return $body;
}
protected function shouldApplyHeraldRules(
PhabricatorLiskDAO $object,
array $xactions) {
return true;
}
protected function buildHeraldAdapter(
PhabricatorLiskDAO $object,
array $xactions) {
return id(new HeraldPonderQuestionAdapter())
->setQuestion($object);
}
}
diff --git a/src/applications/ponder/storage/PonderAnswerTransaction.php b/src/applications/ponder/storage/PonderAnswerTransaction.php
index 784b8a36e7..efbe020106 100644
--- a/src/applications/ponder/storage/PonderAnswerTransaction.php
+++ b/src/applications/ponder/storage/PonderAnswerTransaction.php
@@ -1,26 +1,33 @@
<?php
final class PonderAnswerTransaction
extends PhabricatorModularTransaction {
public function getApplicationName() {
return 'ponder';
}
public function getTableName() {
return 'ponder_answertransaction';
}
public function getApplicationTransactionType() {
return PonderAnswerPHIDType::TYPECONST;
}
public function getApplicationTransactionCommentObject() {
return new PonderAnswerTransactionComment();
}
public function getBaseTransactionClass() {
return 'PonderAnswerTransactionType';
}
+ public function getMailTags() {
+ $tags = parent::getMailTags();
+ $tags[] = PonderQuestionTransaction::MAILTAG_OTHER;
+
+ return $tags;
+ }
+
}
diff --git a/src/applications/ponder/xaction/PonderAnswerContentTransaction.php b/src/applications/ponder/xaction/PonderAnswerContentTransaction.php
index 5d5c6ad157..2e55ef5fea 100644
--- a/src/applications/ponder/xaction/PonderAnswerContentTransaction.php
+++ b/src/applications/ponder/xaction/PonderAnswerContentTransaction.php
@@ -1,56 +1,73 @@
<?php
final class PonderAnswerContentTransaction
extends PonderAnswerTransactionType {
const TRANSACTIONTYPE = 'ponder.answer:content';
public function generateOldValue($object) {
return $object->getContent();
}
public function applyInternalEffects($object, $value) {
$object->setContent($value);
}
public function getTitle() {
+ $old = $this->getOldValue();
+
+ if (!strlen($old)) {
+ return pht(
+ '%s added an answer.',
+ $this->renderAuthor());
+ }
+
return pht(
'%s updated the answer details.',
$this->renderAuthor());
}
public function getTitleForFeed() {
+ $old = $this->getOldValue();
+
+ if (!strlen($old)) {
+ return pht(
+ '%s added %s.',
+ $this->renderAuthor(),
+ $this->renderObject());
+ }
+
return pht(
'%s updated the answer details for %s.',
$this->renderAuthor(),
$this->renderObject());
}
public function hasChangeDetailView() {
return true;
}
public function getMailDiffSectionHeader() {
return pht('CHANGES TO ANSWER DETAILS');
}
public function newChangeDetailView() {
$viewer = $this->getViewer();
return id(new PhabricatorApplicationTransactionTextDiffDetailView())
->setViewer($viewer)
->setOldText($this->getOldValue())
->setNewText($this->getNewValue());
}
public function newRemarkupChanges() {
$changes = array();
$changes[] = $this->newRemarkupChange()
->setOldValue($this->getOldValue())
->setNewValue($this->getNewValue());
return $changes;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jul 24, 7:11 AM (19 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
182583
Default Alt Text
(17 KB)

Event Timeline