forked from GNUsocial/gnu-social
QnA
* Some bug fixes * Better Question page
This commit is contained in:
parent
cd7ab56874
commit
6c0bb0f35b
@ -97,7 +97,49 @@ class QnashowquestionAction extends ShownoticeAction
|
|||||||
|
|
||||||
function showContent()
|
function showContent()
|
||||||
{
|
{
|
||||||
|
$this->elementStart('div', 'qna-full-question');
|
||||||
$this->raw($this->question->asHTML());
|
$this->raw($this->question->asHTML());
|
||||||
|
|
||||||
|
$answer = $this->question->getAnswers();
|
||||||
|
|
||||||
|
$this->elementStart('div', 'qna-full-question-answers');
|
||||||
|
|
||||||
|
$answerIds = array();
|
||||||
|
|
||||||
|
// @fixme use a filtered stream!
|
||||||
|
|
||||||
|
if (!empty($answer)) {
|
||||||
|
while ($answer->fetch()) {
|
||||||
|
$answerIds[] = $answer->getNotice()->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($answerIds) > 0) {
|
||||||
|
$notice = new Notice();
|
||||||
|
$notice->query(
|
||||||
|
sprintf(
|
||||||
|
'SELECT notice.* FROM notice WHERE notice.id IN (%s)',
|
||||||
|
implode(',', $answerIds)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$nli = new NoticeList($notice, $this);
|
||||||
|
$nli->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = common_current_user();
|
||||||
|
|
||||||
|
if (!empty($user)) {
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
$answer = QnA_Question::getAnswer($profile);
|
||||||
|
if (empty($answer)) {
|
||||||
|
$form = new QnanewanswerForm($this, $this->question, false);
|
||||||
|
$form->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->elementEnd('div');
|
||||||
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,9 +153,11 @@ class QnashowquestionAction extends ShownoticeAction
|
|||||||
{
|
{
|
||||||
// TRANS: Page title for a question.
|
// TRANS: Page title for a question.
|
||||||
// TRANS: %1$s is the nickname of the user who asked the question, %2$s is the question.
|
// TRANS: %1$s is the nickname of the user who asked the question, %2$s is the question.
|
||||||
return sprintf(_m('%1$s\'s question: %2$s'),
|
return sprintf(
|
||||||
$this->user->nickname,
|
_m('%1$s\'s question: %2$s'),
|
||||||
$this->question->title);
|
$this->user->nickname,
|
||||||
|
$this->question->title
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,6 +155,11 @@ class QnA_Answer extends Managed_DataObject
|
|||||||
return Notice::staticGet('uri', $this->uri);
|
return Notice::staticGet('uri', $this->uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function fromNotice($notice)
|
||||||
|
{
|
||||||
|
return QnA_Answer::staticGet('uri', $notice->uri);
|
||||||
|
}
|
||||||
|
|
||||||
function bestUrl()
|
function bestUrl()
|
||||||
{
|
{
|
||||||
return $this->getNotice()->bestUrl();
|
return $this->getNotice()->bestUrl();
|
||||||
|
@ -47,6 +47,7 @@ if (!defined('STATUSNET')) {
|
|||||||
class QnanewanswerForm extends Form
|
class QnanewanswerForm extends Form
|
||||||
{
|
{
|
||||||
protected $question;
|
protected $question;
|
||||||
|
protected $showQuestion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new answer form
|
* Construct a new answer form
|
||||||
@ -56,10 +57,11 @@ class QnanewanswerForm extends Form
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct(HTMLOutputter $out, QnA_Question $question)
|
function __construct(HTMLOutputter $out, QnA_Question $question, $showQuestion = true)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
$this->question = $question;
|
$this->question = $question;
|
||||||
|
$this->showQuestion = $showQuestion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,9 +105,10 @@ class QnanewanswerForm extends Form
|
|||||||
$out = $this->out;
|
$out = $this->out;
|
||||||
$id = "question-" . $question->id;
|
$id = "question-" . $question->id;
|
||||||
|
|
||||||
$out->raw($this->question->asHTML());
|
if ($this->showQuestion) {
|
||||||
|
$out->raw($this->question->asHTML());
|
||||||
|
}
|
||||||
|
|
||||||
$out->element('p', 'answer', 'Your answer');
|
|
||||||
$out->hidden('id', $id);
|
$out->hidden('id', $id);
|
||||||
$out->textarea('answer', 'answer');
|
$out->textarea('answer', 'answer');
|
||||||
}
|
}
|
||||||
|
@ -46,14 +46,14 @@ require_once INSTALLDIR . '/lib/form.php';
|
|||||||
class QnashowanswerForm extends Form
|
class QnashowanswerForm extends Form
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The answer to revise
|
* The answer to show
|
||||||
*/
|
*/
|
||||||
var $answer = null;
|
protected $answer = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The question this is an answer to
|
* The question this is an answer to
|
||||||
*/
|
*/
|
||||||
var $question = null;
|
protected $question = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -76,7 +76,7 @@ class QnashowanswerForm extends Form
|
|||||||
*/
|
*/
|
||||||
function id()
|
function id()
|
||||||
{
|
{
|
||||||
return 'revise-' . $this->answer->id;
|
return 'show-' . $this->answer->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,8 +109,8 @@ class QnashowanswerForm extends Form
|
|||||||
*/
|
*/
|
||||||
function formLegend()
|
function formLegend()
|
||||||
{
|
{
|
||||||
// TRANS: Form legend for revising the answer.
|
// TRANS: Form legend for showing the answer.
|
||||||
$this->out->element('legend', null, _('Revise your answer'));
|
$this->out->element('legend', null, _('Answer'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,10 +122,12 @@ class QnashowanswerForm extends Form
|
|||||||
{
|
{
|
||||||
$this->out->hidden(
|
$this->out->hidden(
|
||||||
'id',
|
'id',
|
||||||
'revise-' . $this->answer->id
|
'answer-' . $this->answer->id
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->out->raw($this->answer->asHTML());
|
|
||||||
|
|
||||||
|
// $this->out->raw($this->answer->asHTML());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,6 +186,6 @@ class QnashowanswerForm extends Form
|
|||||||
*/
|
*/
|
||||||
function formClass()
|
function formClass()
|
||||||
{
|
{
|
||||||
return 'form_revise ajax';
|
return 'form_show ajax';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user