Commit eeff6285 authored by Zach Copley's avatar Zach Copley

Make new answers work

parent 7669bed9
......@@ -120,9 +120,8 @@ class QnAPlugin extends MicroAppPlugin
array('action' => 'qnanewquestion')
);
$m->connect(
'main/qna/newanswer/:id',
array('action' => 'qnanewanswer'),
array('id' => $UUIDregex)
'main/qna/newanswer',
array('action' => 'qnanewanswer')
);
$m->connect(
'question/vote/:id',
......
......@@ -91,7 +91,10 @@ class QnanewanswerAction extends Action
$this->checkSessionToken();
}
$id = $this->trimmed('id');
$id = substr($this->trimmed('id'), 9);
common_debug("XXXXXXXXXXXXXXXXXX id = " . $id);
$this->question = QnA_Question::staticGet('id', $id);
if (empty($this->question)) {
......@@ -145,8 +148,8 @@ class QnanewanswerAction extends Action
$this->showPage();
return;
}
if ($this->boolean('ajax')) {
common_debug("ajaxy part");
header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8');
$this->elementStart('html');
......@@ -176,7 +179,6 @@ class QnanewanswerAction extends Action
}
$form = new QnaanswerForm($this->question, $this);
$form->show();
return;
......
......@@ -69,6 +69,12 @@ class QnashowanswerAction extends ShownoticeAction
throw new ClientException(_('No such answer.'), 404);
}
$this->question = $this->answer->getQuestion();
if (empty($this->question)) {
throw new ClientException(_('No question for this answer.'), 404);
}
$this->notice = Notice::staticGet('uri', $this->answer->uri);
if (empty($this->notice)) {
......@@ -105,9 +111,11 @@ class QnashowanswerAction extends ShownoticeAction
{
$question = $this->answer->getQuestion();
return sprintf(_('%s\'s answer to "%s"'),
return sprintf(
_('%s\'s answer to "%s"'),
$this->user->nickname,
$question->title);
$question->title
);
}
/**
......@@ -121,9 +129,14 @@ class QnashowanswerAction extends ShownoticeAction
$this->elementStart('h1');
$this->element(
'a',
array('href' => $this->answer->url),
$this->answer->title
array('href' => $this->answer->uri),
$this->question->title
);
$this->elementEnd('h1');
}
function showContent()
{
$this->raw($this->answer->asHTML());
}
}
......@@ -167,11 +167,11 @@ class QnA_Answer extends Managed_DataObject
*/
function getQuestion()
{
$question = self::staticGet('id', $this->question_id);
$question = QnA_Question::staticGet('id', $this->question_id);
if (empty($question)) {
throw new Exception("No question with ID {$this->question_id}");
}
return question;
return $question;
}
function getProfile()
......
......@@ -89,7 +89,7 @@ class QnaanswerForm extends Form
*/
function action()
{
return common_local_url('qnanewanswer', array('id' => $this->question->id));
return common_local_url('qnanewanswer');
}
/**
......@@ -104,6 +104,7 @@ class QnaanswerForm extends Form
$id = "question-" . $question->id;
$out->element('p', 'answer', $question->title);
$out->hidden('id', $id);
$out->element('input', array('type' => 'text', 'name' => 'answer'));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment