X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FQnA%2Factions%2Fqnanewanswer.php;h=5543cba06c623dbff942744d3401abcff7b8e6b2;hb=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a;hp=dbab6c5eefa6692dfda3cdfc0b4bdd6808d7b62c;hpb=31b29fde50e9664e1b70064c043879ce87553883;p=quix0rs-gnu-social.git diff --git a/plugins/QnA/actions/qnanewanswer.php b/plugins/QnA/actions/qnanewanswer.php index dbab6c5eef..5543cba06c 100644 --- a/plugins/QnA/actions/qnanewanswer.php +++ b/plugins/QnA/actions/qnanewanswer.php @@ -74,14 +74,14 @@ class QnanewanswerAction extends Action { parent::prepare($argarray); if ($this->boolean('ajax')) { - StatusNet::setApi(true); + GNUsocial::setApi(true); } common_debug("in qnanewanswer"); $this->user = common_current_user(); if (empty($this->user)) { - // TRANS: Client exception thrown trying to answer a question while not logged in. throw new ClientException( + // TRANS: Client exception thrown trying to answer a question while not logged in. _m("You must be logged in to answer to a question."), 403 ); @@ -93,11 +93,11 @@ class QnanewanswerAction extends Action $id = substr($this->trimmed('id'), 9); - $this->question = QnA_Question::staticGet('id', $id); + $this->question = QnA_Question::getKV('id', $id); if (empty($this->question)) { - // TRANS: Client exception thrown trying to respond to a non-existing question. throw new ClientException( + // TRANS: Client exception thrown trying to respond to a non-existing question. _m('Invalid or missing question.'), 404 ); @@ -151,10 +151,8 @@ class QnanewanswerAction extends Action if ($this->boolean('ajax')) { common_debug("ajaxy part"); $answer = $this->question->getAnswer($profile); - header('Content-Type: text/xml;charset=utf-8'); - $this->xw->startDocument('1.0', 'UTF-8'); - $this->elementStart('html'); + $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Page title after sending an answer. $this->element('title', null, _m('Answers')); @@ -162,15 +160,14 @@ class QnanewanswerAction extends Action $this->elementStart('body'); - $nli = new NoticeAnswerListItem($notice, $this, $this->question, $answer); $nli->show(); $this->elementEnd('body'); - $this->elementEnd('html'); + $this->endHTML(); } else { common_debug("not ajax"); - common_redirect($this->question->bestUrl(), 303); + common_redirect($this->question->getUrl(), 303); } } @@ -200,7 +197,7 @@ class QnanewanswerAction extends Action * * @return boolean is read only action? */ - function isReadOnly($args) + function isReadOnly(array $args=array()) { if ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') { @@ -229,7 +226,7 @@ class QnanewanswerAction extends Action $this->elementStart('body'); $this->element('p', array('id' => 'error'), $msg); $this->elementEnd('body'); - $this->elementEnd('html'); + $this->endHTML(); } /** @@ -255,7 +252,7 @@ class QnanewanswerAction extends Action $form->show(); $this->elementEnd('body'); - $this->elementEnd('html'); + $this->endHTML(); } /** @@ -278,7 +275,6 @@ class QnanewanswerAction extends Action $this->msg = $msg; $this->showPage(); } - } class NoticeAnswerListItem extends NoticeListItem @@ -330,24 +326,17 @@ class NoticeAnswerListItem extends NoticeListItem */ function showContent() { - $this->out->elementStart('p', array('class' => 'entry-content answer-content')); - if ($this->notice->rendered) { - $this->out->raw($this->notice->rendered); - } else { - // XXX: may be some uncooked notices in the DB, - // we cook them right now. This should probably disappear in future - // versions (>> 0.4.x) - $this->out->raw(common_render_content($this->notice->content, $this->notice)); - } + $this->out->elementStart('p', array('class' => 'e-content answer-content')); + $this->out->raw($this->notice->getRendered()); if (!empty($this->answer)) { $form = new QnashowanswerForm($this->out, $this->answer); $form->show(); } else { + // TRANS: Error message displayed when an answer has no content. $out->text(_m('Answer data is missing.')); } $this->out->elementEnd('p'); } - -} \ No newline at end of file +}