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',
// TRANS: %s is the unpexpected object type.
throw new Exception(
sprintf(
- _m('Unexpected type for QnA plugin: %s.'),
+ _m('Unexpected type for QnA plugin: %s.'),
$notice->object_type
)
);
}
}
-
+
function showNoticeQuestion($notice, $out)
{
$user = common_current_user();
$out->elementStart('div', array('class' => 'entry-content question-content'));
$question = QnA_Question::getByNotice($notice);
-
+
if ($question) {
if ($user) {
$profile = $user->getProfile();
*/
class QnanewanswerAction extends Action
{
- protected $user = null;
- protected $error = null;
- protected $complete = null;
+ protected $user = null;
+ protected $error = null;
+ protected $complete = null;
- protected $question = null;
- protected $content = null;
+ protected $question = null;
+ protected $content = null;
/**
* Returns the title of the 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)) {
// TRANS: Client exception thrown trying to respond to a non-existing question.
throw new ClientException(
- _m('Invalid or missing question.'),
+ _m('Invalid or missing question.'),
404
);
}
$this->answerText = $this->trimmed('answer');
-
+
return true;
}
$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');
}
$form = new QnaanswerForm($this->question, $this);
-
$form->show();
return;
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)) {
{
$question = $this->answer->getQuestion();
- return sprintf(_('%s\'s answer to "%s"'),
- $this->user->nickname,
- $question->title);
+ return sprintf(
+ _('%s\'s answer to "%s"'),
+ $this->user->nickname,
+ $question->title
+ );
}
/**
$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());
+ }
}
*/
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()
function __construct(QnA_Answer $answer, HTMLOutputter $out)
{
parent::__construct($out);
- $this->question = $answer->getQuestion();
+ $this->question = $answer->getQuestion();
$this->answer = $answer;
}
*/
function action()
{
- return common_local_url('qnanewanswer', array('id' => $this->question->id));
+ return common_local_url('qnanewanswer');
}
/**
$id = "question-" . $question->id;
$out->element('p', 'answer', $question->title);
+ $out->hidden('id', $id);
$out->element('input', array('type' => 'text', 'name' => 'answer'));
}