X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FQnA%2FQnAPlugin.php;h=6841ec9873204e7d8e82001838ae9a20c19f3cf8;hb=68f6076831b1bb9ce2e1d8d1f5360a7d17533892;hp=375e87f615d2ad1eabff4f060c9ebd7fae0cc412;hpb=d09995561dc2b63dc63d537fce922237bfbde9f1;p=quix0rs-gnu-social.git diff --git a/plugins/QnA/QnAPlugin.php b/plugins/QnA/QnAPlugin.php index 375e87f615..6841ec9873 100644 --- a/plugins/QnA/QnAPlugin.php +++ b/plugins/QnA/QnAPlugin.php @@ -205,7 +205,7 @@ class QnAPlugin extends MicroAppPlugin $questionObj = $activity->objects[0]; - if ($questinoObj->type != QnA_Question::OBJECT_TYPE) { + if ($questionObj->type != QnA_Question::OBJECT_TYPE) { throw new Exception('Wrong type for object.'); } @@ -375,20 +375,10 @@ class QnAPlugin extends MicroAppPlugin $question = QnA_Question::getByNotice($notice); if (!empty($question)) { - if (empty($user)) { - $form = new QnashowquestionForm($out, $question); - $form->show(); - } else { - $profile = $user->getProfile(); - $answer = $question->getAnswer($profile); - if (empty($answer)) { - $form = new QnanewanswerForm($out, $question); - $form->show(); - } else { - $form = new QnashowquestionForm($out, $question); - $form->show(); - } - } + + $form = new QnashowquestionForm($out, $question); + $form->show(); + } else { $out->text(_m('Question data is missing.')); } @@ -398,6 +388,71 @@ class QnAPlugin extends MicroAppPlugin $out->elementStart('div', array('class' => 'entry-content')); } + + /** + * Output the HTML for this kind of object in a list + * + * @param NoticeListItem $nli The list item being shown. + * + * @return boolean hook value + * + * @fixme WARNING WARNING WARNING this closes a 'div' that is implicitly opened in BookmarkPlugin's showNotice implementation + */ + function onStartShowNoticeItem($nli) + { + if (!$this->isMyNotice($nli->notice)) { + return true; + } + + $out = $nli->out; + $notice = $nli->notice; + + $this->showNotice($notice, $out); + + $nli->showNoticeLink(); + $nli->showNoticeSource(); + $nli->showNoticeLocation(); + $nli->showContext(); + $nli->showRepeat(); + + $out->elementEnd('div'); + + $nli->showNoticeOptions(); + + if ($notice->object_type == QnA_Question::OBJECT_TYPE) { + + $user = common_current_user(); + $question = QnA_Question::getByNotice($notice); + + if (!empty($user)) { + + $profile = $user->getProfile(); + $answer = $question->getAnswer($profile); + + // Output a placeholder input -- clicking on it will + // bring up a real answer form + + // NOTE: this whole ul is just a placeholder + if (empty($question->closed) && empty($answer)) { + $out->elementStart('ul', 'notices qna-dummy'); + $out->elementStart('li', 'qna-dummy-placeholder'); + $out->element( + 'input', + array( + 'class' => 'placeholder', + 'value' => _m('Your answer...') + ) + ); + $out->elementEnd('li'); + $out->elementEnd('ul'); + } + } + } + + return false; + } + + function showNoticeAnswer($notice, $out) { $user = common_current_user();