X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FQnA%2FQnAPlugin.php;h=2c28bf6055483bef7e6468ba4e85e7ef3469b83a;hb=4694d068f965ec733edcfe5c9afe8244ae01f00a;hp=beae1cb6b20a0381fbca794d2ad0f636a42bbbaf;hpb=38bea345620738f0095b9d7f8fc6e2fe1774116a;p=quix0rs-gnu-social.git diff --git a/plugins/QnA/QnAPlugin.php b/plugins/QnA/QnAPlugin.php index beae1cb6b2..2c28bf6055 100644 --- a/plugins/QnA/QnAPlugin.php +++ b/plugins/QnA/QnAPlugin.php @@ -46,6 +46,9 @@ if (!defined('STATUSNET')) { */ class QnAPlugin extends MicroAppPlugin { + + var $oldSaveNew = true; + /** * Set up our tables (question and answer) * @@ -72,12 +75,12 @@ class QnAPlugin extends MicroAppPlugin /** * Map URLs to actions * - * @param Net_URL_Mapper $m path-to-action mapper + * @param URLMapper $m path-to-action mapper * * @return boolean hook value; true means continue processing, false means stop. */ - function onRouterInitialized($m) + public function onRouterInitialized(URLMapper $m) { $UUIDregex = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'; @@ -121,7 +124,7 @@ class QnAPlugin extends MicroAppPlugin return true; } - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $versions[] = array( 'name' => 'QnA', @@ -257,7 +260,7 @@ class QnAPlugin extends MicroAppPlugin * @return boolean hook value */ - function onStartOpenNoticeListItemElement($nli) + function onStartOpenNoticeListItemElement(NoticeListItem $nli) { $type = $nli->notice->object_type; @@ -313,57 +316,6 @@ class QnAPlugin extends MicroAppPlugin return true; } - /** - * Custom HTML output for our notices - * - * @param Notice $notice - * @param HTMLOutputter $out - */ - function showNotice(Notice $notice, $out) - { - switch ($notice->object_type) { - case QnA_Question::OBJECT_TYPE: - return $this->showNoticeQuestion($notice, $out); - case QnA_Answer::OBJECT_TYPE: - return $this->showNoticeAnswer($notice, $out); - default: - throw new Exception( - // TRANS: Exception thrown when performing an unexpected action on a question. - // TRANS: %s is the unpexpected object type. - sprintf(_m('Unexpected type for QnA plugin: %s.'), - $notice->object_type - ) - ); - } - } - - function showNoticeQuestion(Notice $notice, $out) - { - $user = common_current_user(); - - // @hack we want regular rendering, then just add stuff after that - $nli = new NoticeListItem($notice, $out); - $nli->showNotice(); - - $out->elementStart('div', array('class' => 'e-content question-description')); - - $question = QnA_Question::getByNotice($notice); - - if (!empty($question)) { - - $form = new QnashowquestionForm($out, $question); - $form->show(); - - } else { - // TRANS: Error message displayed when question data is not present. - $out->text(_m('Question data is missing.')); - } - $out->elementEnd('div'); - - // @fixme - $out->elementStart('div', array('class' => 'e-content')); - } - /** * Output the HTML for this kind of object in a list * @@ -373,7 +325,7 @@ class QnAPlugin extends MicroAppPlugin * * @todo FIXME: WARNING WARNING WARNING this closes a 'div' that is implicitly opened in BookmarkPlugin's showNotice implementation */ - function onStartShowNoticeItem($nli) + function onStartShowNoticeItem(NoticeListItem $nli) { if (!$this->isMyNotice($nli->notice)) { return true; @@ -382,15 +334,12 @@ class QnAPlugin extends MicroAppPlugin $out = $nli->out; $notice = $nli->notice; - $this->showNotice($notice, $out); + $nli->showNotice($notice, $out); $nli->showNoticeLink(); $nli->showNoticeSource(); $nli->showNoticeLocation(); - $nli->showContext(); - $nli->showRepeat(); - - $out->elementEnd('div'); + $nli->showPermalink(); $nli->showNoticeOptions(); @@ -427,30 +376,8 @@ class QnAPlugin extends MicroAppPlugin return false; } - function showNoticeAnswer(Notice $notice, $out) - { - $user = common_current_user(); - - $answer = QnA_Answer::getByNotice($notice); - $question = $answer->getQuestion(); - - $nli = new NoticeListItem($notice, $out); - $nli->showNotice(); - - $out->elementStart('div', array('class' => 'e-content answer-content')); - - if (!empty($answer)) { - $form = new QnashowanswerForm($out, $answer); - $form->show(); - } else { - // TRANS: Error message displayed when answer data is not present. - $out->text(_m('Answer data is missing.')); - } - - $out->elementEnd('div'); - - // @todo FIXME - $out->elementStart('div', array('class' => 'e-content')); + function adaptNoticeListItem($nli) { + return new QnAListItem($nli); } static function shorten($content, $notice) @@ -496,28 +423,28 @@ class QnAPlugin extends MicroAppPlugin { switch ($notice->object_type) { case QnA_Question::OBJECT_TYPE: - common_log(LOG_DEBUG, "Deleting question from notice..."); + common_debug("Deleting question from notice..."); $question = QnA_Question::fromNotice($notice); $question->delete(); break; case QnA_Answer::OBJECT_TYPE: - common_log(LOG_DEBUG, "Deleting answer from notice..."); + common_debug("Deleting answer from notice..."); $answer = QnA_Answer::fromNotice($notice); - common_log(LOG_DEBUG, "to delete: $answer->id"); + common_debug("to delete: $answer->id"); $answer->delete(); break; default: - common_log(LOG_DEBUG, "Not deleting related, wtf..."); + common_debug("Not deleting related, wtf..."); } } - function onEndShowScripts($action) + function onEndShowScripts(Action $action) { $action->script($this->path('js/qna.js')); return true; } - function onEndShowStyles($action) + function onEndShowStyles(Action $action) { $action->cssLink($this->path('css/qna.css')); return true;