mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-12 06:48:31 +01:00
Update ponder answer view to use newer fangled abstractions
Summary: also did a wee bit o' formatting stuff while I was in there. Test Plan: it looks... well, it looks like its using the new UI component and all the information is there! Reviewers: epriestley, pieter CC: aran, Korvin Maniphest Tasks: T1845 Differential Revision: https://secure.phabricator.com/D3611
This commit is contained in:
parent
284bf71a8d
commit
b440830cb7
2 changed files with 42 additions and 119 deletions
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PonderAnswerSummaryView extends AphrontView {
|
||||
private $user;
|
||||
private $answer;
|
||||
private $handles;
|
||||
|
||||
public function setAnswer($answer) {
|
||||
$this->answer = $answer;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHandles($handles) {
|
||||
$this->handles = $handles;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUser(PhabricatorUser $user) {
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private static function abbreviate($w) {
|
||||
return phutil_utf8_shorten($w, 60);
|
||||
}
|
||||
|
||||
public function render() {
|
||||
require_celerity_resource('ponder-feed-view-css');
|
||||
|
||||
$user = $this->user;
|
||||
$answer = $this->answer;
|
||||
$question = $answer->getQuestion();
|
||||
$author_phid = $question->getAuthorPHID();
|
||||
$handles = $this->handles;
|
||||
|
||||
$votecount =
|
||||
'<div class="ponder-summary-votes">'.
|
||||
phutil_escape_html($answer->getVoteCount()).
|
||||
'<div class="ponder-question-label">'.
|
||||
'votes'.
|
||||
'</div>'.
|
||||
'</div>';
|
||||
|
||||
$title =
|
||||
'<h2 class="ponder-question-title">'.
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
"href" => id(new PhutilURI('/Q' . $question->getID()))
|
||||
->setFragment('A' . $answer->getID())
|
||||
),
|
||||
phutil_escape_html('A' . $answer->getID() . ' ' .
|
||||
self::abbreviate($answer->getContent())
|
||||
)
|
||||
).
|
||||
'</h2>';
|
||||
|
||||
$rhs =
|
||||
'<div class="ponder-metadata">'.
|
||||
$title.
|
||||
'<span class="ponder-small-metadata">'.
|
||||
phutil_escape_html(
|
||||
'answer to "'. self::abbreviate($question->getTitle()). '" on ' .
|
||||
phabricator_datetime($answer->getDateCreated(), $user)
|
||||
).
|
||||
'</span>'.
|
||||
'</div>';
|
||||
|
||||
$summary =
|
||||
'<div class="ponder-answer-summary">'.
|
||||
$votecount.
|
||||
$rhs.
|
||||
'</div>';
|
||||
|
||||
return $summary;
|
||||
}
|
||||
}
|
|
@ -73,37 +73,53 @@ final class PonderUserProfileView extends AphrontView {
|
|||
$aparam = $this->aparam;
|
||||
$pagesize = $this->pagesize;
|
||||
|
||||
// display answers
|
||||
$answer_panel = id(new AphrontPanelView())
|
||||
->setHeader("Your Answers")
|
||||
->addClass("ponder-panel")
|
||||
->appendChild(
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array('id' => 'answers'),
|
||||
"")
|
||||
);
|
||||
|
||||
$apagebuttons = id(new AphrontPagerView())
|
||||
->setPageSize($pagesize)
|
||||
->setOffset($aoffset)
|
||||
->setURI(
|
||||
$uri
|
||||
->setFragment("answers"),
|
||||
->setFragment('answers'),
|
||||
$aparam);
|
||||
|
||||
$answers = $apagebuttons->sliceResults($answers);
|
||||
|
||||
$view = new PhabricatorObjectItemListView();
|
||||
$view->setNoDataString(pht('No matching answers.'));
|
||||
|
||||
foreach ($answers as $answer) {
|
||||
$cur = id(new PonderAnswerSummaryView())
|
||||
->setUser($user)
|
||||
->setAnswer($answer)
|
||||
->setHandles($handles);
|
||||
$answer_panel->appendChild($cur);
|
||||
$question = $answer->getQuestion();
|
||||
$author_phid = $question->getAuthorPHID();
|
||||
|
||||
$item = new PhabricatorObjectItemView();
|
||||
$href = id(new PhutilURI('/Q' . $question->getID()))
|
||||
->setFragment('A' . $answer->getID());
|
||||
$item->setHeader(
|
||||
'A'.$answer->getID().' '.self::abbreviate($answer->getContent())
|
||||
);
|
||||
$item->setHref($href);
|
||||
|
||||
$item->addDetail(
|
||||
pht('Votes'),
|
||||
$answer->getVoteCount()
|
||||
);
|
||||
|
||||
$item->addDetail(
|
||||
pht('Question'),
|
||||
self::abbreviate($question->getTitle())
|
||||
);
|
||||
|
||||
$item->addAttribute(
|
||||
pht('Created %s', phabricator_date($answer->getDateCreated(), $user))
|
||||
);
|
||||
|
||||
$view->addItem($item);
|
||||
}
|
||||
|
||||
$answer_panel->appendChild($apagebuttons);
|
||||
$view->appendChild($apagebuttons);
|
||||
|
||||
return $answer_panel->render();
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
private function abbreviate($w) {
|
||||
return phutil_utf8_shorten($w, 60);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue